/* ===== App screens: setup, game table, summary, players ===== */
.screen[hidden] { display: none !important; }
body.in-game { background: var(--table); }
body.in-game .site-header, body.in-game .site-footer, body.in-game main > .page { display: none; }

/* ---------- Setup ---------- */
.hero { margin: 4px 0 16px; }
.hero h1 { margin-bottom: 4px; }
.hero p { color: var(--ink-soft); margin: 0; }

.banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 14px; background: var(--accent-soft); }
.banner p { margin: 0; flex: 1 1 200px; }
.banner .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.banner.resume { background: var(--table); color: var(--table-ink); }
.banner.resume .btn-ghost { color: var(--table-ink); border-color: var(--table-3); }

.lastgame-names { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.name-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 6px; border-radius: 999px; background: var(--surface-2); font-weight: 600; font-size: 0.92rem; max-width: 100%; }
.name-pill .dot, .swatch-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--pc); border: 1.5px solid rgb(0 0 0 / 0.25); flex: none; }
.lastgame-meta { color: var(--ink-soft); font-size: 0.9rem; margin-bottom: 12px; }

.groups { display: grid; gap: 8px; }
.group-btn { justify-content: flex-start; text-align: left; border-radius: var(--r-md); padding: 8px 12px; min-height: 52px; background: var(--surface-2); font-weight: 600; }
.group-btn .dots { display: inline-flex; gap: 3px; flex: none; }
.group-btn .dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); border: 1px solid rgb(0 0 0 / 0.25); }
.group-btn span.names { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.players-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.seats { display: grid; gap: 10px; margin-bottom: 12px; }
.seat { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.seat-num { position: absolute; }
.color-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 3px solid var(--surface); background: var(--pc);
  box-shadow: 0 0 0 1.5px var(--line), inset 0 -4px 0 rgb(0 0 0 / 0.12); cursor: pointer; padding: 0; position: relative;
}
.color-btn::after { content: '↻'; position: absolute; right: -4px; bottom: -4px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); color: var(--ink-soft); font-size: 12px; display: grid; place-items: center; box-shadow: 0 0 0 1px var(--line); }
.seat-name { position: relative; min-width: 0; }
.seat-name input { padding-right: 34px; }
.linked { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--accent-strong); font-size: 1rem; pointer-events: none; }
.seat select { width: 84px; padding: 0 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  appearance: none; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600;
  min-height: 44px; padding: 0 14px; border-radius: 999px; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip:hover { background: var(--surface-2); }
.chip-plus::before { content: '+ '; color: var(--accent-strong); }

.rules { display: grid; gap: 8px; margin-bottom: 8px; }
.rule {
  display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; padding: 12px 14px; border-radius: var(--r-md);
  border: 1.5px solid var(--line); cursor: pointer; background: var(--surface);
}
.rule input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); }
.rule b { display: block; }
.rule small { color: var(--ink-soft); font-size: 0.88rem; }
.rule:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.preview-line { font-size: 0.9rem; color: var(--ink-soft); background: var(--surface-2); padding: 8px 12px; border-radius: var(--r-sm); margin: 6px 0 4px; }

