/* ==========================================================================
   Sector 196 - "command centre" look. Rules: design-system/MASTER.md
   Change colours/fonts here in the tokens, not per screen.
   ========================================================================== */

:root {
  --bg: #04070c;
  --panel: rgba(12, 32, 44, 0.55);
  --panel-solid: #0a1a24;
  --line: rgba(34, 211, 238, 0.28);
  --text: #d8f6ff;
  --muted: #6fa3b3;
  --accent: #22d3ee;
  --territory: #2dd4bf;
  --territory-glow: rgba(45, 212, 191, 0.9);
  --win: #2dd4bf;
  --loss: #fb7185;
  --over: #fbbf24;
  --gold: #facc15;
  --ocean: #030c14;
  --land: #0f2a33;
  --border: #1b4a57;

  --head-font: "Rajdhani", "Arial Narrow", sans-serif;
  --body-font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --num-font: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 2px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0 auto;
  max-width: 760px;
  padding: 0 16px 24px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body-font);
  font-size: 16px;
  line-height: 1.5;
}

/* The simulation screen gets extra width so the map and log fit side by side */
body.wide {
  max-width: 1100px;
}

h1,
h2,
h3 {
  font-family: var(--head-font);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.2;
}

h2 {
  font-size: 1.5rem;
  margin: 1.25rem 0 0.25rem;
}

h3 {
  font-size: 1.1rem;
  color: var(--muted);
  margin: 1.5rem 0 0.5rem;
}

a {
  color: var(--accent);
}

/* ---- Buttons: outlined cyan, 44px+ tall ---- */

button,
.button-link {
  font-family: var(--head-font);
  font-weight: 700;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  min-height: 44px;
  padding: 0 18px;
  margin: 4px 4px 4px 0;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

button:hover,
.button-link:hover {
  background: rgba(34, 211, 238, 0.12);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.35);
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* The main action on a screen: filled cyan */
.btn-primary {
  background: var(--accent);
  color: #03141a;
}

.btn-primary:hover {
  background: #67e8f9;
  color: #03141a;
}

/* ---- Top bar (every page): home far left, logo centred, sign-in space right ---- */

.top-bar {
  display: grid;
  grid-template-columns: 88px 1fr 88px;
  align-items: center;
  height: 60px;
  margin: 0 -16px 8px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  /* Pinned to the top while scrolling */
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(4, 7, 12, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* "See summary" scrolls here - leave room for the pinned bar */
#resultSection {
  scroll-margin-top: 72px;
}

.home-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--text);
}

.home-link:hover {
  color: var(--accent);
}

.logo {
  justify-self: center;
  font-family: var(--head-font);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.18em;
  color: var(--text);
  text-decoration: none;
  text-shadow: 0 0 12px rgba(34, 211, 238, 0.55);
}

.logo span {
  color: var(--accent);
}

/* ---- Flags ---- */

.flag {
  display: inline-block;
  width: 1.5em;
  height: 1.125em;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(216, 246, 255, 0.25);
  vertical-align: -0.15em;
}

/* ---- World map ---- */

/* Frame around the map: grid backdrop + HUD corner brackets */
.map-frame {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background-color: var(--ocean);
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.06) 1px, transparent 1px);
  background-size: 32px 32px;
  overflow: hidden;
}

.map-frame::before,
.map-frame::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid var(--accent);
  z-index: 2;
  pointer-events: none;
}

.map-frame::before {
  top: 8px;
  left: 8px;
  border-right: 0;
  border-bottom: 0;
}

.map-frame::after {
  bottom: 8px;
  right: 8px;
  border-left: 0;
  border-top: 0;
}

.map-wrap {
  position: relative;
}

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

/* Faint radar sweep over the map during the simulation */
.map-frame.radar .map-wrap::after {
  content: "";
  position: absolute;
  inset: -50%;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(34, 211, 238, 0.10) 40deg, transparent 60deg);
  animation: radar-sweep 6s linear infinite;
  pointer-events: none;
}

@keyframes radar-sweep {
  to { transform: rotate(360deg); }
}

/* Ocean is transparent so the grid shows through */
.map-wrap .oceanxx {
  fill: transparent !important;
  stroke: none !important;
}

