/* ============================================
   Cartographer's Desk — visual identity
   Palette:
   --paper:  #EFE8D8  aged atlas paper
   --paper-dark: #E4DAC4
   --ink:    #1B2A41  deep chart navy (text, borders)
   --ink-soft: #33465F
   --sea:    #C9DCD6  pale chart-teal water
   --found:  #3C7A6A  map-line teal (correct/found)
   --gold:   #C9A24B  brass/compass accent
   --miss:   #B5482F  correction red (timer/errors)
   ============================================ */

@font-face {
  font-family: 'Fraunces';
  src: local('Georgia');
}

:root {
  --paper: #EFE8D8;
  --paper-dark: #E4DAC4;
  --paper-darker: #D9CCAE;
  --ink: #1B2A41;
  --ink-soft: #33465F;
  --ink-faint: #5C6E85;
  --sea: #CBDBD5;
  --found: #3C7A6A;
  --found-dark: #2A5A4E;
  --gold: #B8863E;
  --miss: #AD4A32;
  --radius: 3px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(255,255,255,0.35), transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(0,0,0,0.04), transparent 50%);
  color: var(--ink);
  font-family: 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
  line-height: 1.5;
}

.display {
  font-family: 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.mono {
  font-family: 'Courier New', ui-monospace, monospace;
}

.sans {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

a { color: var(--found-dark); }

::selection { background: var(--gold); color: var(--paper); }

/* ---------- Header ---------- */

.site-header {
  border-bottom: 2px solid var(--ink);
  padding: 18px 24px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

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

.brand-mark {
  font-size: 26px;
  transform: rotate(-8deg);
  display: inline-block;
}

.brand-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-tag {
  font-size: 12px;
  color: var(--ink-faint);
  font-style: italic;
}

.site-nav {
  font-size: 13px;
  display: flex;
  gap: 18px;
}

.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px dotted var(--ink-faint);
  padding-bottom: 1px;
}
.site-nav a:hover { color: var(--found-dark); border-color: var(--found-dark); }

/* ---------- Hero / Game Frame ---------- */

.game-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 10px;
}

.game-title {
  text-align: center;
  margin-bottom: 4px;
}

.game-title h1 {
  font-size: clamp(28px, 4vw, 42px);
  margin: 0 0 6px;
}

.game-title p {
  color: var(--ink-soft);
  font-size: 15px;
  margin: 0;
}

/* Control bar */

.control-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 22px 0 18px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.35);
  border: 1px solid var(--paper-darker);
  border-radius: var(--radius);
}

.mode-toggle {
  display: inline-flex;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  overflow: hidden;
}
.mode-toggle button {
  background: transparent;
  border: none;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
  border-right: 1px solid var(--ink);
}
.mode-toggle button:last-child { border-right: none; }
.mode-toggle button.active {
  background: var(--ink);
  color: var(--paper);
}

.btn {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1.5px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}
.btn:hover { background: var(--paper-darker); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--found);
  border-color: var(--found-dark);
  color: #fff;
}
.btn-primary:hover { background: var(--found-dark); }

.btn-gold {
  background: var(--gold);
  border-color: #8c6528;
  color: #fff;
}
.btn-gold:hover { background: #a3762f; }

.btn-ghost {
  border-style: dashed;
}

#btn-giveup {
  border-color: var(--miss);
  color: var(--miss);
}
#btn-giveup:hover {
  background: var(--miss);
  color: #fff;
}
#btn-giveup:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: var(--ink);
  color: var(--ink);
  background: transparent;
}
#btn-giveup:disabled:hover {
  background: transparent;
  color: var(--ink);
}

.divider-v {
  width: 1px;
  align-self: stretch;
  background: var(--paper-darker);
  margin: 0 4px;
}

/* Stats strip */
.stats-strip {
  display: flex;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  font-size: 14px;
}
.stat {
  text-align: center;
}
.stat .num {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  display: block;
  line-height: 1.1;
}
.stat.timer .num { color: var(--miss); }
.stat .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}

/* ---------- Game layout: map + input + list ---------- */

.game-body {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 18px;
  align-items: start;
}

@media (max-width: 880px) {
  .game-body { grid-template-columns: 1fr; }
}

.map-panel {
  background: var(--sea);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  box-shadow: 4px 4px 0 rgba(27,42,65,0.12);
}

.map-panel svg {
  display: block;
  width: 100%;
  height: auto;
}

.map-panel .bg-land {
  fill: #D8CCA9;
  stroke: #B9A97C;
  stroke-width: 0.4;
}

.country-path {
  fill: var(--paper-dark);
  stroke: var(--ink);
  stroke-width: 0.4;
  transition: fill 0.5s ease;
  cursor: default;
}

