@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Work+Sans:wght@400;600&display=swap');

:root {
  --ink: #1b1712;
  --muted: #5f584f;
  --paper: #f7f1e7;
  --accent: #d46849;
  --accent-dark: #a74a33;
  --ocean: #cfe3ef;
  --land: #3f3d3b;
  --good: #2f8f6f;
  --bad: #c23b22;
  --glass: rgba(255, 252, 247, 0.72);
  --glass-border: rgba(220, 196, 176, 0.65);
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  font-family: 'Work Sans', system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #fff8ef 0%, var(--paper) 50%, #efe4d7 100%);
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  opacity: 0;
}

body.intro::before {
  opacity: 1;
  background: rgba(245, 239, 230, 0.72);
  backdrop-filter: blur(2px);
}

.app {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(320px, 1fr);
  gap: 24px;
  padding: 28px;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  min-height: 100vh;
}

.panel {
  background: #fffdf9;
  border: 1px solid #e5d8c9;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 12px 30px rgba(50, 36, 22, 0.12);
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  z-index: 4;
}

.intro-only {
  display: grid;
  gap: 18px;
}

.intro-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
  align-items: start;
}

.intro-copy {
  display: grid;
  gap: 16px;
}

.intro-copy h1 {
  font-size: 3rem;
  margin: 0;
}

.intro-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.how-to-play {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #fff7ef;
  border: 1px solid #f0d9c7;
  color: var(--muted);
  font-size: 0.92rem;
}

.how-steps {
  display: grid;
  gap: 8px;
}

.how-steps div {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 8px;
  align-items: center;
}

.how-steps span {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f0d9c7;
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 0.8rem;
}

.settings {
  display: grid;
  gap: 10px;
  margin: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.mode-toggle {
  display: inline-flex;
  align-items: center;
  background: #fff4ea;
  border: 1px solid #f0d9c7;
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
  width: fit-content;
}

.segment-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.segment-btn.active {
  background: #ffffff;
  color: var(--accent-dark);
  box-shadow: 0 8px 16px rgba(216, 106, 74, 0.18);
}

.segment-btn:focus-visible {
  outline: 2px solid rgba(216, 106, 74, 0.35);
  outline-offset: 2px;
}

.setting {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.setting select {
  border: 1px solid #e5c7b4;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--ink);
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border: 1px solid #e5c7b4;
  border-radius: 10px;
  padding: 4px;
  background: #fff;
}

.stepper-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: #f7ebe1;
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 1rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.stepper-btn:disabled {
  opacity: 0.4;
}

.stepper-value {
  min-width: 44px;
  text-align: center;
  font-weight: 700;
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.stat-card {
  background: #ffffff;
  border: 1px solid #f0d9c7;
  border-radius: 14px;
  padding: 12px;
  text-align: center;
  box-shadow: 0 8px 16px rgba(216, 106, 74, 0.08);
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-dark);
}

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

.intro-side {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(240, 217, 199, 0.6);
  border-radius: 18px;
  padding: 16px;
  display: grid;
  gap: 16px;
}

.rules {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.brand h1 {
  font-family: 'Playfair Display', serif;
  font-size: 2.2rem;
  margin: 10px 0 6px;
}

.badge {
  display: inline-block;
  background: #f6dccf;
  color: var(--accent-dark);
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

body.intro .subtitle {
  font-size: 1.1rem;
}

.target {
  border: 1px dashed #e3c9b1;
  border-radius: 16px;
  padding: 16px;
  background: #fff6ef;
}

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

.capital {
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: 6px;
}

.country {
  font-size: 1rem;
  color: var(--accent-dark);
  min-height: 1.2em;
}

.stats {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.intro-actions {
  display: grid;
  gap: 10px;
  margin: 0;
}

.intro-actions .primary {
  width: 100%;
  justify-content: center;
  padding: 12px 16px;
  font-size: 1rem;
}

.online-setup {
  margin-top: 6px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid #f0d9c7;
  background: #fff6ef;
  display: grid;
  gap: 8px;
}

.online-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.online-row input {
  flex: 1;
  min-width: 180px;
  border: 1px solid #e5c7b4;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
}

.online-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
}

.round-summary {
  border: 1px dashed rgba(224, 196, 176, 0.7);
  border-radius: 12px;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
  background: rgba(255, 248, 241, 0.85);
  font-size: 0.85rem;
  color: var(--muted);
}

.round-summary .summary-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}

.round-summary .name {
  font-weight: 600;
  color: var(--ink);
}

.round-summary .value {
  color: var(--accent-dark);
  font-weight: 600;
}

.online-bar .chip {
  background: #e9f4ef;
  color: var(--good);
  border: 1px solid #cfe6da;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.online-bar .room {
  font-weight: 700;
  color: var(--accent-dark);
}

.online-bar .vs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.online-bar .sep {
  color: var(--muted);
  font-size: 0.75rem;
}

.hud {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hud-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) minmax(220px, 0.9fr) auto;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255, 252, 247, 0.82);
  border: 1px solid rgba(224, 196, 176, 0.55);
  box-shadow: 0 10px 24px rgba(30, 20, 10, 0.08);
}

.hud-prompt {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.hud-prompt .capital {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-prompt .country {
  font-size: 0.95rem;
  color: var(--accent-dark);
}

.hud-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: nowrap;
}

.state-pill {
  display: grid;
  gap: 2px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  border: none;
  font-variant-numeric: tabular-nums;
}

.state-pill .value {
  font-weight: 700;
}

.timer-pill {
  position: relative;
  width: 52px;
  height: 52px;
}

.timer-pill::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: rgba(255, 252, 247, 0.9);
  box-shadow: inset 0 0 0 1px rgba(216, 106, 74, 0.08);
  z-index: 0;
}

.timer-pill svg {
  width: 52px;
  height: 52px;
  transform: rotate(-90deg);
  position: relative;
  z-index: 1;
}

.timer-pill .time-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
  z-index: 2;
  line-height: 1;
}

