:root {
  --bg: #1b1020;
  --bg2: #26162d;
  --card: #2f1d38;
  --line: #4a3056;
  --text: #f7eef6;
  --muted: #b9a3bd;
  --accent: #ff6b8b;
  --accent2: #ffb86b;
  --ok: #56d39a;
  --warn: #ffd166;
  --bad: #ff5d5d;
  --l1: #56d39a;
  --l2: #ffb86b;
  --l3: #ff6b8b;
  --l4: #b46bff;
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; }
.loading { text-align: center; margin-top: 40vh; color: var(--muted); }

.page { display: flex; flex-direction: column; min-height: 100dvh; }
.bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.bar h1 { flex: 1; font-size: 19px; margin: 0; text-align: center; }
.icon { width: 44px; height: 44px; border: 0; background: none; color: var(--text); font-size: 30px; line-height: 1; cursor: pointer; border-radius: 12px; }
main { flex: 1; padding: 8px 16px 28px; display: flex; flex-direction: column; gap: 14px; }

h2 { font-size: 24px; margin: 8px 0 0; }
h3 { margin: 0 0 6px; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 15px; }
.small { font-size: 13px; }
.center { text-align: center; }
.err { color: var(--bad); min-height: 1.2em; font-size: 15px; }

.btn {
  display: block; width: 100%; min-height: 52px; padding: 12px 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-align: center;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: 0; color: #2a0f1c; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: var(--bad); color: var(--bad); background: transparent; }
.btn.small { min-height: 40px; padding: 8px 12px; font-size: 15px; }
.btn:disabled { opacity: .45; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.tile {
  display: flex; gap: 14px; align-items: center; width: 100%; padding: 16px; text-align: left;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; cursor: pointer;
}
.tile .emoji { font-size: 34px; }
.tile b { display: block; font-size: 18px; }
.tile.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }

.option {
  display: block; width: 100%; padding: 15px 16px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.option.on { border-color: var(--accent); background: #3d2140; box-shadow: 0 0 0 2px var(--accent) inset; }
.link { background: none; border: 0; color: var(--muted); font: inherit; text-decoration: underline; cursor: pointer; padding: 8px; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 15px; color: var(--muted); }
input, select {
  font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; min-height: 48px; width: 100%;
}
input.pin { text-align: center; font-size: 28px; letter-spacing: 12px; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; }
.check input { width: 24px; height: 24px; min-height: 0; flex: none; margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; cursor: pointer; }
.chip.on { border-color: var(--accent); background: #3d2140; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; color: #1b1020; }
.lvl1 { background: var(--l1); } .lvl2 { background: var(--l2); } .lvl3 { background: var(--l3); } .lvl4 { background: var(--l4); color: #fff; }

.progress { height: 6px; border-radius: 3px; background: var(--bg2); overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .3s; }

/* Game */
.gamebar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.scores { display: flex; flex-wrap: wrap; gap: 6px; font-size: 14px; color: var(--muted); }
.pause { background: var(--bad); color: #fff; border: 0; border-radius: 12px; padding: 8px 14px; font: inherit; font-weight: 700; cursor: pointer; }
.turn { text-align: center; margin: 12vh 0 4vh; }
.turn .who { font-size: 56px; }
.turn h2 { font-size: 30px; }

.card {
  border-radius: 24px; padding: 22px 20px; min-height: 300px; display: flex; flex-direction: column; gap: 14px;
  background: linear-gradient(160deg, #3a2244, #24142b); border: 1px solid var(--line); box-shadow: 0 12px 40px #0008;
}
.card.l3 { border-color: var(--l3); } .card.l4 { border-color: var(--l4); }
.card .kind { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.card .for { font-weight: 700; color: var(--accent2); }
.card .text { font-size: 23px; line-height: 1.35; font-weight: 600; flex: 1; }
.card .text.blur { filter: blur(9px); cursor: pointer; user-select: none; }
.card .extra { background: #0003; border-radius: 14px; padding: 12px 14px; font-size: 16px; }
.card .legend { font-size: 14px; color: var(--muted); }
.card.wild { background: linear-gradient(160deg, #3b2a14, #24142b); border-color: var(--accent2); }
.card .big { font-size: 64px; text-align: center; }
.timer { font-variant-numeric: tabular-nums; }

.handoff { font-size: 64px; text-align: center; }

.modal-wrap { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--bg2); border: 1px solid var(--line); border-radius: 22px; padding: 22px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; transition: .25s; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.list { display: flex; flex-direction: column; gap: 10px; }
.note { background: var(--bg2); border: 1px dashed var(--line); border-radius: 14px; padding: 12px 14px; font-size: 15px; color: var(--muted); }
.lights { display: flex; gap: 6px; }
.lights button { flex: 1; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 20px; cursor: pointer; }
.lights button.on { box-shadow: 0 0 0 3px var(--text) inset; }
.person-row { display: flex; align-items: center; gap: 10px; }
.person-row > span { flex: 1; }
