:root {
  /* === PLUG IN BRAND HERE ============================================ */
  --brand: #3fbfff;          /* SUPPMAN / Kosso brand blue                */
  --brand-dark: #145f96;     /* deep shadow blue                          */
  --brand-glow: #8ddcff;     /* highlight blue                            */
  --accent: #ff6b5b;         /* coral (GOAT flavor band)                  */
  /* =================================================================== */

  --bg: #050912;
  --bg-soft: #0c1422;
  --ink: #f5f9ff;
  --ink-dim: #8aa7c2;
  --pellet: #8ddcff;
  --power: #3fbfff;
  --scared: #2266ff;
  --scared-end: #ffffff;
  --pad: rgba(63,191,255,0.10);
  --pad-active: rgba(63,191,255,0.25);
}

* {
  box-sizing: border-box;
  /* Disable iOS double-tap-zoom on every element. The canvas and D-pad
     re-override this to 'none' below where they need to swallow all
     touch gestures for input. */
  touch-action: manipulation;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
  height: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100vw;
  align-items: center;
  justify-content: flex-start;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#topbar {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  gap: 12px;
}

#logo {
  height: 36px;
  width: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 6px rgba(0,0,0,0.5));
}

#audio-toggle {
  appearance: none;
  background: rgba(63,191,255,0.10);
  border: 1px solid rgba(63,191,255,0.30);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 16px;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
  margin-left: 4px;
  flex: 0 0 auto;
  transition: background 0.12s ease, border-color 0.12s ease;
}
#audio-toggle:hover  { background: rgba(63,191,255,0.18); border-color: var(--brand); }
#audio-toggle:active { transform: translateY(1px); }
#audio-toggle .audio-on,
#audio-toggle .audio-off { display: inline-block; }
@media (max-width: 480px) {
  #audio-toggle { padding: 3px 6px; font-size: 14px; }
}

#hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(40px, auto));
  gap: 10px;
  font-size: 12px;
  letter-spacing: 0.05em;
}

.hud-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1;
}

.hud-cell .label {
  color: var(--ink-dim);
  font-size: 9px;
  margin-bottom: 3px;
}

.hud-cell span:last-child {
  font-size: 16px;
  color: var(--brand-glow);
  text-shadow: 0 0 6px rgba(255, 106, 96, 0.45);
}

#stage {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  min-height: 0;
}

canvas#game {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 448 / 496;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  border-radius: 6px;
  box-shadow:
    0 0 0 2px rgba(255,255,255,0.04),
    0 18px 40px rgba(0,0,0,0.5);
  touch-action: none;          /* swipe gestures own the canvas      */
  -webkit-touch-callout: none;
}

/* Overlays --------------------------------------------------------------- */
.overlay {
  /* Cover the entire viewport, not just the canvas area. On small phones
     the panel is taller than the stage; absolute-inset-0 was clipping the
     title at the top and the buttons at the bottom. */
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.55), rgba(0,0,0,0.92));
  backdrop-filter: blur(3px);
  display: flex;
  flex-direction: column;
  align-items: center;
  /* 'safe center' falls back to flex-start when the content overflows,
     so the title never gets pushed off the top of the viewport. */
  justify-content: safe center;
  padding:
    max(env(safe-area-inset-top), 14px)
    14px
    max(env(safe-area-inset-bottom), 14px);
  z-index: 100;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.overlay.hidden { display: none; }

.panel {
  background: var(--bg-soft);
  border: 2px solid var(--brand);
  border-radius: 10px;
  padding: 22px 20px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 0 30px rgba(63,191,255,0.22), inset 0 0 0 1px rgba(255,255,255,0.04);
  /* Let the panel exceed the flex line and the viewport scroll the overlay
     instead of squishing the panel. */
  flex: 0 0 auto;
  margin: auto 0;
}

.panel h1 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: 0.1em;
  color: #fff;
  text-shadow: 0 0 12px var(--brand), 3px 3px 0 var(--brand-dark);
}
.panel h1 .accent { color: var(--brand); }

.panel p {
  margin: 6px 0;
  color: var(--ink-dim);
  font-size: 13px;
  line-height: 1.4;
}

