:root {
  --bg0: #0b0e1a;
  --bg1: #141a2e;
  --panel: rgba(255, 255, 255, 0.05);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text: #eef1ff;
  --muted: #9aa3c7;
  --gold: #ffd94d;
  --accent: #8b3dff;
  --danger: #ff4d5e;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 70% -10%, #2a1b4d 0%, transparent 55%),
              radial-gradient(900px 700px at 10% 110%, #10233f 0%, transparent 50%),
              linear-gradient(160deg, var(--bg0), var(--bg1));
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 16px 28px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.title { display: flex; align-items: center; gap: 12px; }

.logo {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  font-size: 24px;
  color: #2b1600;
  background: radial-gradient(circle at 35% 30%, #fff7ae, #ffd84d 55%, #ff9d00);
  border-radius: 14px;
  box-shadow: 0 0 24px rgba(255, 190, 60, 0.45);
}

.title h1 { font-size: 22px; letter-spacing: 2px; }
.title p { font-size: 11px; color: var(--muted); letter-spacing: 3px; text-transform: uppercase; }

.stats {
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 6px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  min-width: 76px;
}

.stat .label { font-size: 11px; color: var(--muted); }
.stat .value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

.next-ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  margin: auto;
  background: radial-gradient(circle at 35% 30%, #fffbe6, #ffd84d 55%, #ff9d00);
  box-shadow: 0 0 12px rgba(255, 200, 70, 0.6);
}

.icon-btn {
  align-self: center;
  width: 42px; height: 42px;
  font-size: 18px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.12); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0); }

.lang-switch { display: flex; gap: 3px; align-items: center; padding: 3px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; }
.lang-btn { border: none; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; padding: 6px 8px; border-radius: 9px; cursor: pointer; line-height: 1; transition: color 0.15s ease, background 0.15s ease; }
.lang-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.1); }
.lang-btn.active { background: linear-gradient(135deg, #ffe99a, #ffb347); color: #4a2c00; }

/* ---------- stage ---------- */
.stage-wrap {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: center;
}

.stage {
  position: relative;
  width: min(92vw, 380px);
  flex: 0 0 auto;
}

#game {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 340 / 520;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(0,0,0,0.25));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), inset 0 0 60px rgba(90, 60, 200, 0.12);
  cursor: crosshair;
  touch-action: none;
}

/* ---------- overlay ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(6, 8, 18, 0.72);
  backdrop-filter: blur(6px);
  border-radius: 18px;
  animation: fadeIn 0.25s ease;
}

.overlay.hidden { display: none; }

.overlay-card {
  text-align: center;
  padding: 26px 30px;
  width: min(86%, 320px);
  background: linear-gradient(180deg, rgba(30, 34, 60, 0.95), rgba(18, 20, 40, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: pop 0.3s ease;
}

.overlay-emoji { font-size: 44px; margin-bottom: 6px; }
.overlay-card h2 { font-size: 22px; margin-bottom: 8px; }
.overlay-final { font-size: 15px; color: var(--muted); margin-bottom: 6px; }
.overlay-final b { color: var(--gold); font-size: 22px; margin: 0 4px; }
.overlay-tip { font-size: 12px; color: var(--muted); margin-bottom: 16px; }

.new-record {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 10px;
  font-size: 12px;
  color: #2b1600;
  background: linear-gradient(90deg, #ffe98a, #ffb347);
  border-radius: 999px;
  animation: pulse 1s ease infinite;
}
.new-record.hidden { display: none; }

.primary-btn {
  padding: 12px 34px;
  font-size: 16px;
  font-weight: 700;
  color: #241000;
  background: linear-gradient(90deg, #ffe98a, #ffb347);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 180, 60, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(255, 180, 60, 0.5); }
.primary-btn:active { transform: translateY(0); }

/* ---------- side panel ---------- */
.panel {
  flex: 1 1 300px;
  max-width: 420px;
  min-width: 260px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 18px 20px;
}

.panel h2 {
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--muted);
  margin: 14px 0 10px;
}
.panel h2:first-child { margin-top: 0; }

.chain { list-style: none; display: flex; flex-direction: column; gap: 6px; }

.chain li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  font-size: 13px;
}

.chain .dot {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  border-radius: 50%;
}

.chain .arrow { color: var(--muted); font-size: 11px; }
.chain .pts { margin-left: auto; color: var(--gold); font-weight: 700; font-size: 12px; }

.rules { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.rules li {
  position: relative;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.55;
  color: #c9cfe8;
}
.rules li::before {
  content: "✦";
  position: absolute;
  left: 0;
  color: var(--accent);
}

/* ---------- footer ---------- */
.foot {
  margin-top: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

@media (max-width: 760px) {
  .stage-wrap { flex-direction: column; align-items: center; }
  .panel { max-width: none; width: min(92vw, 380px); }
  .topbar { justify-content: center; }
}
