:root {
  --deep-teal: #004f62;
  --pastel-teal: #80a7b1;
  --light-deep-teal-bg: #d0e7ea;
  --ocean-blue: #1f93b4;
  --pastel-blue: #8fc9da;
  --light-ocean-blue-bg: #d1eef4;
  --accent-coral: #ff6f61;
  --pastel-coral: #ffc2b9;
  --light-coral-bg: #fff1ee;
  --accent-orange: #e67e22;
  --pastel-orange: #ffcc80;
  --light-orange-bg: #fff3e8;
  --sunny-yellow: #ffeb3b;
  --pastel-yellow: #fff9c4;
  --light-yellow-bg: #fffde7;
  --deep-green: #2e7d32;
  --pastel-green: #a5d6a7;
  --light-green-bg: #e8f5e9;
  --light-background: #e8f1f2;
  --pure-white: #ffffff;
  --snow: #fffafa;
  --ivory: #fffff0;
  --light-gray: #f5f5f5;
  --gainsboro: #dcdcdc;
  --floral-white: #fffaf0;
  --alice-blue: #f0f8ff;
  --bg: var(--deep-teal);
  --panel: var(--deep-teal);
  --panel-edge: rgba(180, 214, 255, 0.16);
  --text: var(--snow);
  --muted: var(--pastel-blue);
  --accent: var(--sunny-yellow);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: Georgia, "Trebuchet MS", serif;
  color: var(--text);
  background: var(--bg);
}

.orientation-notice {
  display: none;
}

@media (pointer: coarse) and (orientation: portrait) {
  .orientation-notice {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 28px;
    text-align: center;
    font-size: clamp(1.3rem, 6vw, 2rem);
    background: var(--deep-teal);
  }

  .orientation-phone {
    display: block;
    font: 700 5rem/1 sans-serif;
    transform: rotate(90deg);
    animation: orientation-turn 1.6s ease-in-out infinite alternate;
  }
}

@keyframes orientation-turn {
  from { transform: rotate(0deg); }
  to { transform: rotate(90deg); }
}

.layout {
  width: min(100vw, 1240px);
  margin: 0 auto;
  padding: 0 0 18px;
}

.playfield-section {
  position: relative;
  width: 100%;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  touch-action: none;
  background: linear-gradient(180deg, var(--deep-teal) 0%, var(--ocean-blue) 100%);
}

.menu-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 11, 20, 0.58);
}

.menu-overlay.is-hidden {
  display: none;
}

body.menu-active {
  background: #06131e;
}

body.menu-active .layout {
  width: 100%;
  padding: 0;
}

body.menu-active .playfield-section {
  min-height: 100vh;
}

body.menu-active canvas,
body.menu-active .controls {
  display: none;
}

body.menu-active .menu-overlay {
  position: fixed;
  inset: 0;
  overflow: auto;
  align-items: flex-start;
  padding: 28px;
  background:
    radial-gradient(circle at 18% 8%, rgba(31, 147, 180, 0.24), transparent 32%),
    linear-gradient(145deg, #06131e, #003f51);
}

.help-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: auto;
  padding: 22px;
  background: rgba(5, 11, 20, 0.94);
}

.help-overlay.is-hidden {
  display: none;
}

.help-card {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 24px;
  border: 1px solid var(--panel-edge);
  border-radius: 24px;
  background: var(--deep-teal);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
}

.help-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.help-header h2 {
  margin: 7px 0 0;
  font-size: clamp(1.55rem, 4vw, 2.3rem);
}

.help-close-button {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 1px solid var(--panel-edge);
  border-radius: 50%;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  font: 700 1.8rem/1 sans-serif;
  cursor: pointer;
}

.help-games {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.help-games article {
  padding: 16px 18px;
  border: 1px solid var(--panel-edge);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
}

.help-games h3 {
  margin: 0 0 8px;
  color: var(--accent);
}

.help-games p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.help-games strong {
  color: var(--text);
}

.help-open-button {
  min-height: 46px;
  margin-top: 14px;
  padding: 0 20px;
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.help-done-button {
  display: block;
  margin: 18px auto 0;
}

.menu-card {
  position: relative;
  width: min(100%, 1180px);
  max-height: min(92vh, 900px);
  overflow: auto;
  padding: 28px;
  border-radius: 26px;
  background: rgba(9, 18, 30, 0.94);
  border: 1px solid var(--panel-edge);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.menu-fullscreen-button {
  position: absolute;
  top: 20px;
  right: 20px;
  width: auto;
  min-width: 110px;
  min-height: 40px;
  z-index: 1;
}

.menu-kicker,
.menu-copy,
.mode-name {
  margin: 0;
}

.menu-kicker {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
}

.menu-card h1 {
  margin: 10px 0 12px;
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  line-height: 0.95;
}

.menu-copy {
  color: var(--muted);
  line-height: 1.55;
}

.menu-feature {
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr) auto;
  gap: 18px;
  margin-top: 22px;
  padding: 18px;
  border: 1px solid var(--panel-edge);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)), rgba(255, 255, 255, 0.03);
  text-align: left;
}

