/* Reel Runner by Halawi Media. Brand tokens mirror /assets/css/styles.css */
:root {
  --brand-violet: #9b3df5;
  --brand-magenta: #c84fb4;
  --brand-coral: #ea6a5a;
  --brand-gradient: linear-gradient(100deg, #9b3df5 0%, #c84fb4 52%, #ea6a5a 100%);
  --brand-gradient-strong: linear-gradient(100deg, #8b35ec 0%, #b0409e 55%, #c94a3a 100%);
  --brand-violet-text: #c191ff;
  --brand-coral-text: #ff9384;
  --c-bg: #0a0a0c;
  --c-surface: rgba(17, 17, 22, 0.72);
  --c-line: rgba(232, 222, 255, 0.12);
  --c-line-strong: rgba(232, 222, 255, 0.24);
  --c-text: #f6f3fa;
  --c-text-body: #cbc5d4;
  --c-text-muted: #a69fb2;
  --font-display: "Blockjock", "Lexend", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-accent: "Drawntastic", "Patrick Hand", "Comic Neue", "Segoe Print", cursive;
  --font-sans: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --radius: 16px;
  --radius-lg: 24px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; background: var(--c-bg); color: var(--c-text);
  font-family: var(--font-sans); -webkit-font-smoothing: antialiased;
  overscroll-behavior: none; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
#app { position: fixed; inset: 0; overflow: hidden; background: var(--c-bg); }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: pointer; }

/* ---------- HUD ---------- */
.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; gap: clamp(10px, 2vw, 28px);
  padding: calc(clamp(10px, 1.6vw, 22px) + var(--safe-t)) calc(clamp(12px, 2.2vw, 32px) + var(--safe-r)) 0 calc(clamp(12px, 2.2vw, 32px) + var(--safe-l));
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-brand { display: block; flex: 0 0 auto; line-height: 0; opacity: .95; transition: opacity .2s; }
.hud-brand:hover { opacity: 1; }
.hud-brand img { height: clamp(22px, 2.6vw, 38px); width: auto; filter: drop-shadow(0 4px 18px rgba(155,61,245,.35)); }
.hud-stats { display: flex; gap: clamp(8px, 1.6vw, 22px); margin-left: auto; pointer-events: none; }
.stat {
  display: flex; flex-direction: column; align-items: flex-end; min-width: 3.6em;
  padding: 6px 12px; border-radius: 12px; background: rgba(10,10,12,.42);
  border: 1px solid var(--c-line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.stat-label { font-size: clamp(10px, .8vw, 12px); letter-spacing: .14em; text-transform: uppercase; color: var(--c-text-muted); font-weight: 700; }
.stat-value { font-family: var(--font-display); font-weight: 700; font-size: clamp(16px, 1.7vw, 26px); line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat--score .stat-value { background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; min-width: 4ch; text-align: right; }
.hud-actions { display: flex; gap: 10px; }
.icon-btn {
  width: clamp(44px, 3.4vw, 54px); height: clamp(44px, 3.4vw, 54px); border-radius: 14px;
  display: grid; place-items: center; cursor: pointer; color: var(--c-text);
  background: rgba(10,10,12,.5); border: 1px solid var(--c-line-strong);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: transform .15s var(--ease-out), border-color .2s, background .2s;
}
.icon-btn:hover { border-color: var(--brand-violet-text); background: rgba(155,61,245,.18); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.icon-btn .ico-on, .icon-btn .ico-off { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon-btn[aria-pressed="false"] .ico-on { display: none; }
.icon-btn[aria-pressed="true"] .ico-off { display: none; }
#btnPause { visibility: hidden; }
body.is-playing #btnPause { visibility: visible; }
body.is-start .hud-stats .stat:not(:nth-child(2)) { display: none; }

:focus-visible { outline: 3px solid var(--brand-violet-text); outline-offset: 3px; }

/* ---------- Toast ---------- */
.toast {
  position: absolute; left: 50%; top: 24%; z-index: 4; transform: translate(-50%, -50%) scale(.9);
  font-family: var(--font-display); font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  font-size: clamp(22px, 4vw, 54px); color: var(--c-text); opacity: 0; pointer-events: none;
  text-shadow: 0 6px 30px rgba(200,79,180,.65);
  transition: opacity .35s var(--ease-out), transform .5s var(--ease-out);
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0; z-index: 10; display: grid; place-items: center;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  background: radial-gradient(120% 90% at 50% 40%, rgba(10,10,12,.15) 0%, rgba(10,10,12,.62) 100%);
  opacity: 0; visibility: hidden; transition: opacity .35s var(--ease-out), visibility 0s linear .35s;
  overflow: auto; touch-action: pan-y;
}
.screen.is-active { opacity: 1; visibility: visible; transition: opacity .35s var(--ease-out); }
.panel {
  position: relative; width: min(680px, 100%); margin: auto;
  padding: clamp(20px, 3.2vw, 42px);
  border-radius: var(--radius-lg); background: var(--c-surface);
  border: 1px solid var(--c-line-strong);
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.8), 0 18px 60px -28px rgba(155,61,245,.6), inset 0 1px 0 rgba(255,255,255,.06);
  backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2);
  text-align: center; transform: translateY(14px) scale(.98); transition: transform .5s var(--ease-out);
}
.screen.is-active .panel { transform: none; }
.panel::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--brand-gradient); opacity: .9;
}
.panel--small { width: min(440px, 100%); }
.panel--over { width: min(520px, 100%); }
.eyebrow { margin: 0 0 4px; font-family: var(--font-accent); font-size: clamp(18px, 1.8vw, 24px); color: var(--brand-coral-text); }
.title {
  margin: 0; font-family: var(--font-display); font-weight: 700; line-height: 1;
  font-size: clamp(40px, 6.4vw, 84px); letter-spacing: -.01em;
  background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 8px 30px rgba(155,61,245,.35)); padding-bottom: .06em;
}
.title--md { font-size: clamp(36px, 5vw, 60px); }
.title--xl { font-size: clamp(56px, 9vw, 112px); }
.lede { margin: 12px auto 0; max-width: 34em; color: var(--c-text-body); font-size: clamp(15px, 1.15vw, 17px); line-height: 1.5; }
.panel-body { margin-top: clamp(14px, 2vw, 24px); display: grid; gap: 14px; text-align: left; }
.howto { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.howto li {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px;
  background: rgba(255,255,255,.035); border: 1px solid var(--c-line); font-size: 15px; color: var(--c-text-body);
}
.keys { display: inline-flex; align-items: center; gap: 5px; min-width: 9.6em; flex: 0 0 auto; }
.or { font-size: 13px; color: var(--c-text-muted); }
kbd {
  display: inline-block; min-width: 2em; padding: 2px 8px; border-radius: 7px; text-align: center;
  font-family: var(--font-sans); font-weight: 700; font-size: 13px; color: var(--c-text);
  background: linear-gradient(180deg, #24222d, #16151c); border: 1px solid var(--c-line-strong);
  box-shadow: 0 2px 0 rgba(0,0,0,.5);
}
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.legend-col { padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.035); border: 1px solid var(--c-line); }
.legend-title { margin: 0 0 6px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--c-text-muted); font-weight: 700; }
.legend ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--c-text-body); }
.legend li b { margin-left: auto; color: var(--brand-violet-text); }
.lg-ico { width: 22px; height: 22px; flex: 0 0 auto; }
.legend-text { margin: 0; font-size: 14px; line-height: 1.5; color: var(--c-text-body); }
.panel-foot { margin-top: clamp(16px, 2.2vw, 26px); display: grid; justify-items: center; gap: 12px; }
.note { margin: 0; font-size: 13.5px; color: var(--c-text-muted); }
.note b { color: var(--c-text); }
.accent { font-family: var(--font-accent); font-size: 1.2em; color: var(--brand-coral-text); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 0 30px; border-radius: 999px; cursor: pointer;
  font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: .02em;
  color: #fff; border: 1px solid transparent; text-decoration: none;
  transition: transform .18s var(--ease-out), box-shadow .25s, filter .2s;
}
.btn svg { width: 20px; height: 20px; fill: currentColor; }
.btn--primary { background: var(--brand-gradient-strong); box-shadow: 0 16px 40px -14px rgba(200,79,180,.85); min-width: 200px; }
.btn--primary:hover { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 20px 48px -14px rgba(200,79,180,1); }
.btn--primary:active { transform: translateY(0) scale(.98); }
.btn--ghost { background: rgba(255,255,255,.05); border-color: var(--c-line-strong); color: var(--c-text); }
.btn--ghost:hover { border-color: var(--brand-violet-text); }
.btn-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 18px; }

