#view {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
}

#sorry { position: fixed; inset: 0; margin: 0; display: grid; place-items: center; }
#sorry[hidden] { display: none; }

#bar .gap { margin-left: 14px; }
#bar .icon[hidden] { display: none; }
#bar .icon[hidden] + .gap { margin-left: 0; }
#volume { padding: 14px 16px; }
#volume input { width: 170px; margin: 0; accent-color: var(--punch); cursor: pointer; }

/* The back arrow, in the picture's bottom-left, level with the bar and clear of the play area. */
.tile { left: max(14px, env(safe-area-inset-left)); bottom: var(--gap); transform: none; display: flex; gap: 2px; padding: 8px 10px; z-index: 2; }
.tile[hidden] { display: none; }

/* Everything over the picture lets clicks through, moves by transform alone, and has no blurred shadows. */
#score, #meter, #bossbar, #warn, #cut, #panel, #pops { position: fixed; pointer-events: none; }
#intro[hidden], #panel[hidden], #score[hidden], #meter[hidden], #bossbar[hidden], #warn[hidden], #cut[hidden], #title[hidden], #over[hidden], #mult[hidden] { display: none; }

#score {
    top: max(12px, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: baseline;
    gap: 12px;
    font: 700 40px/1 "Chakra Petch", ui-sans-serif, system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
    font-style: italic;
    color: #fff;
    -webkit-text-stroke: 7px #000;
    paint-order: stroke fill;
    letter-spacing: 0.02em;
}
#mult { font-size: 28px; color: var(--punch); -webkit-text-stroke-width: 6px; }
#mult.bump { animation: bump 0.25s ease-out; }
@keyframes bump { from { transform: scale(1.5); } }

/* Overdrive fills under the score, in hazard stripes once it's nearly there. */
#meter {
    top: calc(max(12px, env(safe-area-inset-top)) + 46px);
    left: 50%;
    width: 180px;
    height: 7px;
    margin-left: -90px;
    background: rgba(0, 0, 0, 0.55);
    outline: 2px solid #000;
    clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
}
#meter i {
    display: block;
    height: 100%;
    background: var(--punch);
    transform-origin: left;
    transform: scaleX(0);
    transition: transform 0.15s;
}
#meter.full i, .overdrive #meter i {
    background: repeating-linear-gradient(-45deg, var(--punch) 0 6px, #000 6px 12px);
    background-size: 17px 100%;
    animation: stripes 0.4s linear infinite;
}
@keyframes stripes { to { background-position: 17px 0; } }

#bossbar {
    top: calc(max(12px, env(safe-area-inset-top)) + 62px);
    left: 50%;
    width: min(520px, 70vw);
    height: 9px;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    outline: 2px solid #000;
    clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}
#bossbar i { display: block; height: 100%; background: linear-gradient(90deg, #ff2a4d, #ff7a1a); transform-origin: left; transition: transform 0.1s; }

/* The warning: hazard stripes in a band along the top edge and another along the bottom, thin enough to leave the
   boss's panel and the play clear. Each band's stripes are a strip one tile wider than the screen, slid along by
   transform: sliding the background itself showed a seam where it wrapped. */
#warn { inset: 0; --edge: clamp(30px, 8vh, 76px); --tile: clamp(56px, 12vmin, 96px); }
#warn i {
    position: absolute;
    left: 0;
    right: 0;
    height: var(--edge);
    overflow: hidden;
    opacity: 0;
}
#warn i::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    left: calc(var(--tile) * -1);
    background: linear-gradient(-45deg, var(--punch) 25%, #000 25% 50%, var(--punch) 50% 75%, #000 75%) 0 0 / var(--tile) var(--tile);
    animation: slide 0.8s linear infinite;
}
#warn i:first-child { top: 0; border-bottom: 5px solid #000; }
#warn i:last-child { bottom: 0; border-top: 5px solid #000; }
#warn.go i { animation: warn 3s steps(1) both; }
/* Held on, for the opening: stripes over the whole screen, and the film sits on them in a frame. */
#warn.hold i { opacity: 1; }
#warn.hold i:first-child { height: 100%; border: 0; }
#warn.hold i:last-child { display: none; }
@keyframes warn { 0%, 16%, 33%, 50%, 66%, 83% { opacity: 0.92; } 8%, 25%, 41%, 58%, 75%, 92% { opacity: 0.25; } 100% { opacity: 0; } }
@keyframes slide { to { transform: translateX(var(--tile)); } }

/* The opening: a few seconds of anime, as big as the screen lets it be without cutting much off, with what it's
   about written across it. main.js sizes and places it. */
