/* RETRO KICK — flat panels, blocky colour, compact retro typography
   (spec §13.4). The game canvas renders at low internal resolution and is
   scaled with crisp pixels. */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --panel: #1c2030;
  --panel-edge: #10131e;
  --ink: #e8e8f0;
  --accent: #ffd24a;
  --accent2: #5ac8fa;
  --focusbg: #2e3650;
}

html, body {
  height: 100%;
  background: #0c0e16;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: "Courier New", ui-monospace, monospace;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#stage {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  /* fit WITHOUT stretching: the limiting axis decides, the other follows
     the aspect ratio (height:100vh + max-width together distorted on
     narrow phones — both constraints bound and aspect-ratio lost) */
  height: min(100vh, calc(100vw * 560 / 416));
  height: min(100dvh, calc(100vw * 560 / 416));
  aspect-ratio: 416 / 560;
  background: #222;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-top {
  margin-top: 8px;
  display: flex;
  gap: 0;
  align-items: stretch;
  font-weight: bold;
  font-size: clamp(12px, 2.4vh, 20px);
  letter-spacing: 1px;
  box-shadow: 0 2px 0 rgba(0,0,0,0.5);
}
.hud-team {
  padding: 3px 8px;
  border: 2px solid var(--panel-edge);
}
.hud-score {
  padding: 3px 10px;
  background: var(--panel);
  border-top: 2px solid var(--panel-edge);
  border-bottom: 2px solid var(--panel-edge);
}
.hud-clock {
  padding: 3px 8px;
  background: #10131e;
  color: var(--accent);
  border: 2px solid var(--panel-edge);
}

.hud-banner {
  margin-top: 12vh;
  font-size: clamp(26px, 7vh, 54px);
  font-weight: bold;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 3px 3px 0 #10131e, -1px -1px 0 #10131e, 1px -1px 0 #10131e, -1px 1px 0 #10131e;
  animation: pop 0.18s ease-out;
}
.hud-banner.goal { color: var(--accent); }
.hud-banner.off { color: #ff9a4a; }
.hud-banner.replay { color: var(--accent2); font-size: clamp(18px, 4vh, 32px); animation: blink 0.7s step-start infinite; }

.hud-sub {
  margin-top: 6px;
  font-size: clamp(11px, 2vh, 16px);
  background: rgba(16, 19, 30, 0.85);
  padding: 3px 10px;
  border: 1px solid #000;
  letter-spacing: 1px;
}

@keyframes pop { from { transform: scale(1.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- menus ---------- */
.menu-root {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 18, 0.72);
}

.menu-panel {
  min-width: min(420px, 92vw);
  max-width: 94vw;
  max-height: 92vh;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--panel);
  border: 3px solid var(--panel-edge);
  box-shadow: 0 0 0 3px #2c3350, 6px 8px 0 rgba(0, 0, 0, 0.5);
  padding: 14px 16px 12px;
}
.menu-panel.wide { min-width: min(560px, 94vw); }

.menu-back {
  font-size: clamp(11px, 2.2vmin, 14px);
  color: var(--accent2);
  letter-spacing: 1px;
  margin-bottom: 8px;
  cursor: pointer;
  width: max-content;
  padding: 2px 6px 2px 0;
}
.menu-back:active { color: var(--accent); }

.menu-title {
  font-size: clamp(14px, 3vmin, 22px);
  font-weight: bold;
  letter-spacing: 2px;
  color: var(--accent);
  border-bottom: 2px solid #2c3350;
  padding-bottom: 6px;
  margin-bottom: 8px;
}

.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 8px;
  font-size: clamp(12px, 2.6vmin, 17px);
  letter-spacing: 1px;
  cursor: pointer;
  border-left: 4px solid transparent;
}
.menu-row.focus {
  background: #2e3650;
  border-left-color: var(--accent);
  color: #fff;
}
.menu-row.disabled { opacity: 0.38; cursor: default; }
.menu-label { white-space: nowrap; }
.menu-value { color: var(--accent2); white-space: nowrap; font-weight: bold; }
.menu-row.focus .menu-value { color: var(--accent); }

.menu-swatch { display: inline-flex; gap: 2px; }
.menu-swatch i {
  width: 12px; height: 12px;
  display: inline-block;
  border: 1px solid #000;
}

.menu-footer {
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px solid #2c3350;
  font-size: clamp(9px, 1.7vmin, 12px);
  color: #8890a8;
  letter-spacing: 0.5px;
}

.menu-html { margin-bottom: 8px; }

.logo {
  /* sized by the NARROW axis so it can never outgrow a phone screen */
  font-size: clamp(26px, 9vmin, 64px);
  font-weight: bold;
  letter-spacing: 4px;
  text-align: center;
  color: #fff;
  text-shadow: 4px 4px 0 #c8102e, 8px 8px 0 rgba(0,0,0,0.4);
  margin: 10px 0 0;
}
.logo span { color: var(--accent); }
.tagline {
  text-align: center;
  letter-spacing: 6px;
  color: var(--accent2);
  margin: 4px 0 18px;
  font-size: clamp(9px, 2vmin, 14px);
}

/* stats + competition tables */
table.stats, table.bracket, table.league {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(11px, 1.9vh, 15px);
  margin: 6px 0;
}
/* ---------- Playzooka splash ---------- */
#splash {
  position: absolute;
  inset: 0;
  z-index: 60;
  background: #4e4957;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.45s ease;
}
#splash.out { opacity: 0; pointer-events: none; }
#splash svg {
  width: min(68vmin, 400px);
  animation: splash-in 0.55s ease-out;
}
@keyframes splash-in {
  from { opacity: 0; transform: scale(0.93); }
}

