/* Hanabi — shared design system */
:root {
  --bg: #0b1020;
  --bg-2: #121a33;
  --bg-3: #1a2446;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-2: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.12);
  --text: #eef1ff;
  --muted: #9aa3c7;
  --accent: #ffb347;
  --accent-2: #ff6b6b;
  --ok: #43a047;
  --warn: #fdd835;
  --danger: #e53935;
  --info: #1e88e5;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 20% -10%, #1f2a5a 0%, transparent 60%),
              radial-gradient(900px 500px at 100% 0%, #3a1d4f 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 16px; }

h1, h2, h3 { margin: 0 0 0.5em; font-weight: 700; letter-spacing: 0.2px; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-size: 0.75rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; }
.hidden { display: none !important; }

.container { max-width: 720px; margin: 0 auto; padding: 16px; }
.wide { max-width: 1200px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 12px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: transform 0.08s, background 0.15s, opacity 0.15s; min-height: 44px;
}
.btn:hover { background: rgba(255, 255, 255, 0.16); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(135deg, #ff9f43, #ff6b6b); border-color: transparent; color: #1b0f12; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ok { background: var(--ok); border-color: transparent; color: #fff; }
.btn.danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn.info { background: var(--info); border-color: transparent; color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 0.85rem; min-height: 32px; border-radius: 9px; }
.btn.lg { padding: 14px 22px; font-size: 1.1rem; }
.btn.block { width: 100%; }
.btn.icon { padding: 8px; min-width: 40px; }

/* inputs */
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25); color: var(--text); outline: none;
}
.input:focus { border-color: var(--accent); }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
label.field > .input { font-size: 1rem; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { width: 18px; height: 18px; }

/* avatar */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
  width: 36px; height: 36px; font-size: 20px; flex: 0 0 auto; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.25);
}
.avatar-sm { width: 26px; height: 26px; font-size: 15px; }
.avatar-lg { width: 56px; height: 56px; font-size: 32px; }
.avatar-xl { width: 80px; height: 80px; font-size: 46px; }

/* cards */
.card {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; font-weight: 800; user-select: none; flex: 0 0 auto;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35), inset 0 0 0 2px rgba(255, 255, 255, 0.25);
  transition: transform 0.12s, box-shadow 0.12s;
}
.card-xs { width: 30px; height: 42px; font-size: 16px; border-radius: 6px; }
.card-sm { width: 44px; height: 62px; font-size: 24px; border-radius: 8px; }
.card-md { width: 58px; height: 82px; font-size: 32px; }
.card-lg { width: 72px; height: 102px; font-size: 40px; border-radius: 12px; }
.card-xl { width: 92px; height: 130px; font-size: 52px; border-radius: 14px; }
.card .rank { line-height: 1; text-shadow: 0 1px 2px rgba(0,0,0,0.25); }
.card .corner { position: absolute; font-size: 0.34em; font-weight: 700; opacity: 0.85; }
.card .corner.tl { top: 4px; left: 6px; }
.card .corner.br { bottom: 4px; right: 6px; }
.card-xs .corner, .card-sm .corner { display: none; }
.card.back {
  background: repeating-linear-gradient(45deg, #2a3566 0 6px, #222b54 6px 12px);
  color: #cfd6ff; border: 1px solid rgba(255,255,255,0.15);
}
.card.back .rank { opacity: 0.9; }
.card.back.known-suit .rank { opacity: 1; }
.card.clickable { cursor: pointer; }
.card.clickable:hover { transform: translateY(-4px); }
.card.selected { transform: translateY(-8px) scale(1.04); box-shadow: 0 0 0 3px var(--accent), 0 8px 20px rgba(0,0,0,0.5); }
.card.fresh { box-shadow: 0 0 0 3px #fff, 0 0 18px #fff; }
.card.dim { opacity: 0.45; }
.card .hints { position: absolute; bottom: 5px; left: 0; right: 0; display: flex; justify-content: center; gap: 2px; flex-wrap: wrap; padding: 0 3px; }
.card .hints .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1px rgba(0,0,0,0.4); }
.card .hints.ranks { bottom: auto; top: 5px; }
.card .hints.ranks b { font-size: 9px; line-height: 1; background: rgba(0,0,0,0.45); border-radius: 3px; padding: 1px 2px; }
.card.back .hints.ranks + .rank { display: none; }
.card .clue-badges { position: absolute; top: -6px; right: -6px; display: flex; gap: 2px; }
.card .clue-badges .badge {
  display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%;
  font-size: 10px; font-weight: 800; color: #fff; background: #333; box-shadow: 0 0 0 2px var(--bg);
}
.card .clue-badges .rank-badge { background: #111; }
.card-xs .clue-badges .badge { width: 12px; height: 12px; font-size: 8px; }
.card .card-label { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); }
.card-lg .card-label, .card-xl .card-label { font-size: 12px; }

.hand { display: flex; gap: 10px; flex-wrap: nowrap; overflow-x: auto; padding: 8px 2px 22px; }
.hand.compact { gap: 6px; padding: 4px 0 6px; }

/* suit chips (for clue buttons, legend) */
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 12px; border-radius: 999px;
  font-weight: 700; border: 2px solid transparent; cursor: pointer; min-height: 40px; min-width: 44px; color: #fff;
}
.chip.rank { background: #1f2750; border-color: rgba(255,255,255,0.25); font-size: 1.1rem; }
.chip.selected { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,0.4); }
.chip:disabled { opacity: 0.35; cursor: not-allowed; }

