:root {
  --bg: #fff8ec;
  --ink: #2b2118;
  --muted: #8a7a68;
  --card: #ffffff;
  --line: #eadcc6;
  --accent: #ff6b35;
  --accent-ink: #fff;
  --grass: #dff3d2;
  --grass-2: #cbeabb;
  --shadow: 0 2px 0 rgba(60, 40, 20, .12);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
button {
  font: inherit; border: 2px solid var(--ink); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 8px 14px; cursor: pointer; box-shadow: var(--shadow); font-weight: 600;
}
button:hover:not(:disabled) { transform: translateY(-1px); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.big { background: var(--accent); color: var(--accent-ink); font-size: 17px; padding: 11px 22px; }
button.mini { padding: 2px 8px; font-size: 12px; margin-left: auto; }
button.link { border: 0; box-shadow: none; background: none; color: var(--muted); text-decoration: underline; margin-top: 12px; }
input {
  font: inherit; border: 2px solid var(--line); border-radius: 10px; padding: 9px 12px; background: #fff; color: var(--ink);
  min-width: 0; flex: 1;
}
input:focus { outline: none; border-color: var(--accent); }
h1, h2, h3, h4 { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
.err { color: #c62828; font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); flex: none; }
.boot { text-align: center; margin-top: 30vh; color: var(--muted); }

/* 首页 */
.home { max-width: 420px; margin: 0 auto; padding: 48px 20px 80px; display: flex; flex-direction: column; gap: 14px; }
.logo { font-size: 44px; text-align: center; letter-spacing: 6px; }
.home h1 { font-size: 40px; text-align: center; letter-spacing: 2px; }
.sub { text-align: center; color: var(--muted); margin: -8px 0 8px; }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.or { text-align: center; color: var(--muted); font-size: 13px; }
.codein { text-transform: uppercase; letter-spacing: 4px; font-weight: 700; }
.rules { background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.rules summary { cursor: pointer; font-weight: 700; }
.rules ol { padding-left: 20px; margin: 8px 0; }
.foot { text-align: center; color: var(--muted); font-size: 12px; }

/* 大厅 / 结算 */
.panel { max-width: 560px; margin: 0 auto; padding: 32px 20px 100px; display: flex; flex-direction: column; gap: 12px; }
.code { background: var(--ink); color: #fff; padding: 2px 12px; border-radius: 8px; letter-spacing: 6px; }
.plist, .rank { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.plist li, .rank li {
  display: flex; align-items: center; gap: 8px; background: var(--card); border: 2px solid var(--line);
  border-radius: 10px; padding: 8px 12px;
}
.plist em, .rank em { font-style: normal; font-size: 11px; background: var(--line); border-radius: 6px; padding: 0 6px; }
.plist em.off { background: #ffd6d6; }
.rank li strong { margin-left: auto; font-size: 18px; }
.rank li span { color: var(--muted); font-size: 13px; }
.rank li:first-child { border-color: #f5b301; background: #fff6d6; }
.waiting { font-weight: 600; }

/* 游戏页 */
.wide { max-width: 1280px; margin: 0 auto; padding: 16px 16px 140px; display: flex; flex-direction: column; gap: 12px; }
.bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.bar > span:last-child { margin-left: auto; color: var(--muted); }
.hl { color: var(--accent); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
aside { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 12px; }
@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  aside { position: static; }
}

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.card { background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); }
.card-h { display: flex; gap: 8px; align-items: center; }
.card-h b { display: block; font-size: 15px; }
.card-h small { color: var(--muted); font-size: 11px; }
.card p { margin: 6px 0 0; font-size: 13px; }
.emo { font-size: 28px; line-height: 1; }
sup { color: var(--accent); }
.card.pick { cursor: pointer; }
.card.pick:hover { border-color: var(--accent); transform: translateY(-2px); }
.card.sel { border-color: var(--accent); background: #fff1e8; outline: 2px solid var(--accent); }
.card.dim { opacity: .4; }

.team { background: var(--card); border: 2px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.team.turn { border-color: var(--accent); }
.team h4 { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.team h4 small { margin-left: auto; color: var(--muted); }
.chips, .readies { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; font-size: 12px; }

.score { list-style: none; margin: 0; padding: 0; background: var(--card); border: 2px solid var(--line); border-radius: 12px; }
.score li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.score li:last-child { border-bottom: 0; }
.score li.turn { background: #fff1e8; }
.score .pn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score .medals { font-size: 13px; }
.score b { font-size: 18px; min-width: 24px; text-align: right; }

.log {
  background: #2b2118; color: #f5ead8; border-radius: 12px; padding: 8px 10px; font-size: 12.5px;
  height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
}
.log div { border-bottom: 1px dashed rgba(255, 255, 255, .08); padding-bottom: 2px; }

/* 赛道：SVG 跑道 */
.track-host { width: 100%; }
svg.track { display: block; width: 100%; height: auto; border: 3px solid var(--ink); border-radius: 22px; }
.grass { fill: #bfe3a8; }
.t-edge, .t-line, .t-surf, .t-lane { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.t-edge { stroke: #5b3a24; stroke-width: 128; }
.t-line { stroke: #fff; stroke-width: 118; }
.t-surf { stroke: #d9774e; stroke-width: 108; }
.t-lane { stroke: rgba(255, 255, 255, .75); stroke-width: 3; stroke-dasharray: 16 12; }
.tile .bg { fill: #fffaf2; stroke: #8a6a4f; stroke-width: 2; }
.tile .hl { fill-opacity: 0; transition: fill-opacity .25s; pointer-events: none; }
.tile.trail .hl { fill-opacity: .35; }
.tile.start .bg { fill: #ececec; }
.tile.fin .bg { fill: url(#chk); stroke: #2b2118; }
.tile.sp-arrow .bg { fill: #e3f1ff; stroke: #2e86ab; stroke-width: 3; }
.tile.sp-arrow.back .bg { fill: #ffe6de; stroke: #e4572e; }
.tile.sp-trip .bg { fill: #fff0c2; stroke: #f2a541; stroke-width: 3; }
.tile.sp-star .bg { fill: #fff7cf; stroke: #d9a400; stroke-width: 3; }
.tile .n { font-size: 14px; font-weight: 800; fill: #8a7a68; }
.tile .b { font-size: 13px; font-weight: 800; fill: #2b2118; paint-order: stroke; stroke: #fff; stroke-width: 4px; stroke-linejoin: round; }
.tk { transition: transform .22s ease-out, opacity .3s; }
.tk.out { opacity: 0; }
.tk-in { transform-box: fill-box; transform-origin: center; transition: transform .3s; }
.tk-in circle { fill: #fff; stroke-width: 4.5; }
.tk-in text { font-size: 19px; }
.tk.trip .tk-in { transform: rotate(90deg); opacity: .7; }
.tk.cur .tk-in { animation: bob .7s ease-in-out infinite; }
.tk.cur .tk-in circle { stroke-width: 7; }
.pl circle { fill: #2b2118; }
.pl text { fill: #fff; font-size: 12px; font-weight: 800; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.mv { border: 2px solid var(--c); border-radius: 10px; padding: 2px 10px; background: #fff; }
.speed { display: inline-flex; gap: 4px; }
.speed .on { background: var(--ink); color: #fff; }

.die { background: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 2px 10px; box-shadow: var(--shadow); }
.die b { font-size: 20px; }
.die.pop { animation: pop .4s; }
@keyframes pop { 0% { transform: scale(.6) rotate(-20deg); } 70% { transform: scale(1.2); } }

.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin-top: 12px; }
.rs { background: var(--card); border: 2px solid var(--line); border-left: 6px solid var(--c); border-radius: 10px; padding: 6px 10px; }
.rs.cur { border-color: var(--accent); border-left-color: var(--c); }
.rs.out { opacity: .45; }
.rs-h { display: flex; align-items: center; gap: 6px; }
.rs-h small { color: var(--muted); }
.rs-h em { margin-left: auto; font-style: normal; font-size: 12px; font-weight: 700; }
.rs p { margin: 4px 0 0; font-size: 12.5px; }
.rs .emo { font-size: 22px; }

/* 底部提示条 */
.prompt, .wait {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(680px, calc(100% - 24px));
  background: var(--ink); color: #fff; border-radius: 16px; padding: 12px 14px; z-index: 10;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.wait { text-align: center; font-weight: 600; background: #5a4a3a; }
.prompt { animation: rise .25s; }
@keyframes rise { from { transform: translate(-50%, 20px); opacity: 0; } }
.ptext { font-weight: 700; margin-bottom: 8px; }
.ptext small { color: #ffb38a; margin-left: 6px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opts button { border-color: #fff; display: flex; flex-direction: column; align-items: flex-start; text-align: left; flex: 1 1 auto; }
.opts button small { font-weight: 400; font-size: 12px; color: var(--muted); }
.prompt.roll .opts button, .prompt.next .opts button { background: var(--accent); color: #fff; font-size: 20px; align-items: center; }
.prompt.genius .opts button { flex: 1 0 40px; align-items: center; font-size: 18px; }
.prompt.sent { opacity: .5; pointer-events: none; }
