:root {
  --glass: rgba(16, 17, 26, .74);
  --line: rgba(255, 255, 255, .12);
  --text: #f3f4fa;
  --mute: #a4a8bd;
  --accent: #5cffc8;
  --accent-ink: #06231a;
  --hot: #ff6bd6;
  --r: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; background: #0b0c12; color: var(--text);
  font: 14px/1.4 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif; }
#stage { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; touch-action: none; cursor: crosshair; display: block; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }

/* panels */
#brand, #rail, #dock, .pop, #game { position: fixed; z-index: 5; background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3); border-radius: var(--r); }
#brand { top: max(12px, env(safe-area-inset-top)); left: 12px; padding: 8px 12px; display: flex; gap: 10px; align-items: center; }
#brand b { letter-spacing: .02em; }
#brand a { color: var(--mute); text-decoration: none; font-size: 13px; }
#brand a:hover { color: var(--text); }
#status { color: var(--mute); font-size: 13px; }
#status.live { color: var(--accent); }

#rail { left: 12px; top: 64px; padding: 6px; display: flex; flex-direction: column; gap: 6px; max-height: calc(100dvh - 170px); overflow: auto; scrollbar-width: none; }
#rail .grp { display: flex; flex-direction: column; gap: 4px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
#rail .grp:last-child { border: 0; padding: 0; }
#rail button, #dock button { min-width: 52px; min-height: 46px; padding: 4px 6px; border-radius: 10px; display: grid; place-items: center; gap: 0; transition: background .12s, transform .12s; }
#rail button span, #dock button span { font-size: 19px; line-height: 1.1; }
#rail button em, #dock button em { font-style: normal; font-size: 10.5px; color: var(--mute); }
button:hover, button.air-hover { background: rgba(255, 255, 255, .1); }
button.air-hover { outline: 2px solid var(--accent); transform: scale(1.06); }
button.on { background: rgba(92, 255, 200, .16); box-shadow: inset 0 0 0 1.5px var(--accent); }
button.on em { color: var(--text); }
button.pulse { animation: pulse .3s; }
@keyframes pulse { 50% { transform: scale(.9); background: rgba(92, 255, 200, .35); } }
.dot { width: var(--d); height: var(--d); border-radius: 50%; background: var(--text); display: block; }
.swatches { display: grid !important; grid-template-columns: 1fr 1fr; gap: 5px !important; padding: 2px 2px 8px !important; }
.swatches button { min-width: 0 !important; min-height: 0 !important; width: 23px; height: 23px; padding: 0 !important; border-radius: 50% !important; background: var(--c); border: 2px solid rgba(255, 255, 255, .25); }
.swatches button.on { box-shadow: 0 0 0 2px #0b0c12, 0 0 0 4px var(--accent); }

#dock { left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom)); padding: 6px; display: flex; gap: 2px; align-items: center; max-width: calc(100vw - 16px); overflow-x: auto; scrollbar-width: none; }
#dock .sep { width: 1px; align-self: stretch; margin: 6px 4px; background: var(--line); flex: none; }
#dock button { flex: none; }
#dock .hero { background: linear-gradient(135deg, rgba(92, 255, 200, .2), rgba(255, 107, 214, .2)); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18); min-width: 64px; }
#dock .hero em { color: var(--text); font-weight: 600; }
#dock .hero.busy span { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
#recBtn.rec { background: rgba(255, 70, 70, .25); box-shadow: inset 0 0 0 1.5px #ff5a5a; }
#recBtn.rec span { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* popovers */
.pop { padding: 14px; width: min(360px, calc(100vw - 24px)); }
.pop h3 { margin: 0 0 10px; font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.pop label { display: block; margin: 12px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--mute); }
.pop input, .sheet input { -webkit-user-select: text; user-select: text; }
.pop input { width: 100%; padding: 9px 10px; border-radius: 9px; border: 1px solid var(--line); background: rgba(0, 0, 0, .35); color: var(--text); font: inherit; min-width: 0; }
.pop input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips button, .row button { padding: 7px 11px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.row .go { margin-left: auto; }
.go { background: var(--accent) !important; color: var(--accent-ink) !important; font-weight: 700; border: 0 !important; }
.x { border: 0 !important; padding: 2px 6px !important; color: var(--mute); }
.fine { color: var(--mute); font-size: 12px; margin: 12px 0 0; }
.sw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); }
#settings { right: 12px; top: max(12px, env(safe-area-inset-top)); max-height: calc(100dvh - 110px); overflow: auto; }
#picpop, #presentpop, #directpop { left: 50%; bottom: 92px; transform: translateX(-50%); }
#directpop { width: min(440px, calc(100vw - 24px)); }
#hear { position: fixed; z-index: 32; left: 50%; bottom: 100px; transform: translateX(-50%); max-width: calc(100vw - 24px); padding: 12px 20px; border-radius: 999px; font-size: 18px; font-weight: 600;
  background: rgba(16, 17, 26, .92); border: 1.5px solid var(--hot); box-shadow: 0 0 30px rgba(255, 107, 214, .35); animation: hear 1.2s ease-in-out infinite; }