.timer-pill .time-text .unit {
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--muted);
  transform: translateY(2px);
}

.timer-pill .track {
  stroke: rgba(216, 106, 74, 0.18);
  stroke-width: 6;
  fill: none;
}

.timer-pill .progress {
  stroke: var(--good);
  stroke-width: 6;
  fill: none;
  stroke-linecap: round;
  transition: stroke 0.2s ease;
}

.timer-pill.warn .progress {
  stroke: #e27a4b;
}

.timer-pill.danger .progress {
  stroke: #d0523b;
}

.timer-pill.warn .time-text {
  color: #e27a4b;
}

.timer-pill.danger .time-text {
  color: #d0523b;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
  position: relative;
}

.menu-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
}

.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: #fffdf9;
  border: 1px solid rgba(224, 196, 176, 0.7);
  border-radius: 12px;
  box-shadow: 0 14px 28px rgba(30, 20, 10, 0.18);
  padding: 6px;
  display: grid;
  gap: 4px;
  z-index: 12;
}

.menu button {
  background: transparent;
  border: none;
  padding: 8px 10px;
  text-align: left;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--ink);
}

.menu button:hover {
  background: #fff2e6;
  transform: none;
  box-shadow: none;
}

.scores-drawer {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, 90vw);
  max-height: 40vh;
  overflow: auto;
  background: #fffdf9;
  border: 1px solid rgba(224, 196, 176, 0.7);
  border-radius: 16px;
  box-shadow: 0 18px 36px rgba(30, 20, 10, 0.18);
  padding: 14px 16px;
  z-index: 12;
}

.scores-drawer.hidden {
  display: none;
}

.scores-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.scores-drawer h3 {
  margin: 4px 0 0;
  font-family: 'Playfair Display', serif;
}

.feedback.hidden {
  display: none;
}

.hud .target {
  background: rgba(255, 247, 240, 0.86);
  border: 1px solid rgba(224, 196, 176, 0.8);
}