.palettes { display: flex; gap: 10px; flex-wrap: wrap; }
.palette-btn { appearance: none; border: 2px solid transparent; background: none; cursor: pointer; display: grid; justify-items: center; gap: 4px; padding: 4px; border-radius: var(--r-md); color: var(--ink-soft); font: inherit; font-size: 0.8rem; font-weight: 600; min-width: 56px; }
.palette-btn i { width: 36px; height: 40px; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.palette-btn[aria-pressed='true'] { border-color: var(--accent); color: var(--ink); }
.row-wrap { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 12px; }

.start-wrap { position: sticky; bottom: 0; padding: 12px 0 max(12px, env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); z-index: 5; }

/* ---------- Game table ---------- */
.game {
  --ring: var(--pc, var(--accent));
  min-height: 100vh; min-height: 100dvh; background: var(--table); color: var(--table-ink);
  display: flex; flex-direction: column; padding: max(10px, env(safe-area-inset-top)) var(--gutter) max(14px, env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto; position: relative;
}
.game[data-status='warning'] { --ring: var(--warn); }
.game[data-status='bank'] { --ring: var(--bank); }
.game[data-status='overtime'] { --ring: var(--over); }
.game[data-phase='robber'] { --ring: var(--robber); }
.game[data-phase='robber'][data-status='warning'] { --ring: var(--warn); }
.game[data-phase='robber'][data-status='overtime'] { --ring: var(--over); }

.game-top { display: flex; align-items: center; gap: 8px; }
.game-meta { font-weight: 700; color: var(--table-ink-soft); font-size: 0.92rem; margin-right: auto; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tbtn {
  appearance: none; border: 1.5px solid var(--table-3); background: var(--table-2); color: var(--table-ink); font: inherit; font-weight: 700;
  min-height: 44px; padding: 0 13px; border-radius: 999px; cursor: pointer; touch-action: manipulation; display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; flex: none; font-size: 0.95rem;
}
@media (max-width: 374px) { .tbtn { padding: 0 10px; font-size: 0.88rem; } .game-meta { font-size: 0.85rem; } }
.tbtn:active { transform: scale(0.96); }
.tbtn[disabled] { opacity: 0.35; }
.tbtn.confirm { background: var(--over); border-color: var(--over); color: #fff; }

.game-player { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 14px 0 4px; min-width: 0; }
.game-player .pdot { width: 22px; height: 22px; border-radius: 50%; background: var(--pc); border: 2px solid rgb(255 255 255 / 0.5); flex: none; }
.game-player h1 { margin: 0; font-size: clamp(2rem, 10vw, 3.2rem); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.ring-wrap { position: relative; width: min(70vw, 300px, 40vh); aspect-ratio: 1; margin: 6px auto; flex: none; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring .track { fill: none; stroke: var(--table-2); stroke-width: 7; }
.ring .prog { fill: none; stroke: var(--ring); stroke-width: 7; stroke-linecap: round; transition: stroke-dashoffset 0.22s linear, stroke 0.3s ease; }
.ring-glow { position: absolute; inset: 6%; border-radius: 50%; box-shadow: 0 0 0 0 transparent; transition: box-shadow 0.3s ease; pointer-events: none; }
.game[data-status='warning'] .ring-glow { box-shadow: 0 0 46px 6px var(--warn-glow); }
.game[data-status='overtime'] .ring-glow, .game[data-status='bank'] .ring-glow { box-shadow: 0 0 46px 6px var(--over-glow); }
.game[data-phase='robber'][data-status='normal'] .ring-glow { box-shadow: 0 0 46px 4px var(--robber-glow); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 2px; }
.digits { font-family: var(--font-display); font-size: clamp(2.8rem, 15vw, 4.6rem); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; white-space: nowrap; }
.digits .d { display: inline-block; width: 0.74em; text-align: center; }
.digits .c { display: inline-block; width: 0.32em; text-align: center; }
.digits .s { display: inline-block; width: 0.5em; text-align: center; }
.ring-sub { font-size: 0.85rem; color: var(--table-ink-soft); font-weight: 600; min-height: 1.3em; }
.game[data-status='overtime'] .digits { color: var(--over); }
.game[data-status='bank'] .digits { color: var(--bank); }
.game[data-status='warning'] .digits { color: var(--warn); animation: pulse 1s ease-in-out infinite; }

.status-label { text-align: center; min-height: 2em; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.95rem; color: var(--table-ink-soft); display: flex; align-items: center; justify-content: center; gap: 8px; }
.game[data-status='warning'] .status-label { color: var(--warn); }
.game[data-status='overtime'] .status-label, .game[data-status='bank'] .status-label { color: var(--over); }
.game[data-phase='robber'] .status-label { color: var(--robber); }
.status-label .tag { border-radius: 999px; padding: 2px 10px; border: 1.5px solid currentColor; }

.game-actions { margin-top: auto; padding-top: 8px; display: grid; gap: 10px; }
.dice-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.num-chip {
  appearance: none; border: 0; cursor: pointer; touch-action: manipulation; aspect-ratio: 1; min-height: 48px; border-radius: 50%;
  background: var(--land-sand); color: #2b2216; font-family: var(--font-display); font-size: clamp(1.2rem, 5.5vw, 1.6rem);
  box-shadow: inset 0 -4px 0 rgb(0 0 0 / 0.15), 0 0 0 3px rgb(255 255 255 / 0.08); display: grid; place-items: center; line-height: 1; padding: 0;
  position: relative;
}
.num-chip:active { transform: scale(0.92); }
.num-chip.hot { box-shadow: inset 0 -4px 0 rgb(0 0 0 / 0.15), inset 0 0 0 4px var(--land-clay), 0 0 0 3px rgb(255 255 255 / 0.08); } /* 6 and 8: most likely after 7 */
.num-chip.seven { background: var(--robber); color: #fff; }
.num-chip small { position: absolute; bottom: 14%; font-family: var(--font-body); font-size: 0.5rem; letter-spacing: 1px; opacity: 0.6; }
.dice-hint { text-align: center; color: var(--table-ink-soft); font-weight: 600; margin: 0; }
.big-btn {
  appearance: none; border: 0; cursor: pointer; touch-action: manipulation; width: 100%; min-height: 92px; border-radius: 28px;
  background: var(--pc); color: var(--pc-ink); font-family: var(--font-display); font-size: clamp(1.6rem, 8vw, 2.2rem);
  box-shadow: inset 0 -6px 0 rgb(0 0 0 / 0.18), 0 10px 30px -12px var(--pc);
}
.big-btn:active { transform: scale(0.98); box-shadow: inset 0 -2px 0 rgb(0 0 0 / 0.18); }
.big-btn.robber { background: var(--robber); color: #fff; box-shadow: inset 0 -6px 0 rgb(0 0 0 / 0.2), 0 10px 30px -12px var(--robber); }
.no-roll { justify-self: center; color: var(--table-ink-soft); }

.game-bottom { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.upnext { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--table-ink-soft); font-size: 0.85rem; min-width: 0; overflow: hidden; }
.upnext b { font-weight: 600; white-space: nowrap; }
.upnext .np { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; min-width: 0; }
.upnext .np i { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); flex: none; }
.upnext .np span { overflow: hidden; text-overflow: ellipsis; max-width: 7ch; }
.bank-line { text-align: center; color: var(--table-ink-soft); font-size: 0.88rem; min-height: 1.3em; font-variant-numeric: tabular-nums; }

.flash { position: fixed; inset: 0; pointer-events: none; background: var(--over); opacity: 0; z-index: 30; }
.flash.go { animation: flash 0.9s ease-out; }

.pause-veil { position: absolute; inset: 0; z-index: 20; display: grid; place-content: center; gap: 18px; text-align: center; background: rgb(10 12 18 / 0.82); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-radius: 0; }
.pause-veil[hidden] { display: none; }
.pause-veil h2 { font-size: 2.4rem; margin: 0; color: var(--table-ink); }
.pause-veil .big-btn { min-width: 240px; }
.pause-veil .tbtn { justify-self: center; }

@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.045); } }
@keyframes flash { 0% { opacity: 0.45; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .game[data-status='warning'] .digits, .game[data-status='overtime'] .digits { animation: none; }
  .game[data-status='warning'] .ring-wrap, .game[data-status='overtime'] .ring-wrap, .game[data-status='bank'] .ring-wrap { outline: 4px solid var(--ring); outline-offset: 6px; border-radius: 50%; }
  .flash.go { animation: none; }
  .ring .prog { transition: none; }
}
@media (min-height: 760px) { .ring-wrap { width: min(72vw, 320px, 42vh); } }
@media (min-width: 900px) { .game { max-width: 600px; } }

/* ---------- Summary ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 8px; text-align: center; box-shadow: var(--shadow); }
.tile b { display: block; font-family: var(--font-display); font-size: clamp(1.25rem, 6vw, 1.8rem); font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile span { color: var(--ink-soft); font-size: 0.8rem; font-weight: 600; }
.fb-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.fb-row .btn { padding: 0 8px; font-size: 0.95rem; }
.fb-row .btn[aria-pressed='true'] { background: var(--accent); color: var(--accent-ink); }
.adjust { margin-top: 12px; }

.prow { padding: 12px 0; border-top: 1px solid var(--line); }
.prow:first-of-type { border-top: 0; padding-top: 0; }
.prow-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prow-head b { font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.prow-bar { height: 10px; border-radius: 999px; background: var(--surface-2); margin: 8px 0 6px; overflow: hidden; }
.prow-bar i { display: block; height: 100%; border-radius: 999px; background: var(--pc); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.15); }
.prow-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; font-size: 0.85rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.prow-stats strong { display: block; color: var(--ink); font-size: 0.98rem; }
.awards { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.award { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); font-size: 0.85rem; font-weight: 700; }
.prow .btn-sm { margin-left: auto; }

.hist { margin-top: 4px; }
.hist-plot { position: relative; height: 150px; display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 4px; border-bottom: 2px solid var(--line); }
.hist-col { position: relative; height: 100%; }
.hist-bar { position: absolute; left: 12%; right: 12%; bottom: 0; background: var(--accent); border-radius: 6px 6px 0 0; min-height: 0; }
.hist-col.seven .hist-bar { background: var(--robber); }
.hist-exp { position: absolute; left: 0; right: 0; height: 0; border-top: 2.5px dashed var(--ink); opacity: 0.7; }
.hist-counts, .hist-axis { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 4px; text-align: center; font-variant-numeric: tabular-nums; }
.hist-counts { font-weight: 800; font-size: 0.85rem; padding-top: 4px; }
.hist-axis { color: var(--ink-soft); font-size: 0.75rem; }
.hist-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.82rem; color: var(--ink-soft); margin-top: 8px; align-items: center; }
.hist-legend i { display: inline-block; width: 18px; height: 0; border-top: 2.5px dashed var(--ink); opacity: 0.7; vertical-align: middle; margin-right: 4px; }
.hist-legend em { display: inline-block; width: 12px; height: 12px; background: var(--accent); border-radius: 3px; vertical-align: middle; margin-right: 4px; }
.sevens-line { font-weight: 700; margin: 12px 0 0; }

.summary-btns { display: grid; gap: 10px; margin-top: 6px; }
.copy-fallback textarea { width: 100%; min-height: 160px; font: inherit; font-size: 0.85rem; border-radius: var(--r-sm); border: 1.5px solid var(--line); padding: 10px; background: var(--surface); color: var(--ink); }

/* ---------- Players / profiles ---------- */
.plist { display: grid; gap: 8px; }
.plist a { display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 60px; border-radius: var(--r-md); background: var(--surface-2); color: var(--ink); text-decoration: none; }
.plist a:hover { background: var(--accent-soft); }
.plist .avatar { width: 38px; height: 42px; flex: none; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-family: var(--font-display); }
.plist .pmeta { color: var(--ink-soft); font-size: 0.85rem; }
.plist .pname { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.add-form { display: flex; gap: 8px; }
.add-form input { flex: 1; min-width: 0; }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
@media (min-width: 520px) { .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface-2); border-radius: var(--r-md); padding: 10px 12px; }
.stat b { display: block; font-family: var(--font-display); font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.8rem; color: var(--ink-soft); font-weight: 600; }
.trend svg { width: 100%; height: auto; display: block; }
.trend .area { fill: var(--accent); opacity: 0.18; }
.trend .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.trend .pt { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.trend .pt-last { fill: var(--accent); stroke: var(--surface); stroke-width: 3; }
.trend .lbl { fill: var(--ink-soft); font-size: 11px; font-family: var(--font-body); }
.trend .lbl-last { fill: var(--ink); font-weight: 800; font-size: 12px; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.badge { border-radius: var(--r-md); padding: 10px 12px; background: var(--surface-2); display: grid; gap: 2px; }
.badge.zero { opacity: 0.45; }
.badge b { font-size: 0.92rem; }
.badge span { font-size: 0.8rem; color: var(--ink-soft); }
.badge .ico { font-size: 1.3rem; }
.gsignin { margin-top: 12px; }
.err { color: var(--over); font-weight: 600; }
