/* World Map Game — bright, kid-friendly, no external assets */

:root {
  --sky-top: #7ec8ea;
  --sky-mid: #c7ecfa;
  --sky-bottom: #f3fbff;
  --navy: #16324f;
  --navy-soft: #2a4a6b;
  --ink: #1a2b3c;
  --paper: #fffdf6;
  --land: #ffe08a;
  --land-stroke: #c9892e;
  --land-hover: #ffcf4d;
  --correct: #2db86a;
  --correct-dark: #1d8a4b;
  --wrong: #ef5a5a;
  --reveal: #4d8dff;
  --btn-state: #ff8a3d;
  --btn-capital: #6c63ff;
  --btn-practice: #1faf9a;
  --shadow: 0 8px 0 rgba(22, 50, 79, 0.12);
  --radius: 18px;
  --font: "Trebuchet MS", "Segoe UI", "Avenir Next", "Avenir", system-ui, sans-serif;
  --hud-h: 0px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 38%, var(--sky-bottom) 100%);
  background-attachment: fixed;
}

body {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  font-family: inherit;
  cursor: pointer;
}

h1, h2, p {
  margin: 0;
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  max-width: 1100px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #ffd24a;
  border: 3px solid var(--navy);
  display: grid;
  place-items: center;
  font-size: 24px;
  line-height: 1;
  box-shadow: var(--shadow);
}

.brand h1 {
  font-size: clamp(1.3rem, 3vw, 1.9rem);
  color: var(--navy);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.tagline {
  font-size: 0.92rem;
  color: var(--navy-soft);
  font-weight: 700;
}

.toggle {
  border: 3px solid var(--navy);
  background: var(--paper);
  color: var(--navy);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: var(--shadow);
  min-height: 44px;
}

.toggle[aria-pressed="true"] {
  background: #e8ffe8;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.screen[hidden] {
  display: none !important;
}

/* Start */
.start-card, .end-card {
  background: var(--paper);
  border: 3px solid var(--navy);
  border-radius: 28px;
  padding: 28px 24px 32px;
  box-shadow: 0 12px 0 rgba(22, 50, 79, 0.14);
  text-align: center;
  margin: 8px auto 0;
  width: 100%;
  max-width: 720px;
}

.start-card h2, .end-card h2 {
  color: var(--navy);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  margin-bottom: 8px;
}

.lead {
  font-size: 1.1rem;
  line-height: 1.45;
  margin: 0 auto 22px;
  max-width: 38em;
}

.mode-buttons {
  display: grid;
  gap: 14px;
}

.mode-btn {
  border: 3px solid var(--navy);
  border-radius: 20px;
  padding: 16px 18px;
  color: #fff;
  text-align: left;
  box-shadow: var(--shadow);
  min-height: 72px;
  transition: transform 0.08s ease;
}

.mode-btn:hover {
  transform: translateY(-2px);
}

.mode-btn:active {
  transform: translateY(2px);
  box-shadow: 0 4px 0 rgba(22, 50, 79, 0.12);
}

.mode-btn .mode-title {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
}

.mode-btn .mode-desc {
  display: block;
  font-size: 0.98rem;
  opacity: 0.95;
  margin-top: 2px;
  font-weight: 600;
}

.mode-btn.states { background: var(--btn-state); }
.mode-btn.capitals { background: var(--btn-capital); }
.mode-btn.practice { background: var(--btn-practice); }

.best-row {
  margin-top: 20px;
  font-weight: 700;
  color: var(--navy-soft);
  font-size: 0.98rem;
}

/* Game HUD */
.hud {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 10px;
}

.stat, .prompt-box {
  background: var(--paper);
  border: 3px solid var(--navy);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 8px 12px;
}

.stat {
  min-width: 86px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat .label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--navy-soft);
}

.stat .value {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.1;
}

.stat.timer.warn .value { color: #d97706; }
.stat.timer.danger .value { color: #dc2626; }

.prompt-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 64px;
}

#prompt {
  font-size: clamp(1.15rem, 2.8vw, 1.7rem);
  font-weight: 800;
  color: var(--navy);
  line-height: 1.2;
}

#prompt.ok { color: var(--correct-dark); }
#prompt.bad { color: #b42318; }

.hud-actions {
  display: flex;
  align-items: center;
}

.linkish {
  background: var(--paper);
  border: 3px solid var(--navy);
  border-radius: 16px;
  padding: 0 14px;
  font-weight: 800;
  color: var(--navy);
  box-shadow: var(--shadow);
  min-height: 64px;
}