.menu-feature-art {
  min-height: 148px;
  border-radius: 18px;
  background-color: #143847;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.menu-feature-copy h2,
.menu-feature-copy p,
.menu-feature-kicker {
  margin: 0;
}

.menu-feature-kicker {
  margin-bottom: 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.7rem;
}

.menu-feature-copy h2 {
  margin-bottom: 10px;
  font-size: clamp(1.35rem, 2.6vw, 2rem);
}

.menu-feature-copy p {
  color: var(--muted);
  line-height: 1.5;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.is-mobile-game .layout {
  width: 100%;
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: 0;
  overflow: hidden;
}

body.is-mobile-game .playfield-section {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0;
}

body.is-mobile-game canvas {
  width: min(100%, 200dvh);
  max-height: 100dvh;
  border-radius: 0;
}

body.is-mobile-game .controls {
  position: fixed;
  z-index: 4;
  top: max(6px, env(safe-area-inset-top));
  left: 50%;
  width: min(94vw, 620px);
  padding: 0;
  transform: translateX(-50%);
  pointer-events: none;
}

body.is-mobile-game .hud {
  grid-template-columns: 1fr auto 1fr;
  gap: 5px;
  margin: 0;
}

body.is-mobile-game .hud div {
  min-height: 38px;
  padding: 5px 8px;
  border-radius: 12px;
  background: rgba(0, 79, 98, 0.82);
  backdrop-filter: blur(6px);
  pointer-events: auto;
}

body.is-mobile-game .start-buttons button {
  min-width: 76px;
  min-height: 38px;
  padding: 0 10px;
  font-size: 0.78rem;
}

body.is-mobile-game .score-dot {
  width: 12px;
  height: 12px;
  border-width: 1px;
}

body.is-mobile-game .label,
body.is-mobile-game .mode-name,
body.is-mobile-game #controlsHint {
  display: none;
}

body.is-mobile-game .score-track {
  min-height: 20px;
  gap: 5px;
  padding-top: 5px;
}

body.is-mobile-game .start-buttons {
  min-height: 38px;
  flex-wrap: nowrap;
  gap: 5px;
}

body.is-mobile-game .menu-card {
  width: min(100%, 1000px);
  padding: 22px 18px;
}

body.is-mobile-game .menu-feature {
  grid-template-columns: 1fr;
}

body.is-mobile-game .menu-feature-art {
  min-height: 112px;
}

body.is-mobile-game .controls p {
  font-size: 0.95rem;
}

.controls {
  padding: 12px 14px 0;
}

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

.hud div {
  min-height: 68px;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  text-align: center;
}

.label {
  display: block;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--muted);
}

.score-track {
  display: flex;
  justify-content: center;
  gap: 10px;
  min-height: 32px;
  padding-top: 6px;
}

.score-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.08);
}

.score-dot.is-on {
  background: var(--sunny-yellow);
  border-color: rgba(255, 249, 196, 0.85);
  box-shadow: 0 0 0 2px rgba(245, 208, 109, 0.12);
}

.menu-buttons,
.start-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.menu-picker {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 22px;
  align-items: stretch;
}

.keyboard-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--panel-edge);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
}

.keyboard-picker label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.keyboard-picker select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  color: var(--text);
  background: rgba(7, 17, 28, 0.82);
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
}

.menu-grid {
  display: grid;
  gap: 18px;
  text-align: left;
}

.menu-category {
  --category-accent: #f5d06d;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--category-accent) 28%, transparent);
  border-radius: 22px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--category-accent) 10%, transparent), rgba(255, 255, 255, 0.025) 42%);
}