/* tokens */
.tokens { display: flex; gap: 4px; flex-wrap: wrap; }
.token { width: 18px; height: 18px; border-radius: 50%; background: #2c3666; border: 1px solid rgba(255,255,255,0.2); }
.token.clue.on { background: #29b6f6; box-shadow: 0 0 8px #29b6f6; }
.token.strike { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; background: #2c3666; }
.token.strike.on { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

/* piles */
.piles { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.pile { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pile .card.empty { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.35); box-shadow: inset 0 0 0 2px rgba(255,255,255,0.12); border: 1px dashed rgba(255,255,255,0.25); }
.pile .lbl { font-size: 11px; color: var(--muted); }

/* toast */
.toast-root { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(92vw, 420px); }
.toast { background: #202a55; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transform: translateY(-8px); transition: 0.25s; font-weight: 600; text-align: center; border-left: 4px solid var(--info); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--danger); }
.toast-warn { border-left-color: var(--warn); }

/* fireworks canvas */
.fireworks { position: fixed; inset: 0; pointer-events: none; z-index: 9000; }

/* badges / pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--panel-2); font-size: 0.8rem; font-weight: 600; }
.pill.ok { background: rgba(67,160,71,0.25); color: #a5d6a7; }
.pill.warn { background: rgba(253,216,53,0.2); color: #fff59d; }
.pill.danger { background: rgba(229,57,53,0.25); color: #ef9a9a; }
.pill.info { background: rgba(30,136,229,0.25); color: #90caf9; }
.dot-online { width: 8px; height: 8px; border-radius: 50%; background: #555; display: inline-block; }
.dot-online.on { background: #4caf50; box-shadow: 0 0 6px #4caf50; }

/* log */
.log { max-height: 220px; overflow-y: auto; font-size: 0.9rem; display: flex; flex-direction: column; gap: 4px; }
.log .entry { padding: 4px 8px; border-radius: 8px; background: rgba(0,0,0,0.2); }
.log .entry.play-ok { border-left: 3px solid var(--ok); }
.log .entry.play-bad { border-left: 3px solid var(--danger); }
.log .entry.clue { border-left: 3px solid var(--info); }
.log .entry.discard { border-left: 3px solid #888; }
.log .entry.end, .log .entry.finalRound { border-left: 3px solid var(--accent); font-weight: 700; }
.log .entry.mine { background: rgba(255,179,71,0.12); }

/* tables/lists */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--border); }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: rgba(255,255,255,0.15); }

table.grid { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.grid th, table.grid td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
table.grid th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; }
table.grid tr:hover td { background: rgba(255,255,255,0.04); }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 5000; padding: 16px; }
.modal { background: var(--bg-2); border: 1px solid var(--border); border-radius: 16px; padding: 18px; width: min(520px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }

/* topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: rgba(0,0,0,0.25); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; backdrop-filter: blur(8px); }
.brand { font-weight: 800; letter-spacing: 1px; display: flex; align-items: center; gap: 8px; }
.brand .logo { font-size: 1.3rem; }

/* timer */
.timer { font-variant-numeric: tabular-nums; font-weight: 800; }
.timer.urgent { color: var(--accent-2); animation: pulse 0.8s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes pop { 0% { transform: scale(0.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.pop { animation: pop 0.2s ease-out; }

/* responsive */
@media (max-width: 480px) {
  .container { padding: 10px; }
  .card-md { width: 50px; height: 72px; font-size: 28px; }
  .card-lg { width: 62px; height: 88px; font-size: 34px; }
  .btn { padding: 10px 12px; }
}
