:root {
  color-scheme: dark;
  --bg: #0b121b;
  --panel: #111c28;
  --panel-2: #172535;
  --line: rgba(160, 190, 215, .16);
  --text: #e7eef6;
  --muted: #8fa4b8;
  --gold: #e0b85d;
  --blue: #6eb8ea;
  --danger: #e07b73;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: radial-gradient(1100px 700px at 50% -10%, #193047 0%, var(--bg) 58%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  user-select: none;
}
#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 4px 8px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
}
.brand em { color: var(--gold); font-style: normal; font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px rgba(224,184,93,.7); }
.turn {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(17,28,40,.65);
  white-space: nowrap;
}
.meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; }
#points-label { color: var(--gold); font-variant-numeric: tabular-nums; }
#phase-label { color: var(--blue); }
.scorebar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 4px 8px;
}
.score-card {
  min-width: 0;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(17,28,40,.62);
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.score-name { font-size: 11px; font-weight: 700; margin-bottom: 1px; }
.score-p1 .score-name { color: #8ecdf2; }
.score-p2 .score-name { color: #a8d48c; }
.score-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-line b { color: var(--text); font-weight: 700; }
#board-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(520px 360px at 50% 45%, rgba(38,68,94,.32), transparent 75%),
    rgba(10,17,26,.7);
  box-shadow: inset 0 0 40px rgba(0,0,0,.28);
}
#board { display: block; width: 100%; height: 100%; touch-action: none; }
.thinking {
  position: absolute;
  left: 50%; bottom: 14px;
  transform: translateX(-50%);
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(8,14,21,.86);
  border: 1px solid rgba(224,184,93,.35);
  color: var(--gold);
  font-size: 12px;
  animation: pulse 1.4s ease-in-out infinite;
}
.hidden { display: none !important; }
@keyframes pulse { 0%,100% { opacity: .6; } 50% { opacity: 1; } }
.controls {
  display: flex;
  gap: 10px;
  padding: 10px 0 0;
}
.btn {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 18px;
  min-height: 48px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  background: var(--panel-2);
  touch-action: manipulation;
}
.btn:disabled { opacity: .38; }
.btn.primary {
  flex: 1;
  border-color: rgba(224,184,93,.45);
  background: linear-gradient(180deg, #d6aa52, #b88a35);
  color: #151006;
  box-shadow: 0 5px 18px rgba(185,140,53,.18);
}
.btn.ghost { background: rgba(17,28,40,.8); color: var(--muted); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.result {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3,8,13,.72);
  backdrop-filter: blur(5px);
  z-index: 20;
}
.result-card {
  width: min(340px, 100%);
  padding: 24px 20px 20px;
  border: 1px solid rgba(224,184,93,.35);
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(32,48,64,.98), rgba(12,20,30,.98));
  box-shadow: 0 24px 70px rgba(0,0,0,.5);
  text-align: center;
}
.result-title { font-size: 22px; color: var(--gold); margin-bottom: 8px; }
.result-card p { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 18px; }
.result-card .btn { width: 100%; }
@media (max-width: 420px) {
  #app { padding-left: 8px; padding-right: 8px; }
  .brand { font-size: 13px; }
  .turn { font-size: 11px; }
  .meta { width: 100%; order: 3; justify-content: space-between; padding: 0 4px; }
}
