:root {
  --bg: #1c2320;
  --panel: #252e2a;
  --line: #36423c;
  --text: #f1ece0;
  --muted: #9aa69f;
  --gold: #f2c14e;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 16px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", Helvetica, Arial, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
body { position: fixed; inset: 0; display: flex; flex-direction: column; }
button {
  font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer;
  touch-action: manipulation;
}

#bar {
  display: flex; align-items: center; gap: 4px; min-height: 58px;
  padding: calc(env(safe-area-inset-top) + 6px) 8px 6px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.dot {
  display: inline-block; width: 11px; height: 11px; border-radius: 50%; flex: none; background: var(--c);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .45); vertical-align: 1px; margin-right: 6px;
}
.player {
  flex: 1; min-width: 0; padding: 4px 5px; border-radius: 12px; background: #1d2421; border: 2px solid transparent;
}
.player .who .dot { margin-right: 4px; }
.player .who { display: flex; align-items: center; white-space: nowrap; overflow: hidden; }
.player .name { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.player .pts { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; }
.player .score { font-size: 19px; font-variant-numeric: tabular-nums; }
.player .supply { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.player .supply svg { width: 12px; height: 13px; vertical-align: -2px; margin-right: 1px; }
.player.active { border-color: var(--c); background: #34403a; }
.chip {
  display: flex; align-items: center; gap: 5px; height: 40px; padding: 0 10px;
  border-radius: 12px; background: #1d2421; font-variant-numeric: tabular-nums;
}
#menu { font-size: 20px; padding: 0 12px; }
#chips { display: flex; justify-content: flex-end; gap: 8px; }
#chips .chip { background: #34403a; }
.stack { width: 14px; height: 14px; border-radius: 3px; background: #8cb955; box-shadow: 2px -2px 0 #5d7d39; }

#wrap { flex: 1; position: relative; overflow: hidden; touch-action: none; background:
  radial-gradient(circle at 50% 40%, #2f3b33 0%, #1f2823 70%); }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#fit {
  position: absolute; right: 12px; bottom: 12px; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(20, 26, 23, .8); font-size: 22px; border: 1px solid var(--line);
}
#toast {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); max-width: 90%;
  padding: 8px 14px; border-radius: 10px; background: rgba(20, 26, 23, .92); font-size: 15px;
  border: 1px solid var(--line); text-align: center; pointer-events: none;
}

#tray {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px calc(env(safe-area-inset-bottom) + 10px);
  background: var(--panel); border-top: 1px solid var(--line);
}
#hand { width: 132px; height: 132px; flex: none; overflow: visible; }
#side { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
#status { font-size: 17px; min-height: 22px; }
#buttons { display: flex; gap: 10px; }
#buttons button {
  height: 54px; border-radius: 14px; background: #34403a; font-size: 18px; font-weight: 600;
}
#rotate { width: 62px; font-size: 28px !important; }
#ok { flex: 1; }
#ok.primary { background: var(--gold); color: #2a2110; }
#buttons button:disabled { opacity: .35; }

.cell { fill: rgba(255, 255, 255, .13); stroke: rgba(255, 255, 255, .75); stroke-width: 2.5; stroke-dasharray: 9 6; }
.chosen { fill: none; stroke: var(--gold); stroke-width: 5; }
.lastcpu { fill: none; stroke-width: 5; }
.lastyou { fill: none; stroke-width: 3; stroke-opacity: .6; }
.target { fill: rgba(255, 255, 255, .28); stroke: #fff; stroke-width: 2; stroke-dasharray: 4 3; }

.pop, .final { font: 700 34px -apple-system, Helvetica, sans-serif; paint-order: stroke; stroke: #fff; stroke-width: 6px;
  text-anchor: middle; }
.pop { animation: pop 1.8s ease-out forwards; }
@keyframes pop {
  0% { opacity: 0; transform: translateY(8px); }
  15% { opacity: 1; transform: translateY(0); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-34px); }
}

#sheet {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .5); display: flex; align-items: flex-end;
  justify-content: center; z-index: 10;
}
#sheet[hidden] { display: none; }
.card {
  width: 100%; max-height: 85%; overflow-y: auto; background: var(--panel);
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom) + 16px);
  border-top: 1px solid var(--line);
}
.card h2 { margin: 0 0 14px; font-size: 22px; text-align: center; }
.card .list { display: flex; flex-direction: column; gap: 10px; }
.card .list button { height: 54px; border-radius: 14px; background: #34403a; font-size: 18px; font-weight: 600; }
.card .list button.primary { background: var(--gold); color: #2a2110; }
.card .list button.quiet { background: none; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 16px; }
.tiles div { text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; }
.tiles div.none { opacity: .3; }
.tiles svg { width: 100%; aspect-ratio: 1; display: block; margin-bottom: 2px; }
table.result { width: 100%; border-collapse: collapse; margin-bottom: 18px; font-variant-numeric: tabular-nums; }
table.result th, table.result td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--line); }
table.result th:first-child, table.result td:first-child { text-align: left; color: var(--muted); font-weight: 400; }
table.result tr.total td { font-size: 20px; font-weight: 700; color: var(--text); border-bottom: 0; }
table.result th { font-size: 14px; font-weight: 600; }
table.result th .dot { margin: 0 0 4px; }
.card .row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.card .row > span { color: var(--muted); flex: none; }
.card .row .dot { margin: 0; }
.card .row + .list { margin-top: 16px; }
.seg { flex: 1; display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: #1d2421; }
.seg button { flex: 1; min-width: 0; height: 40px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--gold); color: #2a2110; }