/* Unowned land */
.map-wrap .landxx,
.map-wrap .limitxx {
  fill: var(--land) !important;
  stroke: var(--border) !important;
  stroke-width: 0.9 !important;
  stroke-linejoin: round !important;
  stroke-linecap: round !important;
}

/* Microstate circle markers */
.map-wrap .circlexx,
.map-wrap .subxx,
.map-wrap .noxx,
.map-wrap .unxx {
  fill: var(--land) !important;
  stroke: var(--border) !important;
  stroke-width: 1.5 !important;
  r: 6.5;
}

/* Player's territory: glowing teal */
.map-wrap .player-territory {
  fill: var(--territory) !important;
  filter: drop-shadow(0 0 3px var(--territory-glow));
}

/* A country captured this year flashes bright, then settles */
.map-wrap .just-captured {
  animation: capture-flash 0.9s ease-out;
}

@keyframes capture-flash {
  0% { fill: #ffffff; filter: drop-shadow(0 0 10px #ffffff); }
  100% { fill: var(--territory); filter: drop-shadow(0 0 3px var(--territory-glow)); }
}

/* ---- Simulation screen ---- */

/* Full conquest: the moment the last country falls, the Territory tile, result
   line and map frame turn gold (the map itself stays teal - tried gold, Sam
   found the teal-to-gold change looked messy) */
.sim-screen.conquered .stat-value.hero,
.sim-screen.conquered .sim-result {
  color: var(--gold);
  text-shadow: 0 0 12px rgba(250, 204, 21, 0.6);
}

.sim-screen.conquered .map-frame {
  border-color: rgba(250, 204, 21, 0.5);
  box-shadow: 0 0 24px rgba(250, 204, 21, 0.25);
}

.empire-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.empire-head h2 {
  margin: 0;
}

.empire-head .flag {
  width: 40px;
  height: 30px;
}

.sim-context {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.sim-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 14px 0 12px;
}

.stat-tiles {
  display: flex;
  gap: 10px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 14px;
  min-width: 96px;
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.stat-value {
  font-family: var(--num-font);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat-value.hero {
  color: var(--accent);
  text-shadow: 0 0 12px rgba(34, 211, 238, 0.6);
}

/* Final placement, shown above the map when the run ends */
.sim-result {
  margin: 0 0 12px;
  font-family: var(--head-font);
  font-weight: 700;
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.sim-result:empty {
  display: none;
}

/* Map ~65%, log ~35%. The log column takes the map's height, and the log
   scrolls inside it instead of growing the page. */
.sim-layout {
  display: grid;
  grid-template-columns: 65fr 35fr;
  gap: 14px;
}

.sim-layout .map-frame {
  align-self: start;
}

.sim-log-col {
  position: relative;
}

.sim-log-col .event-log {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding-right: 4px;
}

/* ---- Event log ---- */

.event {
  margin: 0 0 8px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--edge, var(--line));
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.45;
  animation: log-in 0.35s ease-out;
}

@keyframes log-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.event-numbers {
  font-family: var(--num-font);
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.event-year {
  color: var(--text);
  font-weight: 600;
}

.event-change {
  font-weight: 600;
}

.event-win { --edge: var(--win); }
.event-loss { --edge: var(--loss); }
.event-overextended { --edge: var(--over); }
.event-ruling { --edge: var(--gold); }

.event-win .event-change { color: var(--win); }
.event-loss .event-change { color: var(--loss); }
.event-overextended .event-change { color: var(--over); }
.event-ruling .event-change { color: var(--gold); }

/* Big wins (+5%) and disasters (-3%): bold, thicker edge */
.event-big {
  border-left-width: 6px;
}

.event-big .event-text,
.event-overextended .event-text {
  font-weight: 700;
}

.event-overextended .event-text {
  font-style: italic;
}

/* ---- Phones and narrow windows ---- */

@media (max-width: 768px) {
  .sim-layout {
    grid-template-columns: 1fr;
  }

  .sim-log-col {
    height: 260px;
  }

  .sim-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .stat {
    flex: 1;
    min-width: 0;
    padding: 6px 10px;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .sim-bar button {
    width: 100%;
    margin: 0;
  }

  h2 {
    font-size: 1.3rem;
  }
}

/* ---- Draft screen ---- */

.draft-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 16px;
}

.draft-head h2 {
  margin: 0;
}

.pool-count {
  font-family: var(--num-font);
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

/* 8 segments, one per pick */
.draft-progress {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  margin: 10px 0 16px;
}

.draft-progress span {
  height: 4px;
  background: var(--line);
}

.draft-progress .done {
  background: var(--territory);
  box-shadow: 0 0 6px rgba(45, 212, 191, 0.7);
}

.draft-progress .current {
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.4; }
}

/* The drawn country: big flag that spins, then lands */
.drawn-card {
  text-align: center;
  padding: 18px 16px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.drawn-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.drawn-flag {
  display: block;
  width: 160px;
  height: 120px;
  margin: 10px auto;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px rgba(216, 246, 255, 0.25);
  transition: opacity 0.4s;
}

.drawn-name {
  font-family: var(--head-font);
  font-weight: 700;
  font-size: 1.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  min-height: 1.3em;
}

.drawn-card.landed .drawn-flag {
  animation: land-flash 0.6s ease-out;
}

.drawn-card.landed .drawn-name {
  animation: fade-in 0.4s ease-out;
  text-shadow: 0 0 14px rgba(34, 211, 238, 0.5);
}

@keyframes land-flash {
  0% { box-shadow: 0 0 0 2px #fff, 0 0 30px 6px rgba(34, 211, 238, 0.9); transform: scale(1.06); }
  100% { box-shadow: 0 0 0 1px rgba(216, 246, 255, 0.25); transform: none; }
}

.draft-instruction {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  margin: 14px 0 10px;
}

/* 8 category tiles: open ones are buttons, filled ones show the pick */
.cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Draft Complete: every tile stretches to the tallest one's height */
.cat-grid.complete {
  grid-auto-rows: 1fr;
}

.cat-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  height: 84px; /* identical whether empty or filled - nothing shifts on a pick */
  min-width: 0;
  margin: 0;
  padding: 10px 12px;
  text-align: left;
  border-radius: var(--radius);
}

.cat-name {
  font-family: var(--head-font);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.95rem;
}

.cat-open {
  justify-content: center;
  border: 1px dashed var(--accent);
  color: var(--accent);
}

.cat-hint {
  font-family: var(--body-font);
  font-size: 0.75rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
}

.cat-open:disabled {
  opacity: 0.4;
  cursor: wait;
  box-shadow: none;
  background: transparent;
}

.cat-filled {
  background: var(--panel);
  border: 1px solid var(--line);
}

.cat-filled .cat-name {
  font-size: 0.75rem;
  color: var(--muted);
}

.cat-grid.complete .cat-tile {
  height: auto;
}

.cat-country,
.cat-tier {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-country {
  font-weight: 600;
}

.cat-tier {
  font-family: var(--num-font);
  font-size: 0.8rem;
}

.cat-grid.complete .cat-country,
.cat-grid.complete .cat-tier {
  white-space: normal;
}

/* The verdict on the country just placed */
.last-pick {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  font-size: 0.9rem;
  animation: log-in 0.35s ease-out;
}

.last-pick .cat-tier {
  white-space: normal;
}

/* Tier colours: weak = rose, average = muted, strong = teal/cyan */
.tier-very-weak { color: var(--loss); }
.tier-weak { color: #fda4af; }
.tier-average { color: var(--muted); }
.tier-strong { color: var(--territory); }
.tier-very-strong { color: var(--accent); text-shadow: 0 0 8px rgba(34, 211, 238, 0.5); }

.pick-fact {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Laptop: drawn country on the left, tiles on the right, all on one screen */
@media (min-width: 900px) {
  body.drafting {
    max-width: 1100px;
  }

  .draft-body {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 20px;
    align-items: start;
  }

  .draft-instruction {
    margin-bottom: 0;
  }
}

.btn-secondary {
  border-color: var(--line);
  color: var(--muted);
}

.summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.summary-actions button {
  margin: 0;
}

/* Laptop: tiles on the left, map + buttons on the right - all on one screen */
@media (min-width: 900px) {
  body.completing {
    max-width: 1100px;
  }

  .complete-body {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    align-items: start;
  }

  .complete-side h3 {
    margin-top: 0;
  }

  .summary-actions button {
    flex: 1 1 100%;
  }
}

/* Phone: Run / Restart pinned to the bottom of the screen while scrolling */
@media (max-width: 899px) {
  .complete-body {
    padding-bottom: 120px; /* room so the pinned bar never covers the map */
  }

  .summary-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    margin: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: rgba(4, 7, 12, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
  }

  .summary-actions .btn-primary {
    flex: 1 1 100%;
  }

  .summary-actions .btn-secondary {
    flex: 1 1 100%;
    min-height: 36px;
    border: 0;
    font-size: 0.85rem;
  }
}

@media (max-width: 768px) {
  .drawn-flag {
    width: 128px;
    height: 96px;
  }
}

/* ---- End screen (below the log) ---- */

.end-screen {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* Result panel: big placement, title, stat tiles */
.end-hero {
  text-align: center;
  padding: 20px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.end-place {
  font-family: var(--head-font);
  font-weight: 700;
  font-size: 3.5rem;
  line-height: 1;
  margin-top: 8px;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(34, 211, 238, 0.55);
}

.end-place small {
  font-size: 1.5rem;
  color: var(--muted);
  text-shadow: none;
}

.end-title {
  font-family: var(--head-font);
  font-weight: 700;
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 4px;
}

.end-tiles {
  justify-content: center;
  margin-top: 16px;
}

/* 1st place and full conquest get their own glow */
.end-first .end-hero {
  border-color: var(--accent);
  box-shadow: 0 0 24px rgba(34, 211, 238, 0.25);
}

.end-conquest .end-hero {
  border-color: var(--gold);
  box-shadow: 0 0 28px rgba(250, 204, 21, 0.3);
}

.end-conquest .end-place,
.end-conquest .end-title {
  color: var(--gold);
  text-shadow: 0 0 20px rgba(250, 204, 21, 0.5);
}

.end-summary {
  margin: 14px 0;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  background: var(--panel);
  border-radius: var(--radius);
  line-height: 1.6;
}

.end-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.end-actions button {
  margin: 0;
}

.share-note {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Best / worst year */
.year-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
}

.year-card {
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--edge, var(--line));
  border-radius: var(--radius);
}

.year-best { --edge: var(--win); }
.year-worst { --edge: var(--loss); }
.year-best .event-change { color: var(--win); }
.year-worst .event-change { color: var(--loss); }

.year-card-head {
  font-family: var(--num-font);
  font-weight: 600;
  margin: 2px 0;
}

.year-card-text {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.45;
}

/* Greatest Empires leaderboard */
.ladder-note {
  font-size: 0.875rem;
  color: var(--muted);
}

.empire-ladder {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ladder-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.lr-rank,
.lr-score {
  font-family: var(--num-font);
  font-weight: 600;
  font-size: 1rem;
}

.lr-rank {
  color: var(--muted);
}

.lr-name {
  font-weight: 600;
}

.lr-you {
  color: var(--muted);
  font-weight: 400;
}

.ladder-reason {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.ladder-reason:empty {
  display: none;
}

/* Thin bar: score out of 1000 */
.lr-bar {
  height: 3px;
  margin-top: 6px;
  background: rgba(34, 211, 238, 0.12);
}

.lr-bar span {
  display: block;
  height: 100%;
  background: var(--muted);
}

.ladder-you {
  background: rgba(45, 212, 191, 0.1);
  border-left: 4px solid var(--territory);
}

.ladder-you .lr-rank,
.ladder-you .lr-score {
  color: var(--territory);
}

.ladder-you .lr-bar span {
  background: var(--territory);
  box-shadow: 0 0 6px rgba(45, 212, 191, 0.8);
}

.ladder-conqueror {
  background: rgba(250, 204, 21, 0.08);
  border-left-color: var(--gold);
}

.ladder-conqueror .lr-rank,
.ladder-conqueror .lr-score {
  color: var(--gold);
}

.ladder-conqueror .lr-bar span {
  background: var(--gold);
  box-shadow: 0 0 6px rgba(250, 204, 21, 0.8);
}

@media (max-width: 768px) {
  .year-cards {
    grid-template-columns: 1fr;
  }

  .end-place {
    font-size: 2.8rem;
  }

  .end-actions button {
    flex: 1;
  }
}

/* ---- Home screen ---- */

.home-hero {
  text-align: center;
  padding: 28px 0 20px;
}

.home-logo {
  font-size: 3.2rem;
  letter-spacing: 0.16em;
  margin: 0;
  text-shadow: 0 0 24px rgba(34, 211, 238, 0.55);
}

.home-logo span {
  color: var(--accent);
}

.tagline {
  font-family: var(--head-font);
  font-weight: 700;
  font-size: 1.3rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin: 6px 0 0;
}

.home-sub {
  color: var(--muted);
  max-width: 440px;
  margin: 10px auto 20px;
}

.start-button {
  font-size: 1.2rem;
  min-height: 52px;
  padding: 0 36px;
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.35);
}

.home-map {
  margin-top: 8px;
}

.home-steps {
  list-style: none;
  padding: 0;
  margin: 20px 0 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.home-steps li {
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.step-num {
  display: block;
  font-family: var(--num-font);
  font-size: 0.8rem;
  color: var(--accent);
}

.home-steps strong {
  font-family: var(--head-font);
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.home-steps p {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 768px) {
  .home-logo {
    font-size: 2.4rem;
  }

  .home-steps {
    grid-template-columns: 1fr 1fr;
  }
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

/* ---- How to Play page ---- */

.htp-hero {
  padding: 16px 0 4px;
}

.htp-hero h1 {
  font-size: 2.4rem;
  margin: 0 0 8px;
  text-shadow: 0 0 20px rgba(34, 211, 238, 0.5);
}

.htp-hero p {
  color: var(--muted);
  font-size: 1.05rem;
}

.htp-hero strong {
  color: var(--text);
}

.htp-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.htp-steps li,
.htp-panel,
.htp-tips li {
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.htp-steps strong {
  font-family: var(--head-font);
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.htp-steps p {
  margin: 4px 0 0;
  color: var(--muted);
}

.htp-steps b {
  color: var(--text);
  font-weight: 600;
}

.htp-panel {
  margin-bottom: 12px;
}

.htp-panel p {
  margin: 0 0 8px;
}

.htp-panel p:last-child {
  margin-bottom: 0;
}

.htp-conquest {
  margin-top: 12px;
  border-color: rgba(250, 204, 21, 0.5);
}

.htp-conquest strong {
  color: var(--gold);
}

.htp-tips {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.htp-tips strong {
  color: var(--accent);
}

.htp-ready {
  text-align: center;
  margin-top: 28px;
}

.htp-ready h2 {
  margin-bottom: 12px;
}

.credits {
  margin-top: 28px;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---- Footer (every page) ---- */

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  margin-top: 3rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  font-size: 0.9em;
}

/* ---- Reduce motion: every animation becomes a simple fade ---- */

@media (prefers-reduced-motion: reduce) {
  .map-frame.radar .map-wrap::after {
    display: none;
  }

  .map-wrap .just-captured {
    animation: fade-in 0.4s ease-out;
  }

  .event {
    animation: fade-in 0.3s ease-out;
  }

  .drawn-card.landed .drawn-flag,
  .draft-progress .current {
    animation: none;
  }
}

@keyframes fade-in {
  from { opacity: 0.3; }
  to { opacity: 1; }
}

/* ---- Icons (game-icons.net, inline SVG coloured by currentColor) ---- */

.icon {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  flex: none;
  vertical-align: -0.2em;
}

.icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.cat-name .icon {
  margin-right: 5px;
  color: var(--accent);
}

/* Big faint icon in the corner of each category tile */
.cat-tile {
  position: relative;
  overflow: hidden;
}

.cat-tile > :not(.tile-wm) {
  position: relative;
}

.icon.tile-wm {
  position: absolute;
  right: -8px;
  bottom: -12px;
  width: 76px;
  height: 76px;
  color: var(--accent);
  opacity: 0.08;
  pointer-events: none;
}

.cat-open .icon.tile-wm {
  opacity: 0.06;
}

/* Log: category icon at the start of the meta line */
.event-numbers .icon {
  margin-right: 5px;
  color: var(--edge, var(--muted));
}

/* Home / How to Play step icons */
.step-icon {
  display: block;
  width: 34px;
  height: 34px;
  margin-bottom: 6px;
  color: var(--accent);
}

/* Feedback link in the top bar (the space kept for sign-in) */
.top-bar-right {
  justify-self: end;
}

.feedback-link {
  font-family: var(--head-font);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-decoration: none;
  padding: 12px 0;
}

.feedback-link:hover {
  color: var(--accent);
}

/* ---- End-screen charts ---- */

.chart-wrap {
  padding: 10px 8px 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.chart {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid {
  stroke: rgba(34, 211, 238, 0.12);
  stroke-width: 1;
}

.chart-label {
  fill: var(--muted);
  font-family: var(--num-font);
  font-size: 15px;
}

.chart-line {
  fill: none;
  stroke: var(--territory);
  stroke-width: 2.5;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 4px rgba(45, 212, 191, 0.8));
}

.chart-peak {
  fill: var(--bg);
  stroke: var(--accent);
  stroke-width: 2.5;
}

.chart-peak-label {
  fill: var(--accent);
  font-family: var(--num-font);
  font-size: 16px;
  font-weight: 600;
}

.chart-finish {
  stroke: var(--gold);
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
}

/* Won (right, teal) and lost (left, rose) per category */
.cat-bars {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.cat-bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 48px;
  gap: 10px;
  align-items: center;
  font-size: 0.85rem;
}

.cat-bar-name .icon {
  margin-right: 6px;
  color: var(--accent);
}

.cat-bar-track {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 10px;
  border-left: 0;
}

.cat-bar-half {
  display: flex;
  height: 100%;
  background: rgba(34, 211, 238, 0.06);
}

.cat-bar-half.lost {
  justify-content: flex-end;
  border-right: 1px solid var(--muted);
}

.cat-bar-half span {
  display: block;
  height: 100%;
}

.cat-bar-half.lost span {
  background: var(--loss);
}

.cat-bar-half.won span {
  background: var(--win);
  box-shadow: 0 0 6px rgba(45, 212, 191, 0.6);
}

.cat-bar-net {
  font-family: var(--num-font);
  font-weight: 600;
  text-align: right;
  color: var(--muted);
}

.cat-bar-net.pos { color: var(--win); }
.cat-bar-net.neg { color: var(--loss); }

@media (max-width: 768px) {
  .cat-bar-row {
    grid-template-columns: 1fr 44px;
  }

  .cat-bar-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

.htp-tips li {
  display: grid;
  grid-template-columns: 32px 1fr;
  column-gap: 10px;
}

.tip-icon {
  grid-row: span 2;
  width: 28px;
  height: 28px;
  color: var(--accent);
}

/* Laptop: chart and category bars side by side */
@media (min-width: 900px) {
  .end-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
  }

  .end-charts .cat-bar-row {
    grid-template-columns: 1fr 44px;
  }

  .end-charts .cat-bar-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

/* ---- Data & Credits page ---- */

.credits-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.credits-table th,
.credits-table td {
  text-align: left;
  vertical-align: top;
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--line);
}

.credits-table th {
  font-family: var(--head-font);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.credits-table td:first-child {
  font-weight: 600;
  white-space: nowrap;
}

.credits-note,
.credits-list {
  font-size: 0.875rem;
  color: var(--muted);
}

.credits-list li {
  margin-bottom: 6px;
}

/* Phones: each source becomes a small card (category, source, then licence) */
@media (max-width: 600px) {
  .credits-table thead {
    display: none;
  }

  .credits-table tr {
    display: block;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }

  .credits-table td {
    display: block;
    padding: 2px 0;
    border: 0;
  }

  .credits-table td:nth-child(3)::before {
    content: "Licence: ";
    color: var(--muted);
  }
}

/* Social icons, pushed to the right of the footer */
.social-links {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: var(--accent);
  border-radius: var(--radius);
  transition: color 0.15s, filter 0.15s;
}

.social-links a:hover {
  color: var(--hover);
  filter: drop-shadow(0 0 6px var(--hover));
}

.social-links svg {
  width: 20px;
  height: 20px;
}

/* ---- x2 speed button (next to Skip) ---- */

.reveal-controls {
  display: flex;
  gap: 8px;
}

.reveal-controls button {
  margin: 0;
}

.speed-btn.on {
  background: var(--accent);
  color: #03141a;
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.45);
}

@media (max-width: 768px) {
  .reveal-controls button {
    flex: 1;
  }
}

/* The second row of end-screen buttons, after the draft */
.end-actions-bottom {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* ---- Footer on phones: social icons centred on one line, links centred below ---- */

@media (max-width: 600px) {
  .site-footer {
    justify-content: center;
    row-gap: 8px;
  }

  .social-links {
    order: -1;
    flex-basis: 100%;
    justify-content: center;
    margin-left: 0;
  }
}
