:root {
  --bg: #0b1220;
  --bg2: #111a2e;
  --card: #151f36;
  --line: #24314f;
  --text: #e8eefc;
  --muted: #8b97b5;
  --gold: #ffcc4d;
  --gold-ink: #3a2500;
  --cyan: #7ee0ff;
  --radius: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at 50% 20%, #16264a 0%, var(--bg) 60%) fixed;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 1100px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.stage { position: relative; flex: 1 1 52%; min-height: 240px; }
#map { display: block; width: 100%; height: 100%; touch-action: manipulation; }

/* 3D 地图上的 HTML 层：省名、引线、距离、南海小图 */
.map-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; font-size: 12px; }
.map-labels span {
  position: absolute; left: 0; top: 0; white-space: nowrap; font-weight: 600; line-height: 1;
  color: #8b97b5; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8); transition: color 0.3s; will-change: transform;
}
.map-labels span.on { color: #e6f1ff; }
.map-labels span.hot { color: #3a2500; text-shadow: 0 0 3px rgba(255, 240, 200, 0.7); }
.map-labels span.warm { color: #ffd76e; }
.map-labels span.pick { color: #04222c; text-shadow: 0 0 3px rgba(200, 245, 255, 0.8); }
.map-labels.clickable span { pointer-events: auto; cursor: pointer; padding: 4px; }
.map-labels .leaders { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.map-labels .leaders line { stroke: rgba(150, 170, 210, 0.6); stroke-width: 1; }
.map-labels .link-label {
  position: absolute; left: 0; top: 0; padding: 3px 8px; border-radius: 6px; font-size: 13px;
  background: rgba(11, 18, 32, 0.85); color: var(--cyan); border: 1px solid rgba(126, 224, 255, 0.5);
}
.sea-inset {
  position: absolute; right: 10px; bottom: 26px; border: 1px solid rgba(150, 170, 210, 0.45);
  background: rgba(11, 18, 32, 0.85); border-radius: 4px; pointer-events: none; transition: opacity 0.4s;
}
.sea-inset.away { opacity: 0; }
.map-hint {
  position: absolute; left: 0; right: 0; bottom: 4px; margin: 0;
  text-align: center; font-size: 13px; color: var(--muted); pointer-events: none;
}

.panel { flex: 0 0 auto; padding: 0 16px 16px; }
.card {
  background: linear-gradient(180deg, var(--card), var(--bg2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  animation: rise 0.25s ease-out;
}
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

.kicker { margin: 0 0 6px; color: var(--cyan); font-size: 13px; letter-spacing: 0.12em; }
h1 { margin: 0 0 10px; font-size: 30px; line-height: 1.2; }
h2 { margin: 0 0 14px; font-size: 20px; line-height: 1.45; min-height: 2.9em; }
.lead { margin: 0 0 16px; color: #c5d0ea; line-height: 1.6; }
.lead b { color: var(--gold); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; margin: 10px 0 0; }

.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-bottom: 12px; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--gold)); transition: width 0.3s; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  appearance: none; border: 1px solid var(--line); border-radius: 12px;
  background: #1b2742; color: var(--text);
  font: inherit; font-size: 16px; line-height: 1.35;
  padding: 14px 12px; min-height: 56px; cursor: pointer;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: #3a4c78; background: #213055; }
.btn:active { transform: scale(0.97); }
.btn:focus-visible, .link:focus-visible, select:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.btn.primary { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); font-weight: 700; }
.btn.primary:hover { background: #ffd76e; }
.btn.big { width: 100%; font-size: 18px; }
.choice { font-weight: 600; }

.minor { display: flex; justify-content: space-between; margin-top: 10px; }
.link { appearance: none; border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px; padding: 8px 4px; cursor: pointer; }
.link:hover { color: var(--text); }
.link:disabled { visibility: hidden; }

.guess { min-height: 0; font-size: 22px; margin-bottom: 4px; }
.guess b { color: var(--gold); font-size: 34px; margin: 0 2px; }
#guessConf { margin: 0 0 14px; }

.consent { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; color: #c5d0ea; cursor: pointer; }
.consent input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--gold); flex: none; }
.consent small { color: var(--muted); font-size: 12px; line-height: 1.5; }

.react { margin: 0 0 6px; min-height: 1.4em; font-size: 14px; color: var(--gold); animation: pop 0.3s ease-out; }
.react:empty { visibility: hidden; }
@keyframes pop { from { transform: translateY(4px); opacity: 0; } }
/* 平面地图时卡片右上角的省份明信片 */
.postcard { float: right; width: 88px; margin: -4px 0 8px 14px; transform: rotate(4deg); filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45)); }
.postcard canvas { display: block; width: 100%; height: auto; }
.portrait { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -6px 0 14px; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: #1f2c4b; border: 1px solid var(--line); color: #dbe4f7; }
.chip.odd { border-color: var(--cyan); color: var(--cyan); }
.portrait .note { font-size: 12px; color: var(--muted); }

/* 反向模式 */
.btn.alt { margin-top: 10px; background: #1b2742; border-color: #3a4c78; }
.btn.wide { width: 100%; margin-top: 10px; }
.rv-top { display: flex; justify-content: space-between; }
.rv-top .kicker:last-child { color: var(--gold); }
.rv-lead { margin: 0 0 8px; color: #c5d0ea; font-size: 15px; }
.clues { list-style: none; margin: 0 0 12px; padding: 0; max-height: 32vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.clues li { animation: pop 0.3s ease-out; }
.clues .cq { display: block; font-size: 13px; color: var(--muted); line-height: 1.5; }
.clues .ca { display: inline-block; margin-top: 3px; padding: 5px 12px; border-radius: 4px 14px 14px 14px; background: #24375e; color: var(--text); font-weight: 600; font-size: 15px; }
.clues .ca::before { content: 'TA：'; color: var(--cyan); font-weight: 400; }
#rvRevealText { line-height: 1.6; margin: 6px 0 4px; }
#rvRadar { margin: 0 0 14px; font-size: 14px; }
.rv-rows { margin: 0 0 14px; padding-left: 1.4em; color: #c5d0ea; font-size: 14px; line-height: 1.8; }
.rv-rows b { color: var(--gold); }

#fix label { display: block; margin: 14px 0 8px; color: #c5d0ea; }
.row { display: flex; gap: 10px; }
select {
  flex: 1; font: inherit; font-size: 16px; color: var(--text);
  background: #1b2742; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; min-height: 52px;
}
#after > p:first-child { line-height: 1.6; margin: 14px 0 6px; }
.misleads { margin: 0 0 14px; padding-left: 1.2em; color: #c5d0ea; font-size: 14px; line-height: 1.6; }
.misleads b { color: var(--gold); font-weight: 600; }

/* 横屏 / 电脑：地图在左，卡片在右 */
@media (min-width: 820px) and (min-aspect-ratio: 1/1) {
  .app { flex-direction: row; align-items: center; padding: 24px; gap: 24px; }
  .stage { flex: 1 1 auto; height: 100%; }
  .panel { flex: 0 0 380px; padding: 0; }
  h1 { font-size: 36px; }
}
@media (max-height: 640px) and (max-width: 819px) {
  h2 { font-size: 18px; }
  .btn { min-height: 50px; padding: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .react, .clues li { animation: none; }
  .progress span { transition: none; }
}