.panel .hint {
  margin-top: 16px;
  font-size: 11px;
  color: var(--ink-dim);
  opacity: 0.8;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin: 14px 0 8px;
}
.stats div { display: flex; flex-direction: column; align-items: center; }
.stats .label { font-size: 10px; color: var(--ink-dim); }
.stats span:last-child { font-size: 22px; color: var(--brand-glow); }

.promo {
  border: 1px dashed var(--brand);
  border-radius: 8px;
  padding: 12px 8px;
  margin: 14px 0;
  background: rgba(255,59,48,0.08);
}
.promo-line, .promo-sub { font-size: 11px; margin: 2px 0; color: var(--ink-dim); }
.code {
  font-size: 24px;
  letter-spacing: 0.25em;
  color: var(--ink);
  background: rgba(0,0,0,0.4);
  padding: 8px 10px;
  border-radius: 6px;
  margin: 6px auto;
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.08);
}

.actions { display: flex; gap: 10px; justify-content: center; margin-top: 4px; }

/* Menu (start overlay multi-scene) --------------------------------------- */
.panel-menu { max-width: 380px; padding: 18px 18px 14px; }
.menu-scene { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.menu-scene.hidden { display: none; }

.menu-logo {
  display: block;
  max-width: 100%;
  height: auto;
  max-height: 110px;
  margin: 0 auto 4px;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 18px rgba(63,191,255,0.35));
}
.menu-tag {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--ink-dim);
  text-align: center;
  letter-spacing: 0.04em;
}