.hud-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  display: flex;
  gap: 6px;
  align-items: center;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.stat .label {
  display: none;
}

.stat.timer-stat .label {
  margin-top: -2px;
}

.stat .value {
  font-size: 0.95rem;
  font-weight: 700;
}

.stat .icon {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(216, 106, 74, 0.12);
  color: var(--accent-dark);
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
}

.timer-stat {
  justify-items: center;
  text-align: center;
}

.timer-ring {
  position: relative;
  width: 48px;
  height: 48px;
  margin: 0 auto;
}

.timer-ring::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: rgba(255, 252, 247, 0.85);
  box-shadow: inset 0 0 0 1px rgba(216, 106, 74, 0.08);
  z-index: 0;
}

.timer-ring svg {
  width: 48px;
  height: 48px;
  transform: rotate(-90deg);
  position: relative;
  z-index: 1;
}

.timer-ring .time-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
  z-index: 2;
  line-height: 1;
}

.timer-ring .time-text .unit {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--muted);
  transform: translateY(2px);
}

.timer-ring .track {
  stroke: rgba(216, 106, 74, 0.18);
  stroke-width: 6;
  fill: none;
}

.timer-ring .progress {
  stroke: var(--good);
  stroke-width: 6;
  fill: none;
  stroke-linecap: round;
  transition: stroke 0.2s ease;
}

.timer-ring.warn .progress {
  stroke: #e27a4b;
}

.timer-ring.danger .progress {
  stroke: #d0523b;
}

.timer-ring.warn .time-text {
  color: #e27a4b;
}

.timer-ring.danger .time-text {
  color: #d0523b;
}

.score-ribbon {
  position: absolute;
  right: 18px;
  bottom: 18px;
  background: rgba(255, 250, 240, 0.92);
  border: 1px solid rgba(224, 196, 176, 0.8);
  padding: 10px 14px;
  border-radius: 999px;
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 700;
  color: var(--accent-dark);
  box-shadow: 0 12px 24px rgba(30, 20, 10, 0.2);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  z-index: 3;
}

.score-ribbon.show {
  animation: ribbonPop 1.2s ease forwards;
}

@keyframes ribbonPop {
  0% { opacity: 0; transform: translateY(10px) scale(0.98); }
  20% { opacity: 1; transform: translateY(0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-6px) scale(0.98); }
}

