/* ---------- tokens ---------- */
:root {
  --bg: #080a09;
  --ink: #0b0e0c;
  --surface: #121614;
  --surface-2: #181d1a;
  --line: rgba(241, 236, 223, 0.1);
  --line-strong: rgba(241, 236, 223, 0.2);
  --text: #f1ecdf;
  --muted: #98a098;
  --dim: #626b64;
  --raise: #cbf65a;
  --raise-deep: #a9d63f;
  --liar: #ff5f4f;
  --gold: #e8c87d;
  --felt-1: #1c3a2e;
  --felt-2: #0d1c17;
  --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --sans: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --shadow-lg: 0 40px 90px -40px rgba(0, 0, 0, 0.9);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
  background:
    radial-gradient(1100px 700px at 50% -12%, rgba(28, 58, 46, 0.55), transparent 62%),
    radial-gradient(900px 600px at 88% 112%, rgba(58, 48, 25, 0.28), transparent 58%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.felt-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(60% 45% at 50% 32%, rgba(203, 246, 90, 0.055), transparent 70%);
  z-index: 0;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.7'/%3E%3C/svg%3E");
}

main { position: relative; z-index: 2; }

/* ---------- topbar ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px max(16px, calc((100vw - 1140px) / 2));
  background: linear-gradient(180deg, rgba(8, 10, 9, 0.9), rgba(8, 10, 9, 0));
}

.topbar-brand {
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: 0.12em;
  opacity: 0.9;
}

.topbar-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(18, 22, 20, 0.7);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { border-color: var(--line-strong); background: var(--surface-2); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn[aria-pressed='false'] .wave { opacity: 0.15; }

/* ---------- shared ---------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 14px;
  min-height: 50px;
  padding: 0 22px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  transition: transform 0.14s var(--ease), background 0.18s, box-shadow 0.2s, opacity 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.32; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-wide { width: 100%; }

.btn-primary {
  background: var(--text);
  color: var(--ink);
  border-color: var(--text);
}
.btn-primary:not(:disabled):hover { background: #fff; box-shadow: 0 10px 30px -12px rgba(241, 236, 223, 0.5); }

.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
}
.btn-ghost:not(:disabled):hover { background: rgba(241, 236, 223, 0.06); }

.text-btn {
  appearance: none;
  background: none;
  border: 0;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  padding: 6px;
  text-decoration: underline;
  text-decoration-color: rgba(152, 160, 152, 0.35);
  text-underline-offset: 3px;
  transition: color 0.2s;
}
.text-btn:hover { color: var(--text); }

.eyebrow {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dim);
}

.hint { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 10px 0 0; }

.form-error {
  min-height: 20px;
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--liar);
}

/* ---------- dice ---------- */
.die {
  --size: 54px;
  width: var(--size);
  height: var(--size);
  flex: 0 0 auto;
  border-radius: calc(var(--size) * 0.21);
  background: linear-gradient(150deg, #fdf7e8 0%, #eee2c9 62%, #dccdb0 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -3px 6px rgba(120, 96, 50, 0.22),
    0 10px 20px -10px rgba(0, 0, 0, 0.85);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: calc(var(--size) * 0.12);
  position: relative;
}
.die span {
  width: 64%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #2a2d2a, #121412 70%);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.22);
  align-self: center;
  justify-self: center;
}
.die.p1 span:nth-child(1) { grid-area: 2 / 2; }
.die.p2 span:nth-child(1) { grid-area: 1 / 1; }
.die.p2 span:nth-child(2) { grid-area: 3 / 3; }
.die.p3 span:nth-child(1) { grid-area: 1 / 1; }
.die.p3 span:nth-child(2) { grid-area: 2 / 2; }
.die.p3 span:nth-child(3) { grid-area: 3 / 3; }
.die.p4 span:nth-child(1) { grid-area: 1 / 1; }
.die.p4 span:nth-child(2) { grid-area: 1 / 3; }
.die.p4 span:nth-child(3) { grid-area: 3 / 1; }
.die.p4 span:nth-child(4) { grid-area: 3 / 3; }
.die.p5 span:nth-child(1) { grid-area: 1 / 1; }
.die.p5 span:nth-child(2) { grid-area: 1 / 3; }
.die.p5 span:nth-child(3) { grid-area: 2 / 2; }
.die.p5 span:nth-child(4) { grid-area: 3 / 1; }
.die.p5 span:nth-child(5) { grid-area: 3 / 3; }
.die.p6 span:nth-child(1) { grid-area: 1 / 1; }
.die.p6 span:nth-child(2) { grid-area: 1 / 3; }
.die.p6 span:nth-child(3) { grid-area: 2 / 1; }
.die.p6 span:nth-child(4) { grid-area: 2 / 3; }
.die.p6 span:nth-child(5) { grid-area: 3 / 1; }
.die.p6 span:nth-child(6) { grid-area: 3 / 3; }
.die.p1 span:nth-child(n + 2),
.die.p2 span:nth-child(n + 3),
.die.p3 span:nth-child(n + 4),
.die.p4 span:nth-child(n + 5),
.die.p5 span:nth-child(n + 6),
.die.p6 span:nth-child(n + 7) { display: none; }

.die.mini { --size: 22px; }
.die.tiny { --size: 15px; padding: calc(var(--size) * 0.1); }

.die.is-match {
  box-shadow:
    0 0 0 2px var(--raise),
    0 0 24px rgba(203, 246, 90, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transform: translateY(-3px);
}
.die.is-dim { opacity: 0.32; filter: saturate(0.4); }

/* ---------- landing ---------- */
.screen-landing {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 72px 20px 40px;
}

.landing {
  width: min(430px, 100%);
  padding: clamp(28px, 5vw, 44px) clamp(22px, 5vw, 36px) 24px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(26, 32, 28, 0.82), rgba(11, 14, 12, 0.92));
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  position: relative;
  overflow: hidden;
}
.landing::before {
  content: '';
  position: absolute;
  inset: -40% -20% auto;
  height: 70%;
  background: radial-gradient(closest-side, rgba(203, 246, 90, 0.12), transparent);
  pointer-events: none;
}

.brand { text-align: center; position: relative; }

.brand-dice {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
}
.bdie {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(150deg, #fdf7e8, #e4d7bd);
  box-shadow: 0 12px 24px -12px rgba(0, 0, 0, 0.9), inset 0 1px 0 #fff;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 7px;
}
.bdie i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #141614;
  align-self: center;
  justify-self: center;
}
.bdie.b1 { transform: rotate(-9deg) translateY(5px); }
.bdie.b2 { transform: rotate(3deg) translateY(-3px); }
.bdie.b3 { transform: rotate(12deg) translateY(6px); }
.bdie.b1 i:nth-child(1) { grid-area: 1 / 1; }
.bdie.b1 i:nth-child(2) { grid-area: 1 / 3; }
.bdie.b1 i:nth-child(3) { grid-area: 2 / 2; }
.bdie.b1 i:nth-child(4) { grid-area: 3 / 1; }
.bdie.b1 i:nth-child(5) { grid-area: 3 / 3; }
.bdie.b2 i:nth-child(1) { grid-area: 1 / 1; }
.bdie.b2 i:nth-child(2) { grid-area: 2 / 2; }
.bdie.b2 i:nth-child(3) { grid-area: 3 / 3; }
.bdie.b3 i:nth-child(1) { grid-area: 2 / 2; }

.brand h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(66px, 15vw, 92px);
  line-height: 0.86;
  letter-spacing: 0.015em;
  margin: 0 0 14px;
  text-shadow: 0 22px 50px rgba(0, 0, 0, 0.6);
}

.tagline {
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  line-height: 1.4;
  color: var(--muted);
  margin: 0 0 26px;
}

.landing-form { position: relative; }

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 8px;
}