.scores { display: grid; grid-template-columns: 1fr 1fr .8fr; gap: 10px; margin-top: 18px; }
.score-box { padding: 12px 8px; border-radius: 14px; background: rgba(255,255,255,.04); border: 1px solid var(--c-line); display: grid; gap: 2px; }
.score-num { font-family: var(--font-display); font-weight: 700; font-size: clamp(26px, 3vw, 38px); font-variant-numeric: tabular-nums; }
.score-box:first-child .score-num { background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.badge-new {
  display: inline-block; margin: 12px 0 0; padding: 5px 14px; border-radius: 999px;
  font-family: var(--font-accent); font-size: 20px; color: #fff; background: var(--brand-gradient-strong);
  animation: pop .6s var(--ease-out);
}
.badge-new[hidden] { display: none; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.hint { margin: 10px 0 0; font-size: 13px; color: var(--c-text-muted); }
.cta {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px;
  margin-top: 18px; padding: 14px 18px; border-radius: 14px; text-decoration: none;
  background: linear-gradient(100deg, rgba(155,61,245,.14), rgba(234,106,90,.12));
  border: 1px solid rgba(193,145,255,.3); transition: border-color .2s, transform .2s var(--ease-out);
}
.cta:hover { border-color: var(--brand-coral-text); transform: translateY(-1px); }
.cta-k { font-family: var(--font-accent); font-size: 19px; color: var(--brand-coral-text); }
.cta-v { font-weight: 700; color: var(--c-text); font-size: 15px; }
.link-back {
  display: inline-block; margin-top: 14px; padding: 8px 6px; font-size: 14px; font-weight: 500;
  color: var(--c-text-muted); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(193,145,255,.5);
}
.link-back:hover { color: var(--c-text); }

/* ---------- Touch controls ---------- */
.touch-controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; pointer-events: none;
  display: none; justify-content: space-between;
  padding: 0 calc(16px + var(--safe-r)) calc(18px + var(--safe-b)) calc(16px + var(--safe-l));
}
body.is-touch.is-playing .touch-controls { display: flex; }
.touch-btn {
  pointer-events: auto; width: clamp(76px, 22vw, 104px); height: clamp(76px, 22vw, 104px); border-radius: 50%;
  display: grid; place-items: center; align-content: center; gap: 0; color: var(--c-text);
  background: rgba(10,10,12,.38); border: 1.5px solid rgba(232,222,255,.28);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font-family: var(--font-sans); font-weight: 700; font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  touch-action: none; transition: transform .1s, background .15s;
}
.touch-btn svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.touch-btn.is-down { transform: scale(.92); background: rgba(155,61,245,.35); }
.touch-btn--jump { border-color: rgba(234,106,90,.5); }

.noscript { position: absolute; inset: 0; display: grid; place-items: center; z-index: 20; background: var(--c-bg); }
.noscript a { color: var(--brand-violet-text); }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .hud { gap: 8px; }
  .hud-brand img { height: 20px; }
  .stat { padding: 4px 8px; min-width: 0; border-radius: 10px; }
  .stat-label { font-size: 9px; }
  .stat-value { font-size: 16px; }
  .icon-btn { width: 44px; height: 44px; border-radius: 12px; }
  .legend { grid-template-columns: 1fr; }
  .howto li { font-size: 14px; padding: 8px 10px; }
  .keys { min-width: 7.6em; }
  .or { font-size: 12px; }
  .panel { padding: 22px 18px; }
  .lede { font-size: 14.5px; }
}
@media (max-width: 400px) {
  .legend-col:last-child { display: none; }
}
/* Short landscape screens (phones sideways) */
@media (max-height: 520px) {
  .panel--start { width: min(860px, 100%); padding: 16px 20px; display: grid; grid-template-columns: 1fr 1.15fr; gap: 6px 20px; text-align: left; align-items: center; }
  .panel--start .panel-head { grid-row: 1; grid-column: 1; }
  .panel--start .panel-body { grid-row: 1 / span 2; grid-column: 2; margin-top: 0; gap: 8px; }
  .panel--start .panel-foot { grid-row: 2; grid-column: 1; justify-items: start; margin-top: 8px; gap: 8px; }
  .panel--start .title { font-size: clamp(32px, 7vh, 52px); }
  .panel--start .lede { font-size: 13.5px; margin-top: 6px; }
  .panel--start .eyebrow { font-size: 17px; }
  .panel--start .legend { grid-template-columns: 1fr; }
  .panel--start .legend-col:last-child { display: none; }
  .panel--start .legend-col { padding: 8px 12px; }
  .panel--start .howto li { padding: 6px 10px; font-size: 13px; }
  .btn { min-height: 48px; font-size: 16px; }
  .panel--over { width: min(720px, 100%); padding: 16px 22px; }
  .panel--over .title--xl { font-size: clamp(44px, 12vh, 72px); }
  .panel--over .scores { margin-top: 10px; }
  .panel--over .score-box { padding: 6px; }
  .panel--over .score-num { font-size: 24px; }
  .panel--over .btn-row { margin-top: 10px; }
  .panel--over .hint { display: none; }
  .panel--over .cta { margin-top: 10px; padding: 9px 14px; }
  .panel--over .link-back { margin-top: 4px; padding: 4px; }
  .touch-controls { padding-bottom: calc(6px + var(--safe-b)); }
  .touch-btn { width: 64px; height: 64px; font-size: 10px; }
  .touch-btn svg { width: 24px; height: 24px; }
  .stat { padding: 3px 9px; }
}
@media (max-height: 420px) {
  .panel--over { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; align-items: center; }
  .panel--over > .eyebrow, .panel--over > .title, .panel--over > .badge-new { grid-column: 1; }
  .panel--over > .scores { grid-column: 1; }
  .panel--over > .btn-row, .panel--over > .cta, .panel--over > .link-back { grid-column: 2; }
  .panel--over > .btn-row { grid-row: 1 / span 2; align-self: end; }
  .panel--over > .cta { grid-row: 3; }
  .panel--over > .link-back { grid-row: 4; }
}
@media (hover: none) and (pointer: coarse) {
  .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
