:root {
  --bg: #010207;
  --panel: rgba(4, 8, 24, .76);
  --line: rgba(120, 235, 255, .28);
  --cyan: #63f7ff;
  --blue: #4b8cff;
  --violet: #b66cff;
  --pink: #ff4fd8;
  --text: #eaffff;
  --muted: #7c9cad;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: radial-gradient(circle at 50% 0%, #07142d 0%, #020711 32%, #010207 72%); color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }
body { min-height: 100dvh; overflow-x: hidden; overscroll-behavior: none; }
button { font: inherit; touch-action: manipulation; }
.app-shell { width: min(100%, 1840px); min-height: 100dvh; margin: auto; display: grid; grid-template-rows: auto 1fr auto; padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); gap: 9px; }
.topbar, .statusbar { border: 1px solid rgba(93, 220, 255, .22); background: linear-gradient(180deg, rgba(7,16,36,.9), rgba(2,5,14,.82)); box-shadow: inset 0 0 34px rgba(58,170,255,.05), 0 0 36px rgba(32,123,255,.06); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.topbar { position: relative; min-height: 66px; padding: 9px 12px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.brand { display: flex; gap: 11px; align-items: center; min-width: 0; }
.brand strong { display: block; letter-spacing: .13em; font-size: clamp(.74rem, 1.05vw, 1rem); text-shadow: 0 0 12px rgba(99,247,255,.5); white-space: nowrap; }
.brand small { display: block; color: var(--muted); font-size: .58rem; letter-spacing: .08em; margin-top: 3px; white-space: nowrap; }
.brand-mark { width: 31px; height: 31px; flex: 0 0 31px; border: 1px solid var(--cyan); transform: rotate(45deg); box-shadow: 0 0 15px rgba(99,247,255,.45), inset 0 0 14px rgba(99,247,255,.2); position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 6px; border: 1px solid var(--pink); box-shadow: 0 0 10px rgba(255,79,216,.45); }
.hud { display: flex; gap: clamp(13px, 2.25vw, 36px); justify-content: center; }
.hud > div { text-align: center; min-width: 59px; }
.hud span { color: #598094; font-size: .54rem; letter-spacing: .16em; display: block; }
.hud b { color: #dffeff; font-size: clamp(.78rem, 1vw, 1rem); letter-spacing: .07em; text-shadow: 0 0 10px rgba(99,247,255,.4); }
.top-actions { justify-self: end; display: flex; gap: 7px; }
.icon-btn { color: #a9d9e3; border: 1px solid rgba(113,220,255,.24); background: rgba(5,15,30,.7); min-height: 34px; padding: 0 11px; cursor: pointer; font-size: .63rem; letter-spacing: .08em; }
.icon-btn:hover, .icon-btn:focus-visible { color: white; border-color: var(--cyan); box-shadow: 0 0 13px rgba(99,247,255,.17); outline: none; }
.icon-btn[aria-pressed="true"] { color: var(--pink); border-color: rgba(255,79,216,.5); }
.game-frame { position: relative; width: 100%; aspect-ratio: 16/9; max-height: calc(100dvh - 126px); align-self: center; justify-self: center; background: #01040b; border: 1px solid rgba(104,224,255,.35); overflow: hidden; isolation: isolate; contain: layout paint style; box-shadow: 0 0 65px rgba(0,90,255,.1), inset 0 0 80px rgba(28,100,190,.08); }
#game { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; outline: none; background: #01040b; user-select: none; -webkit-user-select: none; }
#game:focus-visible { box-shadow: inset 0 0 0 2px rgba(99,247,255,.7); }
.glass-vignette, .scanlines { position: absolute; inset: 0; pointer-events: none; }
.glass-vignette { z-index: 3; background: radial-gradient(ellipse at center, transparent 47%, rgba(0,0,6,.09) 70%, rgba(0,0,8,.6) 100%); }
.scanlines { z-index: 4; opacity: .085; background: repeating-linear-gradient(to bottom, transparent 0, transparent 3px, rgba(168,242,255,.09) 4px); }
.overlay { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s ease; background: radial-gradient(circle at center, rgba(8,18,46,.4), rgba(1,2,8,.86)); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
.overlay.visible { opacity: 1; visibility: visible; }
.panel { border: 1px solid rgba(104,236,255,.42); background: linear-gradient(145deg, rgba(3,9,25,.94), rgba(5,3,20,.88)); box-shadow: 0 0 65px rgba(48,140,255,.15), inset 0 0 55px rgba(36,126,255,.05); text-align: center; position: relative; overflow: hidden; }
.panel::before, .panel::after { content: ""; position: absolute; width: 34px; height: 34px; border-color: var(--cyan); opacity: .7; }
.panel::before { left: 9px; top: 9px; border-left: 1px solid; border-top: 1px solid; }
.panel::after { right: 9px; bottom: 9px; border-right: 1px solid; border-bottom: 1px solid; }
.hero-panel { width: min(690px, 92%); padding: clamp(22px, 4vw, 48px); }
.eyebrow { color: #65b9d4; letter-spacing: .2em; font-size: clamp(.55rem, .8vw, .7rem); margin-bottom: 14px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 18px; font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif; font-style: italic; font-size: clamp(3rem, 7.6vw, 6.8rem); line-height: .74; letter-spacing: -.025em; transform: skewX(-4deg); text-shadow: 0 0 9px rgba(99,247,255,.6), 0 0 28px rgba(70,100,255,.38); }
h1 span { color: transparent; -webkit-text-stroke: 1px var(--pink); text-shadow: 0 0 10px rgba(255,79,216,.5), 0 0 30px rgba(255,79,216,.25); }
.hero-panel p { width: min(540px, 100%); margin: 0 auto 21px; color: #9bc4d0; line-height: 1.55; font-size: clamp(.68rem, 1.05vw, .9rem); }
.primary-btn { border: 1px solid var(--cyan); color: #eaffff; background: linear-gradient(90deg, rgba(18,79,123,.38), rgba(107,27,133,.32)); padding: 12px 32px; min-width: 180px; cursor: pointer; letter-spacing: .2em; font-weight: 800; box-shadow: 0 0 22px rgba(99,247,255,.16), inset 0 0 22px rgba(99,247,255,.08); }
.primary-btn:hover, .primary-btn:focus-visible { outline: none; border-color: white; box-shadow: 0 0 30px rgba(99,247,255,.3), inset 0 0 30px rgba(99,247,255,.12); }
.control-grid { margin: 22px auto 14px; display: flex; gap: 10px 17px; justify-content: center; flex-wrap: wrap; max-width: 590px; }
.control-grid span { color: #7aa4b2; font-size: .56rem; display: flex; align-items: center; gap: 4px; }
kbd, .control-grid b { border: 1px solid rgba(108,205,226,.3); background: rgba(14,40,59,.45); color: #c8f7ff; padding: 4px 6px; font: inherit; }
.control-grid em { font-style: normal; margin-left: 3px; }
.entry-note { width: min(560px, 100%); margin: 0 auto 12px; padding: 8px 10px; border: 1px solid rgba(101,255,209,.16); background: rgba(20,70,68,.12); color: #78aead; font-size: .56rem; line-height: 1.45; }
.entry-note strong { color: #bfffee; }
.power-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px 10px; margin: 0 auto 12px; color: #678a98; font-size: .51rem; letter-spacing: .04em; }
.power-legend span { border-left: 1px solid rgba(99,247,255,.24); padding-left: 6px; }
.clean-room { display: block; color: #536d7c; font-size: .52rem; line-height: 1.4; }
.message-panel { width: min(540px, 88%); padding: 42px 30px; }
.message-panel h2 { font-size: clamp(1.7rem, 4vw, 3rem); margin-bottom: 12px; letter-spacing: .05em; }
.message-panel p { color: #8eb6c3; margin-bottom: 25px; line-height: 1.5; }
.power-toast { --toast-color: #63f7ff; position: absolute; z-index: 7; top: 3.2%; left: 50%; transform: translate(-50%, -18px); display: flex; align-items: center; gap: 11px; min-width: min(410px, 80%); padding: 10px 14px; border: 1px solid var(--toast-color); background: rgba(2,8,21,.88); box-shadow: 0 0 30px rgba(99,247,255,.16), inset 0 0 24px rgba(99,247,255,.06); opacity: 0; visibility: hidden; transition: opacity .18s ease, transform .22s ease, visibility .18s ease; pointer-events: none; }
.power-toast.visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.power-toast > b { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 36px; border: 1px solid var(--toast-color); color: #fff; box-shadow: 0 0 16px rgba(99,247,255,.28); }
.power-toast strong, .power-toast span { display: block; text-align: left; }
.power-toast strong { color: #efffff; font-size: .7rem; letter-spacing: .12em; }
.power-toast span { color: #7fa8b6; font-size: .57rem; margin-top: 3px; }
.touch-hint { position: absolute; z-index: 5; bottom: 3%; left: 50%; transform: translateX(-50%); color: rgba(161,233,244,.42); font-size: .58rem; letter-spacing: .14em; pointer-events: none; opacity: 0; transition: opacity .3s; }
.statusbar { min-height: 31px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 15px; color: #507686; font-size: .56rem; letter-spacing: .07em; }
.statusbar span:first-child { color: #79bfd1; }
@media (pointer: coarse) { .touch-hint { opacity: 1; } }
@media (max-width: 1050px) {
  .brand small { display: none; }
  .hud { gap: 10px; }
  .hud > div { min-width: 52px; }
}
@media (max-width: 900px) {
  .app-shell { gap: 5px; padding: max(4px, env(safe-area-inset-top)) max(4px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left)); }
  .topbar { grid-template-columns: 1fr auto; min-height: 48px; padding: 5px 7px; }
  .brand-mark { width: 22px; height: 22px; flex-basis: 22px; }
  .hud { grid-row: 2; grid-column: 1/-1; width: 100%; justify-content: space-around; gap: 2px; border-top: 1px solid rgba(80,180,220,.11); padding-top: 4px; }
  .hud > div { min-width: 47px; }
  .top-actions { grid-column: 2; grid-row: 1; }
  .icon-btn { min-height: 27px; padding: 0 7px; font-size: .52rem; }
  .game-frame { max-height: none; }
  .statusbar { display: none; }
}
@media (max-width: 520px) {
  .brand strong { font-size: .65rem; }
  .hero-panel { padding: 20px 15px; }
  .control-grid { margin-top: 16px; gap: 7px; }
  .hud span { font-size: .46rem; }
  .hud b { font-size: .7rem; }
  .power-toast { min-width: 88%; top: 2%; }
}
@media (prefers-reduced-motion: reduce) {
  .overlay, .power-toast { transition: none; }
  .scanlines { display: none; }
}

/* v3: attract mode, leaderboard, replay and optional GPU overlay */
.gpu-fx { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; pointer-events: none; opacity: .34; }
.hero-panel { max-height: 94%; overflow: auto; scrollbar-width: thin; scrollbar-color: rgba(99,247,255,.35) transparent; }
.hero-actions, .score-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; }
.secondary-btn { border: 1px solid rgba(182,108,255,.58); color: #d9c9ff; background: rgba(33,16,57,.44); padding: 11px 18px; min-width: 180px; cursor: pointer; letter-spacing: .1em; font-weight: 700; }
.secondary-btn:hover, .secondary-btn:focus-visible { outline: none; border-color: #e5d7ff; box-shadow: 0 0 20px rgba(182,108,255,.2); }
.primary-btn:disabled, .secondary-btn:disabled { opacity: .5; cursor: progress; }
.leaderboard-card { width: min(560px, 100%); margin: 14px auto 4px; padding: 9px 11px; border: 1px solid rgba(99,247,255,.15); background: linear-gradient(90deg, rgba(0,22,38,.42), rgba(31,8,45,.34)); }
.leaderboard-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: #bff9ff; font-size: .56rem; letter-spacing: .09em; }
.leaderboard-head span { color: #5f8493; font-size: .48rem; }
.leaderboard-list { list-style-position: inside; margin: 7px 0 0; padding: 0 4px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 3px 15px; text-align: left; counter-reset: leaderboard; max-height: min(29vh, 250px); overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.leaderboard-list li { list-style: none; display: grid; grid-template-columns: 20px 1fr auto; gap: 5px; color: #7195a3; font-size: .52rem; min-width: 0; }
.leaderboard-list li::before { counter-increment: leaderboard; content: counter(leaderboard, decimal-leading-zero); color: #4d7281; }
.leaderboard-list li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #9dd3dc; }
.leaderboard-list li b { color: #e7ffff; font-weight: 700; }
.demo-banner { position: absolute; z-index: 7; left: 50%; top: 2.5%; transform: translateX(-50%); width: min(620px, 88%); padding: 8px 14px; border: 1px solid rgba(99,247,255,.48); background: rgba(2,8,21,.82); box-shadow: 0 0 26px rgba(99,247,255,.15); text-align: center; pointer-events: none; }
.demo-banner strong, .demo-banner span { display: block; }
.demo-banner strong { color: #dfffff; font-size: .62rem; letter-spacing: .14em; }
.demo-banner span { margin-top: 2px; color: #719aa7; font-size: .48rem; letter-spacing: .1em; }
.score-panel { width: min(540px, 90%); padding: 38px 32px; }
.score-panel h2 { margin-bottom: 9px; font-size: clamp(1.7rem, 4vw, 2.8rem); }
.score-panel p { color: #95bdc8; margin-bottom: 18px; }
.callsign-label { display: block; text-align: left; width: min(390px, 100%); margin: 0 auto 6px; color: #79bdcc; font-size: .58rem; letter-spacing: .15em; }
#callsign { display: block; width: min(390px, 100%); margin: 0 auto; border: 1px solid rgba(99,247,255,.45); background: rgba(0,9,20,.85); color: #f0ffff; padding: 12px 13px; font: 800 1rem ui-monospace, monospace; letter-spacing: .08em; text-transform: uppercase; outline: none; }
#callsign:focus { border-color: #fff; box-shadow: 0 0 18px rgba(99,247,255,.18); }
#namePolicy { display: block; width: min(390px, 100%); margin: 8px auto 18px; color: #597987; font-size: .52rem; line-height: 1.45; text-align: left; }
.score-result { min-height: 2.8em; margin-top: 13px; color: #bfffee; font-size: .62rem; line-height: 1.45; }
@media (max-width: 720px) {
  .leaderboard-list { grid-template-columns: 1fr; max-height: min(25vh, 220px); }
  .leaderboard-card { margin-top: 10px; }
  .hero-actions .primary-btn, .hero-actions .secondary-btn { min-width: 150px; padding-left: 14px; padding-right: 14px; }
}
@media (max-height: 760px) and (min-width: 700px) {
  .hero-panel { padding-top: 18px; padding-bottom: 18px; }
  .hero-panel h1 { font-size: clamp(2.7rem, 6vw, 5rem); margin-bottom: 10px; }
  .hero-panel p { margin-bottom: 11px; }
  .control-grid { margin-top: 11px; margin-bottom: 8px; }
  .clean-room { display: none; }
}


/* v3.2 cross-browser compositing, audio mixer, and iPhone immersive viewport */
.audio-menu { position: absolute; z-index: 30; right: 10px; top: calc(100% - 4px); width: min(310px, calc(100vw - 20px)); padding: 13px 14px 12px; border: 1px solid rgba(99,247,255,.34); background: rgba(2,8,21,.97); box-shadow: 0 16px 45px rgba(0,0,0,.48), 0 0 28px rgba(99,247,255,.1); }
.audio-menu[hidden] { display: none !important; }
.audio-menu-head, .audio-menu label { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.audio-menu-head { margin-bottom: 10px; color: #dffeff; font-size: .62rem; letter-spacing: .12em; }
.audio-menu-head span { color: #76a8b7; font-size: .49rem; }
.audio-menu label { margin: 9px 0 4px; color: #8fc7d1; font-size: .56rem; letter-spacing: .1em; }
.audio-menu output { color: #eaffff; font: 700 .58rem ui-monospace, monospace; }
.audio-menu input[type="range"] { width: 100%; accent-color: var(--cyan); }
.audio-menu small { display: block; margin-top: 9px; color: #5c7d89; font-size: .49rem; line-height: 1.35; }

/* WebKit receives the same visual composition. Essential gameplay effects are Canvas2D;
   prefixed backdrop-filter keeps the surrounding chrome equivalent on older Safari. */
html.webkit-engine .gpu-fx { mix-blend-mode: normal; opacity: .34; }

/* iPhone has no element Fullscreen API: gameplay uses an edge-to-edge viewport shell instead. */
@media (hover: none) and (pointer: coarse) and (max-width: 980px) {
  body.mobile-immersive { width: 100%; height: var(--app-vh, 100dvh); overflow: hidden; background: radial-gradient(circle at 50% 44%, #06162e 0%, #01040b 58%, #000208 100%); }
  body.mobile-immersive .app-shell { position: fixed; left: 0; top: 0; width: var(--app-vw, 100vw); height: var(--app-vh, 100dvh); min-height: var(--app-vh, 100dvh); margin: 0; padding: 0; gap: 0; display: block; max-width: none; overflow: hidden; }
  body.mobile-immersive .game-frame { position: absolute; inset: 0; width: 100%; height: 100%; max-height: none; aspect-ratio: auto; border: 0; box-shadow: none; }
  body.mobile-immersive .topbar { position: absolute; z-index: 25; top: env(safe-area-inset-top); left: env(safe-area-inset-left); right: env(safe-area-inset-right); min-height: 0; padding: 4px 6px; grid-template-columns: 1fr auto; border: 0; background: linear-gradient(180deg, rgba(1,5,15,.8), rgba(1,5,15,.18), transparent); box-shadow: none; pointer-events: none; }
  body.mobile-immersive .topbar .brand { display: none; }
  body.mobile-immersive .topbar .hud { grid-column: 1; grid-row: 1; border: 0; padding: 0 4px; justify-content: flex-start; gap: clamp(8px, 2vw, 18px); pointer-events: none; }
  body.mobile-immersive .topbar .hud > div { min-width: 0; }
  body.mobile-immersive .topbar .hud span { font-size: .39rem; }
  body.mobile-immersive .topbar .hud b { font-size: .62rem; }
  body.mobile-immersive .top-actions { grid-column: 2; grid-row: 1; pointer-events: auto; }
  body.mobile-immersive .icon-btn { min-height: 28px; padding: 0 7px; background: rgba(2,8,21,.78); }
  body.mobile-immersive .statusbar { display: none; }
  body.mobile-immersive .audio-menu { pointer-events: auto; right: 5px; top: 36px; }
  body.mobile-immersive #game { width: 100%; height: 100%; }

  /* The display canvas always fills the immersive shell. game.js presents the fixed
     logical world through an aspect-preserving camera (including portrait pan mode). */
  body.mobile-immersive.portrait-mode #game,
  body.mobile-immersive.landscape-mode #game { position: absolute; inset: 0; width: 100%; height: 100%; }
  body.mobile-immersive.portrait-mode .touch-hint { bottom: calc(env(safe-area-inset-bottom) + 4%); }

  /* In landscape, gameplay fills the display but the paddle is lifted in logical
     coordinates, leaving a generous empty finger runway below its artwork. */
  body.mobile-immersive.landscape-mode .touch-hint {
    bottom: calc(env(safe-area-inset-bottom) + 2.5%);
    opacity: .58;
  }
}

@supports not (height: 100dvh) {
  body.mobile-immersive, body.mobile-immersive .app-shell { height: 100vh; min-height: 100vh; }
}


/* v3.2.2 desktop WebKit parity profile.
   Safari/Orion on older macOS stay on a main-thread Canvas render path; keep browser chrome
   composition conservative so CSS GPU layers cannot hide or reorder the game's Canvas effects. */
html.legacy-webkit .gpu-fx { display: none !important; }
html.legacy-webkit .game-frame { isolation: auto; contain: layout; transform: none; }
html.legacy-webkit .topbar,
html.legacy-webkit .statusbar,
html.legacy-webkit .overlay,
html.legacy-webkit .audio-menu {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
html.legacy-webkit .topbar { background: rgba(2,8,21,.94); }
html.legacy-webkit .statusbar { background: rgba(2,8,21,.96); }
