:root {
  --panel: rgba(8, 14, 26, 0.74);
  --panel-2: rgba(16, 26, 44, 0.86);
  --line: #34507c;
  --accent: #5fd0ff;
  --hp: #5dff7a;
  --sp: #ff5fd0;
  --warn: #ff4a4a;
  --gold: #f3c11c;
  --text: #e8eef8;
  --muted: #93a4bf;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0a0e16; color: var(--text); font-family: 'Rajdhani', system-ui, sans-serif; overscroll-behavior: none; }
/* touch-action: none keeps a thumb drag from scrolling, zooming or pulling to refresh instead of playing */
#app { position: fixed; inset: 0; touch-action: none; }
canvas#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; cursor: crosshair; touch-action: none; }
/* menus stay scrollable, but 'manipulation' drops the double-tap-to-zoom gesture */
.screen { touch-action: manipulation; }
.hidden { display: none !important; }
button { font-family: 'Rajdhani', sans-serif; font-weight: 700; cursor: pointer; }

#vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(255, 20, 20, 0.55) 100%); opacity: 0; transition: opacity 0.35s; }
#vignette.on { opacity: 1; transition: opacity 0.05s; }
#vignette.low { opacity: 0.6; animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
#flash { position: absolute; inset: 0; pointer-events: none; background: #fff; opacity: 0; }
/* boost dash speed lines */
#speedlines { position: absolute; inset: -20%; pointer-events: none; opacity: 0;
  background: repeating-conic-gradient(from 0deg at 50% 50%, rgba(255,255,255,0) 0deg 3.1deg, rgba(220,240,255,0.5) 3.3deg 3.5deg, rgba(255,255,255,0) 3.7deg 7.3deg);
  -webkit-mask-image: radial-gradient(ellipse 60% 55% at 50% 50%, transparent 45%, #000 85%); mask-image: radial-gradient(ellipse 60% 55% at 50% 50%, transparent 45%, #000 85%);
  animation: lines 0.12s steps(2) infinite; }
@keyframes lines { 50% { transform: rotate(1.7deg) scale(1.02); } }
/* officer arrival letterbox */
#letterbox .lb { position: absolute; left: 0; right: 0; height: 11vh; background: #000; pointer-events: none; transition: transform 0.35s ease-out; }
#letterbox .top { top: 0; transform: translateY(-100%); }
#letterbox .bot { bottom: 0; transform: translateY(100%); }
#letterbox.on .lb { transform: none; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#stage-info { position: absolute; left: 22px; top: 18px; text-shadow: 0 2px 6px rgba(0,0,0,0.7); }
.stage-jp { font-family: 'Noto Sans JP', sans-serif; font-weight: 900; font-size: 30px; letter-spacing: 4px; color: #fff; line-height: 1; }
.stage-name { font-weight: 700; font-size: 13px; letter-spacing: 5px; color: var(--accent); margin-top: 4px; }
#objective { margin-top: 10px; font-weight: 600; font-size: 15px; padding: 5px 12px 5px 10px; background: var(--panel); border-left: 3px solid var(--gold); display: inline-block; }

#map-wrap { position: absolute; right: 18px; top: 18px; width: 200px; }
#minimap { width: 200px; height: 200px; border: 1px solid var(--line); background: rgba(6, 12, 22, 0.75); display: block; box-shadow: 0 0 0 3px rgba(8, 14, 26, 0.6), inset 0 0 30px rgba(0,0,0,0.6); }
#ko { display: flex; align-items: baseline; justify-content: flex-end; gap: 8px; margin-top: 6px; text-shadow: 0 2px 8px rgba(0,0,0,0.8); }
.ko-label { font-family: 'Russo One', sans-serif; font-size: 16px; color: var(--gold); letter-spacing: 2px; }
#ko-count { font-family: 'Russo One', sans-serif; font-size: 42px; line-height: 1; color: #fff; }
#ko-count.bump { animation: bump 0.18s; }
@keyframes bump { 40% { transform: scale(1.18); color: var(--gold); } }
#timer { text-align: right; font-weight: 700; font-size: 15px; color: var(--muted); letter-spacing: 2px; }

#guide { position: absolute; left: 22px; top: 132px; display: grid; grid-template-columns: auto auto; gap: 1px 10px; align-items: center; padding: 8px 6px 9px 5px; background: var(--panel); border-left: 3px solid var(--accent); font-size: 12.5px; font-weight: 600; color: var(--muted); text-shadow: 0 1px 3px #000; pointer-events: none; }
#guide .gd-head { grid-column: 1 / -1; padding-left: 5px; font-family: 'Russo One', sans-serif; font-size: 11px; letter-spacing: 3px; color: var(--accent); margin-bottom: 2px; }
/* a row spans its two columns as a subgrid so it can carry a highlight; --c is the colour it lights in */
#guide .gd-row { --c: var(--accent); display: grid; grid-column: span 2; grid-template-columns: subgrid; align-items: center; padding: 1px 6px 1px 5px; border-radius: 2px; transform-origin: left center; transition: opacity 0.12s; }
#guide .gd-row[data-end="K"] { --c: var(--gold); }
#guide .gd-row[data-end="S"] { --c: var(--sp); }
#guide .gd-k { display: flex; gap: 2px; }
#guide .gd-k b { --c: var(--accent); min-width: 14px; padding: 0 3px; text-align: center; border-radius: 2px; background: rgba(255,255,255,0.1); color: var(--text); font-weight: 700; }
#guide .gd-k b[data-t="K"] { --c: var(--gold); }
#guide .gd-k b[data-t="S"] { --c: var(--sp); }
#guide .gd-v { display: flex; align-items: center; gap: 5px; min-width: 0; }
#guide .src-legend { grid-column: 1 / -1; margin-top: 3px; padding-left: 5px; font-size: 10.5px; }
/* mid-combo: everything but the move in progress and the charge attack K would start next steps back */
#guide.busy .gd-row:not(.on):not(.next) { opacity: 0.3; }
/* the move in progress: a bar and a wash in its colour, pushed out of the column */
#guide .gd-row.on { background: linear-gradient(90deg, color-mix(in srgb, var(--c) 55%, transparent), color-mix(in srgb, var(--c) 12%, transparent)); box-shadow: inset 3px 0 0 var(--c), 0 0 12px color-mix(in srgb, var(--c) 30%, transparent); transform: translateX(4px) scale(1.04); animation: gdon 0.3s ease-out; }
#guide .gd-row.on .gd-v { color: #fff; }
@keyframes gdon { from { background-color: color-mix(in srgb, var(--c) 80%, transparent); filter: brightness(1.6); } }
/* inputs that are in: solid; the newest pops; the string's steps still to come stay faint */
#guide .gd-k b.done { background: var(--c); color: #06101c; text-shadow: none; }
#guide .gd-k b.cur { box-shadow: 0 0 0 1px #fff, 0 0 10px var(--c); animation: gdpop 0.22s ease-out; }
@keyframes gdpop { from { transform: scale(1.7); filter: brightness(2); } }
#guide .gd-row.on b:not(.done) { opacity: 0.4; }
/* the branch: the inputs it shares are dimmer, and the K still to press is hollow and pulses */
#guide .gd-row.next .gd-v { color: var(--gold); }
#guide .gd-row.next b.done:not(.cur) { opacity: 0.55; }
#guide .gd-k b.nx { background: rgba(243, 193, 28, 0.14); color: var(--gold); box-shadow: inset 0 0 0 1.5px var(--gold); animation: gdnx 0.5s ease-in-out infinite alternate; }
@keyframes gdnx { to { background: rgba(243, 193, 28, 0.4); box-shadow: inset 0 0 0 1.5px var(--gold), 0 0 9px var(--gold); } }
#combo { position: absolute; right: 26px; top: 46%; text-align: right; font-family: 'Russo One', sans-serif; text-shadow: 0 3px 10px rgba(0,0,0,0.8); transform-origin: right center; }
#combo-count { font-size: 64px; line-height: 1; color: #fff; display: block; }
#combo .combo-label { font-size: 18px; color: var(--sp); letter-spacing: 6px; }
#combo.pop #combo-count { animation: pop 0.14s; }
@keyframes pop { 30% { transform: scale(1.2); color: #ffd1f1; } }
#combo.big #combo-count { color: var(--gold); }

#player { position: absolute; left: 20px; bottom: 22px; display: flex; align-items: flex-end; gap: 12px; }
.pf-wrap { position: relative; flex: none; }
#player-unit { position: absolute; left: -14%; bottom: -12%; width: 72%; height: 56%; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.9)); pointer-events: none; }
#player-unit:not([src]), #player-unit[src=""] { display: none; }
#portrait-frame { width: 96px; height: 96px; border-radius: 50%; overflow: hidden; border: 3px solid var(--accent); box-shadow: 0 0 0 4px rgba(8,14,26,0.7), 0 0 20px rgba(95,208,255,0.35); background: #0b1424; }
#portrait { width: 100%; height: 100%; image-rendering: pixelated; display: block; object-fit: cover; object-position: 50% 30%; }
#bars { width: min(46vw, 520px); display: flex; flex-direction: column; gap: 5px; padding-bottom: 6px; }
.pilot { display: flex; align-items: baseline; gap: 10px; text-shadow: 0 2px 6px rgba(0,0,0,0.8); }
.pilot-jp { font-family: 'Noto Sans JP', sans-serif; font-weight: 900; font-size: 22px; }
.pilot-en { font-weight: 700; font-size: 12px; letter-spacing: 3px; color: var(--accent); }
.bar { position: relative; height: 16px; background: rgba(4, 8, 14, 0.8); border: 1px solid var(--line); overflow: hidden; clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 100%, 0 100%); }
.sp-row { display: flex; align-items: center; gap: 6px; width: 86%; }
.bar.sp { height: 11px; flex: 1; }
#hp-fill, #hp-lag, #sp-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; }
#hp-lag { background: #ff6a4a; transition: width 0.6s ease-out 0.25s; }
#hp-red { background: repeating-linear-gradient(135deg, #b0303a 0 6px, #7a1c26 6px 12px); width: 100%; }
#hp-red.regen { animation: regen 0.5s infinite alternate; }
@keyframes regen { to { filter: brightness(1.7); } }
.bar.boost { height: 6px; width: 62%; border-color: #2a5a7a; }
#boost-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: linear-gradient(180deg, #d6f4ff, #5fd0ff 55%, #1f7fb0); }
.bar.boost.low #boost-fill { background: linear-gradient(180deg, #ffe0b0, #ff9a3a 55%, #b0561f); }
.boost-label { position: absolute; right: 14px; top: -5px; font-size: 9px; font-weight: 700; letter-spacing: 3px; color: #bfe9ff; opacity: 0.8; }
#hp-fill { background: linear-gradient(180deg, #9dffae, var(--hp) 45%, #25b048); }
#hp-fill.mid { background: linear-gradient(180deg, #fff1a0, #f3c11c 45%, #b88a0e); }
#hp-fill.low { background: linear-gradient(180deg, #ffb0a0, #ff4a4a 45%, #a41d1d); }
#hp-text { position: absolute; right: 16px; top: -2px; font-weight: 700; font-size: 14px; text-shadow: 0 1px 3px #000; }
#sp-fill { background: linear-gradient(180deg, #ffc1ee, var(--sp) 50%, #b02a8f); width: 0; }
/* three SP stocks (Reborn): dividers at the thirds, stocks being charged turn orange, and the count beside the bar */
#sp-charge { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(180deg, #ffe6b8, #ffa640 50%, #b8601a); }
.sp-tick { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: rgba(4, 8, 14, 0.9); left: 33.33%; }
.sp-tick + .sp-tick { left: 66.67%; }
#sp-stocks { flex: none; min-width: 26px; font-weight: 700; font-size: 13px; letter-spacing: 1px; color: var(--sp); text-shadow: 0 1px 3px #000; opacity: 0.4; }
#sp-stocks.on { opacity: 1; text-shadow: 0 0 8px var(--sp), 0 1px 3px #000; }
#sp-stocks.charging { color: #ffb050; text-shadow: 0 0 8px #ff9a3a, 0 1px 3px #000; opacity: 1; }
.bar.sp.ready { border-color: var(--sp); box-shadow: 0 0 12px var(--sp); animation: sp 0.6s infinite alternate; }
@keyframes sp { to { box-shadow: 0 0 22px var(--sp); } }
#sp-ready { position: absolute; right: 16px; top: -3px; font-size: 11px; font-weight: 700; letter-spacing: 2px; opacity: 0; }
.bar.sp.ready #sp-ready { opacity: 1; }

#boss-bars { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(40vw, 460px); }
.boss { background: var(--panel); border: 1px solid var(--line); padding: 5px 10px 7px; }
.boss .bname { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; letter-spacing: 2px; font-size: 13px; }
.boss .bname .jp { font-family: 'Noto Sans JP', sans-serif; font-size: 16px; letter-spacing: 1px; }
.boss.char { border-color: #c0283a; box-shadow: 0 0 16px rgba(192, 40, 58, 0.45); }
.boss:has(.bunit) { display: flex; align-items: center; gap: 8px; padding-left: 4px; }
.boss .bbody { flex: 1; min-width: 0; }
.boss .bunit { height: 40px; width: 56px; object-fit: contain; flex: none; filter: drop-shadow(0 0 4px rgba(0,0,0,0.8)); }
.boss .bbar { height: 8px; background: #200; margin-top: 4px; position: relative; }
.boss .bfill { position: absolute; inset: 0; background: linear-gradient(90deg, #ff4a4a, #ff9a3a); transform-origin: left; }
.boss .blag { position: absolute; inset: 0; background: #fff; opacity: 0.6; transform-origin: left; transition: transform 0.5s ease-out 0.2s; }

#tags { position: absolute; inset: 0; }
.tag { position: absolute; transform: translate(-50%, -100%); font-weight: 700; font-size: 13px; letter-spacing: 1px; text-align: center; white-space: nowrap; text-shadow: 0 1px 3px #000, 0 0 6px #000; }
.tag .tjp { font-family: 'Noto Sans JP', sans-serif; font-size: 15px; display: block; }
.tag .tbar { width: 70px; height: 4px; background: rgba(0,0,0,0.6); margin: 3px auto 0; }
.tag .tbar div { height: 100%; background: #ff5a4a; }
.tag.char .tjp { color: #ff6a7a; }
.tag.captain { font-size: 11px; color: #d8e4a8; }
.tag.captain .tjp { font-size: 13px; }
.tag.captain .tbar { width: 54px; }
.tag.ally { font-size: 11px; color: #8fe4ff; }
.tag.ally .tjp { font-size: 13px; color: #6fd8ff; }

/* objective marker: sits on the target, or pinned to the screen edge pointing at it */
#objmarker { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 2px; pointer-events: none; text-shadow: 0 1px 3px #000, 0 0 6px #000; }
.om-arrow { width: 18px; height: 18px; background: #ff4a5a; clip-path: polygon(50% 100%, 0 0, 100% 0); filter: drop-shadow(0 0 6px #ff4a5a); animation: om 0.9s infinite alternate; }
#objmarker.edge .om-arrow { clip-path: polygon(100% 50%, 0 0, 0 100%); }
@keyframes om { to { transform: translateY(-4px); } }
.om-body { display: flex; flex-direction: column; align-items: center; line-height: 1; }
#om-label { font-weight: 700; font-size: 12px; letter-spacing: 3px; color: #ffb0b8; }
#om-dist { font-family: 'Russo One', sans-serif; font-size: 13px; color: #fff; }

/* lock-on reticle: rotating brackets on the locked commander */
#lockon { position: absolute; transform: translate(-50%, -50%); pointer-events: none; display: flex; flex-direction: column; align-items: center; }
.lk-ring { width: 64px; height: 64px; border: 2px solid #ff4a5a; border-radius: 4px; transform: rotate(45deg); animation: lk 1.4s linear infinite;
  -webkit-mask: conic-gradient(#000 0 12%, transparent 12% 25%, #000 25% 37%, transparent 37% 50%, #000 50% 62%, transparent 62% 75%, #000 75% 87%, transparent 87%);
  mask: conic-gradient(#000 0 12%, transparent 12% 25%, #000 25% 37%, transparent 37% 50%, #000 50% 62%, transparent 62% 75%, #000 75% 87%, transparent 87%);
  filter: drop-shadow(0 0 6px #ff4a5a); }
@keyframes lk { from { transform: rotate(45deg); } to { transform: rotate(405deg); } }
.lk-name { margin-top: 6px; font-weight: 700; font-size: 12px; letter-spacing: 3px; color: #ffb0b8; text-shadow: 0 1px 3px #000, 0 0 6px #000; white-space: nowrap; }
#lockon.edge .lk-ring { width: 34px; height: 34px; }

/* officer name card */
#namecard { position: absolute; right: 0; top: 58%; width: min(560px, 70vw); height: 120px; pointer-events: none; }
.nc-band { position: absolute; inset: 0; background: linear-gradient(270deg, rgba(160,20,30,0.9), rgba(60,10,20,0.85) 60%, rgba(60,10,20,0)); transform-origin: right; animation: ncband 2.6s forwards; }
.nc-text { position: absolute; right: 40px; top: 10px; text-align: right; animation: nctext 2.6s forwards; }
.nc-tag { font-weight: 700; font-size: 12px; letter-spacing: 6px; color: #ffb0b8; }
#nc-jp { font-family: 'Noto Sans JP', sans-serif; font-weight: 900; font-size: 44px; line-height: 1.05; color: #fff; text-shadow: 0 0 18px rgba(255, 60, 60, 0.7); }
#nc-en { font-family: 'Russo One', sans-serif; font-size: 20px; letter-spacing: 8px; color: #fff; }
#nc-unit { font-weight: 700; font-size: 13px; letter-spacing: 4px; color: var(--gold); }
#namecard.char .nc-band { background: linear-gradient(270deg, rgba(220,30,50,0.95), rgba(90,10,20,0.9) 60%, rgba(90,10,20,0)); }
@keyframes ncband { 0% { transform: scaleX(0); } 12% { transform: scaleX(1); } 85% { opacity: 1; } 100% { opacity: 0; } }
@keyframes nctext { 0% { transform: translateX(50vw); opacity: 0; } 14% { transform: translateX(0); opacity: 1; } 82% { transform: translateX(-1.5vw); opacity: 1; } 100% { transform: translateX(-10vw); opacity: 0; } }

#dialogue { position: absolute; left: 22px; bottom: 138px; display: flex; gap: 12px; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 18px 10px 10px; width: min(520px, 90vw); animation: slideup 0.2s ease-out; }
#dialogue.zeon { border-left-color: #6fa04a; }
#dialogue.char { border-left-color: #e0283a; }
@keyframes slideup { from { transform: translateY(16px); opacity: 0; } }
#dlg-portrait { width: 64px; height: 64px; image-rendering: pixelated; border: 2px solid var(--line); object-fit: cover; }
.sheet-portraits #cutin-portrait { height: 190px; top: -20px; }
#dlg-name { font-weight: 700; font-size: 13px; letter-spacing: 3px; color: var(--accent); }
#dialogue.zeon #dlg-name { color: #9fd06a; }
#dialogue.char #dlg-name { color: #ff6a7a; }
#dlg-text { font-weight: 600; font-size: 19px; line-height: 1.25; margin-top: 2px; }

#announce { position: absolute; left: 0; right: 0; top: 30%; text-align: center; pointer-events: none; }
.ann { display: inline-block; font-family: 'Russo One', sans-serif; font-size: clamp(28px, 5vw, 64px); letter-spacing: 6px; color: #fff; text-shadow: 0 4px 18px rgba(0,0,0,0.8), 0 0 30px rgba(95, 208, 255, 0.4); animation: ann 2.6s forwards; }
.ann small { display: block; font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: clamp(14px, 1.6vw, 20px); letter-spacing: 8px; color: var(--gold); margin-top: 6px; }
.ann.warn { color: #ff5a6a; text-shadow: 0 4px 18px rgba(0,0,0,0.8), 0 0 30px rgba(255, 60, 60, 0.6); }
@keyframes ann { 0% { transform: scale(1.6); opacity: 0; letter-spacing: 30px; } 10% { transform: scale(1); opacity: 1; letter-spacing: 6px; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-20px); } }

#toasts { position: absolute; left: 50%; top: 60%; transform: translateX(-50%); text-align: center; }
.toast { font-weight: 700; font-size: 18px; letter-spacing: 3px; animation: toast 1.4s forwards; text-shadow: 0 2px 6px #000; }
@keyframes toast { from { transform: translateY(10px); opacity: 0; } 15% { transform: none; opacity: 1; } 75% { opacity: 1; } to { opacity: 0; transform: translateY(-20px); } }

#keys { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); display: flex; gap: 14px; font-size: 12px; color: var(--muted); white-space: nowrap; text-shadow: 0 1px 3px #000; }
#keys b { color: var(--text); background: rgba(255,255,255,0.1); padding: 0 4px; border-radius: 2px; }

/* SP cut-in */
#cutin { position: absolute; left: 0; right: 0; top: 34%; height: 150px; pointer-events: none; overflow: hidden; }
.cutin-band { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(255,40,160,0.0), rgba(255,60,170,0.85) 20%, rgba(40,20,80,0.9) 60%, rgba(255,60,170,0.0)); transform: skewY(-4deg); animation: band 1.05s forwards; }
#cutin-portrait { position: absolute; left: 12%; top: -10px; height: 170px; image-rendering: pixelated; animation: cutp 1.05s forwards; filter: drop-shadow(0 0 12px #ff5fd0); }
.cutin-text { position: absolute; left: 36%; top: 26px; animation: cutt 1.05s forwards; }
.cutin-jp { font-family: 'Noto Sans JP', sans-serif; font-weight: 900; font-size: 60px; line-height: 1; color: #fff; text-shadow: 0 0 20px #ff5fd0; }
.cutin-en { font-family: 'Russo One', sans-serif; font-size: 30px; letter-spacing: 12px; color: #ffe2f6; }
@keyframes band { 0% { transform: skewY(-4deg) scaleX(0); } 15% { transform: skewY(-4deg) scaleX(1); } 85% { opacity: 1; } 100% { opacity: 0; } }
@keyframes cutp { 0% { transform: translateX(-60vw); } 18% { transform: translateX(0); } 80% { transform: translateX(3vw); opacity: 1; } 100% { transform: translateX(60vw); opacity: 0; } }
@keyframes cutt { 0% { transform: translateX(60vw); } 20% { transform: translateX(0); } 80% { transform: translateX(-2vw); opacity: 1; } 100% { transform: translateX(-60vw); opacity: 0; } }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
#title { background: linear-gradient(90deg, rgba(5,10,20,0.92) 0%, rgba(5,10,20,0.75) 42%, rgba(5,10,20,0.05) 70%); justify-content: flex-start; padding-left: clamp(24px, 7vw, 110px); }
.title-inner { max-width: 560px; }
.logo-jp { font-family: 'Noto Sans JP', sans-serif; font-weight: 900; font-size: clamp(18px, 2.4vw, 28px); letter-spacing: 10px; color: var(--accent); }
.logo { font-family: 'Russo One', sans-serif; font-size: clamp(48px, 8vw, 104px); line-height: 0.95; letter-spacing: 2px; color: #fff; text-shadow: 0 6px 30px rgba(0,0,0,0.6); }
.logo span { color: var(--gold); display: block; }
.logo-sub { font-weight: 700; letter-spacing: 8px; font-size: 14px; color: var(--muted); margin-top: 10px; }
.mission { margin: 26px 0 18px; border-left: 3px solid #e0283a; padding: 4px 0 4px 14px; }
.mission-tag { font-weight: 700; font-size: 12px; letter-spacing: 5px; color: #ff6a7a; }
.mission-name { font-weight: 700; font-size: 24px; }
.mission-desc { color: var(--muted); font-size: 16px; line-height: 1.35; margin-top: 4px; }
.diff { display: flex; gap: 6px; margin-bottom: 14px; }
.diff button, .panel button { background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 7px 16px; font-size: 15px; letter-spacing: 3px; }
.diff button.on { border-color: var(--accent); color: #fff; background: rgba(95,208,255,0.12); }
button.big { background: linear-gradient(180deg, #f5d24a, #d8a50e); color: #1a1406; border: none; font-family: 'Russo One', sans-serif; font-size: 26px; letter-spacing: 8px; padding: 12px 42px; clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%); transition: transform 0.1s, filter 0.1s; }
button.big:hover { transform: translateX(4px); filter: brightness(1.1); }
.hint { font-size: 13px; color: var(--muted); margin-top: 10px; letter-spacing: 1px; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 18px; margin-top: 18px; font-size: 14px; color: var(--muted); }
.controls b { color: var(--text); }
.combo-guide { margin-top: 12px; font-size: 13px; color: var(--muted); line-height: 1.4; max-width: 520px; }
.combo-guide b { color: var(--gold); }
.credit { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-size: 12px; color: rgba(147, 164, 191, 0.7); }
.credit a { color: var(--accent); }

.panel { background: var(--panel-2); border: 1px solid var(--line); padding: 28px 36px; display: flex; flex-direction: column; gap: 10px; align-items: stretch; min-width: 320px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.panel.wide { min-width: min(560px, 92vw); align-items: center; }
.panel-title { font-family: 'Russo One', sans-serif; font-size: 34px; letter-spacing: 6px; text-align: center; margin-bottom: 8px; }
.panel button:hover { color: #fff; border-color: var(--accent); }
#pause, #results { background: rgba(4, 8, 14, 0.55); backdrop-filter: blur(3px); }
#res-rank { font-family: 'Russo One', sans-serif; font-size: 110px; line-height: 1; color: var(--gold); text-shadow: 0 0 30px rgba(243, 193, 28, 0.5); }
#res-stats { display: grid; grid-template-columns: auto auto; gap: 4px 30px; font-size: 18px; margin: 10px 0 16px; }
#res-stats .k { color: var(--muted); letter-spacing: 2px; }
#res-stats .v { font-weight: 700; text-align: right; }
.row { display: flex; gap: 10px; align-items: center; }

#loading { background: #0a0e16; flex-direction: column; gap: 14px; letter-spacing: 3px; color: var(--muted); z-index: 10; }
.spinner { width: 44px; height: 44px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- touch controls ---------- */
/* Hidden on anything with a real pointer; main.js only builds the layer on a touch device. */
#touch { position: absolute; inset: 0; pointer-events: none; z-index: 6; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
#touch button { pointer-events: auto; touch-action: none; -webkit-tap-highlight-color: transparent; }

/* floating movement stick: appears under the thumb, wherever it lands on the left half */
#tc-stick { position: absolute; width: 0; height: 0; }
.tc-ring { position: absolute; left: 0; top: 0; width: 132px; height: 132px; margin: -66px 0 0 -66px; border-radius: 50%; border: 2px solid rgba(95, 208, 255, 0.35); background: radial-gradient(circle, rgba(8,14,26,0.45), rgba(8,14,26,0.18) 70%, transparent 72%); }
.tc-knob { position: absolute; left: 0; top: 0; width: 62px; height: 62px; border-radius: 50%; border: 2px solid rgba(95, 208, 255, 0.8); background: radial-gradient(circle at 40% 35%, rgba(150, 230, 255, 0.55), rgba(20, 60, 96, 0.6)); box-shadow: 0 0 16px rgba(95, 208, 255, 0.35); transform: translate(-50%, -50%); }

/* action cluster: a diamond under the right thumb, scaled down on short screens */
#tc-pad { position: absolute; right: env(safe-area-inset-right, 0px); bottom: env(safe-area-inset-bottom, 0px); width: 350px; height: 250px; transform: scale(var(--tcs, 1)); transform-origin: 100% 100%; }
.tc-btn { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; border-radius: 50%; border: 2px solid rgba(95, 208, 255, 0.55); background: radial-gradient(circle at 42% 34%, rgba(38, 70, 108, 0.72), rgba(8, 14, 26, 0.66)); color: var(--text); font-family: 'Russo One', sans-serif; letter-spacing: 1px; padding: 0; text-shadow: 0 1px 3px #000; transition: transform 0.06s, filter 0.06s; }
.tc-btn b { font-weight: 400; font-size: 15px; }
.tc-btn i { font-family: 'Rajdhani', sans-serif; font-style: normal; font-weight: 700; font-size: 9px; letter-spacing: 2px; color: var(--muted); }
.tc-btn.on { transform: scale(0.92); filter: brightness(1.7); background: radial-gradient(circle at 42% 34%, rgba(95, 208, 255, 0.5), rgba(20, 50, 82, 0.8)); }
.tc-btn[data-a="attack"] { right: 16px; bottom: 92px; width: 88px; height: 88px; border-color: rgba(243, 193, 28, 0.7); }
.tc-btn[data-a="attack"] b { font-size: 19px; }
.tc-btn[data-a="charge"] { right: 96px; bottom: 172px; width: 72px; height: 72px; }
.tc-btn[data-a="dodge"] { right: 176px; bottom: 92px; width: 72px; height: 72px; }
.tc-btn[data-a="jump"] { right: 96px; bottom: 16px; width: 72px; height: 72px; }
.tc-btn[data-a="musou"] { right: 268px; bottom: 150px; width: 68px; height: 68px; border-color: rgba(255, 95, 208, 0.5); }
.tc-btn[data-a="lock"] { right: 268px; bottom: 62px; width: 60px; height: 60px; border-color: rgba(255, 90, 106, 0.6); }
.tc-btn[data-a="lock"] b { font-size: 12px; }
.tc-btn[data-a="musou"].ready { border-color: var(--sp); box-shadow: 0 0 18px var(--sp); animation: sp 0.6s infinite alternate; }
.tc-btn[data-a="dodge"].low { border-color: rgba(255, 154, 58, 0.8); }
.tc-btn[data-a="dodge"].low i { color: #ff9a3a; }

#tc-pause { position: absolute; top: calc(14px + env(safe-area-inset-top, 0px)); right: calc(150px + env(safe-area-inset-right, 0px)); width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; gap: 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
#tc-pause span { width: 4px; height: 15px; background: var(--text); }
#tc-sound { position: absolute; top: calc(14px + env(safe-area-inset-top, 0px)); right: calc(198px + env(safe-area-inset-right, 0px)); width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); padding: 0; }
#tc-sound .spk { width: 18px; height: 16px; background: currentColor; clip-path: polygon(0 32%, 26% 32%, 55% 0, 55% 100%, 26% 68%, 0 68%); }
/* muted: struck through, and dimmed so "on" is the one that draws the eye */
#tc-sound.off { color: var(--muted); }
#tc-sound.off::after { content: ''; position: absolute; left: 7px; right: 7px; top: 50%; height: 2px; background: var(--warn); transform: rotate(-38deg); }

/* a menu is up: only the pause button stays, so there is always a way back out */
#touch.menu-only #tc-pad, #touch.menu-only #tc-sound, #touch.menu-only #tc-stick { display: none; }

@media (max-height: 430px) { #touch { --tcs: 0.84; } }
@media (max-height: 360px) { #touch { --tcs: 0.72; } }

/* ---------- portrait / fullscreen prompts ---------- */
#rotate { display: none; position: absolute; inset: 0; z-index: 20; background: #0a0e16; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px; }
.rot-icon { width: 56px; height: 88px; border: 3px solid var(--accent); border-radius: 9px; animation: rot 1.8s ease-in-out infinite; }
@keyframes rot { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
.rot-text { font-family: 'Russo One', sans-serif; font-size: 22px; letter-spacing: 4px; }
.rot-sub { font-size: 14px; color: var(--muted); letter-spacing: 2px; }
@media (orientation: portrait) and (pointer: coarse) { #rotate { display: flex; } }

#touch-help { display: none; margin-top: 14px; font-size: 14px; color: var(--muted); line-height: 1.45; }
.th-row b { color: var(--text); }
#touch-help .th-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
#touch-help .coop-btn { margin-top: 0; }
#a2hs { margin-top: 8px; font-size: 13px; line-height: 1.4; max-width: 420px; }
#a2hs b { color: var(--accent); }
body.touch #touch-help { display: block; }
body.touch .hint { display: none; }

@media (max-width: 760px) {
  #keys, .controls, .combo-guide, #guide { display: none; }
  #bars { width: 60vw; }
  .pilot-en { display: none; }
  .pilot-jp { font-size: 18px; }
  #portrait-frame { width: 64px; height: 64px; }
  #minimap { width: 120px; height: 120px; }
  #map-wrap { width: 120px; }
  #boss-bars { top: 80px; width: 70vw; }
}

/* On a phone the title screen is taller than a landscape viewport, and notches eat into the HUD. */
body.touch .title-inner, body.touch .panel { max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }
body.touch #title { padding: 10px 0 10px clamp(16px, 5vw, 60px); align-items: flex-start; }
body.touch .credit { display: none; }
body.touch #stage-info { left: calc(22px + env(safe-area-inset-left, 0px)); top: calc(18px + env(safe-area-inset-top, 0px)); }
body.touch #map-wrap { right: calc(18px + env(safe-area-inset-right, 0px)); top: calc(18px + env(safe-area-inset-top, 0px)); }
body.touch #player { left: calc(20px + env(safe-area-inset-left, 0px)); bottom: calc(22px + env(safe-area-inset-bottom, 0px)); }
/* the thumb cluster sits where the combo counter and the toasts used to */
body.touch #combo { right: auto; left: calc(22px + env(safe-area-inset-left, 0px)); top: 34%; text-align: left; transform-origin: left center; }
body.touch #toasts { top: 52%; }
body.touch #bars { width: min(42vw, 360px); }
/* a short landscape phone has no room for a 96px portrait plus three bars */
@media (max-height: 430px) {
  /* the title has to fit LAUNCH above the fold on a phone held sideways */
  body.touch .logo { font-size: clamp(30px, 5.6vw, 52px); }
  body.touch .logo span { display: inline; }
  body.touch .logo-jp { font-size: 15px; letter-spacing: 6px; }
  body.touch .logo-sub, body.touch #touch-help .th-row:nth-child(3) { display: none; }
  body.touch .mission { margin: 10px 0 10px; }
  body.touch .mission-name { font-size: 19px; }
  body.touch .mission-desc { font-size: 13px; }
  body.touch button.big { font-size: 21px; padding: 9px 30px; }
  body.touch #touch-help { font-size: 13px; }
  /* pause and results have to fit their buttons above the fold too */
  body.touch .panel { padding: 14px 22px; gap: 6px; }
  body.touch .panel-title { font-size: 24px; margin-bottom: 4px; }
  body.touch #res-rank { font-size: 62px; }
  body.touch #res-stats { font-size: 14px; gap: 2px 20px; margin: 6px 0 10px; }
  body.touch .panel button { padding: 6px 16px; }
  body.touch #portrait-frame { width: 52px; height: 52px; }
  body.touch #combo-count { font-size: 44px; }
  body.touch #ko-count { font-size: 30px; }
  body.touch #minimap, body.touch #map-wrap { width: 96px; }
  body.touch #minimap { height: 96px; }
  body.touch #dialogue { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); width: min(420px, 62vw); }
  body.touch #ally { left: calc(84px + env(safe-area-inset-left, 0px)); bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- mobile suit select ---------- */
#select { background: linear-gradient(90deg, rgba(5,10,20,0.94) 0%, rgba(5,10,20,0.8) 45%, rgba(5,10,20,0.05) 72%); justify-content: flex-start; padding-left: clamp(16px, 6vw, 100px); }
.sel-inner { width: min(560px, 100%); max-height: 100%; overflow-y: auto; padding: 12px 0; }
.sel-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.sel-jp { font-family: 'Noto Sans JP', sans-serif; font-weight: 900; font-size: 26px; letter-spacing: 6px; color: var(--accent); }
.sel-title { font-family: 'Russo One', sans-serif; font-size: clamp(22px, 3.2vw, 34px); letter-spacing: 4px; }
#sel-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; margin: 12px 0 10px; }
.sel-card { position: relative; display: flex; align-items: center; gap: 12px; text-align: left; background: var(--panel); border: 1px solid var(--line); color: var(--text); padding: 10px 12px; clip-path: polygon(0 0, 100% 0, calc(100% - 12px) 100%, 0 100%); transition: background 0.12s, border-color 0.12s; }
.sel-card img:not(.sc-suit) { width: 58px; height: 58px; border-radius: 50%; border: 2px solid var(--line); background: #0b1424; object-fit: cover; object-position: 50% 30%; flex: none; }
.sel-card.on { background: rgba(243, 193, 28, 0.14); border-color: var(--gold); box-shadow: inset 4px 0 0 var(--gold); }
.sel-card.on img:not(.sc-suit) { border-color: var(--gold); }
.sel-card:hover { border-color: var(--accent); }
.sel-card .sc-suit { position: absolute; right: 18px; top: 50%; width: auto; height: 86%; max-width: 46%; object-fit: contain; opacity: 0.3; transform: translateY(-50%); filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6)); transition: transform 0.15s, opacity 0.15s; pointer-events: none; }
.sel-card.on .sc-suit { opacity: 0.45; transform: translateY(-50%) scale(1.1); }
.sd-head { display: flex; align-items: center; gap: 14px; }
.sd-head .sd-role { flex: 1; }
.sd-unit { height: 96px; width: 130px; object-fit: contain; flex: none; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.6)); animation: sdunit 0.25s ease-out; }
@keyframes sdunit { from { opacity: 0; transform: translateX(12px); } }
.sel-card > img:not(.sc-suit), .sc-text { position: relative; z-index: 1; }
.sc-text { display: flex; flex-direction: column; line-height: 1.15; }
.sc-jp { font-family: 'Noto Sans JP', sans-serif; font-weight: 700; font-size: 13px; color: var(--muted); }
.sc-unit { font-family: 'Russo One', sans-serif; font-size: 16px; letter-spacing: 1px; }
.sc-pilot { font-weight: 700; font-size: 12px; letter-spacing: 1px; color: var(--accent); }
#sel-detail { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--gold); padding: 12px 14px; }
.sd-role { color: var(--muted); font-size: 14px; line-height: 1.3; margin-bottom: 8px; }
.sd-stats { display: grid; grid-template-columns: 78px 1fr 44px; gap: 2px 10px; align-items: center; font-size: 13px; }
.st-k { font-weight: 700; letter-spacing: 2px; color: var(--muted); font-size: 12px; }
.st-bar { height: 6px; background: rgba(0,0,0,0.5); border: 1px solid #22385a; }
.st-bar div { height: 100%; background: linear-gradient(90deg, #5fd0ff, #f3c11c); }
.st-v { font-family: 'Russo One', sans-serif; font-size: 13px; text-align: right; }
.sd-equip { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.sd-equip span { font-weight: 700; font-size: 12px; letter-spacing: 1px; padding: 2px 8px; border: 1px solid #5f86d8; color: #b8ccff; }
.sd-moves { display: grid; grid-template-columns: auto 1fr auto; gap: 1px 12px; font-size: 14px; align-items: baseline; }
.mv-k { font-weight: 700; color: var(--gold); white-space: nowrap; }
.mv-v { color: var(--text); }
/* where a combo comes from: Reborn's footage (quiet), the DWG1-3 move lists (blue), or made up here (stands out) */
.src { display: inline-block; flex: none; font-style: normal; font-weight: 700; font-size: 0.72em; line-height: 1.3; letter-spacing: 1px; padding: 0 3px; border: 1px solid; border-radius: 2px; vertical-align: 0.1em; text-shadow: none; }
.src[data-src="reborn"] { color: var(--muted); border-color: rgba(147, 164, 191, 0.4); }
.src[data-src="dwg"] { color: #b8ccff; border-color: #5f86d8; background: rgba(95, 134, 216, 0.16); }
.src[data-src="new"] { color: #1a0d04; border-color: #ff9a4a; background: #ff9a4a; }
.src-legend { color: var(--muted); font-size: 12px; font-weight: 600; }
.sd-moves + .src-legend { margin-top: 6px; }
.mv-s { text-align: right; white-space: nowrap; }
.mv-s .src + .src, .lobby-controls .src + .src { margin-left: 3px; }
/* the spec sheet can be taller than the window (a phone held sideways, a long roster), so SORTIE stays pinned to the
   bottom of the scroll */
.sel-buttons { position: sticky; bottom: 0; margin-top: 10px; padding: 10px 0 8px; background: #060b15; box-shadow: 0 -10px 14px 4px #060b15; }
/* a bigger roster packs its cards tighter */
#sel-cards:has(.sel-card:nth-child(5)) { gap: 8px; }
#sel-cards:has(.sel-card:nth-child(5)) .sel-card { padding: 6px 10px; }
#sel-cards:has(.sel-card:nth-child(5)) .sel-card img:not(.sc-suit) { width: 46px; height: 46px; }
.sel-back { background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 10px 20px; font-size: 15px; letter-spacing: 3px; }
.sel-back:hover { color: #fff; border-color: var(--accent); }
@media (max-width: 760px) {
  #select { padding: 0 16px; background: rgba(5,10,20,0.86); }
  .sd-moves { font-size: 13px; }
}
@media (max-height: 720px) {
  .sd-role, .sd-unit { display: none; }
  .sel-card { padding: 6px 10px; }
  .sel-card img:not(.sc-suit) { width: 46px; height: 46px; }
  #select .hint { display: none; }
  #select button.big { font-size: 22px; padding: 9px 34px; }
}

/* ---------- co-op ---------- */
.title-inner .row { gap: 12px; flex-wrap: wrap; }
.coop-btn { background: rgba(47, 85, 176, 0.25); border: 1px solid #5f86d8; color: #fff; font-family: 'Russo One', sans-serif; font-size: 16px; letter-spacing: 3px; padding: 8px 18px; clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%); display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.coop-btn small { font-family: 'Rajdhani', sans-serif; font-size: 11px; letter-spacing: 2px; color: #9fc0ff; }
.coop-btn:hover { background: rgba(47, 85, 176, 0.45); }
#coop-panel { margin-top: 12px; background: var(--panel); border: 1px solid #5f86d8; padding: 10px 12px; max-width: 520px; }
#coop-status { font-weight: 700; letter-spacing: 1px; color: #9fc0ff; }
#coop-status.ok { color: var(--hp); }
.coop-link { display: flex; gap: 6px; margin: 8px 0 4px; }
.coop-link input { flex: 1; min-width: 0; background: rgba(0,0,0,0.4); border: 1px solid var(--line); color: var(--text); font-family: 'Rajdhani', sans-serif; font-size: 14px; padding: 6px 8px; }
.coop-link button { background: #2f55b0; border: none; color: #fff; padding: 6px 12px; letter-spacing: 2px; }
.coop-note { font-size: 13px; color: var(--muted); }
#lobby { background: rgba(5, 10, 20, 0.88); }
.lobby-art { display: flex; align-items: center; gap: 12px; }
#lobby-unit { width: 150px; height: 120px; object-fit: contain; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.6)); }
#lobby-portrait { width: 96px; height: 96px; image-rendering: pixelated; border: 3px solid #5f86d8; border-radius: 50%; background: #0b1424; }
.lobby-unit { font-family: 'Russo One', sans-serif; letter-spacing: 3px; color: #9fc0ff; }
#lobby-status { font-weight: 700; font-size: 18px; }
#lobby-team { font-size: 14px; color: var(--muted); letter-spacing: 1px; text-align: center; }
#lobby-team b { color: #9fc0ff; }
.lobby-controls { margin: 6px 0 10px; }
#ally { position: absolute; left: 130px; bottom: 112px; display: flex; flex-direction: column; gap: 2px; font-weight: 700; font-size: 12px; letter-spacing: 2px; color: #9fc0ff; text-shadow: 0 1px 3px #000; }
.ally-row { display: flex; align-items: center; gap: 8px; }
.ally-bar { width: 160px; height: 6px; background: rgba(0,0,0,0.6); border: 1px solid var(--line); }
.ally-unit { height: 28px; width: 38px; object-fit: contain; filter: drop-shadow(0 1px 3px #000); }
.ally-unit:not([src]), .ally-unit[src=""] { display: none; }
.ally-fill { height: 100%; background: linear-gradient(90deg, #5fd0ff, #9fe6ff); width: 100%; }
.ally-state { color: var(--warn); }
#res-wait { color: var(--muted); letter-spacing: 1px; }

/* ---------- touch: keyboard-only chrome and the combo guide ----------
   A phone held sideways is usually WIDER than 760px (852 on an iPhone 14 Pro, 915 on a Pixel), so the
   narrow-screen rules above never fire there. Gate on the device instead. */
body.touch #keys,
body.touch .controls,
body.touch .combo-guide { display: none; }
body.touch .pilot-en { display: none; }
body.touch #boss-bars { top: calc(72px + env(safe-area-inset-top, 0px)); width: min(48vw, 380px); }

/* The guide is a desktop-sized panel: on touch it has to shrink out of the way of the thumb and the
   health bars, and its rows read ATK / CHG, which are wider than J / K. */
body.touch #guide {
  top: calc(112px + env(safe-area-inset-top, 0px));
  left: calc(20px + env(safe-area-inset-left, 0px));
  /* two entries per row: half the height, which is what a landscape phone is short of */
  grid-template-columns: auto auto auto auto;
  max-width: min(60vw, 500px);
  padding: 5px 5px 6px 4px;
  gap: 1px 7px;
  font-size: 10px;
  background: rgba(8, 14, 26, 0.58);
  transition: opacity 0.18s;
}
/* a radio line lands right under the guide; let the line have the space */
body.touch #guide.ducked { opacity: 0; }
body.touch #guide .gd-head { font-size: 8.5px; letter-spacing: 2px; margin-bottom: 1px; padding-left: 3px; }
body.touch #guide .gd-row { padding: 0 3px; }
/* two to a line: pushed out, not scaled, so it stays clear of its neighbour */
body.touch #guide .gd-row.on { transform: translateX(2px); }
body.touch #guide .gd-k { gap: 1px; }
body.touch #guide .gd-k b { min-width: 0; padding: 0 2px; font-size: 8px; letter-spacing: 0; }
body.touch #guide .gd-v { gap: 3px; }
body.touch #guide .gd-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
body.touch #guide .src-legend { font-size: 8.5px; margin-top: 1px; padding-left: 3px; }
@media (max-height: 430px) {
  body.touch #guide { top: calc(112px + env(safe-area-inset-top, 0px)); font-size: 9px; max-width: min(62vw, 470px); }
  body.touch #guide .gd-k b { font-size: 7.5px; }
}

/* ---------- training ---------- */
#drill { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); width: min(440px, 44vw); pointer-events: none; }
#dr-card { position: relative; overflow: hidden; padding: 10px 16px 12px; background: linear-gradient(180deg, rgba(16, 28, 48, 0.9), rgba(8, 14, 26, 0.82)); border: 1px solid var(--line); border-top: 3px solid var(--accent); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45); text-align: center; clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 12px 100%, 0 calc(100% - 12px)); }
#dr-card.in { animation: drin 0.45s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes drin { from { transform: translateY(-24px) scale(0.94); opacity: 0; } }
/* a light sweep across the card when it arrives */
#dr-card::before { content: ''; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(160, 225, 255, 0.22) 50%, transparent 65%); transform: translateX(-100%); pointer-events: none; }
#dr-card.in::before { animation: drsweep 0.8s 0.1s ease-out; }
@keyframes drsweep { to { transform: translateX(100%); } }
.dr-head { display: flex; justify-content: space-between; font-family: 'Russo One', sans-serif; font-size: 11px; letter-spacing: 3px; }
.dr-tag { color: var(--accent); }
#dr-step { color: var(--muted); }
#dr-dots { display: flex; justify-content: center; gap: 5px; margin: 6px 0 4px; }
#dr-dots i { width: 16px; height: 4px; background: rgba(255, 255, 255, 0.14); transform: skewX(-20deg); transition: background 0.2s; }
#dr-dots i.cur { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
#dr-dots i.done { background: var(--gold); }
#dr-dots i.pop { animation: drdot 0.4s; }
@keyframes drdot { 40% { transform: skewX(-20deg) scaleY(2.4); box-shadow: 0 0 12px var(--gold); } }
.dr-title { display: flex; justify-content: center; align-items: baseline; gap: 10px; margin-top: 2px; }
#dr-jp { font-family: 'Noto Sans JP', sans-serif; font-weight: 900; font-size: 13px; color: var(--gold); }
#dr-name { font-family: 'Russo One', sans-serif; font-size: 26px; letter-spacing: 4px; color: #fff; text-shadow: 0 2px 10px rgba(95, 208, 255, 0.45); }
#dr-keys { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin: 8px 0 6px; min-height: 34px; }
#dr-keys kbd { font-family: 'Russo One', sans-serif; font-size: 15px; letter-spacing: 1px; color: #0a1222; background: linear-gradient(180deg, #f4f8ff, #b9c8de); padding: 5px 11px 4px; border-radius: 5px; box-shadow: 0 3px 0 #5c6f8e, 0 0 16px rgba(95, 208, 255, 0.35); animation: drkey 1.1s ease-in-out infinite; }
#dr-keys kbd:nth-of-type(2) { animation-delay: 0.18s; }
#dr-keys kbd:nth-of-type(3) { animation-delay: 0.36s; }
@keyframes drkey { 0%, 60%, 100% { transform: none; box-shadow: 0 3px 0 #5c6f8e, 0 0 16px rgba(95, 208, 255, 0.35); } 75% { transform: translateY(2px); box-shadow: 0 1px 0 #5c6f8e, 0 0 22px rgba(95, 208, 255, 0.7); } }
#dr-keys em { font-style: normal; font-weight: 700; font-size: 11px; letter-spacing: 2px; color: var(--gold); margin-left: -2px; }
.dr-then { color: var(--muted); font-size: 18px; font-weight: 700; }
.dr-seq { display: inline-flex; align-items: center; gap: 6px; }
.dr-or { font-size: 13px; font-weight: 700; letter-spacing: 2px; color: var(--muted); margin: 0 4px; }
.dr-alt { flex-basis: 100%; font-size: 11.5px; font-weight: 600; letter-spacing: 1px; color: var(--muted); }
#dr-text { font-size: 16px; font-weight: 600; color: var(--text); text-shadow: 0 1px 3px #000; }
#dr-tip { margin-top: 3px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.dr-bar { position: relative; height: 6px; margin-top: 9px; background: rgba(255, 255, 255, 0.1); transform: skewX(-20deg); overflow: hidden; }
#dr-fill { height: 100%; width: 0; background: linear-gradient(90deg, #2d9fd8, var(--accent)); box-shadow: 0 0 10px var(--accent); }
#dr-card.clear { border-top-color: var(--gold); animation: drclear 0.5s ease-out; }
#dr-card.clear #dr-fill { background: linear-gradient(90deg, #d8a50e, #ffe27a); box-shadow: 0 0 14px var(--gold); }
#dr-card.clear #dr-keys kbd { animation: none; }
@keyframes drclear { 0% { box-shadow: 0 0 0 rgba(243, 193, 28, 0); } 25% { box-shadow: 0 0 40px rgba(243, 193, 28, 0.7); transform: scale(1.03); } 100% { box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45); } }
.dr-stamp { position: absolute; left: 50%; top: 50%; font-family: 'Russo One', sans-serif; font-size: 44px; letter-spacing: 6px; color: var(--gold); border: 4px solid var(--gold); padding: 0 14px; background: rgba(10, 14, 22, 0.55); text-shadow: 0 0 18px rgba(243, 193, 28, 0.7); opacity: 0; transform: translate(-50%, -50%) rotate(-8deg) scale(2.2); }
#dr-card.clear .dr-stamp { animation: drstamp 1.2s cubic-bezier(0.2, 1.5, 0.4, 1) forwards; }
@keyframes drstamp { 0% { opacity: 0; transform: translate(-50%, -50%) rotate(-8deg) scale(2.2); } 18% { opacity: 1; transform: translate(-50%, -50%) rotate(-8deg) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) rotate(-8deg) scale(1.05); } }
/* on a phone, the buttons a drill wants pressed pulse */
.tc-btn.tut { border-color: var(--gold); box-shadow: 0 0 0 0 rgba(243, 193, 28, 0.8); animation: tcglow 1s ease-out infinite; }
@keyframes tcglow { 0% { box-shadow: 0 0 0 0 rgba(243, 193, 28, 0.75); } 100% { box-shadow: 0 0 0 18px rgba(243, 193, 28, 0); } }
/* the title's TRAINING button, and its nudge until training has been done once */
.train-btn { background: rgba(95, 208, 255, 0.14); border-color: var(--accent); }
.train-btn small { color: #9fe2ff; }
.train-btn.fresh { animation: trainfresh 1.6s ease-in-out infinite; }
@keyframes trainfresh { 50% { background: rgba(95, 208, 255, 0.34); box-shadow: inset 0 0 18px rgba(95, 208, 255, 0.5); } }
#res-rank.word { font-size: 64px; letter-spacing: 8px; margin: 18px 0 10px; }
body.touch #drill { top: calc(10px + env(safe-area-inset-top, 0px)); width: min(360px, 40vw); }
body.touch #dr-card { padding: 7px 12px 9px; }
body.touch #dr-name { font-size: 19px; }
body.touch #dr-keys { margin: 5px 0 3px; min-height: 26px; }
body.touch #dr-keys kbd { font-size: 12px; padding: 3px 8px 2px; }
body.touch #dr-text { font-size: 13px; }
body.touch #dr-tip { display: none; }
body.touch .dr-stamp { font-size: 30px; }