@keyframes hear { 50% { box-shadow: 0 0 46px rgba(255, 107, 214, .7); } }

/* game */
#game { top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); padding: 10px 14px; width: min(340px, calc(100vw - 24px)); text-align: center; }
#game .word { font-size: 17px; }
#game .word b { color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
#game .bar { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .12); margin: 8px 0; overflow: hidden; }
#game .bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--hot), var(--accent)); transform-origin: left; }
#game .guess { min-height: 22px; font-size: 15px; }
#game .row { justify-content: center; }

/* welcome */
#welcome { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(900px 500px at 50% 30%, rgba(92, 255, 200, .12), transparent 60%), radial-gradient(700px 500px at 70% 80%, rgba(255, 107, 214, .12), transparent 60%), rgba(8, 9, 14, .86); overflow: auto; }
#welcome .card { width: min(560px, 100%); text-align: center; padding: 26px 22px; border-radius: 22px; background: var(--glass); border: 1px solid var(--line); }
#welcome h1 { margin: 0; font-size: clamp(34px, 8vw, 54px); letter-spacing: -.02em; background: linear-gradient(100deg, var(--accent), #5cc8ff 45%, var(--hot)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 16px; color: #d6d9e8; margin: 8px auto 18px; max-width: 42ch; }
.signals { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; margin-bottom: 20px; }
.signals div { background: rgba(255, 255, 255, .05); border-radius: 12px; padding: 10px 6px; font-size: 12px; color: var(--mute); display: grid; gap: 2px; }
.signals span { font-size: 26px; }
.signals b { color: var(--text); font-size: 13px; }
.big { font-size: 17px; padding: 13px 26px; border-radius: 999px; }
.link { display: block; margin: 12px auto 0; color: var(--mute); text-decoration: underline; }

/* full-screen sheets: results and the details form */
.sheet { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; padding: 16px; background: rgba(8, 9, 14, .8); overflow: auto; }
.sheet .card { width: min(560px, 100%); padding: 24px 22px; border-radius: 22px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.sheet h2 { margin: 0 0 6px; font-size: 24px; }
.sheet .lead { margin: 8px 0 14px; max-width: none; }
.sheet input[type="text"], .sheet input[type="email"] { width: 100%; padding: 11px 12px; margin-bottom: 8px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 0, 0, .35); color: var(--text); font: inherit; font-size: 16px; }
.sheet a { color: var(--accent); }
.check { display: flex; gap: 8px; align-items: flex-start; color: var(--mute); font-size: 13px; margin: 4px 0; }
.row.center { justify-content: center; flex-wrap: wrap; }
.rrow { display: grid; gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rrow b { text-transform: uppercase; letter-spacing: .08em; color: #ffe45c; font-size: 13px; }
.rrow .big { font-size: 20px; font-weight: 650; }
.rrow .trail, .rrow .cmp { color: var(--mute); font-size: 13px; }
.rrow .cmp { color: var(--accent); }

/* practice coach */
#coach { position: fixed; z-index: 6; left: 50%; top: max(12px, env(safe-area-inset-top)); transform: translateX(-50%); width: min(460px, calc(100vw - 24px)); padding: 12px 16px;
  background: linear-gradient(135deg, rgba(92, 255, 200, .16), rgba(255, 107, 214, .16)), var(--glass); border: 1px solid rgba(92, 255, 200, .5); border-radius: var(--r); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); text-align: center; }