#intro {
    position: fixed;
    box-sizing: border-box;
    border: 5px solid #000;
    background: #000;
    overflow: hidden;
    cursor: pointer;
    z-index: 1;
    animation: intro-in 0.25s ease-out both;
}
#intro.out { animation: intro-out 0.45s ease-in both; pointer-events: none; }
#intro video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#intro p {
    position: absolute;
    left: 4%;
    right: 4%;
    bottom: 7%;
    margin: 0;
    text-align: center;
    font: 700 clamp(22px, 5.2vw, 64px)/1 "Chakra Petch", ui-sans-serif, system-ui, sans-serif;
    font-style: italic;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--punch);
    -webkit-text-stroke: clamp(5px, 0.9vw, 10px) #000;
    paint-order: stroke fill;
    text-wrap: balance;
}
#intro p.hit { animation: caption 0.35s cubic-bezier(0.25, 1.5, 0.35, 1) both; }
@keyframes intro-in { from { transform: scaleY(0); } }
@keyframes intro-out { to { opacity: 0; transform: scale(1.06); } }
@keyframes caption { from { transform: scale(2.2) rotate(-4deg); opacity: 0; } }

/* The pilot's cut-in: a slanted panel that slashes in from the left. */
#cut {
    left: 0;
    top: 22%;
    width: min(380px, 52vw);
    height: min(150px, 22vh);
    overflow: hidden;
    background: var(--punch);
    clip-path: polygon(0 0, 100% 0, calc(100% - 50px) 100%, 0 100%);
    border-bottom: 5px solid #000;
}
#cut img { position: absolute; right: 30px; top: -12%; height: 160%; }
#cut::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(-60deg, transparent 0 18px, rgba(0, 0, 0, 0.08) 18px 22px); }
#cut.go { animation: cut 1.5s cubic-bezier(0.2, 0.9, 0.2, 1) both; }
#cut.right { left: auto; right: 0; top: 30%; background: #ff2a4d; clip-path: polygon(50px 0, 100% 0, 100% 100%, 0 100%); }
#cut.right img { right: auto; left: 30px; }
#cut.right.go { animation-name: cut-r; }
@keyframes cut-r {
    0% { transform: translateX(105%); }
    14% { transform: translateX(0); }
    80% { transform: translateX(0); opacity: 1; }
    100% { transform: translateX(30%); opacity: 0; }
}

/* A boss's manga panel: a slanted band right across the screen, in hazard yellow and black, slammed in and off. */
#panel {
    left: -5vw;
    right: -5vw;
    top: 50%;
    height: min(50vh, 38vw);
    margin-top: calc(min(50vh, 38vw) / -2);
    overflow: hidden;
    background: #000;
    border-top: 7px solid var(--punch);
    border-bottom: 7px solid var(--punch);
    outline: 3px solid #000;
    z-index: 3;
}
#panel img { width: 100%; height: 100%; object-fit: cover; display: block; }
#panel.go { animation: panel 1.9s both; }
#panel.go img { animation: panel-zoom 1.9s ease-out both; }
@keyframes panel {
    0% { transform: translateX(110%) skewY(-5deg); animation-timing-function: cubic-bezier(0.2, 1.4, 0.4, 1); }
    12% { transform: translateX(0) skewY(-5deg); }
    15% { transform: translate(-14px, 6px) skewY(-5deg); }
    18% { transform: translate(10px, -5px) skewY(-5deg); }
    21% { transform: translate(-6px, 3px) skewY(-5deg); }
    24%, 82% { transform: translateX(0) skewY(-5deg); animation-timing-function: cubic-bezier(0.6, 0, 0.9, 0.4); }
    100% { transform: translateX(-115%) skewY(-5deg); }
}
@keyframes panel-zoom { from { transform: scale(1.18); } to { transform: scale(1); } }
@keyframes cut {
    0% { transform: translateX(-105%); }
    14% { transform: translateX(0); }
    80% { transform: translateX(0); opacity: 1; }
    100% { transform: translateX(-30%); opacity: 0; }
}

#pops { inset: 0; overflow: hidden; }
#pops span {
    position: absolute;
    left: 0;
    top: 0;
    font: 700 italic 22px/1 "Chakra Petch", ui-sans-serif, system-ui, sans-serif;
    color: #fff;
    -webkit-text-stroke: 5px #000;
    paint-order: stroke fill;
    white-space: nowrap;
    will-change: transform, opacity;
}
#pops span.big { font-size: 40px; color: var(--punch); -webkit-text-stroke-width: 8px; }

