:root {
  --bg: #08080b;
  --bg-2: #111116;
  --surface: #16161c;
  --surface-2: #1f1f27;
  --glass: rgba(28, 28, 36, 0.72);
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.13);
  --text: #f6f6f8;
  --muted: #9a9aa6;
  --dim: #5f5f6b;

  --coral: #ff5c4d;
  --mint: #2fd39a;
  --violet: #8a6bff;
  --amber: #ffb22e;
  --sky: #3aa6ff;
  --pink: #ff5ea8;

  --p0: #ff7a5c;
  --p1: #3fe0a6;
  --p2: #a48bff;
  --p3: #ffc145;

  --r-xl: 28px;
  --r-lg: 22px;
  --r-md: 16px;
  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --spring: cubic-bezier(0.22, 1.2, 0.36, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; overflow-x: clip; scrollbar-width: none; }
html::-webkit-scrollbar, body::-webkit-scrollbar, .sheet::-webkit-scrollbar { display: none; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
/* soft aurora behind everything */
body::before {
  content: ''; position: fixed; inset: -20% -20% auto; height: 70vh; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40% 50% at 20% 30%, rgba(138, 107, 255, 0.22), transparent 70%),
    radial-gradient(35% 45% at 80% 20%, rgba(255, 92, 77, 0.16), transparent 70%),
    radial-gradient(40% 40% at 60% 60%, rgba(58, 166, 255, 0.12), transparent 70%);
  filter: blur(20px);
}
button, input, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: not-allowed; opacity: 0.38; }
h1, h2, h3 { margin: 0; letter-spacing: -0.03em; line-height: 1.05; }
img { -webkit-user-drag: none; user-select: none; }

#app {
  max-width: 560px; margin: 0 auto; min-height: 100dvh;
  padding: calc(var(--safe-top) + 14px) 16px calc(var(--safe-bottom) + 96px);
  display: flex; flex-direction: column;
}

/* ---------- primitives ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 54px; padding: 0 22px; border-radius: 999px;
  font-weight: 700; font-size: 16px;
  background: var(--text); color: #0b0b0f;
  transition: transform 0.18s var(--spring), opacity 0.2s, background 0.2s;
  user-select: none; white-space: nowrap;
}
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn.block { width: 100%; }
.btn.accent { background: linear-gradient(180deg, #ff7262, #f2463a); color: #fff; box-shadow: 0 10px 30px -12px rgba(255, 80, 60, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.btn.ghost { background: rgba(255, 255, 255, 0.07); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.btn.sm { height: 40px; padding: 0 16px; font-size: 14px; }
.btn svg { width: 18px; height: 18px; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: rgba(255, 255, 255, 0.07); box-shadow: inset 0 0 0 1px var(--line); font-size: 18px; font-weight: 700;
  transition: transform 0.18s var(--spring);
}
.icon-btn:active:not(:disabled) { transform: scale(0.9); }
.icon-btn svg { width: 19px; height: 19px; }

.card { background: var(--surface); border-radius: var(--r-lg); padding: 16px; box-shadow: inset 0 0 0 1px var(--line); }
.glass { background: var(--glass); backdrop-filter: blur(24px) saturate(1.6); -webkit-backdrop-filter: blur(24px) saturate(1.6); box-shadow: inset 0 0 0 1px var(--line-2), 0 20px 40px -20px rgba(0, 0, 0, 0.8); }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.02em; color: var(--muted); }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 12px; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 999px; font-size: 13px; font-weight: 600; background: rgba(255, 255, 255, 0.08); white-space: nowrap; }

.input {
  width: 100%; height: 54px; padding: 0 20px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.06); border: 0; outline: none; box-shadow: inset 0 0 0 1px var(--line-2);
  font-weight: 500; font-size: 17px; transition: box-shadow 0.2s;
}
.input:focus { box-shadow: inset 0 0 0 2px var(--text); }
.input::placeholder { color: var(--dim); }

.av { width: 1.3em; height: 1.3em; vertical-align: -0.28em; object-fit: contain; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; background: var(--surface-2); flex: none; overflow: hidden; }
.avatar .av { width: 78%; height: 78%; vertical-align: 0; }

/* ---------- top bars ---------- */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; min-height: 42px; }
.topbar .title { flex: 1; min-width: 0; text-align: center; font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; justify-content: safe center; gap: 6px; }
.topbar .title img { width: 24px; height: 24px; flex: none; }
.topbar .title span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.wordmark { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; letter-spacing: -0.03em; }
.wordmark img { width: 28px; height: 28px; transform: rotate(-10deg); }
.me-chip { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px 0 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; font-size: 14px; }