/* Countdown */
.countdown {
  margin: 4px 0 6px;
  padding: 8px 6px;
  border: 1px solid rgba(63,191,255,0.25);
  border-radius: 8px;
  background: rgba(63,191,255,0.06);
  text-align: center;
}
.countdown-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--ink-dim);
  margin-bottom: 6px;
}
.countdown-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.countdown-grid > div {
  background: rgba(0,0,0,0.45);
  border-radius: 6px;
  padding: 6px 2px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid rgba(63,191,255,0.10);
}
.countdown-grid span {
  font-size: 20px;
  line-height: 1;
  color: var(--brand-glow);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-shadow: 0 0 8px rgba(63,191,255,0.35);
}
.countdown-grid em {
  font-style: normal;
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--ink-dim);
  margin-top: 4px;
}
.countdown.urgent .countdown-grid span { color: #ffae9c; text-shadow: 0 0 10px rgba(255,107,91,0.6); }

/* Menu nav */
.menu-nav { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.btn-menu {
  appearance: none;
  background: transparent;
  border: 2px solid rgba(63,191,255,0.45);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 0.18em;
  padding: 11px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.12s ease, border-color 0.12s ease;
  text-align: center;
  text-decoration: none;
  display: block;
  width: 100%;
}
.btn-menu:hover { background: rgba(63,191,255,0.10); border-color: var(--brand); }
.btn-menu:active { transform: translateY(1px); }
.btn-menu.primary {
  background: var(--brand);
  color: #00121f;
  border-color: var(--brand);
  font-weight: bold;
}
.btn-menu.primary:hover { background: var(--brand-glow); border-color: var(--brand-glow); }
.btn-menu[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

/* Lockup state */
.locked {
  border: 1px dashed rgba(255,138,130,0.6);
  border-radius: 8px;
  padding: 10px 8px;
  background: rgba(255,107,91,0.07);
  margin-top: 4px;
}
.locked[hidden] { display: none !important; }
.locked-title {
  margin: 0 0 4px;
  font-size: 13px;
  letter-spacing: 0.16em;
  color: #ffae9c;
}
.locked-sub {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--ink-dim);
}

/* Scene headers */
.menu-h {
  margin: 4px 0 6px;
  text-align: center;
  font-size: 18px;
  letter-spacing: 0.18em;
  color: var(--brand-glow);
  text-shadow: 0 0 10px rgba(63,191,255,0.35);
}

/* Prizes */
.prize-howto {
  border: 1px solid rgba(255,107,91,0.45);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255,107,91,0.06);
  margin: 0 0 10px;
}
.prize-howto-title {
  margin: 0 0 4px;
  font-size: 10px;
  letter-spacing: 0.20em;
  color: #ffae9c;
}
.prize-howto p {
  margin: 0;
  font-size: 12px;
  color: var(--ink);
  line-height: 1.5;
}

.prize-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.prize-list li {
  border: 1px solid rgba(63,191,255,0.20);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(63,191,255,0.05);
}
.prize-list p { margin: 4px 0 0; font-size: 12px; color: var(--ink); line-height: 1.4; }
.prize-tag {
  display: inline-block;
  background: var(--brand);
  color: #00121f;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  letter-spacing: 0.18em;
  font-weight: bold;
}
.prize-tag.gold   { background: #ffcf3a; color: #2b1d00; box-shadow: 0 0 12px rgba(255,207,58,0.45); }
.prize-tag.silver { background: #d6e1ee; color: #1b2735; box-shadow: 0 0 10px rgba(214,225,238,0.35); }
.prize-tag.bronze { background: #cd7f32; color: #2a1400; box-shadow: 0 0 10px rgba(205,127,50,0.35); }

/* Credits */
.credits { font-size: 12px; line-height: 1.6; text-align: center; }
.credits .dim { color: var(--ink-dim); margin: 2px 0; }
.brand-link {
  display: block;
  align-self: center;        /* opt out of .menu-scene's align-items: stretch */
  max-width: 240px;
  margin: 0 auto 6px;
}
.brand-mark {
  display: block;
  /* Explicit height + auto width keeps the wordmark its real aspect
     ratio instead of getting stretched by the flex parent. */
  height: 64px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  margin: 0 auto;
  filter: drop-shadow(0 0 10px rgba(63,191,255,0.35));
}

/* "Tufan was here" maker mark — small + non-obstructive --------------- */
.tufan-mark {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 8px auto 2px;
  opacity: 0.85;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}
.tufan-mark.small  { max-height: 36px; opacity: 0.7; margin-top: 10px; }
.tufan-mark.large  { max-height: 90px; opacity: 0.95; margin: 4px auto 6px; }
.tufan-mark.tiny   { max-height: 24px; opacity: 0.55; }

/* Back button */
.btn-back {
  appearance: none;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.2em;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 6px;
  align-self: center;
}
.btn-back:hover { color: var(--ink); border-color: var(--brand); }

/* Leaderboard ------------------------------------------------------------ */
.panel-over { max-width: 380px; }

.lb {
  border: 1px solid rgba(63,191,255,0.25);
  border-radius: 8px;
  padding: 8px 8px 10px;
  margin: 12px 0 6px;
  background: rgba(63,191,255,0.05);
  text-align: left;
}
.lb-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 4px 6px;
  border-bottom: 1px solid rgba(63,191,255,0.12);
  margin-bottom: 6px;
}
.lb-title {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--brand-glow);
}
.lb-status {
  font-size: 10px;
  color: var(--ink-dim);
}
.lb-list {
  list-style: none;
  margin: 0;
  padding: 0 4px;
  max-height: 188px;
  overflow-y: auto;
  font-size: 12px;
}
.lb-list li {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  padding: 3px 0;
  align-items: baseline;
  border-bottom: 1px dashed rgba(255,255,255,0.04);
}
.lb-list li:last-child { border-bottom: none; }
.lb-list .rank { color: var(--ink-dim); text-align: right; font-size: 10px; }
.lb-list .name { color: var(--ink); letter-spacing: 0.05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-list .pts  { color: var(--brand-glow); font-weight: bold; }
.lb-list li.you { background: rgba(63,191,255,0.10); border-radius: 4px; padding-left: 4px; padding-right: 4px; }
.lb-list li.you .name { color: #fff; }

.submit { margin: 8px 0 10px; display: flex; flex-direction: column; gap: 8px; }
.submit.hidden { display: none; }
.submit-label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--ink-dim);
  margin: 2px 0 -2px;
  text-transform: uppercase;
}
.submit-hint-inline {
  font-size: 9px;
  color: var(--ink-dim);
  opacity: 0.85;
  letter-spacing: 0.04em;
  text-transform: none;
  margin-left: 4px;
}

/* Both inputs share identical chrome.  Sans-serif (not the page monospace)
   so '@', '.', and accented characters render correctly. font-size 16px
   keeps iOS Safari from auto-zooming on focus. */
#submit-name,
#submit-email {
  display: block;
  width: 100%;
  background: rgba(0,0,0,0.45);
  color: var(--ink);
  border: 1px solid var(--brand);
  border-radius: 8px;
  padding: 13px 14px;
  font-family: ui-rounded, ui-sans-serif, system-ui, -apple-system,
               "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  letter-spacing: 0.02em;
  line-height: 1.2;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
#submit-name { text-transform: uppercase; letter-spacing: 0.10em; }
#submit-name::placeholder,
#submit-email::placeholder {
  color: rgba(245,249,255,0.32);
  letter-spacing: 0.05em;
}
#submit-name:focus,
#submit-email:focus {
  border-color: var(--brand-glow);
  box-shadow: 0 0 0 2px rgba(63,191,255,0.35);
}
#submit-name:invalid,
#submit-email:invalid {
  /* Don't shout while the user is still typing */
  border-color: var(--brand);
}