.stats-heads {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin: 8px 2px 0;
  font-weight: bold;
  letter-spacing: 1px;
}
.stats-heads .you-tag { color: #ffd24a; font-weight: normal; font-size: 0.85em; }
table.stats td { width: 20%; text-align: center; font-weight: bold; color: var(--accent2); }
table.stats th { text-align: center; font-weight: normal; color: #a8b0c8; letter-spacing: 1px; padding: 2px 0; }
table.bracket td { width: 42%; text-align: center; padding: 2px 4px; }
table.bracket th { color: #8890a8; font-weight: normal; }
table.bracket tr.you td { color: var(--accent); font-weight: bold; }
table.bracket.small { font-size: clamp(9px, 1.6vh, 12px); color: #a8b0c8; }
table.league th { color: #8890a8; font-weight: normal; text-align: right; padding: 2px 4px; }
table.league td { text-align: right; padding: 2px 4px; }
table.league td:nth-child(2), table.league th:nth-child(2) { text-align: left; }
table.league tr.you td { color: var(--accent); font-weight: bold; }
.comp-round { color: #8890a8; letter-spacing: 2px; margin: 8px 0 4px; font-size: clamp(10px, 1.8vh, 13px); }
.champion {
  text-align: center;
  font-size: clamp(18px, 4vh, 30px);
  color: var(--accent);
  font-weight: bold;
  margin: 12px 0;
  letter-spacing: 2px;
}
.scorer { font-size: clamp(11px, 1.9vh, 14px); color: #c8d0e8; }

/* ---------- touch controls ---------- */
.touch-stick {
  position: absolute;
  left: calc(24px + env(safe-area-inset-left, 0px));
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  width: 88px; height: 88px;
  border: 2px solid rgba(255,255,255,0.45);
  background: rgba(20,24,36,0.25);
  border-radius: 50%;
  pointer-events: none;
  z-index: 5;
}
.touch-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 38px; height: 38px;
  margin: -19px 0 0 -19px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  border: 2px solid rgba(255,255,255,0.55);
}
.touch-btn {
  position: absolute;
  right: calc(18px + env(safe-area-inset-right, 0px));
  bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  width: 78px; height: 78px;
  border-radius: 50%;
  background: rgba(200, 16, 46, 0.55);
  border: 2px solid rgba(255,255,255,0.6);
  color: rgba(255,255,255,0.85);
  font-size: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.touch-switch {
  position: absolute;
  right: calc(30px + env(safe-area-inset-right, 0px));
  bottom: calc(122px + env(safe-area-inset-bottom, 0px));
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(40, 90, 200, 0.45);
  border: 2px solid rgba(255,255,255,0.55);
  color: rgba(255,255,255,0.85);
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.touch-pause {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  width: 42px; height: 42px;
  border-radius: 8px;
  background: rgba(20,24,36,0.5);
  border: 2px solid rgba(255,255,255,0.4);
  color: rgba(255,255,255,0.8);
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6;
}
.touch-fs {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: calc(12px + env(safe-area-inset-left, 0px));
  width: 42px; height: 42px;
  border-radius: 8px;
  background: rgba(20,24,36,0.5);
  border: 2px solid rgba(255,255,255,0.4);
  color: rgba(255,255,255,0.8);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6;
}
@media (hover: hover) and (pointer: fine) {
  .touch-btn, .touch-switch, .touch-pause, .touch-fs, .touch-stick { display: none; }
}