.menu-category--reaction { --category-accent: #ff7f72; }
.menu-category--knowledge { --category-accent: #73c8ef; }
.menu-category--strategy { --category-accent: #ad9df5; }
.menu-category--creative { --category-accent: #ec8fc7; }
.menu-category--experiment { --category-accent: #83e6ad; }

.menu-category-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.menu-category-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  color: #07111c;
  background: var(--category-accent);
  font-size: 1.35rem;
  font-weight: 900;
}

.menu-category-header h2,
.menu-category-header p {
  margin: 0;
}

.menu-category-header h2 {
  color: var(--category-accent);
  font-size: 1.2rem;
}

.menu-category-header p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.menu-category-count {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.menu-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.menu-tile {
  position: relative;
  min-height: 136px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  color: var(--text);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.025)), rgba(7, 17, 28, 0.78);
  text-align: left;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.menu-tile-control {
  display: inline-block;
  margin-top: 9px;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(7, 17, 28, 0.7);
  font-size: 0.68rem;
  font-weight: 700;
}

.menu-tile-count {
  display: block;
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 0.72rem;
}

.menu-tile::before {
  content: "";
  display: block;
  width: 100%;
  height: 42px;
  margin-bottom: 10px;
  border-radius: 12px;
  background-color: #143847;
  background-image: var(--preview-image);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.menu-tile:hover,
.menu-tile:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(255, 235, 59, 0.34);
  outline: none;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.menu-tile.is-selected {
  border-color: color-mix(in srgb, var(--category-accent) 65%, white);
  background: linear-gradient(180deg, color-mix(in srgb, var(--category-accent) 14%, transparent), rgba(255,255,255,0.03)), rgba(7, 17, 28, 0.92);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--category-accent) 22%, transparent);
}

.menu-tile-title,
.menu-tile-subtitle {
  display: block;
}

.menu-tile-title {
  font-weight: 700;
  line-height: 1.15;
}

.menu-tile-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.menu-start-button {
  align-self: start;
  min-width: 190px;
  min-height: 58px;
  padding-inline: 24px;
  font-size: 1.05rem;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.3), 0 0 0 2px rgba(255, 235, 59, 0.16);
}

.mode-button {
  min-width: 120px;
  min-height: 46px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  color: var(--deep-teal);
  background: linear-gradient(180deg, var(--pastel-yellow), var(--accent-orange));
  cursor: pointer;
}

.mode-button.is-active {
  box-shadow: 0 0 0 2px rgba(255, 241, 200, 0.28);
  filter: brightness(1.06);
}

.mode-name {
  margin-bottom: 6px;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
}

.start-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  min-height: 68px;
  gap: 8px;
}

.start-buttons .mode-button {
  min-width: 112px;
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.95rem;
}

.controls p {
  margin: 0;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

kbd {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--alice-blue);
}

@media (max-width: 760px) {
  .controls {
    padding: 10px 10px 0;
  }

  .hud {
    grid-template-columns: 1fr;
  }

  .menu-buttons,
  .start-buttons {
    grid-template-columns: 1fr;
  }

  .menu-picker {
    display: flex;
  }

  .menu-grid {
    gap: 12px;
  }

  .menu-category {
    padding: 12px;
  }

  .menu-category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .menu-category-count {
    display: none;
  }

  .mode-button {
    width: 100%;
  }

  .menu-fullscreen-button {
    top: 12px;
    right: 12px;
    width: auto;
    min-width: 0;
    min-height: 36px;
    padding-inline: 12px;
    font-size: 0.85rem;
  }

  .menu-start-button {
    align-self: stretch;
    min-width: 0;
  }

  .help-overlay {
    padding: 8px;
  }

  .help-card {
    padding: 16px;
  }

  .help-games {
    grid-template-columns: 1fr;
  }
}
.geo-result {
  position: absolute;
  z-index: 1;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: #052c3a;
  color: #fff;
  border-radius: 16px;
  overflow: hidden;
  font-family: "Trebuchet MS", sans-serif;
}
.geo-switcher { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 9px 12px; background: #052c3a; color: white; }
.geo-switcher[hidden] { display: none; }
.geo-switcher label { font-weight: bold; }
.geo-switcher select { flex: 1; min-width: 0; max-width: 480px; padding: 8px; border: 1px solid #91c6cf; border-radius: 8px; background: #123e50; color: white; font: inherit; }
.geo-switcher span { font-size: 12px; color: #c5dade; }
.geo-result header { display: flex; flex-wrap: wrap; gap: 5px 20px; justify-content: space-between; }
.geo-result header strong { color: #ffe66d; }
.geo-result header span { overflow-wrap: anywhere; }
.geo-wikipedia-link { color: #b2e5f3; white-space: nowrap; text-underline-offset: 3px; }
.geo-wikipedia-link:hover { color: white; }
.geo-wikipedia-link:focus-visible { outline: 3px solid #ffe66d; outline-offset: 3px; }
.geo-result nav, .geo-result footer, .geo-result-ranking { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.geo-result footer { justify-content: space-between; max-height: 30%; overflow-y: auto; flex-shrink: 0; }
.geo-result button { cursor: pointer; border: 2px solid #91c6cf; border-radius: 8px; padding: 7px 12px; color: white; background: #123e50; font: inherit; }
.geo-result button:hover { background: #245c70; }
.geo-result button:focus-visible { outline: 3px solid #ffe66d; outline-offset: 1px; }
.geo-result-map { flex: 1; min-height: 80px; border-radius: 8px; background: #77bdd1; color: #172c34; }
.geo-map-status { font-size: 12px; }
.geo-map-status:empty { display: none; }
.geo-guess-attribution { padding: 4px 8px; background: #052c3a; color: #d4e7e9; font: 11px/1.4 sans-serif; }
.geo-guess-attribution a { color: #b2e5f3; }
.geo-guess-icon span { display: grid; place-items: center; width: 28px; height: 28px; box-sizing: border-box; border: 3px solid white; border-radius: 50%; color: #07131d; font: bold 13px sans-serif; box-shadow: 0 1px 5px #0009; }
.geo-target-icon { color: #ffe66d; font: 34px/34px sans-serif; text-align: center; text-shadow: 1px 1px 2px #000, -1px -1px 2px #000; }
@media (max-height: 500px) {
  .geo-result { padding: 6px; gap: 4px; font-size: 12px; }
  .geo-result button { padding: 4px 8px; }
}