input {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(8, 10, 9, 0.6);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input::placeholder { color: #5b635c; }
input:focus {
  border-color: rgba(203, 246, 90, 0.55);
  box-shadow: 0 0 0 3px rgba(203, 246, 90, 0.12);
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 16px;
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.join-row { display: flex; gap: 10px; }
.code-input {
  flex: 1;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  padding-left: calc(0.32em + 4px);
}
.join-row .btn { flex: 0 0 auto; }

.landing-rules { display: block; margin: 16px auto 0; }
.landing-foot {
  margin: 22px 0 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--dim);
  text-align: center;
}

/* ---------- lobby ---------- */
.screen-lobby {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 20px 40px;
}

.lobby {
  width: min(520px, 100%);
  padding: clamp(26px, 5vw, 40px);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(24, 30, 26, 0.85), rgba(11, 14, 12, 0.94));
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.code-display {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  background: none;
  border: 0;
  color: var(--text);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 14px;
  transition: background 0.2s;
}
.code-display:hover { background: rgba(241, 236, 223, 0.05); }
.code-display span {
  font-family: var(--serif);
  font-size: clamp(64px, 14vw, 88px);
  line-height: 1;
  letter-spacing: 0.12em;
  padding-left: 0.12em;
  color: var(--raise);
  text-shadow: 0 0 50px rgba(203, 246, 90, 0.28);
}
.code-display svg { width: 22px; height: 22px; color: var(--dim); }

.lobby-players {
  list-style: none;
  margin: 28px 0;
  padding: 0;
  display: grid;
  gap: 8px;
  text-align: left;
}
.seat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(241, 236, 223, 0.025);
}
.seat-row.is-empty {
  border-style: dashed;
  background: none;
  color: var(--dim);
  font-size: 13px;
}
.seat-no {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--dim);
  width: 18px;
  flex: 0 0 auto;
}
.seat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--raise);
  flex: 0 0 auto;
}
.seat-name { font-size: 14px; font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-tag {
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--gold);
  border-radius: 999px;
  padding: 3px 7px;
  font-weight: 700;
}
.seat-tag.offline { background: transparent; color: var(--dim); border: 1px solid var(--line); }
.seat-kick {
  appearance: none;
  border: 1px solid var(--line);
  background: none;
  color: var(--dim);
  border-radius: 8px;
  width: 26px;
  height: 26px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.seat-kick:hover { color: var(--liar); border-color: rgba(255, 95, 79, 0.4); }

.lobby-actions { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.lobby-actions .btn { min-width: 240px; }
.lobby-note { min-height: 20px; }

/* ---------- game ---------- */
.screen-game {
  min-height: 100dvh;
  max-width: 1080px;
  margin: 0 auto;
  padding: 62px clamp(14px, 3vw, 26px) 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px 2px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(18, 22, 20, 0.6);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
}
.chip b { color: var(--text); font-weight: 600; letter-spacing: 0.02em; }
.chip-code {
  font-family: var(--sans);
  color: var(--raise);
  font-weight: 700;
  letter-spacing: 0.22em;
  padding-left: calc(11px + 0.22em);
  cursor: pointer;
}
.chip-code:hover { border-color: rgba(203, 246, 90, 0.35); }
.chip-die {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: linear-gradient(150deg, #fdf7e8, #e0d3b8);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  display: inline-block;
}

.table-wrap {
  position: relative;
  flex: 1;
  min-height: 400px;
  margin: 2px 0;
}
.table-wrap::before {
  content: '';
  position: absolute;
  inset: 6% 5%;
  border-radius: 50% / 48%;
  background:
    radial-gradient(closest-side, rgba(32, 62, 49, 0.9), rgba(16, 31, 26, 0.65) 62%, rgba(10, 14, 12, 0) 100%);
  border: 1px solid rgba(220, 255, 220, 0.05);
  box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.table-wrap::after {
  content: '';
  position: absolute;
  inset: 12% 11%;
  border-radius: 50% / 48%;
  border: 1px solid rgba(241, 236, 223, 0.045);
  pointer-events: none;
}

.opponents { position: absolute; inset: 0; pointer-events: none; }

.opponent {
  position: absolute;
  width: 160px;
  text-align: center;
  z-index: 2;
  transition: opacity 0.3s, filter 0.3s;
}
.opponent.pos-left { left: 1%; top: 50%; transform: translateY(-50%); }
.opponent.pos-right { right: 1%; top: 50%; transform: translateY(-50%); }
.opponent.pos-top { left: 50%; top: 2%; transform: translateX(-50%); }

.avatar {
  width: 48px;
  height: 48px;
  margin: 0 auto 7px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  font-family: var(--serif);
  font-size: 20px;
  color: var(--text);
  position: relative;
  transition: box-shadow 0.25s, border-color 0.25s, transform 0.25s;
}
.opponent.is-turn .avatar {
  border-color: var(--raise);
  box-shadow: 0 0 0 3px rgba(203, 246, 90, 0.14), 0 0 26px rgba(203, 246, 90, 0.28);
  transform: scale(1.06);
}
.opponent.is-out { opacity: 0.35; filter: grayscale(0.7); }
.opponent.is-out .avatar { border-style: dashed; }
.opponent.is-offline .avatar { border-style: dashed; }

.avatar .crown {
  position: absolute;
  top: -9px;
  right: -5px;
  font-size: 13px;
  color: var(--gold);
  transform: rotate(14deg);
}
.avatar .offline-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--liar);
  border: 2px solid var(--bg);
}

.opp-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0 0 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.opp-name .you-tag { color: var(--dim); font-weight: 400; }
.opp-dice { display: flex; justify-content: center; gap: 3px; flex-wrap: wrap; min-height: 16px; }
.opp-dice .die { --size: 15px; padding: calc(var(--size) * 0.1); }
.opp-empty { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--liar); }
.opp-out-label { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); }

