/* 魔鬼的尾牙 試玩版：三種畫面共用樣式（深色主題，玩家手機優先） */
:root {
  --bg: #0e0d12;
  --bg2: #16141c;
  --panel: #1d1a25;
  --panel2: #262231;
  --line: #3a3447;
  --text: #f3f1f7;
  --muted: #a39db3;
  --accent: #e5484d;
  --accent2: #ff7a59;
  --gold: #f5c451;
  --ok: #3dd68c;
  --warn: #ffb224;
  --bad: #ff6369;
  --radius: 14px;
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #2a1420 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--gold); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.big { font-size: 1.4em; }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; }
.hidden { display: none !important; }
.gold { color: var(--gold); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.mono { font-variant-numeric: tabular-nums; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card + .card { margin-top: 12px; }
.card h3 { font-size: 1rem; color: var(--muted); font-weight: 600; letter-spacing: .02em; }

button, .btn {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  min-height: 44px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
button:hover:not(:disabled), .btn:hover { border-color: #5a5268; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
button.primary:hover:not(:disabled) { background: #f05a5f; }
button.danger { border-color: #7a2a30; color: #ff9da1; }
button.selected { outline: 3px solid var(--gold); outline-offset: 2px; }
button.block { width: 100%; }
button.huge { font-size: 1.5rem; min-height: 72px; border-radius: 16px; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
input[type="checkbox"] { width: auto; min-height: auto; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px; font-size: .85em; font-weight: 600;
  background: var(--panel2); border: 1px solid var(--line); white-space: nowrap;
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: .78em; font-weight: 700; background: var(--panel2); color: var(--muted); }
.badge.open { background: #12351f; color: var(--ok); }
.badge.locked { background: #3a2c10; color: var(--warn); }
.badge.revealed { background: #3a1420; color: #ff9da1; }
.badge.shadow { background: #000; color: #b9a6ff; border: 1px solid #5b4a9e; }

.countdown { font-variant-numeric: tabular-nums; font-weight: 800; }
.countdown.urgent { color: var(--bad); }

.toasts { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: #2b2635; border: 1px solid var(--line); padding: 10px 14px; border-radius: 10px; box-shadow: 0 6px 24px #0008; animation: pop .15s ease-out; }
.toast.error { border-color: var(--bad); background: #4a1820; font-weight: 700; }
.toast.ok { border-color: var(--ok); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }

/* 長條圖 helper */
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(60px, 22%) 1fr auto; gap: 8px; align-items: center; }
.bar-track { background: var(--bg2); border-radius: 6px; height: 1.3em; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--accent); transition: width .5s ease; }
.bar-row.hl .bar-label { color: var(--gold); font-weight: 800; }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vbars { display: flex; align-items: flex-end; gap: 2px; height: 220px; }
.vbar { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 1px; position: relative; }

/* ---------- 玩家（手機） ---------- */
.play { max-width: 560px; margin: 0 auto; padding: 0 16px 96px; }
.play-head { position: sticky; top: 0; z-index: 10; background: #0e0d12ee; backdrop-filter: blur(6px); padding: 10px 0; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.play-head .name { font-weight: 800; }
.play-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; text-align: center; }
.stat .v { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .k { font-size: .72rem; color: var(--muted); }
.run-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.run-head h2 { font-size: 1.35rem; margin: 0; }
.run-timer { font-size: 2rem; }
.rules { margin: 0; padding-left: 1.2em; }
.rules li { margin: 4px 0; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.banner { background: linear-gradient(90deg, #5a1a24, #3b1530); border: 1px solid #7a2a3a; border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; font-weight: 700; }

/* ---------- 主畫面（投影） ---------- */
.screen { height: 100vh; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; font-size: clamp(16px, 1.6vw, 34px); }
.screen-head { display: flex; align-items: center; justify-content: space-between; padding: .6em 1.2em; border-bottom: 1px solid var(--line); background: #0b0a0fcc; gap: 1em; }
.screen-head .event { font-size: .9em; color: var(--muted); }
.screen-head .gtitle { font-size: 1.6em; font-weight: 900; }
.screen-head .timer { font-size: 3em; line-height: 1; }
.screen-main { padding: 1em 1.4em; overflow-y: hidden; display: flex; flex-direction: column; gap: 1em; min-height: 0; }
.screen-main .hist { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.screen-main { overflow-x: hidden; }
.grid-2 > *, .grid-3 > *, .screen-lobby > * { min-width: 0; }
.screen-main .intro-rules { font-size: .8em; }
.screen-foot { display: flex; flex-wrap: wrap; gap: .35em .5em; padding: .4em 1em; border-top: 1px solid var(--line); background: #0b0a0fcc; overflow: hidden; align-items: center; }
.screen-foot .team { display: flex; align-items: center; gap: .3em; padding: .1em .5em; border-radius: 999px; background: var(--panel); white-space: nowrap; font-size: .7em; }
.screen-foot .pool { margin-left: auto; font-weight: 800; color: var(--gold); white-space: nowrap; }
.screen .card { padding: .8em 1em; border-radius: .6em; }
.screen h1 { font-size: 2.6em; }
.screen .hero { font-size: 4.5em; font-weight: 900; line-height: 1.05; }
.screen .lead { font-size: 1.3em; }
.screen .progress { height: .5em; background: var(--bg2); border-radius: 999px; overflow: hidden; }
.screen .progress > div { height: 100%; background: var(--ok); transition: width .4s; }
.screen-lobby { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1.4em; align-items: start; }
.qr { background: #fff; padding: .6em; border-radius: .6em; width: 14em; height: 14em; }
.qr img { width: 100%; height: 100%; display: block; }
.lb { display: grid; grid-template-columns: 2em 1fr auto; gap: .2em .8em; align-items: center; }
.lb .r { color: var(--muted); text-align: right; }
.lb .c { font-weight: 800; font-variant-numeric: tabular-nums; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1em; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1em; }

/* ---------- 主控台 ---------- */
.console { display: grid; grid-template-columns: minmax(420px, 1.25fr) minmax(360px, 1fr); gap: 14px; padding: 14px; max-width: 1600px; margin: 0 auto; }
.console-top { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); gap: 12px; flex-wrap: wrap; }
.console .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.console .action-form { display: flex; gap: 6px; align-items: flex-end; background: var(--bg2); padding: 6px; border-radius: 10px; border: 1px solid var(--line); }
.console .action-form input, .console .action-form select { min-height: 38px; padding: 6px 8px; width: 7em; }
.console .action-form label.field { font-size: .75rem; }
.substatus { display: flex; flex-wrap: wrap; gap: 4px; }
.substatus .s { font-size: .8rem; padding: 2px 8px; border-radius: 6px; background: var(--bg2); border: 1px solid var(--line); }
.substatus .s.y { background: #12351f; border-color: #1f6b3d; }
.game-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.game-item { text-align: left; display: block; padding: 10px 12px; }
.game-item .t { font-weight: 800; }
.game-item .c { font-size: .75rem; color: var(--muted); }
.game-item .d { font-size: .8rem; color: var(--muted); }
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.ledger td { font-size: .82rem; }
details > summary { cursor: pointer; color: var(--muted); }
@media (max-width: 980px) {
  .console { grid-template-columns: 1fr; }
}

/* ---------- 首頁 ---------- */
.landing { max-width: 460px; margin: 0 auto; padding: 48px 16px; display: flex; flex-direction: column; gap: 14px; }
.landing .logo { font-size: 2.2rem; font-weight: 900; letter-spacing: .04em; }
.landing .logo span { color: var(--accent); }