.country-path.found {
  fill: var(--found);
  animation: ink-in 0.6s ease forwards;
}

.country-path.flash {
  fill: var(--gold) !important;
}

@keyframes ink-in {
  0% { fill: var(--paper-dark); }
  30% { fill: var(--gold); }
  100% { fill: var(--found); }
}

.country-path.reveal-miss {
  fill: var(--miss);
  opacity: 0.75;
}

.map-caption {
  position: absolute;
  bottom: 8px;
  left: 12px;
  font-size: 11px;
  color: var(--ink-soft);
  background: rgba(239,232,216,0.85);
  padding: 2px 8px;
  border-radius: var(--radius);
  font-style: italic;
}

.last-found-toast {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--ink);
  color: var(--paper);
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.last-found-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Side panel */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-card {
  background: rgba(255,255,255,0.4);
  border: 1px solid var(--paper-darker);
  border-radius: var(--radius);
  padding: 14px;
}

.input-card label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  display: block;
  margin-bottom: 6px;
}

#country-input {
  width: 100%;
  font-family: inherit;
  font-size: 17px;
  padding: 10px 12px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
}
#country-input:focus {
  outline: none;
  border-color: var(--found);
  box-shadow: 0 0 0 3px rgba(60,122,106,0.15);
}

.input-hint {
  font-size: 12px;
  color: var(--ink-faint);
  margin-top: 6px;
  min-height: 16px;
}
.input-hint.wrong { color: var(--miss); }
.input-hint.right { color: var(--found-dark); }

.found-list-card {
  background: rgba(255,255,255,0.4);
  border: 1px solid var(--paper-darker);
  border-radius: var(--radius);
  padding: 14px;
  max-height: 360px;
  overflow-y: auto;
}
.found-list-card h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  margin: 0 0 8px;
  font-weight: 600;
}
.found-list {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2;
  column-gap: 12px;
  font-size: 13px;
}
.found-list li {
  break-inside: avoid;
  padding: 2px 0;
  color: var(--found-dark);
}
.found-list li::before {
  content: "✓ ";
  color: var(--found);
}

/* End-game summary */
.summary-card {
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  display: none;
}
.summary-card.show { display: block; }
.summary-card h2 { margin: 0 0 8px; font-size: 26px; }
.summary-card .big-stat {
  font-size: 44px;
  font-weight: 700;
  color: var(--gold);
}
.summary-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* Duel panel */
.duel-panel {
  background: rgba(184,134,62,0.1);
  border: 1.5px dashed var(--gold);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 13px;
}
.duel-panel h3 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
}
.duel-code {
  font-family: 'Courier New', monospace;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.1em;
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 6px 10px;
  border-radius: var(--radius);
  display: inline-block;
  margin: 6px 0;
}
.duel-vs {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 13px;
}
.duel-vs .you, .duel-vs .opp { text-align: center; flex: 1; }
.duel-vs .num { font-size: 22px; font-weight: 700; display: block; }

/* ---------- SEO content sections ---------- */

.content-wrap {
  max-width: 820px;
  margin: 60px auto 0;
  padding: 0 20px 60px;
}

.content-wrap h2 {
  font-size: 26px;
  border-bottom: 2px solid var(--paper-darker);
  padding-bottom: 8px;
  margin-top: 48px;
}

.content-wrap h3 {
  font-size: 18px;
  margin-top: 28px;
}

.content-wrap p, .content-wrap li {
  font-size: 15.5px;
  color: var(--ink-soft);
}

.content-wrap ul, .content-wrap ol {
  padding-left: 22px;
}

.faq-item {
  border-bottom: 1px solid var(--paper-darker);
  padding: 14px 0;
}
.faq-item summary {
  font-weight: 700;
  cursor: pointer;
  font-size: 15.5px;
  color: var(--ink);
}
.faq-item p { margin: 10px 0 0; }

.region-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin: 18px 0;
}
.region-card {
  border: 1px solid var(--paper-darker);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: rgba(255,255,255,0.35);
}
.region-card h4 {
  margin: 0 0 4px;
  font-size: 14px;
}
.region-card p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-faint);
}

.ad-slot {
  margin: 32px auto;
  max-width: 728px;
  min-height: 90px;
  border: 1px dashed var(--paper-darker);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-faint);
  font-size: 12px;
  font-family: -apple-system, sans-serif;
}

footer {
  border-top: 2px solid var(--ink);
  padding: 24px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-faint);
}
footer a { color: var(--ink-soft); }

/* Utility */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
}

.sr-announce { position: absolute; left: -9999px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

:focus-visible {
  outline: 2px solid var(--found);
  outline-offset: 2px;
}