:root {
  --bg: #070b16;
  --bg-2: #0e1628;
  --card: rgba(16, 24, 42, 0.88);
  --line: rgba(212, 168, 75, 0.28);
  --gold: #d4a84b;
  --gold-2: #f3d27a;
  --cyan: #3ec7ff;
  --text: #eef3ff;
  --muted: #9aa8c2;
  --danger: #ff6b6b;
  --ok: #3ddc97;
  --cn: #e23d2a;
  --asia: #d4a017;
  --eu: #2f6bff;
  --energy: #1aa36b;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }

#app { min-height: 100dvh; }
.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

.hero, .panel {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: calc(28px + var(--safe-top)) 20px calc(28px + var(--safe-bottom));
}

.hero { text-align: center; position: relative; }
.hero-orbit {
  width: 220px; height: 220px; margin: 12px auto 8px;
  border: 1px solid rgba(62, 199, 255, 0.25);
  border-radius: 50%;
  box-shadow: 0 0 80px rgba(62, 199, 255, 0.18), inset 0 0 40px rgba(212, 168, 75, 0.12);
  background:
    radial-gradient(circle at 50% 50%, rgba(62, 199, 255, 0.18), transparent 55%),
    radial-gradient(circle at 30% 40%, #d4a84b 0 6px, transparent 7px),
    conic-gradient(from 120deg, transparent 0 70%, rgba(212,168,75,.35) 80%, transparent 90%);
}
.eyebrow { letter-spacing: 0.28em; color: var(--cyan); font-size: 12px; margin: 0; }
h1 { font-size: 42px; margin: 8px 0 0; letter-spacing: 0.12em; }
.subtitle { margin: 0; color: var(--gold-2); letter-spacing: 0.4em; font-size: 16px; }
.tagline { color: var(--muted); margin: 16px 0 28px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0;
  min-height: 100dvh;
}
@media (min-width: 720px) {
  .panel {
    margin-top: 32px;
    margin-bottom: 32px;
    border-radius: 20px;
    min-height: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  }
}

h2 { margin: 8px 0 12px; font-size: 26px; }
.hint { color: var(--muted); font-size: 14px; line-height: 1.6; }
label { display: block; margin: 16px 0; color: var(--muted); font-size: 13px; }
input, select {
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  background: #0a1220;
  outline: none;
  min-height: 48px;
}
input:focus, select:focus { border-color: var(--cyan); }

.btn {
  border: 1px solid transparent;
  background: #1a2740;
  color: var(--text);
  border-radius: 12px;
  padding: 12px 18px;
  min-height: 48px;
  min-width: 48px;
  letter-spacing: 0.04em;
}
.btn.primary {
  background: linear-gradient(135deg, #d4a84b, #a67920);
  color: #1a1204;
  font-weight: 700;
}
.btn.ghost { border-color: var(--line); background: transparent; }
.btn.compact { min-height: 40px; padding: 8px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.linkish, .back {
  background: none; border: none; color: var(--cyan);
  min-height: 44px; padding: 8px 0;
}
.form-error { color: var(--danger); min-height: 20px; }

.invite-box {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 12px; border: 1px dashed var(--line); border-radius: 12px;
  margin-bottom: 16px;
}
.invite-box .label { display: block; color: var(--muted); font-size: 12px; }
.invite-box strong { font-size: 28px; letter-spacing: 0.2em; color: var(--gold-2); }
.player-list { list-style: none; padding: 0; margin: 0 0 16px; }
.player-list li {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 12px; border-radius: 12px;
  background: #0a1220; margin-bottom: 8px;
}
.player-list .meta { color: var(--muted); font-size: 13px; }
.lobby-actions { display: flex; gap: 10px; flex-wrap: wrap; }

#screen-game {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  position: relative;
}
.game-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(8px + var(--safe-top)) 12px 8px;
  background: linear-gradient(to bottom, rgba(7,11,22,0.92), transparent);
  pointer-events: none;
}
.game-top > * { pointer-events: auto; }
.round-chip, .turn-chip, .my-funds {
  background: rgba(10,18,32,0.85);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
}
.my-funds { color: var(--gold-2); font-weight: 700; font-size: 15px; }
.turn-chip { margin-top: 6px; max-width: 70vw; }

#phaser-root {
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.hud {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 8px 10px calc(10px + var(--safe-bottom));
  background: linear-gradient(to top, rgba(7,11,22,0.96) 70%, rgba(7,11,22,0.4), transparent);
}
.hud-players { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.hud-player {
  min-width: 108px; flex: 1;
  background: #0a1220; border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px; padding: 8px;
  font-size: 12px;
}
.hud-player.current { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.hud-player .name { font-weight: 700; }
.hud-player .cash { color: var(--gold-2); }
.hud-log {
  max-height: 64px; overflow: auto; color: var(--muted);
  font-size: 12px; line-height: 1.5; margin: 4px 0;
}
.hud-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.hud-actions .btn { flex: 1 1 30%; }
.hud-tools {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-top: 8px;
}
.speed-ctl { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.speed-ctl select { width: auto; min-height: 40px; padding: 6px 8px; }

.modal {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 12px;
}
.modal[hidden] { display: none !important; }
.modal-card {
  width: min(640px, 100%);
  max-height: min(86dvh, 860px);
  overflow: auto;
  background: #10182a;
  border: 1px solid var(--line);
  border-radius: 18px 18px 12px 12px;
  padding: 18px 16px calc(16px + var(--safe-bottom));
}
@media (min-width: 720px) {
  .modal { align-items: center; }
  .modal-card { border-radius: 18px; }
}
.modal-close {
  float: right; background: none; border: none; color: var(--cyan);
  min-height: 40px;
}
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 14px; }
.kv span { color: var(--muted); }
.event-title { color: var(--gold-2); margin-top: 0; }
.rules h3 { color: var(--gold-2); margin: 18px 0 8px; }
.rules p, .rules li { color: var(--muted); line-height: 1.65; }

.results-list { padding: 0; margin: 0 0 16px; }
.results-list li {
  display: flex; justify-content: space-between; gap: 8px; align-items: baseline;
  padding: 12px; border-radius: 12px; background: #0a1220; margin-bottom: 8px;
}
.results-list li:first-child { border: 1px solid var(--gold); }
.results-detail { color: var(--muted); font-size: 13px; line-height: 1.6; margin-bottom: 20px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  background: #1a2740; border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 999px; z-index: 30;
  max-width: 90vw;
}
.toast[hidden] { display: none !important; }

.tile-chip { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.region-CN { color: var(--cn); }
.region-ASIA { color: var(--asia); }
.region-EU { color: var(--eu); }
.region-ENERGY { color: var(--energy); }

@media (min-width: 900px) {
  .hud {
    left: auto; width: 340px; top: 70px; bottom: 0;
    background: rgba(7,11,22,0.86);
    border-left: 1px solid var(--line);
    padding-top: 12px;
  }
  .hud-log { max-height: 28vh; }
  #phaser-root { margin-right: 340px; }
  .hud-players { flex-wrap: wrap; overflow: visible; }
  .hud-player { min-width: 140px; }
}
