:root {
  color-scheme: light dark;
  --bg: #f7f7f5;
  --fg: #17181c;
  --muted: #6b7280;
  --line: #e3e3df;
  --tile: #ffffff;
  --tile-line: #cfcfc8;
  --accent: #14713d;
  --warn: #b4462a;
  --chip: #efefe9;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --fg: #f2f2ef;
    --muted: #9aa3af;
    --line: #2b2f36;
    --tile: #f7f6f0;
    --tile-line: #b9b7ac;
    --accent: #3fbf7f;
    --warn: #e2704f;
    --chip: #23272e;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 14px;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
h1 { font-size: 16px; margin: 0; font-weight: 600; }
h1 .mark { color: var(--accent); }
.spacer { flex: 1; }

button {
  font: inherit;
  color: inherit;
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
}
button:disabled { opacity: .5; cursor: default; }

.meta { color: var(--muted); font-size: 12px; margin: 4px 0 8px; }
.banner { background: var(--chip); color: var(--muted); border-radius: 8px; padding: 8px 10px; font-size: 12px; margin-bottom: 8px; }
.result { border: 1px solid var(--accent); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-weight: 600; }
.result.lose { border-color: var(--warn); }

.opponents { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 12px; }
.opponent { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.opponent.active { border-color: var(--accent); }
.opponent h2 { font-size: 12px; margin: 0 0 4px; color: var(--muted); font-weight: 500; }
.opponent .count { font-size: 12px; }
.opponent .mini { font-size: 11px; color: var(--muted); margin-top: 4px; word-break: break-all; }

.mine { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.mine-head { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.mine-head .melds { color: var(--accent); }

.tiles { display: flex; flex-wrap: wrap; gap: 6px; }
.tile {
  min-width: 38px;
  padding: 8px 6px;
  border-radius: 6px;
  border: 1px solid var(--tile-line);
  background: var(--tile);
  color: #17181c;
  font-weight: 600;
  font-size: 14px;
  text-align: center;
  box-shadow: 0 1px 0 var(--tile-line);
}
.tile.playable { cursor: pointer; }
.tile.playable:hover { transform: translateY(-2px); }
.tile.just-drawn { box-shadow: 0 0 0 2px var(--accent); }
.tile.honor { color: #a33; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.actions button.primary { background: var(--accent); color: #fff; border-color: transparent; }

.table { display: grid; grid-template-columns: 1fr; gap: 10px; }
.discards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; font-size: 12px; }
.discards div { border: 1px dashed var(--line); border-radius: 8px; padding: 6px 8px; color: var(--muted); word-break: break-all; }
.log { margin: 0; padding-left: 18px; font-size: 12px; color: var(--muted); }

footer { margin-top: 14px; font-size: 12px; color: var(--muted); }

@media (max-width: 420px) {
  body { padding: 10px; }
  .tile { min-width: 32px; padding: 7px 4px; font-size: 13px; }
}