/* ---------- home ---------- */
.page-title { font-size: clamp(34px, 9.5vw, 44px); font-weight: 800; margin: 10px 0 6px; }
.page-sub { color: var(--muted); margin: 0 0 18px; font-size: 16px; }

.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 16px; padding: 2px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { height: 38px; padding: 0 16px; border-radius: 999px; font-weight: 600; font-size: 14px; white-space: nowrap; background: rgba(255, 255, 255, 0.06); box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); transition: all 0.2s; }
.chips button.on { background: var(--text); color: #0b0b0f; box-shadow: none; }

.games-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile {
  --c: var(--violet);
  position: relative; overflow: hidden; text-align: left; isolation: isolate;
  border-radius: var(--r-lg); padding: 14px; min-height: 164px;
  display: flex; flex-direction: column; justify-content: flex-end;
  background: linear-gradient(155deg, color-mix(in srgb, var(--c) 88%, #fff 12%) 0%, color-mix(in srgb, var(--c) 70%, #000 30%) 100%);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: transform 0.25s var(--spring);
  animation: rise 0.5s var(--spring) both;
}
.tile:active { transform: scale(0.97); }
.tile::before { content: ''; position: absolute; inset: 0; z-index: -1; background: radial-gradient(90% 70% at 85% 10%, rgba(255, 255, 255, 0.28), transparent 60%); }
.tile .ico, .rules-hero .ico { position: absolute; top: 8px; right: 6px; width: 84px; height: 84px; transform: rotate(10deg); filter: drop-shadow(0 12px 14px rgba(0, 0, 0, 0.35)); transition: transform 0.4s var(--spring); }
.tile:hover .ico { transform: rotate(0) scale(1.06); }
.tile h3 { font-size: 18px; font-weight: 800; line-height: 1.1; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.15); }
.tile .meta { font-size: 12.5px; font-weight: 600; opacity: 0.82; margin-top: 4px; }
.tile .badge { position: absolute; top: 12px; left: 12px; display: flex; gap: 4px; }
.tile .badge span { font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.22); backdrop-filter: blur(8px); }
.tile.sel { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--text); }
.tile.off { filter: grayscale(0.8) brightness(0.6); }
.empty-note { grid-column: span 2; text-align: center; color: var(--muted); padding: 40px 0; }