/* Map */
.map-panel {
  flex: 1;
  background: linear-gradient(180deg, #8fd3f4 0%, #bfe9fb 55%, #d9f3c9 55.1%, #c7e8a5 100%);
  border: 3px solid var(--navy);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 8px 8px 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

#map-wrap {
  touch-action: none;
  overflow: hidden;
  position: relative;
  background: #8ec8ea;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#map-wrap {
  background: #8ec8ea;
  touch-action: none;
  overflow: hidden;
  position: relative;
  background: #8ec8ea;
  border-radius: 16px;
}
#map-wrap svg {
  background: #8ec8ea;
  overflow: hidden;
  height: 100%;
  width: auto;
  max-width: 100%;
  max-height: min(62vh, 620px);
  display: block;
  margin: 0 auto;
  cursor: grab;
}
#map-wrap.svg-drag svg { cursor: grabbing; }

.country, .state {
  fill: var(--land);
  stroke: var(--land-stroke);
  stroke-width: 0.6;
  cursor: pointer;
  transition: fill 0.12s ease;
  vector-effect: non-scaling-stroke;
}

.state:hover,
.state.hover,
.callout-hot.hover .state,
.easy-btn.hover {
  /* handled per element */
}

.country:hover,
.country.hover,
.state:hover,
.state.hover {
  fill: var(--land-hover);
}

.country.correct, .state.correct {
  fill: var(--correct);
  stroke: var(--correct-dark);
}

.country.wrong, .state.wrong {
  fill: var(--wrong);
  stroke: #9f1d1d;
}

.country.reveal, .state.reveal {
  fill: var(--reveal);
  stroke: #1d4ed8;
}

.state-hit {
  cursor: pointer;
}

.separator {
  stroke: #7aa3b8;
  stroke-width: 2;
}

.easy-wrap {
  padding: 8px 6px 10px;
  border-top: 2px dashed rgba(22, 50, 79, 0.2);
}

.easy-label {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--navy);
  margin: 0 4px 6px;
}

.easy-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.easy-btn {
  border: 2px solid var(--navy);
  background: #fff7d6;
  color: var(--navy);
  border-radius: 999px;
  padding: 7px 10px;
  font-weight: 800;
  font-size: 0.82rem;
  min-height: 40px;
  box-shadow: 0 3px 0 rgba(22, 50, 79, 0.12);
}

.easy-btn:hover,
.easy-btn.hover {
  background: var(--land-hover);
}

.easy-btn.correct {
  background: var(--correct);
  color: #fff;
}

.easy-btn.wrong {
  background: var(--wrong);
  color: #fff;
}

.easy-btn.reveal {
  background: var(--reveal);
  color: #fff;
}

.easy-btn .abbr {
  display: none;
}

/* End screen */
.score-big {
  font-size: clamp(2.4rem, 8vw, 4rem);
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
  margin: 8px 0 4px;
}

.best-note {
  font-weight: 700;
  color: var(--navy-soft);
  margin-bottom: 16px;
}

.missed-box {
  text-align: left;
  background: #fff7e8;
  border: 2px solid #f0d3a0;
  border-radius: 16px;
  padding: 12px 14px;
  margin: 0 0 18px;
  max-height: 240px;
  overflow: auto;
}

.missed-box h3 {
  margin: 0 0 8px;
  color: var(--navy);
  font-size: 1rem;
}

.missed-box ul {
  margin: 0;
  padding: 0 0 0 18px;
  columns: 2;
  gap: 12px;
}

.missed-box li {
  margin: 0 0 4px;
  font-weight: 700;
  break-inside: avoid;
}

.end-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.primary, .secondary {
  border: 3px solid var(--navy);
  border-radius: 16px;
  padding: 12px 18px;
  font-weight: 800;
  font-size: 1.05rem;
  min-height: 52px;
  box-shadow: var(--shadow);
}

.primary {
  background: var(--btn-state);
  color: #fff;
}

.secondary {
  background: var(--paper);
  color: var(--navy);
}

#feedback[aria-live] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media (max-width: 720px) {
  .hud {
    grid-template-columns: 1fr 1fr auto;
    grid-template-areas:
      "prompt prompt prompt"
      "timer score quit";
  }
  .prompt-box { grid-area: prompt; }
  .stat.timer { grid-area: timer; }
  .stat.score { grid-area: score; }
  .hud-actions { grid-area: quit; }
  .stat.best { display: none; }
  .easy-btn .full { display: none; }
  .easy-btn .abbr { display: inline; }
  .missed-box ul { columns: 1; }
  #map-wrap svg { max-height: 52vh; }
}

@media (prefers-reduced-motion: reduce) {
  .state, .mode-btn { transition: none; }
}

.home-link { display: grid; place-items: center; text-decoration: none; }
.site-mark { width: 44px; height: 44px; border-radius: 14px; display: block; }
.site-name { margin: 0; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.02em; }
.site-name a { color: var(--navy-soft); text-decoration: none; }
.site-name a:hover { text-decoration: underline; }
.site-foot {
  margin: 12px 0 0;
  text-align: center;
  font-weight: 700;
  color: var(--navy);
  font-size: 0.92rem;
}
.site-foot a { color: var(--navy); }