.table-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, 72%);
  text-align: center;
  z-index: 1;
}

.bid-display {
  min-height: 118px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.bid-line { display: flex; align-items: center; justify-content: center; gap: 12px; }
.bid-q {
  font-family: var(--serif);
  font-size: clamp(58px, 9vw, 84px);
  line-height: 0.9;
  color: var(--text);
}
.bid-x {
  font-family: var(--serif);
  font-size: 30px;
  color: var(--dim);
}
.bid-line .die { --size: 58px; }
.bid-by {
  margin: 10px 0 0;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}
.bid-by b { color: var(--muted); font-weight: 600; }

.bid-empty { color: var(--dim); font-family: var(--serif); font-style: italic; font-size: 26px; line-height: 1.3; padding: 0 20px; }
.bid-empty b { color: var(--muted); font-style: normal; font-family: var(--sans); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; display: block; margin-top: 8px; }

.table-msg {
  margin: 6px 0 0;
  min-height: 20px;
  font-size: 13px;
  color: var(--muted);
}
.table-msg b { color: var(--text); font-weight: 600; }
.table-msg .liar-text { color: var(--liar); font-weight: 700; letter-spacing: 0.04em; }

.turn-timer {
  width: 150px;
  height: 3px;
  margin: 12px auto 0;
  border-radius: 99px;
  background: rgba(241, 236, 223, 0.1);
  overflow: hidden;
}
.turn-timer i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: var(--raise);
  transform-origin: left;
  transition: background 0.3s;
}
.turn-timer.is-low i { background: var(--liar); }