#btn-submit {
  width: 100%;
  padding: 13px 16px;
  font-size: 14px;
  letter-spacing: 0.20em;
  margin-top: 2px;
}
#btn-submit { padding: 10px 14px; font-size: 13px; }
.submit-hint {
  font-size: 11px;
  color: var(--ink-dim);
  margin: 6px 2px 0;
  min-height: 14px;
}
.submit-hint.error { color: #ff8a82; }
.submit-hint.success { color: var(--brand-glow); }

.btn {
  appearance: none;
  border: 2px solid var(--brand);
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 0.15em;
  padding: 10px 18px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.05s ease, background 0.15s ease;
}
.btn:hover { background: rgba(255,59,48,0.12); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-glow); }

/* D-pad ------------------------------------------------------------------ */
#dpad {
  display: none;
  width: 210px;
  height: 210px;
  margin: 8px auto 16px;
  position: relative;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#dpad.show { display: block; }

.pad {
  position: absolute;
  width: 70px;
  height: 70px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: var(--pad);
  color: var(--ink);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  pointer-events: auto;
  transition: background 0.05s ease, transform 0.05s ease, box-shadow 0.1s ease;
}
.pad:active,
.pad.active {
  background: var(--pad-active);
  transform: scale(0.96);
  box-shadow: 0 0 0 2px var(--brand), 0 0 18px rgba(63, 191, 255, 0.45);
  color: #fff;
}
.pad.up    { top: 0;       left: 70px; }
.pad.left  { top: 70px;    left: 0; }
.pad.right { top: 70px;    left: 140px; }
.pad.down  { top: 140px;   left: 70px; }

/* center diamond — visual anchor only */
#dpad::before {
  content: "";
  position: absolute;
  inset: 70px;
  width: 70px;
  height: 70px;
  border-radius: 14px;
  background: radial-gradient(circle, rgba(63,191,255,0.18), rgba(63,191,255,0) 70%);
  pointer-events: none;
}

/* Small screens: tighten layout */
@media (max-width: 480px) {
  #topbar { padding: 6px 8px; gap: 6px; }
  #logo { height: 28px; }
  .hud-cell .label { font-size: 8px; }
  .hud-cell span:last-child { font-size: 14px; }
  #dpad { width: 180px; height: 180px; margin: 6px auto 10px; }
  .pad { width: 60px; height: 60px; font-size: 20px; }
  .pad.up    { left: 60px; }
  .pad.left  { top: 60px;  }
  .pad.right { top: 60px; left: 120px; }
  .pad.down  { top: 120px; left: 60px; }
  #dpad::before { inset: 60px; width: 60px; height: 60px; }
}

/* Very tall + narrow phones */
@media (max-height: 700px) and (max-width: 480px) {
  #dpad { width: 156px; height: 156px; }
  .pad { width: 52px; height: 52px; font-size: 18px; }
  .pad.up    { left: 52px; }
  .pad.left  { top: 52px; }
  .pad.right { top: 52px; left: 104px; }
  .pad.down  { top: 104px; left: 52px; }
  #dpad::before { inset: 52px; width: 52px; height: 52px; }
}