.score-ribbon .bonus {
  font-size: 0.8rem;
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.hint.bad {
  color: var(--bad);
}

.hint.good {
  color: var(--good);
}

.scores-block {
  display: grid;
  gap: 6px;
  text-align: left;
}

.scores-block.compact {
  font-size: 0.85rem;
}

.scores {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.modal-scores {
  gap: 6px;
}

.modal-scores li {
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid transparent;
}

.modal-scores li.highlight {
  background: rgba(47, 143, 111, 0.12);
  border-color: rgba(47, 143, 111, 0.3);
  color: var(--good);
  font-weight: 700;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 14, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal.hidden {
  display: none;
}

.modal-card {
  background: #fffdf9;
  border-radius: 16px;
  padding: 20px;
  min-width: min(320px, 90vw);
  box-shadow: 0 18px 40px rgba(20, 18, 14, 0.25);
  display: grid;
  gap: 12px;
}

.results-card {
  padding: 24px;
  min-width: min(720px, 94vw);
  background: linear-gradient(145deg, #fffdf9 0%, #fff7ef 100%);
  border: 1px solid #ecd9c9;
  box-shadow: 0 26px 60px rgba(38, 28, 18, 0.25);
}

.results-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: #fff7ee;
  border: 1px solid #f0d9c7;
  border-radius: 14px;
}

.rematch-requested .results-hero {
  border-color: rgba(47, 143, 111, 0.35);
  box-shadow: 0 0 0 1px rgba(47, 143, 111, 0.2);
}

.result-meta {
  background: #ffffff;
  border: 1px solid #efd8c7;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.result-winner {
  margin: 6px 0 0;
  font-weight: 700;
  color: var(--accent-dark);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.result-card {
  background: #ffffff;
  border: 1px solid #f0d8c7;
  border-radius: 16px;
  padding: 14px 16px;
  display: grid;
  gap: 12px;
  position: relative;
  box-shadow: 0 12px 24px rgba(40, 30, 20, 0.1);
}

.result-card.winner {
  border-color: rgba(47, 143, 111, 0.35);
  box-shadow: 0 16px 30px rgba(47, 143, 111, 0.2);
}

.result-card.winner::after {
  content: 'Winner';
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(47, 143, 111, 0.12);
  color: var(--good);
  border: 1px solid rgba(47, 143, 111, 0.3);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.result-card.you::before {
  content: 'You';
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(216, 106, 74, 0.12);
  color: var(--accent-dark);
  border: 1px solid rgba(216, 106, 74, 0.3);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.result-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.result-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.result-tag {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.result-score-wrap {
  display: grid;
  justify-items: end;
  gap: 2px;
}

.result-score {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent-dark);
}

.result-score-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.result-stat {
  background: #fdf6ef;
  border: 1px solid #f0d8c7;
  border-radius: 12px;
  padding: 8px 10px;
  display: grid;
  gap: 4px;
}

.result-stat .label {
  font-size: 0.7rem;
}

.result-stat .value {
  font-weight: 700;
}

.result-summary {
  display: grid;
  gap: 8px;
}

.summary-text {
  font-weight: 600;
  color: var(--ink);
}

.rematch-banner {
  background: #fff7ef;
  border: 1px solid #f0d8c7;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 600;
  color: var(--accent-dark);
}

.rematch-banner[data-state="incoming"] {
  background: rgba(47, 143, 111, 0.12);
  border-color: rgba(47, 143, 111, 0.3);
  color: var(--good);
}

.rematch-banner[data-state="waiting"] {
  background: rgba(216, 106, 74, 0.08);
  border-color: rgba(216, 106, 74, 0.25);
  color: var(--accent-dark);
}

.rematch-banner[data-state="countdown"] {
  background: rgba(88, 126, 176, 0.12);
  border-color: rgba(88, 126, 176, 0.25);
  color: #35618c;
}

.results-actions {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.rematch-cta.pulse {
  animation: rematchPulse 1.4s infinite;
  border-color: rgba(47, 143, 111, 0.45);
  color: var(--good);
}

@keyframes rematchPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(47, 143, 111, 0.35);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(47, 143, 111, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(47, 143, 111, 0);
  }
}

.rules-modal {
  padding: 32px;
}

.rules-card {
  width: min(1040px, 100%);
  max-height: 88vh;
  background: linear-gradient(165deg, #fffdf9 0%, #fff6ee 100%);
  border: 1px solid rgba(224, 196, 176, 0.7);
  border-radius: 24px;
  box-shadow: 0 28px 60px rgba(38, 28, 18, 0.24);
  padding: 30px 34px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 18px;
}

.rules-card h1 {
  margin: 0;
  font-family: 'Playfair Display', serif;
  font-size: 2.3rem;
  line-height: 1.1;
  color: var(--ink);
}

.rules-header {
  display: grid;
  gap: 8px;
}

.rules-kicker {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.rules-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.rules-body {
  overflow-y: auto;
  padding-right: 4px;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.rules-section {
  background: rgba(255, 247, 239, 0.9);
  border-radius: 18px;
  padding: 16px 18px;
  display: grid;
  gap: 10px;
}

.rules-section--full {
  grid-column: span 2;
}

.rules-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.rules-step {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #fffdf9;
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 6px 12px rgba(50, 36, 22, 0.08);
}

.rules-label {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.rules-formula {
  display: grid;
  gap: 10px;
  margin-left: 42px;
}

.rules-code {
  background: #fff;
  border: 1px solid rgba(224, 196, 176, 0.8);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: 'Work Sans', system-ui, sans-serif;
  font-weight: 700;
  color: var(--accent-dark);
  font-size: 0.88rem;
}

.rules-note {
  color: var(--muted);
  font-size: 0.88rem;
}

.rules-footer {
  border-top: 1px solid rgba(224, 196, 176, 0.6);
  padding-top: 16px;
  display: flex;
  justify-content: flex-end;
}

.modal-card p {
  margin: 0;
  color: var(--muted);
}

.modal-card h2 {
  margin: 0;
  font-family: 'Playfair Display', serif;
}

.modal-card input {
  border: 1px solid #e5c7b4;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 1rem;
}

.modal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 10px);
  background: rgba(255, 253, 249, 0.96);
  border: 1px solid rgba(224, 196, 176, 0.8);
  border-radius: 999px;
  padding: 10px 16px;
  box-shadow: 0 12px 24px rgba(30, 20, 10, 0.18);
  font-weight: 600;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}

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

.toast.good {
  border-color: rgba(47, 143, 111, 0.5);
  color: var(--good);
}

.toast.bad {
  border-color: rgba(194, 59, 34, 0.5);
  color: var(--bad);
}

.countdown-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 241, 231, 0.6);
  backdrop-filter: blur(4px);
  z-index: 50;
}

.countdown-card {
  background: linear-gradient(160deg, #fffdf9 0%, #fff3ea 100%);
  border: 1px solid rgba(240, 217, 199, 0.9);
  border-radius: 24px;
  padding: 28px 46px 30px;
  text-align: center;
  box-shadow: 0 26px 60px rgba(50, 36, 22, 0.22);
  min-width: 220px;
}

.countdown-label {
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.countdown-number {
  font-family: 'Playfair Display', serif;
  font-size: 4.8rem;
  line-height: 1;
  margin-top: 6px;
  color: var(--accent-dark);
  animation: countdownPop 0.6s ease;
}

.countdown-number.pulse {
  animation: countdownPop 0.6s ease;
}

@keyframes countdownPop {
  0% {
    transform: scale(0.85);
    opacity: 0.2;
  }
  60% {
    transform: scale(1.06);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

button {
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover:not(:disabled) {
  box-shadow: 0 8px 16px rgba(50, 36, 22, 0.12);
}

button:active {
  transform: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
}

.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 8px 16px rgba(216, 106, 74, 0.3);
}

.primary:hover:not(:disabled) {
  background: var(--accent-dark);
  box-shadow: 0 12px 20px rgba(216, 106, 74, 0.35);
}

.ghost {
  background: transparent;
  border: 1px solid #e5c7b4;
  color: var(--accent-dark);
}

.ghost:hover:not(:disabled) {
  background: rgba(255, 242, 230, 0.9);
  border-color: rgba(216, 106, 74, 0.45);
}

.controls button:not(.primary):not(.ghost) {
  background: #f4e5d7;
  color: var(--accent-dark);
}

.controls button:not(.primary):not(.ghost):hover:not(:disabled) {
  background: #f1ddcd;
  box-shadow: 0 6px 12px rgba(80, 50, 20, 0.12);
}

.feedback {
  min-height: 1.4em;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--muted);
}

.feedback.good {
  color: var(--good);
}

.feedback.bad {
  color: var(--bad);
}

.hud-helper {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.result-dot {
  color: var(--muted);
  margin: 0 6px;
}

.result-points {
  color: var(--accent-dark);
  font-weight: 700;
}

.result-distance {
  color: var(--muted);
}

.result-bonus {
  color: var(--good);
  font-weight: 700;
}

.credit {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: auto;
}

.map-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.map-frame {
  position: relative;
  width: min(100%, 860px);
  aspect-ratio: 12 / 5;
  background: radial-gradient(circle at top, #e8f3fb 0%, var(--ocean) 45%, #c7dbe8 100%);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid #cfe0ef;
  box-shadow: 0 16px 30px rgba(30, 40, 60, 0.12);
}

.map-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.35), transparent 55%),
    radial-gradient(circle at 70% 80%, rgba(0,0,0,0.18), transparent 60%);
  pointer-events: none;
  z-index: 1;
}

.map-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(120deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0) 35%),
    linear-gradient(60deg, rgba(0,0,0,0.04) 0%, rgba(0,0,0,0) 45%);
  opacity: 0.6;
  pointer-events: none;
  z-index: 1;
}

.map-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: var(--ocean);
  pointer-events: none;
  z-index: 0;
}

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

.map-svg .country path {
  fill: var(--land);
  stroke: #67625e;
  stroke-width: 0.3;
}

.map-svg .country.highlight path {
  stroke: #ffd27d;
  stroke-width: 1.4;
  stroke-linejoin: round;
  stroke-linecap: round;
  animation: highlightFlash 0.8s ease-out;
}

@keyframes highlightFlash {
  0% { stroke-opacity: 0; }
  40% { stroke-opacity: 1; }
  100% { stroke-opacity: 0; }
}

#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  z-index: 2;
}

.marker {
  fill: var(--accent);
  stroke: #fff;
  stroke-width: 2;
}

.marker.correct { fill: var(--good); }
.marker.miss { fill: var(--bad); }
.marker.opp { fill: #2f6fb0; }

.marker-halo {
  fill: none;
  stroke-width: 8;
  opacity: 0.35;
}

.marker-halo.correct { stroke: var(--good); }
.marker-halo.miss { stroke: var(--bad); }

.marker-core {
  fill: #fff8f2;
}

.marker.debug {
  fill: #2f6fb0;
}

.debug-label {
  font-size: 11px;
  fill: #1e1b16;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 3px;
  stroke-linejoin: round;
}

.distance-arc {
  stroke: #ffd27d;
  stroke-width: 2;
  stroke-dasharray: 4 4;
  opacity: 0.9;
  fill: none;
  transition: stroke-dashoffset 0.6s ease;
}

.distance-arc.opp {
  stroke: #8ab0d6;
}

.distance-label {
  font-size: 12px;
  fill: #1e1b16;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 3px;
  stroke-linejoin: round;
}

.pulse {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  opacity: 0.7;
  animation: pulse 1.6s ease-out infinite;
}

@keyframes pulse {
  0% { r: 4; opacity: 0.8; }
  100% { r: 18; opacity: 0; }
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .map-frame {
    width: 100%;
  }

  .intro-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
}

body.intro .app {
  grid-template-columns: 1fr;
  padding: 0;
  max-width: none;
}

body.intro .panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(960px, 94vw);
  max-height: 92vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px 32px;
  background: linear-gradient(140deg, #fffaf4 0%, #fff1e6 100%);
  border: 1px solid #f0d7c3;
  box-shadow: 0 30px 60px rgba(50, 36, 22, 0.18);
  text-align: left;
}

body.intro .map-wrap {
  align-items: center;
  justify-content: center;
  background: var(--ocean);
}

body.intro .map-frame {
  width: 100vw;
  height: auto;
  max-height: 100vh;
  aspect-ratio: 12 / 5;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

body.intro .hud {
  display: none;
}

body.play .app {
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 10px 14px;
  gap: 10px;
  max-width: none;
}

body.play .panel {
  position: relative;
  width: min(980px, 96vw);
  margin: 0 auto;
  max-height: none;
  overflow: visible;
  padding: 0;
  gap: 8px;
  background: transparent;
  border: none;
  box-shadow: none;
}

body.play .map-wrap {
  align-items: center;
  justify-content: center;
  background: var(--ocean);
}

body.play .map-frame {
  width: 100%;
  height: auto;
  max-height: calc(100vh - 64px);
  aspect-ratio: 12 / 5;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

body.play .intro-only {
  display: none;
}

.ghost.mini {
  padding: 6px 10px;
  font-size: 0.8rem;
}


@media (max-width: 700px) {
  body.play .app {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 12px;
  }

  body.play .panel {
    position: static;
    max-height: none;
  }

  body.play .hud {
    grid-template-columns: 1fr;
  }
}

body.play .hud {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

body.play #feedback {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
  padding-left: 0;
  margin-top: 2px;
}