.hand-area {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 12px 16px 6px;
  border-radius: 20px 20px 0 0;
  text-align: center;
  transition: background 0.3s;
  position: relative;
}
.hand-head {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}
.hand-name {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.hand-count { font-size: 11px; color: var(--dim); }
.your-dice { display: flex; justify-content: center; gap: 9px; flex-wrap: wrap; min-height: 54px; }
.your-dice .die { --size: clamp(42px, 7vw, 54px); }
.hand-area.is-turn .hand-name { color: var(--raise); }
.hand-area.is-out .your-dice { display: none; }
.hand-area .spectator-note { color: var(--dim); font-size: 13px; }

.your-dice.is-dealing .die { animation: deal-in 0.55s var(--ease) backwards; }
.your-dice.is-dealing .die:nth-child(2) { animation-delay: 0.05s; }
.your-dice.is-dealing .die:nth-child(3) { animation-delay: 0.1s; }
.your-dice.is-dealing .die:nth-child(4) { animation-delay: 0.15s; }
.your-dice.is-dealing .die:nth-child(5) { animation-delay: 0.2s; }
@keyframes deal-in {
  0% { opacity: 0; transform: translateY(-14px) rotate(-16deg) scale(0.8); }
  100% { opacity: 1; transform: translateY(0) rotate(0) scale(1); }
}

.controls {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(24, 29, 26, 0.9), rgba(14, 17, 15, 0.95));
  box-shadow: 0 24px 50px -30px rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.waiting {
  flex: 1 1 100%;
  margin: 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  padding: 2px 0;
}
.waiting b { color: var(--text); }
.waiting .offline { color: var(--liar); }

.bid-builder {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1 1 auto;
  opacity: 1;
  transition: opacity 0.25s;
}
.bid-builder.is-locked { opacity: 0.32; pointer-events: none; }

.stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px;
  background: rgba(8, 10, 9, 0.45);
}
.step-btn {
  width: 36px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.2s;
}
.step-btn:hover:not(:disabled) { background: rgba(241, 236, 223, 0.07); }
.step-btn:disabled { opacity: 0.25; cursor: not-allowed; }
.step-value { min-width: 52px; text-align: center; line-height: 1; }
.step-value span { font-family: var(--serif); font-size: 30px; }
.step-value small { display: block; font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); margin-top: 3px; }

