:root {
  --ink: #1a2744;
  --muted: #5a6a88;
  --line: #c5d0e6;
  --accent: #2f6fed;
  --accent-soft: #eaf1ff;
  --ok: #1f9d63;
  --bad: #e04b4b;
  --empire: #b4233a;
  --gold: #e2b340;
  --shadow: 0 10px 30px rgba(26, 39, 68, 0.08);
  --radius: 18px;
  --font: "Segoe UI", "Trebuchet MS", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, #dce8ff 0%, transparent 40%),
    radial-gradient(circle at 90% 10%, #ffe8d6 0%, transparent 35%),
    linear-gradient(180deg, #eef3fb, #f8fafc 50%, #eef2f8);
  line-height: 1.45;
}

button,
summary {
  font: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 16px 22px;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
  margin-bottom: 12px;
}

.brand-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.brand span {
  color: var(--accent);
}

.brand:hover {
  text-decoration: none;
  color: var(--accent);
}

.back {
  font-size: 0.82rem;
  color: var(--muted);
}

.heading {
  flex: 1 1 220px;
}

.heading h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 1.85rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.heading p {
  margin: 2px 0 0;
  color: var(--muted);
}

.stats {
  display: flex;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.stats li {
  position: relative;
  min-width: 76px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 12px 7px;
  text-align: center;
}

.stats strong {
  display: block;
  font-size: 1.25rem;
  line-height: 1.1;
}

.stats span {
  color: var(--muted);
  font-size: 0.75rem;
}

.gain {
  position: absolute;
  left: 50%;
  top: 2px;
  color: var(--ok);
  font-style: normal;
  font-weight: 800;
  font-size: 0.85rem;
  pointer-events: none;
  opacity: 0;
}

.gain.go {
  animation: rise 0.8s ease;
}

@keyframes rise {
  0% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -16px);
  }
}

.campaigns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.campaigns button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 650;
}

.campaigns button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.campaigns button:hover {
  border-color: var(--accent);
}

.stage {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
}

.mission {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 16px 14px;
  align-self: start;
}

.kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mission h2 {
  margin: 0 0 8px;
  font-size: clamp(1.45rem, 2.4vw, 1.9rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.mission h2.shake {
  animation: shake 0.35s ease;
}

@keyframes shake {
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

.chip {
  display: inline-flex;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.8rem;
  font-weight: 700;
}

.feedback {
  min-height: 1.4em;
  margin: 10px 0 0;
  font-weight: 650;
}

.feedback.ok {
  color: var(--ok);
}

.feedback.bad {
  color: var(--bad);
}

.capital {
  margin: 6px 0 0;
  font-weight: 700;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.ghost {
  margin-top: 10px;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}

.bar {
  height: 8px;
  margin-top: 14px;
  background: #e7edf7;
  border-radius: 999px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--empire);
  border-radius: inherit;
  transition: width 0.35s ease;
}

.progress,
.best,
.done-lead {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.confirm {
  margin: 12px 0 0;
  padding: 10px;
  background: #fff6ea;
  border-radius: 12px;
}

.done-stats {
  margin: 10px 0 0;
  padding-left: 1.1rem;
}

.done-stats li {
  margin: 2px 0;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  list-style: none;
  margin: 16px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1.5px solid #6b5344;
  display: block;
}

.swatch.empty {
  background: #fbf6ec;
}

.swatch.owned {
  background: var(--empire);
  border-color: #f3d48a;
}

.swatch.empire {
  background: linear-gradient(135deg, #b4233a, #2f6fed 55%, #1f9d63);
  border-color: #f3d48a;
}

.picks {
  margin: 12px 0 0;
}

.picks p {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  font-weight: 700;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1.5px solid #f3d48a;
  flex: none;
}

.flag {
  width: 28px;
  height: 20px;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(26, 39, 68, 0.28);
  flex: none;
  background: #eef2f8;
}

.winner-btn {
  width: 100%;
  margin-top: 8px;
}

.wheel-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(16, 28, 48, 0.48);
}

.wheel-card {
  width: min(460px, 100%);
  background: #fff;
  border-radius: 24px;
  padding: 16px 16px 18px;
  text-align: center;
  box-shadow: var(--shadow);
}

.wheel-stage {
  position: relative;
  width: 340px;
  height: 340px;
  margin: 10px auto 0;
}

.wheel-pointer {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: -4px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 20px solid var(--ink);
}

.wheel {
  width: 340px;
  height: 340px;
  border-radius: 50%;
  position: relative;
  border: 8px solid #fff;
  box-shadow: 0 0 0 4px var(--ink);
  overflow: hidden;
}

.wheel-hub {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--ink);
}

.slice-label {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 132px;
  margin-left: -14px;
  margin-top: -132px;
  transform-origin: center bottom;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

.slice-flag {
  width: 22px;
  height: 15px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  flex: none;
  background: #fff;
}

.slice-name {
  writing-mode: vertical-rl;
  text-orientation: sideways;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.01em;
  max-height: 104px;
  overflow: hidden;
  white-space: nowrap;
}

.wheel-result {
  min-height: 1.4em;
  margin: 12px 0 0;
  font-size: 1.15rem;
  font-weight: 800;
}

details {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
}

details p {
  margin: 8px 0 0;
}

.map-panel {
  position: relative;
  min-height: 560px;
}

.map-wrap {
  position: absolute;
  inset: 0;
  background: #7eb6dc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.map-wrap.dragging {
  cursor: grabbing;
}

.map-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

.land {
  fill: #fbf6ec;
  stroke: #5c4636;
  stroke-width: 1.15;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill 0.2s ease;
}

.land:hover {
  fill: #ffe7ad;
}

.land.owned {
  fill: var(--empire-color, var(--empire));
  stroke: #f3d48a;
  stroke-width: 1.4;
}

.land.owned.fresh {
  animation: paint-country 0.7s ease;
}

.land.picked {
  stroke: #172033;
  stroke-width: 2.8px;
}

.land.owned.picked {
  stroke: #172033;
}

.land.revealed {
  fill: #a3adba;
  stroke: #eef2f6;
}

.land.revealed.fresh {
  animation: paint-reveal 0.45s ease;
}

.land.miss {
  fill: #ef6d5e;
}

.land.owned:hover,
.land.revealed:hover {
  filter: brightness(1.06);
}

@keyframes paint-country {
  0% { fill: #fff6d2; }
  42% { fill: var(--gold); }
  100% { fill: var(--empire-color, var(--empire)); }
}

@keyframes paint-reveal {
  from { fill: #fff6d2; }
  to { fill: #a3adba; }
}

.label {
  font-family: var(--font);
  font-weight: 800;
  fill: #fffaf3;
  stroke: #5c1222;
  stroke-width: 0.45;
  paint-order: stroke;
  pointer-events: none;
  user-select: none;
}

.grat {
  fill: none;
  stroke: rgba(255, 255, 255, 0.55);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.grat-label {
  fill: rgba(255, 255, 255, 0.92);
  font-family: var(--font);
  font-weight: 700;
  pointer-events: none;
  user-select: none;
}

.zoom {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 6px;
  z-index: 2;
}

.zoom button {
  min-width: 42px;
  height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  font-size: 1.15rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.zoom button:hover {
  color: var(--accent);
}

#zoomFit {
  font-size: 0.82rem;
  font-weight: 750;
}

.tip {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 0.85rem;
  transform: translate(14px, 14px);
  max-width: 260px;
}

@media (max-width: 860px) {
  .stage {
    display: block;
  }

  .map-panel {
    height: 72vh;
    min-height: 420px;
    margin-top: 12px;
  }

  .mission {
    align-self: stretch;
  }
}

@media (prefers-reduced-motion: reduce) {
  .land,
  .land.owned.fresh,
  .land.revealed.fresh,
  .mission h2.shake,
  .gain.go,
  .bar span {
    animation: none !important;
    transition: none !important;
  }
}
