:root {
  --bg: #0b0f17;
  --card: #151b27;
  --border: #243044;
  --text: #e6edf3;
  --muted: #8b98a9;
  --accent: #7c9cff;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --land: #1d2636;
  --land-edge: #2c3a52;
  --slide: 450ms;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
}

header { text-align: center; width: 100%; max-width: 900px; }
h1 { margin: 8px 0 4px; font-size: 28px; letter-spacing: -0.02em; }
h1 span:first-child { color: var(--green); }
h1 span:last-child { color: var(--red); }
#status { color: var(--muted); font-size: 14px; }

#progress {
  list-style: none; display: flex; gap: 6px; justify-content: center;
  padding: 0; margin: 10px 0 18px;
}
#progress li { width: 12px; height: 12px; border-radius: 3px; background: var(--border); }
#progress li.ok { background: var(--green); }
#progress li.bad { background: var(--red); }
#progress li.mid { background: var(--amber); }
#progress li.now { outline: 2px solid var(--accent); outline-offset: 1px; }

#modes { display: inline-flex; gap: 4px; padding: 4px; margin: 6px 0 8px;
         background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
#modes button {
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
  background: none; border: 0; border-radius: 8px; padding: 6px 14px; min-height: 36px;
}
#modes button:hover { color: var(--text); }
#modes button[aria-pressed="true"] { background: var(--accent); color: #0b0f17; }

#timer {
  position: relative; height: 10px; max-width: 420px; margin: 10px auto 18px;
  background: var(--border); border-radius: 5px;
}
#timer-fill { height: 100%; width: 100%; border-radius: 5px; background: var(--accent); }
#timer.low #timer-fill { background: var(--red); }
.delta {
  position: absolute; right: 0; bottom: 14px;
  font-weight: 800; font-size: 15px; pointer-events: none;
  animation: float-up 1s ease-out forwards;
}
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
@keyframes float-up { from { opacity: 1; translate: 0 0; } to { opacity: 0; translate: 0 -22px; } }
#best { margin: -8px 0 14px; font-weight: 600; }
#best:empty { display: none; }

#game { width: 100%; max-width: 900px; }
#board { display: flex; align-items: stretch; gap: 16px; position: relative; }

.card {
  flex: 1 1 0;
  min-width: 0;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  transition: transform var(--slide) ease, opacity var(--slide) ease,
              border-color 250ms, box-shadow 250ms;
}
.card.correct { border-color: var(--green); box-shadow: 0 0 32px -6px var(--green); }
.card.wrong { border-color: var(--red); box-shadow: 0 0 32px -6px var(--red); }
.card.exit { opacity: 0; transform: scale(0.92); }
.card.enter { opacity: 0; transform: translateX(40px); }
.no-anim, .no-anim .card { transition: none !important; }

.logo {
  width: 64px; height: 64px; border-radius: 14px;
  background: #fff; display: grid; place-items: center; overflow: hidden;
  font-weight: 700; font-size: 24px; color: #fff; flex-shrink: 0;
}
.logo img { width: 44px; height: 44px; object-fit: contain; }
.company { font-size: 22px; font-weight: 700; margin-top: 4px; }
.title { color: var(--text); opacity: 0.9; }

.map {
  width: 100%; max-width: 280px; aspect-ratio: 16 / 9;
  border-radius: 10px; background: #0e1420; border: 1px solid var(--border);
  position: relative; overflow: hidden; margin: 6px 0 2px;
}
.map svg { display: block; width: 100%; height: 100%; }
.map .land { fill: var(--land); stroke: var(--land-edge); stroke-width: 0.6; vector-effect: non-scaling-stroke; }
.map .inset { position: absolute; right: 4px; bottom: 4px; width: 34px; height: 38px; opacity: 0.9; }
.map .inset .land { stroke: none; fill: #33415a; }
.map .ref { fill: var(--muted); opacity: 0.85; }
.map .ref-dot { fill: var(--muted); opacity: 0.6; }
.map .pin { fill: var(--accent); }
.map .pulse { fill: var(--accent); opacity: 0.35; animation: pulse 1.8s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.map .pin-label { fill: var(--text); font-weight: 600; paint-order: stroke; stroke: #0e1420; }
@keyframes pulse { from { transform: scale(0.6); opacity: 0.5; } to { transform: scale(2.4); opacity: 0; } }

.city { color: var(--muted); font-size: 14px; }
.salary {
  font-size: 40px; font-weight: 800; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; margin-top: 6px;
}
.card.correct .salary { color: var(--green); }
.card.wrong .salary { color: var(--red); }
.card.close { border-color: var(--amber); box-shadow: 0 0 32px -6px var(--amber); }
.card.close .salary { color: var(--amber); }

/* Guess-the-salary slider. Thumb is 28px; marker math below depends on it. */
.guess { width: 100%; margin-top: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.guess-val { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }
.card.correct .guess-val { color: var(--green); }
.card.close .guess-val { color: var(--amber); }
.card.wrong .guess-val { color: var(--red); }
.track { position: relative; width: 100%; }
.guess input[type=range] {
  -webkit-appearance: none; appearance: none; display: block;
  width: 100%; height: 44px; margin: 0; background: transparent; cursor: pointer;
}
.guess input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: var(--border); }
.guess input[type=range]::-moz-range-track { height: 8px; border-radius: 4px; background: var(--border); }
.guess input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; margin-top: -10px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--card); box-shadow: 0 0 0 2px var(--accent);
}
.guess input[type=range]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--card); box-shadow: 0 0 0 2px var(--accent);
}
.guess input[type=range]:disabled { cursor: default; }
.guess input[type=range]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.answer-mark {
  position: absolute; top: 8px; width: 4px; height: 28px; border-radius: 2px; pointer-events: none;
  left: calc(var(--p) * (100% - 28px) + 14px); transform: translateX(-50%);
  background: var(--text); box-shadow: 0 0 0 2px var(--card);
}
[data-mode="salary"] .map { aspect-ratio: 3 / 1; }
.range-labels { width: 100%; display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: -6px; }
.guess .btn { margin-top: 6px; min-width: 160px; }
.n { color: var(--muted); font-size: 12px; }