.sphere { fill: #8ec8ea; stroke: #2a4a6b; stroke-width: 1.2; }
.ocean-bg { fill: #7ec8ea; }
.country.land-other { fill: #f3d9a0; stroke: #c9892e; }
.country.land-antarctica { fill: #f7f4ef; stroke: #b9c3ce; }
.country-hit {
  fill: transparent;
  stroke: rgba(22, 50, 79, 0.35);
  stroke-width: 1.2;
  stroke-dasharray: 2 2;
  cursor: pointer;
}
.country-hit:hover, .country-hit.hover { fill: rgba(255, 207, 77, 0.35); }

#map-wrap.continent-mode .country[data-continent="Africa"] { fill: #f4c45a; }
#map-wrap.continent-mode .country[data-continent="Asia"] { fill: #f3a6a0; }
#map-wrap.continent-mode .country[data-continent="Europe"] { fill: #9ec0f8; }
#map-wrap.continent-mode .country[data-continent="North America"] { fill: #f3b86a; }
#map-wrap.continent-mode .country[data-continent="South America"] { fill: #8fd3a8; }
#map-wrap.continent-mode .country[data-continent="Oceania"] { fill: #d7b0f0; }
#map-wrap.continent-mode .country[data-continent="Antarctica"] { fill: #f7f4ef; }
#map-wrap.continent-mode .country.hover,
#map-wrap.continent-mode .country:hover { filter: brightness(1.08); }
#map-wrap.continent-mode .country.group-hover { fill: #ffcf4d; }

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 8px;
}
.zoom-btn {
  border: 2px solid var(--navy);
  background: var(--paper);
  color: var(--navy);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 800;
  min-height: 36px;
  box-shadow: 0 3px 0 rgba(22, 50, 79, 0.1);
}
.zoom-note {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--navy-soft);
}

.hint { margin: 0 0 8px; font-weight: 700; color: var(--navy-soft); font-size: 0.95rem; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  border: 3px solid var(--navy);
  background: var(--paper);
  color: var(--navy);
  border-radius: 14px;
  padding: 8px 12px;
  font-weight: 800;
  min-height: 44px;
}
.choice[aria-pressed="true"] { background: #d9fff3; }

.player-row { display: flex; flex-wrap: wrap; gap: 8px; }
.player-pill {
  border: 3px solid var(--navy);
  background: var(--paper);
  color: var(--navy);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
  min-height: 44px;
  box-shadow: 0 4px 0 rgba(22, 50, 79, 0.1);
}
.player-pill[aria-pressed="true"] { background: #ffd24a; }
.player-pill .edit {
  border: 0;
  background: transparent;
  padding: 0 0 0 6px;
  min-height: 0;
  font-size: 1rem;
  box-shadow: none;
}
.add-player { background: #e8ffe8; }

.label {
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--navy-soft);
  margin: 16px 0 8px;
}

.start-btn {
  margin-top: 18px;
  border: 3px solid var(--navy);
  border-radius: 16px;
  padding: 12px 18px;
  font-weight: 800;
  font-size: 1.1rem;
  min-height: 52px;
  background: var(--btn-state);
  color: #fff;
  box-shadow: var(--shadow);
  width: 100%;
}

.choices-wrap, .easy-wrap {
  padding: 8px 6px 10px;
  border-top: 2px dashed rgba(22, 50, 79, 0.2);
}
.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.choice-btn {
  border: 3px solid var(--navy);
  background: #fff7d6;
  color: var(--navy);
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 800;
  min-height: 48px;
  box-shadow: 0 3px 0 rgba(22, 50, 79, 0.12);
}
.choice-btn:hover { background: var(--land-hover); }
.choice-btn.correct { background: var(--correct); color: #fff; }
.choice-btn.wrong { background: var(--wrong); color: #fff; }

.mode-row { display: flex; flex-wrap: wrap; gap: 8px; }
.mode-btn { flex: 1; min-width: 180px; text-align: left; border-radius: 16px; }
.mode-btn[aria-pressed="true"] { background: #ffd24a; }

.site-nav, .foot-nav a { font-weight: 800; }

@media (max-width: 720px) {
  #map-wrap svg { max-height: 48vh; }
  .choices { grid-template-columns: 1fr; }
}

/* keep start card scrollable if many options */
#start-screen { overflow: auto; }

/* Setup buttons must stay readable (the states stylesheet uses white text on colored buttons). */
.start-card .mode-btn {
  color: var(--navy);
  background: var(--paper);
}
.start-card .mode-btn[aria-pressed="true"] {
  background: #ffd24a;
  color: var(--navy);
}
.start-card .mode-btn .mode-desc { opacity: 0.9; color: var(--navy); }

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

#map-wrap.continent-mode .country-hit { display: none; }
.country-hit { display: none; }
.country-hit.is-target {
  display: block;
  fill: rgba(255, 207, 77, 0.28);
  stroke: var(--navy);
  stroke-dasharray: 3 3;
  stroke-width: 1.4;
}