.face-picker { display: flex; gap: 5px; flex-wrap: wrap; }
.face-btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(8, 10, 9, 0.45);
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s, opacity 0.2s;
}
.face-btn .die { --size: 26px; }
.face-btn:hover:not(:disabled) { border-color: var(--line-strong); background: rgba(241, 236, 223, 0.06); }
.face-btn.is-selected {
  border-color: var(--raise);
  background: rgba(203, 246, 90, 0.09);
  box-shadow: 0 0 0 2px rgba(203, 246, 90, 0.15);
}
.face-btn:disabled { opacity: 0.22; cursor: not-allowed; }

.action-row { display: flex; gap: 8px; margin-left: auto; }

.btn-raise {
  background: linear-gradient(180deg, var(--raise), var(--raise-deep));
  color: #121608;
  min-width: 130px;
  box-shadow: 0 14px 30px -16px rgba(203, 246, 90, 0.7);
  border-color: rgba(203, 246, 90, 0.6);
}
.btn-raise:not(:disabled):hover { filter: brightness(1.06); }

.btn-liar {
  background: linear-gradient(180deg, #ff7161, var(--liar));
  color: #1e0a06;
  min-width: 108px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 14px 30px -16px rgba(255, 95, 79, 0.6);
  border-color: rgba(255, 95, 79, 0.5);
}
.btn-liar:not(:disabled):hover { filter: brightness(1.07); }
.btn-liar.is-armed {
  animation: armed-pulse 0.6s ease-in-out infinite alternate;
}
@keyframes armed-pulse {
  from { box-shadow: 0 0 0 0 rgba(255, 95, 79, 0.55); }
  to { box-shadow: 0 0 0 7px rgba(255, 95, 79, 0); }
}

.emote-bar {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 2px 0 4px;
}
.emote-btn {
  appearance: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(18, 22, 20, 0.55);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s var(--ease), border-color 0.15s, opacity 0.2s;
  opacity: 0.75;
}
.emote-btn:hover { transform: translateY(-2px) scale(1.06); border-color: var(--line-strong); opacity: 1; }
.emote-btn:active { transform: scale(0.94); }

.emote-bubble {
  position: absolute;
  left: 50%;
  top: -30px;
  transform: translateX(-50%);
  font-size: 30px;
  z-index: 10;
  pointer-events: none;
  animation: emote-pop 2.4s var(--ease) forwards;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.5));
}
@keyframes emote-pop {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(0.5); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1.15); }
  22% { transform: translate(-50%, -2px) scale(1); }
  75% { opacity: 1; transform: translate(-50%, -10px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -22px) scale(0.95); }
}