.actions { display: flex; gap: 10px; margin-top: 10px; width: 100%; justify-content: center; }
.btn {
  font: inherit; font-weight: 700; cursor: pointer;
  padding: 12px 20px; border-radius: 12px; border: 2px solid var(--border);
  background: #1c2433; color: var(--text); min-width: 120px;
  transition: transform 120ms, background 150ms, border-color 150ms;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.higher:hover { border-color: var(--green); background: #12301f; }
.btn.lower:hover { border-color: var(--red); background: #341619; }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }

.vs {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--border);
  display: grid; place-items: center; font-weight: 800; color: var(--muted); z-index: 2;
}

.hint { text-align: center; color: var(--muted); font-size: 13px; margin-top: 14px; }

#end { width: 100%; max-width: 640px; margin-top: 12px; text-align: center; }
#end .result { background: var(--card); border: 2px solid var(--border); border-radius: 18px; padding: 24px 20px; }
#end h2 { font-size: 40px; margin: 0; letter-spacing: -0.02em; }
#verdict { color: var(--muted); margin: 4px 0 16px; }
#emoji { font-size: 28px; line-height: 1.25; letter-spacing: 3px; margin: 0 0 20px; }
.end-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0b0f17; }
.btn.primary:hover { background: #95b0ff; }
.insight {
  text-align: left; margin: 16px 0; padding: 14px 16px; border-radius: 14px;
  background: #141d30; border: 1px solid #2b3b63; display: flex; gap: 10px;
}
#end h3 { font-size: 14px; color: var(--muted); font-weight: 600; text-align: left; margin: 20px 0 8px; }
#recap { list-style: none; padding: 0; margin: 0; text-align: left; font-size: 14px; }
#recap li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 2px; border-bottom: 1px solid var(--border);
}
#recap li span:first-child { color: var(--muted); min-width: 0; }
#recap li b { color: var(--text); font-weight: 600; }
#recap li span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

footer { margin-top: auto; padding-top: 24px; color: var(--muted); font-size: 12px; text-align: center; max-width: 600px; }

@media (max-width: 700px) {
  body { padding: 10px 12px; }
  h1 { font-size: 22px; }
  #progress, #timer { margin: 8px auto 12px; }
  #timer { width: calc(100% - 48px); }
  #board { flex-direction: column; gap: 12px; }
  .card { padding: 12px 14px; gap: 2px; display: grid;
          grid-template-columns: 52px 1fr; grid-template-areas:
            "logo head" "map map" "sal sal" "n n" "act act";
          column-gap: 12px; text-align: left; align-items: center; }
  .logo { grid-area: logo; width: 48px; height: 48px; font-size: 18px; }
  .logo img { width: 34px; height: 34px; }
  .head { grid-area: head; }
  .company { font-size: 18px; margin: 0; }
  .title { font-size: 14px; }
  .map { grid-area: map; max-width: none; aspect-ratio: 3 / 1; margin: 6px 0 0; }
  .salary { grid-area: sal; font-size: 30px; text-align: center; margin-top: 4px; }
  .n { grid-area: n; text-align: center; }
  .actions, .guess { grid-area: act; margin-top: 6px; }
  [data-mode="salary"] .map { aspect-ratio: 6 / 1; }
  .btn { flex: 1; min-width: 0; padding: 10px; }
  .vs { position: relative; left: auto; top: auto; transform: none; margin: -26px auto;
        width: 40px; height: 40px; font-size: 13px; }
  .card.enter { transform: translateY(30px); }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --slide: 1ms; }
  .map .pulse { animation: none; }
  .delta { animation-name: fade-out; }
}
@keyframes fade-out { to { opacity: 0; } }