/* The title: the logo and Play. */
#title {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    align-content: center;
    gap: clamp(18px, 5vh, 48px);
    pointer-events: none;
}
/* The logo slams in, splitting into red and cyan as it lands, then hovers, a light sweeping over it now and then. */
#title .logo { position: relative; width: min(820px, 86vw); animation: slam 0.65s cubic-bezier(0.25, 1.5, 0.35, 1) both, hover 5s 0.65s ease-in-out infinite; }
#title .logo img { display: block; width: 100%; height: auto; }
#title .logo .ghost { position: absolute; left: 0; top: 0; opacity: 0; mix-blend-mode: screen; }
#title .logo .red { filter: sepia(1) saturate(9) hue-rotate(-45deg); animation: split-r 0.9s 0.25s ease-out both, glitch-r 6s 3s steps(1) infinite; }
#title .logo .cyan { filter: sepia(1) saturate(9) hue-rotate(140deg); animation: split-c 0.9s 0.25s ease-out both, glitch-c 6s 3s steps(1) infinite; }
#title .logo .shine {
    position: absolute;
    inset: 0;
    -webkit-mask: url(media/art/logo.webp) center / 100% 100% no-repeat;
    mask: url(media/art/logo.webp) center / 100% 100% no-repeat;
    background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, 0.95) 50%, transparent 62%) no-repeat;
    background-size: 300% 100%;
    background-position: 150% 0;
    animation: shine 3.6s 1s ease-in-out infinite;
}
@keyframes slam { 0% { transform: scale(2.8) rotate(-7deg); opacity: 0; } 55% { transform: scale(0.94) rotate(1deg); opacity: 1; } 100% { transform: none; } }
@keyframes hover { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px) rotate(-0.4deg); } }
@keyframes split-r { 0% { opacity: 0.95; transform: translate(-22px, 3px); } 100% { opacity: 0; transform: none; } }
@keyframes split-c { 0% { opacity: 0.95; transform: translate(22px, -3px); } 100% { opacity: 0; transform: none; } }
@keyframes glitch-r { 0%, 93% { opacity: 0; transform: none; } 94% { opacity: 0.8; transform: translate(-9px, 0); } 96% { opacity: 0.6; transform: translate(5px, 2px); } 98% { opacity: 0; } }
@keyframes glitch-c { 0%, 93% { opacity: 0; transform: none; } 94% { opacity: 0.8; transform: translate(9px, 0); } 96% { opacity: 0.6; transform: translate(-5px, -2px); } 98% { opacity: 0; } }
@keyframes shine { 0% { background-position: 150% 0; } 40%, 100% { background-position: -50% 0; } }
#title .btn { pointer-events: auto; min-width: 170px; font-size: 22px; padding: 16px 28px; animation: logo 0.7s 0.45s cubic-bezier(0.2, 0.9, 0.2, 1.2) both; }
@keyframes logo { from { opacity: 0; transform: translateX(-60px) skewX(-12deg); } }

/* Held upright, a phone turning on its side: it's better that way round. */
#turn { display: none; width: 34px; height: 56px; margin-top: 6px; }
#turn i { display: block; width: 100%; height: 100%; box-sizing: border-box; border: 4px solid var(--punch); border-radius: 7px; outline: 2px solid #000; animation: turn 2.6s ease-in-out infinite; }
@keyframes turn { 0%, 30% { transform: rotate(0); } 55%, 85% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
@media (orientation: portrait) and (pointer: coarse) { #turn { display: block; } }

/* The end. */
#over {
    position: fixed;
    inset: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    padding: 16px;
    animation: over-in 0.4s ease-out both;
    pointer-events: none;
}
#over .window { pointer-events: auto; width: min(400px, 100%); text-align: center; background: rgba(14, 14, 20, 0.82); }
@keyframes over-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } }
#over .inner { padding: 22px 26px 24px; }
#over .logo { width: 70%; height: auto; display: block; margin: 0 auto 6px; }
#over h1 { margin: 0 0 14px; font: 700 italic 54px/1 "Chakra Petch", ui-sans-serif, system-ui, sans-serif; font-variant-numeric: tabular-nums; color: #fff; }
#tally { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 7px; }
#tally li { display: flex; justify-content: space-between; gap: 12px; margin: 0; font: 500 16px/1.1 "Chakra Petch", ui-sans-serif, system-ui, sans-serif; color: #d8d8de; opacity: 0; transform: translateX(-10px); }
#tally li.in { opacity: 1; transform: none; transition: opacity 0.2s, transform 0.2s; }
#tally li b { color: var(--punch); font-weight: 700; font-variant-numeric: tabular-nums; }
#tally li span { color: #fff; font-weight: 700; }
#extra { margin: 0 0 18px; }
#over .row { display: flex; gap: 10px; justify-content: center; }

.btn {
    min-width: 120px;
    padding: 13px 20px;
    font: 700 17px/1 "Chakra Petch", ui-sans-serif, system-ui, sans-serif;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #000;
    background: var(--punch);
    clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
.btn.plain { color: #fff; background: rgba(255, 255, 255, 0.14); }
.btn:hover { background: #fff; color: #000; }
.btn:active { transform: translateY(1px); }

@media (max-width: 600px), (max-height: 500px) {
    #score { font-size: 28px; -webkit-text-stroke-width: 6px; }
    #mult { font-size: 20px; }
    #meter { top: calc(max(12px, env(safe-area-inset-top)) + 34px); width: 130px; margin-left: -65px; }
    #bossbar { top: calc(max(12px, env(safe-area-inset-top)) + 48px); }
    #pops span { font-size: 16px; }
    #pops span.big { font-size: 28px; }
}