/* ---------- overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 7, 6, 0.78);
  backdrop-filter: blur(7px);
  animation: overlay-in 0.25s ease;
  overflow-y: auto;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

.reveal-card, .rules-card {
  width: min(720px, 100%);
  border: 1px solid var(--line);
  border-radius: 26px;
  background: linear-gradient(180deg, #171d19, #0c0f0d);
  box-shadow: var(--shadow-lg);
  padding: clamp(22px, 4vw, 34px);
  text-align: center;
  animation: card-in 0.35s var(--ease);
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.stamp {
  display: inline-block;
  font-size: clamp(18px, 3vw, 24px);
  font-weight: 700;
  letter-spacing: 0.18em;
  padding: 8px 20px 7px;
  border: 2px solid var(--raise);
  border-radius: 10px;
  color: var(--raise);
  transform: rotate(-2.5deg);
  text-transform: uppercase;
  animation: stamp-in 0.4s 0.08s var(--ease) backwards;
}
.stamp.is-lie { color: var(--liar); border-color: var(--liar); }
@keyframes stamp-in {
  from { opacity: 0; transform: rotate(-2.5deg) scale(1.5); }
  to { opacity: 1; transform: rotate(-2.5deg) scale(1); }
}

.reveal-reason { margin: 14px 0 20px; font-size: 14px; color: var(--muted); line-height: 1.5; }
.reveal-reason b { color: var(--text); }

.reveal-players {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.reveal-group { padding: 4px; }
.reveal-group .rg-name {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0 0 8px;
}
.reveal-group.is-loser .rg-name { color: var(--liar); }
.reveal-dice { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.reveal-dice .die { --size: 24px; }
.reveal-group .rg-none { color: var(--dim); font-size: 12px; }

.reveal-loser { margin: 18px 0 0; font-size: 16px; font-weight: 500; }
.reveal-loser b { color: var(--liar); }
.reveal-next { margin: 8px 0 0; font-size: 11px; letter-spacing: 0.08em; color: var(--dim); }

/* winner */
.overlay-winner {
  background:
    radial-gradient(75% 62% at 50% 30%, rgba(232, 200, 125, 0.16), transparent 62%),
    #050706;
}
.winner-card .eyebrow { color: rgba(232, 200, 125, 0.7); }
.winner-card { text-align: center; position: relative; z-index: 2; }
.winner-name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(56px, 11vw, 104px);
  line-height: 0.95;
  margin: 6px 0 8px;
  color: var(--gold);
  text-shadow: 0 0 80px rgba(232, 200, 125, 0.3);
  animation: winner-in 0.7s var(--ease);
  overflow-wrap: anywhere;
  padding: 0 8px;
}
@keyframes winner-in {
  from { opacity: 0; transform: scale(0.85) translateY(12px); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: none; }
}
.winner-sub { color: var(--muted); margin: 0 0 28px; font-size: 14px; }
.winner-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.winner-actions .hint { margin: 6px 0 0; }
.winner-rain { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.falling-die {
  position: absolute;
  top: -60px;
  animation-name: fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  opacity: 0.6;
}
@keyframes fall {
  0% { transform: translateY(-60px) rotate(0deg); opacity: 0; }
  10% { opacity: 0.65; }
  100% { transform: translateY(110dvh) rotate(540deg); opacity: 0.2; }
}

/* rules */
.rules-card { text-align: left; max-width: 560px; }
.rules-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.rules-head h2 { font-family: var(--serif); font-weight: 400; font-size: 34px; margin: 0; }
.rules-head .icon-btn { font-size: 20px; }
.rules-list { margin: 0; padding: 0 0 0 20px; display: grid; gap: 14px; }
.rules-list li { font-size: 14px; line-height: 1.55; color: var(--muted); padding-left: 4px; }
.rules-list li::marker { color: var(--raise); font-weight: 700; font-family: var(--serif); font-size: 16px; }
.rules-list b { color: var(--text); font-weight: 600; }
.rules-tip {
  margin: 20px 0;
  padding: 12px 14px;
  border-left: 2px solid var(--raise);
  background: rgba(203, 246, 90, 0.05);
  border-radius: 0 10px 10px 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}
.rules-tip b { color: var(--text); }

/* toast + connection */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 16px);
  z-index: 80;
  background: var(--text);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s var(--ease);
  max-width: min(90vw, 420px);
  text-align: center;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--liar); color: #1e0a06; }