/* floating dock */
.dock {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: max(12px, calc(var(--safe-bottom) - 12px)); width: min(528px, calc(100% - 24px));
  display: flex; gap: 8px; padding: 8px; border-radius: 999px;
  animation: dock 0.5s var(--spring) both;
}
.dock form { flex: 1; display: flex; gap: 6px; min-width: 0; }
.dock .code-in { flex: 1; min-width: 0; height: 50px; border-radius: 999px; border: 0; outline: none; padding: 0 18px; background: rgba(255, 255, 255, 0.07); text-transform: uppercase; font-weight: 700; letter-spacing: 0.3em; font-size: 17px; }
.dock .code-in::placeholder { letter-spacing: 0.02em; text-transform: none; font-weight: 500; color: var(--dim); }
.dock .code-in:focus { box-shadow: inset 0 0 0 2px var(--text); }
.dock .btn { height: 50px; }
.dock .go { width: 50px; padding: 0; }
.dock .go .lbl { display: none; }
/* while a code is being typed, «+ Комната» steps aside and the arrow becomes «Войти» */
.dock:has(.code-in:focus, .code-in:not(:placeholder-shown)) [data-do='create'] { display: none; }
.dock:has(.code-in:focus, .code-in:not(:placeholder-shown)) .go { width: auto; padding: 0 20px; background: linear-gradient(180deg, #ff7262, #f2463a); color: #fff; box-shadow: none; }
.dock:has(.code-in:focus, .code-in:not(:placeholder-shown)) .go .lbl { display: inline; }

/* ---------- lobby ---------- */
.code-cells { display: flex; gap: 8px; justify-content: center; margin: 4px 0 14px; }
.code-cells span { width: 62px; height: 74px; border-radius: 18px; display: grid; place-items: center; font-size: 38px; font-weight: 800; background: rgba(255, 255, 255, 0.06); box-shadow: inset 0 0 0 1px var(--line-2); animation: rise 0.5s var(--spring) both; }
.code-cells span:nth-child(2) { animation-delay: 0.05s; } .code-cells span:nth-child(3) { animation-delay: 0.1s; } .code-cells span:nth-child(4) { animation-delay: 0.15s; }
.code-actions { display: flex; gap: 8px; justify-content: center; }

.seats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 22px 0; }
.seat { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; position: relative; animation: rise 0.45s var(--spring) both; min-width: 0; }
.seat .ring { width: 68px; height: 68px; border-radius: 50%; padding: 3px; background: conic-gradient(from 200deg, var(--pc), color-mix(in srgb, var(--pc) 30%, transparent), var(--pc)); }
.seat .ring .avatar { width: 100%; height: 100%; background: var(--bg-2); border: 3px solid var(--bg); }
.seat .name { font-weight: 600; font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .sub { font-size: 11px; color: var(--muted); margin-top: -6px; min-height: 13px; }
.seat .crown { position: absolute; top: -10px; left: calc(50% + 14px); width: 26px; height: 26px; transform: rotate(18deg); }
.seat.empty .ring { background: none; box-shadow: inset 0 0 0 2px var(--line-2); display: grid; place-items: center; color: var(--dim); font-size: 22px; }
.seat.offline { opacity: 0.4; }

.picked { min-height: 196px; padding: 104px 18px 18px; animation: none; }
.picked .ico { width: 124px; height: 124px; top: 4px; right: 2px; }
.picked h3 { font-size: 28px; }
.picked p { margin: 8px 0 0; font-size: 14px; opacity: 0.9; line-height: 1.35; }
.picked .tools { display: flex; gap: 8px; margin-top: 14px; }
.picked .tools .btn { background: rgba(0, 0, 0, 0.25); color: #fff; box-shadow: none; backdrop-filter: blur(8px); }
.table-note { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--muted); margin-top: 12px; padding: 12px 14px; border-radius: var(--r-md); background: rgba(255, 255, 255, 0.04); box-shadow: inset 0 0 0 1px var(--line); }
.table-note b { color: var(--text); font-weight: 600; }

/* ---------- game shell ---------- */
.players-strip { display: flex; gap: 6px; margin-bottom: 14px; }
.pl {
  flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 7px; padding: 5px 10px 5px 5px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.05); box-shadow: inset 0 0 0 1px var(--line); position: relative;
  transition: background 0.3s, box-shadow 0.3s;
}
.pl .avatar { width: 30px; height: 30px; box-shadow: 0 0 0 2px var(--pc); }
.pl .txt { min-width: 0; line-height: 1.15; }
.pl .nm { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl .sc { font-size: 13px; font-weight: 800; color: var(--pc); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl .sc .av { width: 1.1em; height: 1.1em; }
.pl.turn { background: color-mix(in srgb, var(--pc) 20%, transparent); box-shadow: inset 0 0 0 1.5px var(--pc); }
.pl.turn::after { content: ''; position: absolute; right: 8px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--pc); animation: pulse 1.2s infinite; }
.pl.out { opacity: 0.35; }

.status { text-align: center; font-weight: 600; font-size: 15px; color: var(--muted); margin: 2px 0 14px; min-height: 22px; }
.status.me { color: var(--text); }
.status b { color: var(--amber); }

.board { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.log { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.log div { padding: 9px 13px; background: rgba(255, 255, 255, 0.04); border-radius: 14px; }
.log div:last-child { color: var(--text); background: rgba(255, 255, 255, 0.07); }

.big-word {
  font-size: clamp(30px, 10vw, 46px); font-weight: 800; text-align: center; letter-spacing: -0.035em; line-height: 1.05;
  padding: 34px 16px; border-radius: var(--r-xl); word-break: break-word;
  background: linear-gradient(160deg, #2a2a35, #17171e); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), inset 0 0 0 1px var(--line);
  animation: pop 0.4s var(--spring);
}
.timer {
  --p: 1; width: 92px; height: 92px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center;
  font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums;
  background: radial-gradient(closest-side, var(--bg) 82%, transparent 83% 100%), conic-gradient(var(--amber) calc(var(--p) * 360deg), rgba(255, 255, 255, 0.08) 0);
}

/* dice */
.dice { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.die {
  width: 54px; height: 54px; border-radius: 15px; color: #16121c;
  background: linear-gradient(160deg, #ffffff, #e9e6f0);
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 9px; gap: 2px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.1), 0 8px 16px -8px rgba(0, 0, 0, 0.8);
  transition: transform 0.2s var(--spring), box-shadow 0.2s;
}
.die.rolling { animation: roll 0.55s var(--spring); }
.die i { width: 9px; height: 9px; border-radius: 50%; background: currentColor; place-self: center; visibility: hidden; }
.die.sm { width: 34px; height: 34px; border-radius: 10px; padding: 5px; }
.die.sm i { width: 5px; height: 5px; }
.die.blank { background: rgba(255, 255, 255, 0.05); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.die.held { transform: translateY(-8px); box-shadow: 0 0 0 3px var(--amber), 0 12px 22px -8px var(--amber); }
.die.hit { background: linear-gradient(160deg, #ffd56b, #ffb22e); }
.die.wild { color: var(--coral); }
.die[data-v='1'] i:nth-child(5),
.die[data-v='2'] i:nth-child(1), .die[data-v='2'] i:nth-child(9),
.die[data-v='3'] i:nth-child(1), .die[data-v='3'] i:nth-child(5), .die[data-v='3'] i:nth-child(9),
.die[data-v='4'] i:is(:nth-child(1), :nth-child(3), :nth-child(7), :nth-child(9)),
.die[data-v='5'] i:is(:nth-child(1), :nth-child(3), :nth-child(5), :nth-child(7), :nth-child(9)),
.die[data-v='6'] i:is(:nth-child(1), :nth-child(3), :nth-child(4), :nth-child(6), :nth-child(7), :nth-child(9)) { visibility: visible; }

.bid-big { text-align: center; }
.bid-big .q { font-size: 46px; font-weight: 800; display: inline-flex; align-items: center; gap: 12px; margin-top: 6px; }

.stepper { display: flex; align-items: center; gap: 14px; justify-content: center; }
.stepper .val { font-size: 34px; font-weight: 800; min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; }
.faces { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.faces .die { width: 100%; height: auto; aspect-ratio: 1; cursor: pointer; }
.faces .die.sel { box-shadow: 0 0 0 3px var(--amber); transform: translateY(-4px); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions .full { grid-column: span 2; }

/* yahtzee sheet */
.sheet-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.sheet-table th, .sheet-table td { padding: 9px 6px; text-align: center; border-bottom: 1px solid var(--line); }
.sheet-table th:first-child, .sheet-table td:first-child { text-align: left; padding-left: 14px; }
.sheet-table thead th { font-size: 18px; }
.sheet-table tr.sep td { border-bottom: 1px solid var(--line-2); }
.sheet-table .opt { color: var(--amber); font-weight: 800; border-radius: 10px; background: rgba(255, 178, 46, 0.14); width: 100%; padding: 6px 0; }
.sheet-table .zero { color: var(--dim); background: rgba(255, 255, 255, 0.04); }
.sheet-table tfoot td { font-weight: 800; border-bottom: 0; font-size: 16px; }
.sheet-table .me-col { background: rgba(255, 255, 255, 0.025); }

/* playing cards */
.hand { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.pcard {
  width: 52px; height: 74px; border-radius: 11px; color: #1d1722;
  background: linear-gradient(170deg, #ffffff, #efebf3);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; font-size: 19px; line-height: 1; letter-spacing: -0.02em;
  box-shadow: 0 8px 16px -8px rgba(0, 0, 0, 0.9);
  transition: transform 0.2s var(--spring), box-shadow 0.2s;
}
.pcard small { font-size: 19px; margin-top: 4px; }
.pcard.red { color: #e3392b; }
.pcard.sel { transform: translateY(-12px); box-shadow: 0 0 0 3px var(--amber), 0 14px 22px -8px var(--amber); }
.pcard.back { background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.25) 0 18%, transparent 19%), repeating-linear-gradient(45deg, #ff6a57 0 6px, #ec4637 6px 12px); box-shadow: inset 0 0 0 3px #fff, 0 8px 16px -8px rgba(0, 0, 0, 0.9); }
.pile { display: flex; justify-content: center; align-items: center; gap: 22px; min-height: 110px; }
.pile .stack { position: relative; width: 64px; height: 90px; }
.pile .stack .pcard { position: absolute; width: 64px; height: 90px; }
.claim-chip { display: inline-block; font-weight: 700; font-size: 15px; padding: 7px 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); }
.ranks { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; }
.ranks button { height: 44px; border-radius: 12px; background: rgba(255, 255, 255, 0.07); font-weight: 700; font-size: 14px; }
.ranks button.sel { background: var(--amber); color: #221600; }

/* memo */
.memo-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.memo-card {
  aspect-ratio: 1; border-radius: 14px; font-size: clamp(20px, 6vw, 30px); display: grid; place-items: center;
  background: linear-gradient(160deg, #262631, #191920); box-shadow: inset 0 0 0 1px var(--line-2);
  transition: transform 0.3s var(--spring), background 0.3s;
}
.memo-card.face { background: linear-gradient(170deg, #ffffff, #ece8f2); animation: flip 0.35s var(--spring); }
.memo-card.taken { background: color-mix(in srgb, var(--pc) 35%, var(--bg-2)); box-shadow: none; opacity: 0.6; }
.memo-card:not(.face):not(.taken)::before { content: ''; width: 22%; aspect-ratio: 1; border-radius: 50%; background: rgba(255, 255, 255, 0.1); }

/* generic choices */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.choice {
  min-height: 54px; padding: 6px 8px; border-radius: 16px; background: rgba(255, 255, 255, 0.07); box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 700; font-size: 17px; transition: transform 0.15s var(--spring), background 0.2s;
}
.choice:active:not(:disabled) { transform: scale(0.94); }
.choice.sel { background: var(--amber); color: #221600; box-shadow: none; }
.choice.used { opacity: 0.25; }

/* pieces stay fully visible when not interactive */
.memo-card:disabled, .pcard:disabled, .choice:disabled, .board .card button:disabled:not(.btn):not(.icon-btn) { opacity: 1; cursor: default; }

/* ---------- overlays / sheets / toasts ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(5, 5, 8, 0.7); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); display: grid; place-items: center; padding: 20px; animation: fade 0.25s; }
.over-card { width: min(400px, 100%); text-align: center; padding: 26px 20px 20px; border-radius: var(--r-xl); animation: pop 0.5s var(--spring); }
.over-card .trophy { width: 120px; height: 120px; animation: bob 2.4s ease-in-out infinite; filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.5)); }
.over-card h2 { font-size: 30px; font-weight: 800; margin: 10px 0 6px; }
.over-card .btns { display: grid; gap: 8px; margin-top: 20px; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 41; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }

.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(5, 5, 8, 0.55); backdrop-filter: blur(6px); animation: fade 0.2s; }
.sheet {
  position: fixed; z-index: 51; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px; max-height: 90dvh; overflow-y: auto;
  background: #121217; border-radius: 30px 30px 0 0; box-shadow: inset 0 1px 0 var(--line-2);
  padding: 10px 18px calc(var(--safe-bottom) + 22px); animation: up 0.42s var(--spring);
}
.sheet { scrollbar-width: none; }
/* primary action of a sheet stays reachable without scrolling */
.sheet .sheet-cta { position: sticky; bottom: calc(-22px - var(--safe-bottom)); margin: 20px -18px calc(-22px - var(--safe-bottom)); padding: 14px 18px calc(var(--safe-bottom) + 16px); background: linear-gradient(to top, #121217 70%, rgba(18, 18, 23, 0)); }
.sheet .grab { width: 40px; height: 5px; border-radius: 99px; background: var(--line-2); margin: 0 auto 14px; }
.sheet h2 { font-size: 24px; font-weight: 800; }
.rules-hero { min-height: 150px; margin-bottom: 14px; animation: none; padding: 18px; }
.rules-hero .ico { width: 110px; height: 110px; }
.rules-hero h2 { font-size: 28px; }
.rule-block { margin-top: 16px; }
.rule-block h3 { font-size: 15px; font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.rule-block h3 span { width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; background: rgba(255, 255, 255, 0.08); }
.rule-block ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rule-block li { padding: 11px 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); font-size: 15px; line-height: 1.45; }
.sheet .note { font-size: 13.5px; color: var(--muted); padding: 12px 14px; border-radius: 14px; margin-top: 14px; background: rgba(255, 178, 46, 0.07); box-shadow: inset 0 0 0 1px rgba(255, 178, 46, 0.15); }
.pick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.pick-grid .tile { min-height: 128px; }
.pick-grid .tile .ico { width: 66px; height: 66px; }
.pick-grid .tile h3 { font-size: 16px; }

.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 12px 0 18px; }
.avatars button { aspect-ratio: 1; border-radius: 18px; background: rgba(255, 255, 255, 0.05); box-shadow: inset 0 0 0 1px var(--line); display: grid; place-items: center; transition: transform 0.2s var(--spring); }
.avatars button .av { width: 72%; height: 72%; vertical-align: 0; }
.avatars button.sel { background: rgba(255, 255, 255, 0.14); box-shadow: inset 0 0 0 2px var(--text); transform: scale(1.06); }

#toasts { position: fixed; z-index: 60; left: 0; right: 0; top: calc(var(--safe-top) + 12px); display: grid; justify-items: center; gap: 8px; pointer-events: none; }
.toast { padding: 12px 18px; border-radius: 999px; background: var(--text); color: #0b0b0f; font-weight: 600; font-size: 14px; box-shadow: 0 14px 30px -10px rgba(0, 0, 0, 0.7); animation: drop 0.4s var(--spring); max-width: 90vw; }
.toast.err { background: #ff5c4d; color: #fff; }
.conn { position: fixed; top: calc(var(--safe-top) + 12px); left: 50%; transform: translateX(-50%); z-index: 35; font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 999px; color: var(--muted); }

/* chat */
.chat-btn { position: relative; }
.chat-btn .dot { position: absolute; top: 7px; right: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 2px var(--bg); }
.chat-list { display: flex; flex-direction: column; gap: 8px; max-height: 45dvh; overflow-y: auto; margin: 14px 0 12px; }
.msg { display: flex; gap: 8px; align-items: flex-end; }
.msg .avatar { width: 28px; height: 28px; }
.msg .bubble { padding: 9px 14px; border-radius: 20px 20px 20px 6px; background: rgba(255, 255, 255, 0.07); font-size: 15px; max-width: 75%; }
.msg .bubble b { display: block; font-size: 11px; color: var(--pc); font-weight: 700; }
.msg.mine { flex-direction: row-reverse; }
.msg.mine .bubble { border-radius: 20px 20px 6px 20px; background: color-mix(in srgb, var(--pc) 30%, #1a1a22); }
.quick { display: flex; gap: 6px; margin-bottom: 10px; overflow-x: auto; scrollbar-width: none; }
.quick button { padding: 7px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); font-size: 16px; white-space: nowrap; }
.chat-form { display: flex; gap: 8px; }

@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
@keyframes pop { from { transform: scale(0.88); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }
@keyframes dock { from { transform: translate(-50%, 120%); } }
@keyframes drop { from { transform: translateY(-20px); opacity: 0; } }
@keyframes roll { 0% { transform: rotate(-220deg) scale(0.4); opacity: 0; } }
@keyframes flip { from { transform: rotateY(90deg); } }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-5deg); } }
@keyframes pulse { 50% { opacity: 0.3; } }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

.games-grid .tile:nth-child(2) { animation-delay: 0.03s; } .games-grid .tile:nth-child(3) { animation-delay: 0.06s; }
.games-grid .tile:nth-child(4) { animation-delay: 0.09s; } .games-grid .tile:nth-child(5) { animation-delay: 0.12s; }
.games-grid .tile:nth-child(6) { animation-delay: 0.15s; } .games-grid .tile:nth-child(n+7) { animation-delay: 0.18s; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (min-width: 600px) { .die { width: 60px; height: 60px; } .tile { min-height: 180px; } }
