:root {
  --bg: #0a0f17;
  --bg-soft: #101726;
  --card: #131b29;
  --card-2: #0e1521;
  --line: #22303f;
  --line-soft: #1a2432;
  --text: #eee7d7;
  --dim: #8d99ab;
  --dim-2: #5f6b7d;
  --gold: #f2b544;
  --gold-deep: #c8871f;
  --ok: #4ade80;
  --radius: 16px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

html {
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
}

body {
  background:
    radial-gradient(900px 420px at 78% -8%, rgba(242, 181, 68, 0.11) 0%, rgba(242, 181, 68, 0) 60%),
    radial-gradient(1100px 600px at 12% 0%, #16202f 0%, var(--bg) 58%) no-repeat,
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.62;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 860px;
  margin: 0 auto;
  padding: 18px 16px 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mark {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: linear-gradient(160deg, #ffd07a 0%, var(--gold) 42%, var(--gold-deep) 100%);
  box-shadow: 0 4px 12px rgba(242, 181, 68, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  place-items: center;
  padding: 4px;
  flex: none;
}

.mark i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #141a26;
}

.mark i:nth-child(1) { grid-area: 1 / 1; }
.mark i:nth-child(2) { grid-area: 2 / 2; }
.mark i:nth-child(3) { grid-area: 1 / 2; opacity: 0; }

.brand h1 {
  font-size: 17px;
  font-weight: 650;
  margin: 0;
  letter-spacing: 0.03em;
}

.meta {
  display: flex;
  gap: 11px;
  font-size: 12.5px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#visit-count {
  padding-left: 11px;
  border-left: 1px solid var(--line);
}

/* ---------- 模式切换 ---------- */

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 10px 0 14px;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(19, 27, 41, 0.55);
  width: fit-content;
}

.tab,
.sound {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--dim);
  font: inherit;
  font-size: 13.5px;
  padding: 6px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
}

.tab.is-on {
  background: rgba(242, 181, 68, 0.13);
  color: var(--gold);
  font-weight: 600;
}

.tab:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sound {
  margin-left: 6px;
  font-size: 12.5px;
  color: var(--dim-2);
}

.sound.is-off { color: var(--dim-2); opacity: 0.7; }

.tab:focus-visible,
.sound:focus-visible,
.btn:focus-visible,
.die:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- 赌桌 ---------- */
.board {
  position: relative;
  padding: 20px 18px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(120% 90% at 50% -20%, rgba(242, 181, 68, 0.10) 0%, rgba(242, 181, 68, 0) 62%),
    linear-gradient(180deg, #161f2e 0%, var(--card-2) 100%);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.board::after {
  /* 顶部一道极细的金线，卡片不至于太平 */
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(242, 181, 68, 0.55), transparent);
}

.round-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--dim);
  letter-spacing: 0.06em;
}

.streak {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.target {
  text-align: center;
  padding: 14px 0 4px;
}

.target-kicker {
  margin: 0;
  font-size: 11.5px;
  letter-spacing: 0.22em;
  color: var(--dim-2);
}

.target-name {
  margin: 6px 0 2px;
  font-size: clamp(30px, 8vw, 40px);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold);
  text-shadow: 0 0 26px rgba(242, 181, 68, 0.28);
}

.target-desc {
  margin: 0;
  font-size: 13px;
  color: var(--dim);
}

/* ---------- 骰子 ---------- */

.dice {
  display: flex;
  justify-content: center;
  gap: clamp(7px, 2.2vw, 14px);
  padding: 22px 0 6px;
  perspective: 800px;
}