.conn-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 90;
  background: var(--liar);
  color: #1e0a06;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 7px 12px;
}

:focus-visible { outline: 2px solid var(--raise); outline-offset: 2px; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .screen-game { padding-top: 58px; }
  .table-wrap { min-height: 340px; }
  .opponent { width: 132px; }
  .bid-line .die { --size: 50px; }
  .controls { gap: 10px; }
  .action-row { margin-left: 0; width: 100%; }
  .action-row .btn { flex: 1; }
}

@media (max-width: 700px) {
  .topbar { padding: 10px 14px; background: linear-gradient(180deg, rgba(8, 10, 9, 0.96), rgba(8, 10, 9, 0.5)); }

  .screen-game { padding: 54px 12px 10px; gap: 6px; min-height: 100dvh; }

  .table-wrap { min-height: 0; display: flex; flex-direction: column; padding-top: 6px; background: radial-gradient(120% 80% at 50% 34%, rgba(31, 62, 48, 0.34), transparent 70%); border-radius: 24px; }
  .table-wrap::before, .table-wrap::after { display: none; }

  .opponents { position: static; display: flex; gap: 8px; justify-content: center; align-items: flex-start; pointer-events: auto; flex-wrap: wrap; }
  .opponent, .opponent.pos-left, .opponent.pos-right, .opponent.pos-top {
    position: relative;
    inset: auto;
    left: auto;
    right: auto;
    top: auto;
    transform: none;
    width: auto;
    min-width: 74px;
    padding: 8px 6px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(16, 21, 18, 0.6);
  }
  .opponent .avatar { width: 34px; height: 34px; font-size: 15px; margin-bottom: 4px; }
  .opp-name { font-size: 11px; margin-bottom: 4px; }
  .opp-dice { gap: 2px; min-height: 12px; }
  .opp-dice .die { --size: 11px; padding: 9%; }
  .opp-empty, .opp-out-label { font-size: 8px; letter-spacing: 0.08em; }

  .table-center { position: static; transform: none; width: 100%; margin: 10px 0 2px; }
  .bid-display { min-height: 92px; }
  .bid-line .die { --size: 44px; }
  .bid-q { font-size: 54px; }
  .bid-x { font-size: 22px; }
  .bid-empty { font-size: 21px; }
  .table-msg { margin-top: 2px; font-size: 12px; }

  .hand-area { padding: 8px 10px 4px; border-radius: 16px; }
  .your-dice { gap: 7px; min-height: 44px; }
  .your-dice .die { --size: 42px; }

  .controls { flex-direction: column; align-items: stretch; padding: 10px; border-radius: 16px; }
  .bid-builder { flex-direction: column; align-items: stretch; gap: 8px; }
  .stepper { align-self: center; }
  .face-picker { justify-content: center; }
  .face-btn { width: 42px; height: 42px; }
  .face-btn .die { --size: 24px; }
  .action-row { gap: 8px; }
  .action-row .btn { min-height: 54px; min-width: 0; }
  .emote-bar { position: static; flex-direction: row; justify-content: center; gap: 6px; padding: 4px 0 10px; z-index: auto; }
  .emote-btn { width: 34px; height: 34px; font-size: 16px; background: rgba(18, 22, 20, 0.85); backdrop-filter: blur(6px); }
  .toast { bottom: 84px; }

  .screen-lobby { padding-top: 64px; }
  .lobby { border-radius: 22px; }
  .reveal-card, .rules-card { border-radius: 20px; max-height: 88dvh; overflow-y: auto; }
  .reveal-players { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
  .reveal-dice .die { --size: 22px; }
}

@media (max-width: 380px) {
  .face-btn { width: 38px; height: 38px; }
  .your-dice .die { --size: 38px; }
  .opponent { min-width: 66px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
