:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --soft: #f7f9fb;
  --ink: #17212f;
  --muted: #667789;
  --line: rgba(23, 33, 47, 0.12);
  --accent: #18a98f;
  --accent-dark: #0d7d69;
  --gold: #f3b331;
  --blue: #3578e5;
  --red: #ef6767;
  --green: #63b86a;
  --shadow: 0 12px 34px rgba(31, 45, 61, 0.12);
  font-family: Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden], .view { display: none !important; }
.view.is-active.gate { display: grid !important; }
.view.is-active.app { display: block !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #fbfcfd, var(--bg));
  color: var(--ink);
}

button, input { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }

.gate, .admin-shell {
  min-height: 100svh;
  place-items: center;
  padding: 18px;
}

.gate-panel, .admin-panel {
  width: min(480px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
}

h1, h2 { margin: 0; line-height: 1.25; }
h1 { font-size: clamp(26px, 8vw, 40px); }
h2 { font-size: 20px; }

.muted { color: var(--muted); line-height: 1.75; }

.field {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  color: #405167;
  font-weight: 900;
}

.field input {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  padding: 0 14px;
  outline: none;
  font-size: 20px;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(24, 169, 143, 0.16);
}

.primary-btn, .duration-option, .game-card, .mini-btn, .tap-btn {
  border: 0;
  border-radius: 8px;
  font-weight: 900;
}

.primary-btn {
  width: 100%;
  min-height: 56px;
  background: var(--accent);
  color: #fff;
}

.duration-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 20px 0;
}

.duration-option {
  min-height: 58px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--ink);
}

.duration-option.active {
  background: var(--gold);
  color: #241900;
}

.code-box {
  margin-top: 20px;
  padding: 18px;
  text-align: center;
  border: 1px solid rgba(243, 179, 49, 0.48);
  border-radius: 8px;
  background: #fff8e8;
}

.code-box span, .code-box small { display: block; color: var(--muted); }
.code-box strong { display: block; font-size: 56px; letter-spacing: 6px; direction: ltr; }
.message { min-height: 24px; color: #976a00; font-weight: 900; }
.home-link { color: var(--accent-dark); text-decoration: none; font-weight: 900; }

.app { min-height: 100svh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

.topbar h1 { font-size: 20px; }

.timer-card, .score-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--panel);
  min-width: 118px;
}

.timer-card span, .score-pill span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.timer-card strong, .score-pill strong {
  display: block;
  direction: ltr;
  font-size: 20px;
}

.home-layout {
  display: grid;
  gap: 14px;
  padding: 12px;
}

.section-title, .champions-panel, .game-shell, .game-board-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.game-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 12px 0;
}

.game-card {
  min-height: 86px;
  padding: 14px;
  text-align: right;
  background: linear-gradient(180deg, #fff, #f2f6f8);
  border: 1px solid var(--line);
  color: var(--ink);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  box-shadow: 0 8px 20px rgba(31, 45, 61, 0.08);
}

.game-card.active {
  outline: 3px solid rgba(24, 169, 143, 0.24);
  background: #e9f7f3;
}

.game-card span { font-size: 34px; }
.game-card strong { display: block; }
.game-card small { color: var(--muted); line-height: 1.5; }

.game-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.play-layout {
  display: grid;
  gap: 12px;
}

.game-area {
  min-height: 430px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fbfcfd;
  overflow: hidden;
  position: relative;
}

.center-play {
  min-height: 430px;
  display: grid;
  place-items: center;
  padding: 14px;
}

.challenge {
  width: min(680px, 100%);
  display: grid;
  gap: 14px;
  text-align: center;
}

.big-number {
  font-size: clamp(42px, 14vw, 72px);
  font-weight: 900;
  color: #9b6d00;
}

.answer-grid, .memory-grid, .target-grid, .sequence-grid, .color-grid {
  display: grid;
  gap: 10px;
}

.answer-grid, .color-grid { grid-template-columns: repeat(2, 1fr); }
.memory-grid, .target-grid, .sequence-grid { grid-template-columns: repeat(3, 1fr); }

.tap-btn, .answer-grid button, .memory-grid button, .target-grid button, .sequence-grid button, .color-grid button {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(31, 45, 61, 0.08);
}

.tap-btn:active, .game-card:active, .answer-grid button:active, .memory-grid button:active, .target-grid button:active, .sequence-grid button:active {
  transform: scale(0.98);
}

.memory-grid button.matched { background: rgba(99, 184, 106, 0.24); }
.target-grid button.hot { background: var(--gold); color: #231900; }

.maze {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  width: min(420px, 92vw);
  margin: 0 auto;
}

.maze-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  background: #e7edf1;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 900;
}

.maze-cell.wall { background: #aeb8c2; }
.maze-cell.player { background: var(--blue); color: #fff; }
.maze-cell.goal { background: var(--gold); color: #201900; }

.controls {
  display: grid;
  grid-template-columns: repeat(3, 58px);
  justify-content: center;
  gap: 8px;
}

.controls button {
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.leaderboard {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.leaderboard li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 11px;
  border-radius: 8px;
  background: #fbfcfd;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 800;
}

.leaderboard li:first-child {
  background: #fff6d9;
  border-color: rgba(243, 179, 49, 0.48);
}

.kick-meter {
  height: 34px;
  border-radius: 8px;
  background: #e3e9ee;
  overflow: hidden;
  border: 1px solid var(--line);
}

.kick-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--gold), var(--green), var(--gold), var(--red));
}

@media (min-width: 760px) {
  .home-layout { padding: 18px; }
  .game-grid { grid-template-columns: repeat(2, 1fr); }
  .play-layout { grid-template-columns: minmax(0, 1fr) 280px; }
  .leaderboard-row { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1080px) {
  .game-grid { grid-template-columns: repeat(3, 1fr); }
  .topbar { padding: 16px 22px; }
}