.die {
  appearance: none;
  border: 1px solid #dfd8c8;
  flex: 0 0 auto;
  width: clamp(50px, 13.4vw, 70px);
  aspect-ratio: 1;
  border-radius: 16%;
  padding: 0;
  background: linear-gradient(155deg, #ffffff 0%, #f3ecdc 55%, #ddd4c1 100%);
  box-shadow:
    0 10px 18px rgba(0, 0, 0, 0.42),
    inset 0 2px 0 rgba(255, 255, 255, 0.95),
    inset 0 -3px 6px rgba(120, 106, 80, 0.22);
  display: block;
  position: relative;
  cursor: pointer;
  transition: box-shadow 0.18s, transform 0.18s, opacity 0.18s;
  touch-action: manipulation;
}

.die:hover { transform: translateY(-2px); }

.die:active { transform: translateY(0); }

.die:disabled {
  cursor: default;
  opacity: 0.92;
  transform: none;
}

.die:disabled:hover { transform: none; }

.die[data-v="0"] {
  background: linear-gradient(155deg, #2a3446 0%, #1e2736 100%);
  border-color: var(--line);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
  cursor: default;
}

.die[data-v="0"] .pip { opacity: 0; }

.die .pip {
  position: absolute;
  width: 17%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #3b4558 0%, #191f2c 72%);
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.12s;
}

/* 九宫格坐标：列 22/50/78，行 22/50/78 */
.die .pip:nth-child(1) { left: 22%; top: 22%; }
.die .pip:nth-child(2) { left: 50%; top: 22%; }
.die .pip:nth-child(3) { left: 78%; top: 22%; }
.die .pip:nth-child(4) { left: 22%; top: 50%; }
.die .pip:nth-child(5) { left: 50%; top: 50%; }
.die .pip:nth-child(6) { left: 78%; top: 50%; }
.die .pip:nth-child(7) { left: 22%; top: 78%; }
.die .pip:nth-child(8) { left: 50%; top: 78%; }
.die .pip:nth-child(9) { left: 78%; top: 78%; }

.die[data-v="1"] .pip:nth-child(5) { width: 26%; }

.die[data-v="1"] .pip:nth-child(5),
.die[data-v="2"] .pip:nth-child(1),
.die[data-v="2"] .pip:nth-child(9),
.die[data-v="3"] .pip:nth-child(1),
.die[data-v="3"] .pip:nth-child(5),
.die[data-v="3"] .pip:nth-child(9),
.die[data-v="4"] .pip:nth-child(1),
.die[data-v="4"] .pip:nth-child(3),
.die[data-v="4"] .pip:nth-child(7),
.die[data-v="4"] .pip:nth-child(9),
.die[data-v="5"] .pip:nth-child(1),
.die[data-v="5"] .pip:nth-child(3),
.die[data-v="5"] .pip:nth-child(5),
.die[data-v="5"] .pip:nth-child(7),
.die[data-v="5"] .pip:nth-child(9),
.die[data-v="6"] .pip:nth-child(1),
.die[data-v="6"] .pip:nth-child(3),
.die[data-v="6"] .pip:nth-child(4),
.die[data-v="6"] .pip:nth-child(6),
.die[data-v="6"] .pip:nth-child(7),
.die[data-v="6"] .pip:nth-child(9) {
  opacity: 1;
}

.die.held {
  box-shadow:
    0 0 0 3px var(--gold),
    0 0 22px rgba(242, 181, 68, 0.32),
    0 14px 22px rgba(0, 0, 0, 0.45);
  transform: translateY(-5px);
}

.die.rolling {
  animation: tumble 0.42s ease-in-out;
}

@keyframes tumble {
  0% { transform: rotate(0deg) scale(1); }
  22% { transform: rotate(-11deg) scale(0.95); }
  48% { transform: rotate(9deg) scale(1.03); }
  74% { transform: rotate(-4deg) scale(0.99); }
  100% { transform: rotate(0deg) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .die.rolling { animation: none; }
  .die { transition: none; }
}

/* ---------- 提示与按钮 ---------- */

.live {
  text-align: center;
  margin: 14px 0 0;
  font-size: 13.5px;
  color: var(--dim);
  min-height: 22px;
  font-variant-numeric: tabular-nums;
}

.live b {
  color: var(--gold);
  font-weight: 650;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 26px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.18s, background 0.18s, opacity 0.18s;
  touch-action: manipulation;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  color: #171207;
  background: linear-gradient(170deg, #ffd07a 0%, var(--gold) 46%, #d9971f 100%);
  box-shadow: 0 10px 22px rgba(242, 181, 68, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.btn-primary:hover { box-shadow: 0 12px 26px rgba(242, 181, 68, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.6); }

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-bank {
  color: var(--gold);
  background: rgba(242, 181, 68, 0.1);
  border: 1px solid rgba(242, 181, 68, 0.42);
}

.btn-bank b {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.btn-bank:hover { background: rgba(242, 181, 68, 0.17); }

/* 投满三次时没有退路，只剩这一个动作，让它亮起来 */
.btn-bank.is-final {
  background: rgba(242, 181, 68, 0.2);
  border-color: rgba(242, 181, 68, 0.75);
  animation: bankPulse 1.6s ease-in-out infinite;
}

@keyframes bankPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(242, 181, 68, 0.28); }
  50% { box-shadow: 0 0 0 7px rgba(242, 181, 68, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .btn-bank.is-final { animation: none; }
}

.btn-ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  font-weight: 500;
}

.btn-ghost:hover { background: rgba(255, 255, 255, 0.09); }

.tip {
  text-align: center;
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--dim-2);
}

/* ---------- 首次引导 ---------- */

.lede {
  margin: -4px 2px 12px;
  font-size: 12.5px;
  color: var(--dim-2);
  letter-spacing: 0.02em;
}

.intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(6, 10, 16, 0.84);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.intro[hidden] { display: none; }

.intro-card {
  width: min(400px, 100%);
  padding: 24px 22px 20px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #18212f 0%, #0e1521 100%);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6);
}

.intro-kicker {
  margin: 0 0 14px;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--gold);
}

.intro-steps {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: grid;
  gap: 14px;
}

.intro-steps li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: start;
}

.intro-steps b {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 16px;
  color: var(--gold);
  background: rgba(242, 181, 68, 0.12);
  border: 1px solid rgba(242, 181, 68, 0.28);
}

.intro-steps span {
  font-size: 13.5px;
  color: var(--dim);
  line-height: 1.55;
  padding-top: 5px;
}

.intro-card .btn { width: 100%; }

/* ---------- 结算 ---------- */

.tally {
  margin-top: 14px;
  padding: 20px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #141d2c 0%, var(--card-2) 100%);
  box-shadow: var(--shadow);
}

.tally-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}

.tally-kicker {
  margin: 0;
  font-size: 11.5px;
  letter-spacing: 0.2em;
  color: var(--dim-2);
}

.tally-total {
  margin: 2px 0 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.tally-total b {
  font-size: clamp(40px, 12vw, 56px);
  font-weight: 700;
  color: var(--gold);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.tally-total span {
  font-size: 14px;
  color: var(--dim);
}

.tally-note {
  margin: 0 0 8px;
  max-width: 210px;
  text-align: right;
  font-size: 12.5px;
  color: var(--dim);
}

.tally-list {
  list-style: none;
  margin: 14px 0 18px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.tally-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.032);
  border: 1px solid var(--line-soft);
  font-size: 13.5px;
}

.tally-list .tl-idx {
  width: 18px;
  color: var(--dim-2);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.tally-list .tl-name {
  min-width: 46px;
  color: var(--dim);
}

.tally-list .tl-dice {
  flex: 1;
  letter-spacing: 0.06em;
  font-size: 17px;
  color: var(--text);
  opacity: 0.9;
}

.tally-list .tl-score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}

.tally-list li.zero .tl-score { color: var(--dim-2); }
.tally-list li.zero .tl-dice { opacity: 0.35; }

.tally-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tally-actions .btn {
  flex: 1 1 120px;
  padding: 11px 14px;
  font-size: 14px;
}

/* ---------- 倒计时 ---------- */

.next {
  margin-top: 12px;
  text-align: center;
  min-height: 20px;
}

.countdown {
  margin: 0;
  font-size: 12.5px;
  color: var(--dim-2);
  font-variant-numeric: tabular-nums;
}

.countdown b {
  color: var(--dim);
  font-weight: 600;
}

/* ---------- 说明与页脚 ---------- */

.howto {
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid var(--line-soft);
}

.howto h2 {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.08em;
  color: var(--dim);
  margin: 0 0 10px;
}

.howto ul {
  margin: 0 0 22px;
  padding-left: 18px;
  color: var(--dim);
  font-size: 13.5px;
}

.howto li { margin-bottom: 6px; }

.howto li b { color: var(--text); font-weight: 600; }

.howto p {
  margin: 0;
  color: var(--dim);
  font-size: 13.5px;
  max-width: 62ch;
}

.foot {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 16px 34px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  font-size: 12px;
  color: var(--dim-2);
}

.foot .dot { opacity: 0.5; }

/* ---------- 轻提示 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 14px);
  margin: 0;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(28, 38, 54, 0.96);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10;
}

.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 轻提示 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 14px);
  margin: 0;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(28, 38, 54, 0.96);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10;
}

.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 480px) {
  .top { padding-top: 14px; }
  .board { padding: 16px 13px 18px; }
  .btn { padding: 12px 20px; }
  .tally-note { max-width: 140px; }
  .meta { font-size: 11.5px; gap: 8px; }
  #visit-count { padding-left: 8px; }
}