#coach p { margin: 0; font-size: 17px; font-weight: 600; }
#coach .row { justify-content: space-between; margin-top: 8px; color: var(--accent); letter-spacing: .1em; }
#coach button { color: var(--mute); border: 0; padding: 2px 6px; font-size: 12px; letter-spacing: 0; }
#count { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; font-size: min(40vw, 300px); font-weight: 800; color: #fff; text-shadow: 0 0 60px var(--accent); pointer-events: none; }

/* air cursor */
#cursor { position: fixed; z-index: 30; left: 0; top: 0; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(var(--accent) calc(var(--p, 0) * 1turn), rgba(255, 255, 255, .28) 0); display: grid; place-items: center; transition: width .1s, height .1s, margin .1s; }
#cursor i { width: 26px; height: 26px; border-radius: 50%; background: rgba(10, 11, 18, .55); display: block; transition: inherit; }
#cursor.down { width: 18px; height: 18px; margin: -9px 0 0 -9px; background: var(--accent); }
#cursor.down i { width: 6px; height: 6px; background: #fff; }

/* toasts */
#toasts { position: fixed; z-index: 40; left: 50%; top: 118px; transform: translateX(-50%); display: grid; gap: 6px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast { background: rgba(16, 17, 26, .92); border: 1px solid var(--line); padding: 8px 14px; border-radius: 999px; animation: tin .2s; text-align: center; }
.toast.err { border-color: #ff7a7a; }
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } }

[hidden] { display: none !important; }

@media (max-width: 640px) {
  #rail { top: 58px; right: 12px; flex-direction: row; max-height: none; overflow-x: auto; }
  #rail .grp { flex-direction: row; border-bottom: 0; border-right: 1px solid var(--line); padding: 0 6px 0 0; }
  .swatches { display: flex !important; align-items: center; padding: 0 8px 0 2px !important; }
  #rail button em, #dock button em { display: none; }
  #rail button, #dock button { min-width: 42px; min-height: 40px; }
  #dock { left: 8px; right: 8px; transform: none; }
  #picpop, #presentpop, #directpop { bottom: calc(74px + env(safe-area-inset-bottom)); max-height: calc(100dvh - 200px); overflow: auto; }
  #hear { bottom: calc(84px + env(safe-area-inset-bottom)); font-size: 16px; }
  .pop input { font-size: 16px; } /* below 16px, phones zoom the page when the box is tapped */
  #rail button, #dock button { min-width: 46px; min-height: 46px; }
  #dock { padding-bottom: 6px; mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%); -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%); }
  .sheet .card, #welcome .card { padding: 18px 16px; }
  .signals { grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px; }
  .signals div { padding: 7px 4px; font-size: 11px; }
  .signals span { font-size: 21px; }
  #coach { top: 112px; }
  #settings { top: 112px; max-height: calc(100dvh - 190px); }
  #game { top: 112px; }
  #toasts { top: 214px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

@media (max-height: 480px) {
  #rail { top: 54px; max-height: calc(100dvh - 130px); }
  #welcome .card { padding: 14px; }
  #welcome h1 { font-size: 30px; }
  .signals { display: none; }
  #dock button em, #rail button em { display: none; }
  #dock button, #rail button { min-height: 40px; }
}

/* messages sit below the experiment panel while it is open */
body.hud #toasts { top: 200px; }
@media (max-width: 640px) { body.hud #toasts { top: 300px; } }
/* short screens (a phone on its side): popovers scroll inside the space above the dock instead of running off the top */
@media (max-height: 480px) {
  .pop { max-height: calc(100dvh - 70px); overflow: auto; }
  #picpop, #presentpop, #directpop { bottom: 58px; }
  #settings { top: 8px; max-height: calc(100dvh - 70px); }
  #game { top: 8px; padding: 6px 12px; }
  #coach { top: 8px; }
}

/* an open popover sits above the practice card */
.pop { z-index: 7; }
