/* Robeža — cartographic warm light theme, deep slate dark theme. */

:root {
  --bg: #f6f5f1;
  --panel: #fffefb;
  --ink: #2c2822;
  --ink-soft: #6b6357;
  --ink-faint: #928878;
  --line: #e2ddd1;
  --accent: #1f7a4d;
  --accent-ink: #ffffff;

  --map-sea: #cadde7;
  --map-land: #efe6d2;
  --map-shadow: rgba(58, 48, 32, .30);
  --map-a: #e9d8a6;
  --map-b: #c3d9c0;
  --map-edge: rgba(70, 60, 42, .45);
  --map-truth: #1f7a4d;
  --map-guess: #d1495b;
  --map-given: rgba(70, 60, 42, .55);
  --map-anchor: #ffffff;
  --map-anchor-ring: #3a3228;
  --map-label: #4a4034;
  --map-label-halo: rgba(255, 255, 255, .85);

  --tier-high: #1f7a4d;
  --tier-mid: #c98a1e;
  --tier-low: #c2503f;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(40, 34, 24, .06), 0 6px 20px rgba(40, 34, 24, .07);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --panel: #1b1f25;
    --ink: #e8e5df;
    --ink-soft: #a5a196;
    --ink-faint: #7d796f;
    --line: #2b3038;
    --accent: #34c27a;
    --accent-ink: #07160e;

    --map-sea: #172029;
    --map-land: #3a4048;
    --map-shadow: rgba(0, 0, 0, .55);
    --map-a: #55503e;
    --map-b: #38473f;
    --map-edge: rgba(230, 226, 216, .30);
    --map-truth: #4ade80;
    --map-guess: #f87171;
    --map-given: rgba(230, 226, 216, .45);
    --map-anchor: #f4f1ea;
    --map-anchor-ring: #0e1114;
    --map-label: #ece8e0;
    --map-label-halo: rgba(10, 13, 16, .8);

    --tier-high: #4ade80;
    --tier-mid: #e3b341;
    --tier-low: #f87171;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 22px rgba(0, 0, 0, .45);
  }
}

:root[data-theme="dark"] {
  --bg: #14161a;
  --panel: #1b1f25;
  --ink: #e8e5df;
  --ink-soft: #a5a196;
  --ink-faint: #7d796f;
  --line: #2b3038;
  --accent: #34c27a;
  --accent-ink: #07160e;

  --map-sea: #172029;
  --map-land: #3a4048;
  --map-shadow: rgba(0, 0, 0, .55);
  --map-a: #55503e;
  --map-b: #38473f;
  --map-edge: rgba(230, 226, 216, .30);
  --map-truth: #4ade80;
  --map-guess: #f87171;
  --map-given: rgba(230, 226, 216, .45);
  --map-anchor: #f4f1ea;
  --map-anchor-ring: #0e1114;
  --map-label: #ece8e0;
  --map-label-halo: rgba(10, 13, 16, .8);

  --tier-high: #4ade80;
  --tier-mid: #e3b341;
  --tier-low: #f87171;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 22px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 16px calc(32px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

main, .topbar, footer { max-width: 680px; margin-inline: auto; }

/* ------------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 0 14px;
}

.brand h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.brand p {
  margin: 2px 0 0;
  font-size: .82rem;
  color: var(--ink-soft);
}

.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; }

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: .82rem;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.chip:hover { color: var(--ink); border-color: var(--ink-faint); }
.chip.icon { padding: 6px; width: 32px; height: 32px; display: grid; place-items: center; }
.chip.icon svg { width: 17px; height: 17px; fill: currentColor; }

/* -------------------------------------------------------------------- board */

.promptbar {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.badge {
  font-size: .72rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

.promptbar p {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 600;
  flex: 1 1 260px;
}

.boardwrap {
  width: 100%;
  aspect-ratio: 1.15;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

#board.nudge { animation: nudge .35s ease; }
@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.hint {
  margin: 10px 2px 0;
  min-height: 1.4em;
  font-size: .86rem;
  color: var(--ink-soft);
  text-align: center;
}

/* ----------------------------------------------------------------- controls */

.controls { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 10px;
  padding: 11px 20px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}

.btn:hover:not(:disabled) { border-color: var(--ink-faint); }
.btn:disabled { opacity: .45; cursor: default; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary.ready { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.btn.ghost { background: transparent; }

/* ------------------------------------------------------------------- result */

.result {
  margin-top: 20px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.result.pop { animation: pop .45s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes pop {
  from { transform: scale(.97); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.score-main { display: flex; align-items: baseline; gap: 12px; }
.score-main strong { font-size: 2.6rem; font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.score-main span { font-size: 1rem; color: var(--ink-soft); font-weight: 600; }

.score-bar {
  --pct: 0%;
  margin-top: 12px;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 10%, transparent);
  overflow: hidden;
}

.score-bar i {
  display: block;
  height: 100%;
  width: var(--pct);
  border-radius: 999px;
  transition: width .6s cubic-bezier(.2, .8, .3, 1);
}

.score-bar[data-tier="high"] i { background: var(--tier-high); }
.score-bar[data-tier="mid"] i { background: var(--tier-mid); }
.score-bar[data-tier="low"] i { background: var(--tier-low); }

.legend {
  list-style: none;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin: 16px 0 0;
  padding: 0;
  font-size: .84rem;
  color: var(--ink-soft);
}

.legend li { display: flex; align-items: center; gap: 7px; }
.sw { width: 18px; height: 3px; border-radius: 2px; }
.sw-guess { background: var(--map-guess); }
.sw-truth { background: var(--map-truth); }

.facts, .stats dl {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 16px 0 0;
}

.stats dl { grid-template-columns: repeat(4, 1fr); }

.facts div, .stats div {
  background: color-mix(in srgb, var(--ink) 4%, transparent);
  border-radius: 10px;
  padding: 10px 12px;
}

.facts dt, .stats dt {
  margin: 0;
  font-size: .72rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.facts dd, .stats dd { margin: 3px 0 0; font-size: 1.06rem; font-weight: 700; }

.result-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.result-actions .btn { flex: 1 1 auto; }

.note { margin: 10px 0 0; font-size: .76rem; color: var(--ink-faint); text-align: center; }
body:not(.is-practice) #practice-note { display: none; }
body.is-practice .countdown { display: none; }

.countdown {
  margin: 14px 0 0;
  text-align: center;
  font-size: .84rem;
  color: var(--ink-soft);
}

.countdown time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }

/* -------------------------------------------------------------------- stats */

.stats { margin-top: 22px; }
.stats h2 {
  margin: 0 0 10px;
  font-size: .78rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 700;
}

/* --------------------------------------------------------------- help modal */

.help {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  max-width: 420px;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}

.help::backdrop { background: rgba(20, 18, 14, .45); backdrop-filter: blur(2px); }
.help h2 { margin: 0 0 12px; font-size: 1.15rem; }
.help ol { margin: 0 0 18px; padding-left: 20px; }
.help li { margin-bottom: 9px; font-size: .93rem; color: var(--ink-soft); }
.help .btn { width: 100%; }

/* -------------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: .86rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------------- footer */

footer {
  margin-top: 34px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: .76rem;
  color: var(--ink-faint);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

footer p { margin: 0; }
footer a { color: inherit; }

/* ------------------------------------------------------------------- mobile */

@media (max-width: 560px) {
  .boardwrap { aspect-ratio: 1; }
  .brand h1 { font-size: 1.35rem; }
  .promptbar p { font-size: .98rem; }
  .stats dl { grid-template-columns: repeat(2, 1fr); }
  .score-main strong { font-size: 2.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
