:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1d1d1f;
  --muted: #8a8a8e;
  --line: #e4e1d9;
  --red: #d63c3c;
  --accent: #d63c3c;
  --ok: #2f8f5b;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a; --surface: #232528; --ink: #f1f0ec; --muted: #8d8f94; --line: #34363a;
    --red: #ff6b6b; --accent: #ff6b6b; --ok: #4cc38a;
  }
  meta { color: #17181a; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}
#app { height: 100%; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom); max-width: 560px; margin: 0 auto; }
h1 { font-size: 28px; font-weight: 650; letter-spacing: -.02em; margin: 0; }
h1 .heart { color: var(--red); }
.muted { color: var(--muted); }
.center { margin: auto 0; display: flex; flex-direction: column; gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }

input, select, button {
  font: inherit; color: inherit; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); padding: 13px 14px; min-height: 48px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input.code { text-transform: uppercase; letter-spacing: .25em; text-align: center; }
button { cursor: pointer; font-weight: 550; }
button:active { transform: scale(.98); }
button.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button:disabled { opacity: .4; cursor: default; }
.sep { text-align: center; color: var(--muted); font-size: 13px; }
details { color: var(--muted); font-size: 14px; }
details p { margin: 8px 0 0; }

/* lobby */
.big-code { font-size: 44px; font-weight: 700; letter-spacing: .18em; text-align: center; padding: 6px 0; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.list > div { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; }
.list > div + div { border-top: 1px solid var(--line); }
.list button { width: auto; min-height: 0; padding: 4px 10px; font-size: 13px; }
.tag { font-size: 12px; color: var(--muted); }

/* game */
.game { flex: 1; display: flex; flex-direction: column; min-height: 0; padding-top: 10px; }
.opps { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.opp {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; display: flex; gap: 8px; align-items: center; transition: border-color .2s, box-shadow .2s;
}
.opp b { font-weight: 600; }
.opp.turn { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.opp.off { opacity: .5; }
.board { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 6px; min-height: 0; }
.suit-row { display: grid; grid-template-columns: repeat(13, 1fr); gap: 3px; }
.slot {
  aspect-ratio: 5 / 7; border-radius: 4px; border: 1px dashed var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: clamp(8px, 2.7vw, 13px); font-weight: 650; line-height: 1.05; color: transparent;
}
.slot.on { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.slot.on.red { color: var(--red); }
.slot.next { border-color: var(--muted); }
.slot.new { animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(1.5); } to { transform: none; } }
.status { text-align: center; min-height: 28px; font-weight: 550; padding: 6px 0; }
.status.you { color: var(--accent); }
.hand-wrap { overflow-x: auto; padding: 14px 4px 10px; margin: 0 -16px; scrollbar-width: none; }
.hand-wrap::-webkit-scrollbar { display: none; }
.hand { display: flex; width: max-content; min-width: 100%; padding: 0 16px; justify-content: center; }
.card {
  flex: none; width: 54px; height: 78px; margin-right: -16px; padding: 6px 0 0 7px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  font-weight: 650; font-size: 17px; line-height: 1.1; min-height: 0;
  box-shadow: 2px 0 4px rgba(0,0,0,.06); transition: transform .15s;
  opacity: .45; cursor: default;
}
.card.red { color: var(--red); }
.card:last-child { margin-right: 0; }
.card.ok { opacity: 1; transform: translateY(-10px); border-color: var(--accent); cursor: pointer; }
.card.ok:active { transform: translateY(-14px); }
.card .s { display: block; font-size: 15px; }
.over {
  position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 88%, transparent);
  display: flex; align-items: center; justify-content: center; padding: 24px; backdrop-filter: blur(4px);
}
.over .box { width: 100%; max-width: 360px; text-align: center; }
.over h2 { font-size: 30px; margin: 0 0 4px; }
.topbar { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); }
.topbar button { width: auto; min-height: 0; padding: 4px 8px; font-size: 13px; }
#toast {
  position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 8px 14px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.show { opacity: 1; }
