:root {
  --bg: #0b1220;
  --ink: #eef2ff;
  --muted: #94a3c4;
  --line: rgba(255, 255, 255, .09);
  --glass: rgba(20, 28, 48, .66);
  --glass-2: rgba(255, 255, 255, .05);
  --accent: #7c5cff;
  --accent-2: #21d4fd;
  --gold: #f6c453;
  --green: #3ddc84;
  --red: #ff5d6c;
  --radius: 18px;
  --font-head: "Space Grotesk", Inter, system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  color: var(--ink); background: var(--bg); min-height: 100vh; overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
.bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(700px 500px at 8% -5%, rgba(124, 92, 255, .32), transparent 60%),
    radial-gradient(600px 500px at 100% 10%, rgba(33, 212, 253, .18), transparent 60%),
    radial-gradient(800px 600px at 50% 120%, rgba(255, 93, 108, .12), transparent 60%),
    linear-gradient(180deg, #0d1426, #080d18);
}
.bg::after {
  content: ""; position: absolute; inset: 0; opacity: .35;
  background-image: radial-gradient(rgba(255,255,255,.06) 1px, transparent 1px); background-size: 26px 26px;
  mask-image: linear-gradient(180deg, black, transparent 70%);
}
h1, h2, h3 { font-family: var(--font-head); margin: 0 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.15rem; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; justify-content: center; }
.pad { padding: 3rem 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
svg.ic { width: 1em; height: 1em; fill: currentColor; vertical-align: -.14em; flex: none; }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 12px; padding: .65rem 1.15rem;
  color: #fff; background: linear-gradient(135deg, var(--accent), #5b8cff);
  box-shadow: 0 8px 22px rgba(124, 92, 255, .32), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .12s, filter .15s, box-shadow .15s, background .15s; display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
  text-decoration: none !important; -webkit-tap-highlight-color: transparent;
}
button:hover, .btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: not-allowed; transform: none; filter: none; }
button.ghost, .btn.ghost, .ghost-btn { background: var(--glass-2); color: var(--ink); box-shadow: none; border: 1px solid var(--line); }
button.ghost:hover, .ghost-btn:hover { background: rgba(255,255,255,.1); }
.ghost-btn { display: inline-grid; place-items: center; min-width: 38px; height: 38px; border-radius: 12px; padding: 0 .6rem; font-size: 1.1rem; text-decoration: none !important; color: var(--ink); }
button.small { padding: .35rem .7rem; font-size: .82rem; border-radius: 10px; }
button.big { padding: .85rem 1.6rem; font-size: 1.05rem; }
button.icon { padding: .45rem .55rem; font-size: 1.05rem; position: relative; }
button.danger { background: linear-gradient(135deg, #ff5d6c, #ff8a5b); box-shadow: 0 8px 22px rgba(255, 93, 108, .3); }
button.success { background: linear-gradient(135deg, #20c997, #3ddc84); box-shadow: 0 8px 22px rgba(61, 220, 132, .25); color: #062615; }
input, select {
  font: inherit; color: var(--ink); background: rgba(0, 0, 0, .28); border: 1px solid var(--line);
  border-radius: 12px; padding: .65rem .85rem; width: 100%; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, .25); }
input[type=checkbox] { width: auto; accent-color: var(--accent); transform: scale(1.2); }
input[type=range] { padding: 0; accent-color: var(--accent); }
select option { background: #141c30; }
label { display: block; font-size: .88rem; color: var(--muted); }
label input, label select { margin-top: .3rem; }
label.check { display: flex; gap: .6rem; align-items: center; color: var(--ink); margin: .5rem 0; }

.glass {
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
}
.panel { padding: 1.2rem 1.3rem; }
.tag { font-size: .72rem; padding: .12rem .5rem; border-radius: 99px; background: rgba(255,255,255,.08); color: var(--muted); font-weight: 600; vertical-align: middle; }
.tag.host { background: linear-gradient(135deg, var(--gold), #ff9f43); color: #2a1800; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #56607a; border: 2px solid var(--bg); }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }

.avatar {
  --av: #5b6ee8; border-radius: 50%; display: inline-grid; place-items: center; flex: none; color: #fff;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--av) 60%, #fff), var(--av) 55%, color-mix(in srgb, var(--av) 70%, #000));
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.18), 0 4px 12px rgba(0,0,0,.35);
}
.avatar svg { width: 60%; height: 60%; fill: currentColor; filter: drop-shadow(0 1px 1px rgba(0,0,0,.3)); }

/* ---------- top nav ---------- */
.topnav {
  position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: calc(.6rem + env(safe-area-inset-top, 0px)) 18px .6rem; background: rgba(8, 13, 24, .6);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .5rem; font-family: var(--font-head); font-size: 1.2rem; color: var(--ink); text-decoration: none !important; }
.brand svg { width: 30px; height: 30px; padding: 5px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.brand b { color: var(--muted); font-weight: 500; }
.nav-right { display: flex; align-items: center; gap: .5rem; }
.me-link { display: flex; align-items: center; gap: .5rem; color: var(--ink); padding: .2rem .7rem .2rem .2rem; border-radius: 99px; background: var(--glass-2); border: 1px solid var(--line); text-decoration: none !important; }
.page { max-width: 1000px; margin: 0 auto; padding: 1.4rem 16px 4rem; }
.page.wide { max-width: 1320px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; gap: 3rem; align-items: center; max-width: 1100px; margin: 0 auto; padding: 2rem 16px; }
.auth-hero h1 { font-size: clamp(2.4rem, 6vw, 4rem); line-height: 1; }
.auth-hero h1 span { background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-hero p { color: var(--muted); font-size: 1.1rem; max-width: 30rem; }
.logo-orb { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; margin-bottom: 1.2rem; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 20px 50px rgba(124, 92, 255, .45); animation: float 6s ease-in-out infinite; }
.logo-orb svg { width: 42px; height: 42px; fill: #fff; }
.hero-icons { display: flex; gap: .8rem; margin-top: 1.6rem; flex-wrap: wrap; }
.hero-icons svg { width: 40px; height: 40px; padding: 8px; border-radius: 12px; background: var(--glass-2); border: 1px solid var(--line); fill: var(--muted); }
@keyframes float { 50% { transform: translateY(-8px) rotate(-3deg); } }
.auth-card { padding: 1.6rem; display: grid; gap: 1rem; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: rgba(0,0,0,.25); border-radius: 12px; padding: 4px; }
.tabs button { background: transparent; box-shadow: none; color: var(--muted); padding: .5rem; }
.tabs button.on { background: rgba(255,255,255,.1); color: var(--ink); }
.field-label { font-size: .88rem; color: var(--muted); }
.picker .avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: .4rem; }
.pick-av { background: transparent; box-shadow: none; padding: 3px; border-radius: 50%; border: 2px solid transparent; }
.pick-av.sel { border-color: var(--accent-2); }
.swatches { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.swatch { width: 26px; height: 26px; padding: 0; border-radius: 50%; box-shadow: none; border: 2px solid transparent; }
.swatch.sel { border-color: #fff; transform: scale(1.12); }

/* ---------- home ---------- */
.home { display: grid; grid-template-columns: 1fr 300px; gap: 1.4rem; align-items: start; }
.welcome { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1.2rem 1.4rem; margin-bottom: 1.2rem;
  background: linear-gradient(120deg, rgba(124,92,255,.28), rgba(33,212,253,.12)), var(--glass); }
.welcome p { margin: 0; }
.joinf { display: flex; gap: .5rem; }
.joinf input { width: 150px; text-transform: uppercase; letter-spacing: .15em; font-weight: 700; }
h3.sec { font-size: .8rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin: 1.4rem 0 .7rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .9rem; }
.tile {
  --tc: #7c5cff; text-align: left; padding: 0; overflow: hidden; display: flex; flex-direction: column; align-items: stretch; color: var(--ink);
  background: var(--glass); border: 1px solid var(--line); box-shadow: 0 12px 30px rgba(0,0,0,.25); border-radius: var(--radius);
}
.tile:hover { transform: translateY(-4px); box-shadow: 0 18px 40px rgba(0,0,0,.4), 0 0 0 1px color-mix(in srgb, var(--tc) 60%, transparent); filter: none; }
.tile-art { height: 104px; display: grid; place-items: center; position: relative; overflow: hidden;
  background: radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--tc) 85%, #fff 15%), var(--tc) 45%, color-mix(in srgb, var(--tc) 50%, #000)); }
.tile-art::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(135deg, rgba(255,255,255,.07) 0 10px, transparent 10px 22px); }
.tile-art svg { width: 64px; height: 64px; fill: #fff; filter: drop-shadow(0 6px 10px rgba(0,0,0,.35)); transition: transform .3s; position: relative; z-index: 1; }
.tile:hover .tile-art svg { transform: scale(1.12) rotate(-6deg); }
.tile-body { padding: .8rem .95rem 1rem; display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.tile-name { font-family: var(--font-head); font-weight: 700; font-size: 1.08rem; }
.tile-tag { font-size: .84rem; color: var(--muted); font-weight: 400; flex: 1; }
.tile-meta { display: flex; gap: .6rem; font-size: .76rem; color: var(--muted); font-weight: 500; align-items: center; }
.tile-meta .cat { margin-left: auto; }
.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .8rem; }
.room-card { --tc: #7c5cff; display: flex; gap: .8rem; align-items: center; padding: .8rem 1rem; color: var(--ink); text-decoration: none !important; border-left: 4px solid var(--tc); }
.room-card > svg { width: 34px; height: 34px; fill: var(--tc); }
.room-card small { display: block; color: var(--muted); }
.friends-panel { padding: 1.1rem; position: sticky; top: 76px; display: grid; gap: .7rem; max-height: calc(100vh - 100px); overflow: auto; }
.fr-section { font-size: .74rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-top: .6rem; }
.fr-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .2rem; }
.fr-list li { display: flex; align-items: center; gap: .5rem; padding: .35rem .3rem; border-radius: 12px; }
.fr-list li:hover { background: rgba(255,255,255,.04); }
.fr-user { display: flex; align-items: center; gap: .55rem; flex: 1; min-width: 0; color: var(--ink); text-decoration: none !important; position: relative; }
.fr-user .dot { position: absolute; left: 22px; top: 22px; }
.fr-name { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; flex: 1; }
.fr-name small { color: var(--muted); font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.credit { font-size: .76rem; color: var(--muted); margin-top: 2.5rem; opacity: .7; }

/* ---------- profile ---------- */
.profile { display: grid; gap: 1rem; max-width: 760px; margin: 0 auto; }
.prof-head { display: flex; align-items: center; gap: 1.2rem; padding: 1.4rem; flex-wrap: wrap; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.stat { padding: 1rem; text-align: center; }
.stat b { display: block; font-family: var(--font-head); font-size: 1.8rem; }
.stat span { color: var(--muted); font-size: .85rem; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--muted); font-weight: 500; font-size: .82rem; }
.bar { height: 8px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.recent { list-style: none; padding: 0; margin: 0; }
.recent li { display: flex; gap: .7rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.res { font-size: .72rem; font-weight: 700; padding: .15rem .5rem; border-radius: 8px; }
.res.w { background: rgba(61,220,132,.15); color: var(--green); }
.res.l { background: rgba(255,93,108,.12); color: var(--red); }

/* ---------- room ---------- */
.room { display: flex; flex-direction: column; min-height: 100vh; }
.room-bar {
  display: flex; align-items: center; gap: .7rem; padding: calc(.5rem + env(safe-area-inset-top, 0px)) 14px .5rem;
  background: rgba(8,13,24,.65); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.room-title { display: flex; align-items: center; gap: .55rem; flex: 1; min-width: 0; font-family: var(--font-head); font-size: 1.1rem; }
.room-title svg { width: 24px; height: 24px; }
.room-title b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code-pill { font-family: ui-monospace, monospace; font-size: .8rem; letter-spacing: .12em; padding: .2rem .55rem; border-radius: 8px; background: rgba(255,255,255,.08); color: var(--muted); cursor: pointer; }
.badge { position: absolute; top: -4px; right: -4px; background: var(--red); color: #fff; border-radius: 99px; font-size: .68rem; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 4px; }
.room-body { flex: 1; display: flex; min-height: 0; position: relative; }
.stage-area { flex: 1; min-width: 0; position: relative; padding: 14px; }
.chat { width: 300px; margin: 14px 14px 14px 0; display: flex; flex-direction: column; max-height: calc(100vh - 90px); position: sticky; top: 72px; align-self: flex-start; height: calc(100vh - 90px); }
.chat[hidden] { display: none; }
.chat-log { flex: 1; overflow: auto; padding: .8rem; display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; }
.msg { padding: .35rem .6rem; border-radius: 12px; background: rgba(255,255,255,.05); word-wrap: break-word; }
.msg.mine { background: rgba(124,92,255,.2); }
.msg b { color: var(--accent-2); font-weight: 600; margin-right: .2rem; }
#chatf { padding: .6rem; border-top: 1px solid var(--line); }

.lobby { max-width: 980px; margin: 0 auto; display: grid; gap: 1rem; }
.lobby-hero { --tc: #7c5cff; display: flex; gap: 1.3rem; align-items: center; padding: 1.3rem; flex-wrap: wrap;
  background: linear-gradient(120deg, color-mix(in srgb, var(--tc) 30%, transparent), transparent 70%), var(--glass); }
.lh-art { width: 92px; height: 92px; border-radius: 24px; display: grid; place-items: center; flex: none;
  background: radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--tc) 80%, #fff), var(--tc) 50%, color-mix(in srgb, var(--tc) 50%, #000)); box-shadow: 0 14px 34px color-mix(in srgb, var(--tc) 40%, transparent); }
.lh-art svg { width: 58px; height: 58px; fill: #fff; }
.lobby-hero > div:last-child { flex: 1; min-width: 240px; }
.share { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; flex-wrap: wrap; }
.share input { flex: 1; min-width: 180px; font-size: .85rem; padding: .45rem .7rem; }
.lobby-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.members { list-style: none; padding: 0; margin: .4rem 0 1rem; }
.members li { display: flex; align-items: center; gap: .7rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.mem-actions { display: flex; gap: .25rem; }
.invite { margin-top: 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.chip { background: var(--glass-2); border: 1px solid var(--line); box-shadow: none; color: var(--ink); padding: .25rem .6rem .25rem .25rem; border-radius: 99px; font-size: .85rem; }
.settings { display: grid; gap: .7rem; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 1rem; color: var(--ink); }
.setting > span { color: var(--muted); }
.setting select, .setting input[type=number] { width: auto; max-width: 60%; margin: 0; }
.start-row { margin-top: 1.3rem; display: flex; flex-direction: column; gap: .6rem; align-items: flex-start; }

.game-root { min-height: calc(100vh - 100px); }
#result-layer { position: absolute; inset: 0; pointer-events: none; display: grid; place-items: center; z-index: 30; }
.result-card { pointer-events: auto; width: min(440px, calc(100% - 32px)); padding: 1.4rem; animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
.result-card.min { position: absolute; bottom: 16px; right: 16px; width: 300px; padding: .8rem 1rem; }
.result-card.min .podium, .result-card.min p { display: none; }
.res-head { display: flex; gap: .9rem; align-items: center; }
.res-head > svg { width: 48px; height: 48px; fill: var(--gold); filter: drop-shadow(0 4px 14px rgba(246,196,83,.5)); }
.res-head > div { flex: 1; }
.res-head p { margin: 0; color: var(--muted); }
.podium { list-style: none; padding: 0; margin: 1rem 0; counter-reset: rank; }
.podium li { display: flex; align-items: center; gap: .6rem; padding: .45rem .5rem; border-radius: 12px; counter-increment: rank; }
.podium li::before { content: counter(rank); width: 1.4em; color: var(--muted); font-weight: 700; }
.podium li.win { background: linear-gradient(90deg, rgba(246,196,83,.18), transparent); }
.podium li > span:not(.avatar) { flex: 1; }
.podium li b svg { fill: var(--gold); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

/* ---------- shared game bits ---------- */
.seatchip { display: flex; align-items: center; gap: .55rem; padding: .4rem .7rem .4rem .4rem; border-radius: 99px; background: var(--glass); border: 1px solid var(--line); transition: box-shadow .2s, transform .2s; min-width: 0; }
.seatchip.active { box-shadow: 0 0 0 2px var(--accent-2), 0 0 24px rgba(33,212,253,.35); }
.seatchip.me { background: rgba(124,92,255,.2); }
.seatchip.dim { opacity: .45; }
.sc-meta { min-width: 0; line-height: 1.2; }
.sc-name { font-weight: 600; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.sc-name small { color: var(--muted); font-weight: 400; }
.sc-sub { font-size: .76rem; color: var(--muted); white-space: nowrap; }
.sc-badge { margin-left: .2rem; font-weight: 700; font-family: var(--font-head); }
.turn-banner { text-align: center; font-family: var(--font-head); font-size: 1.15rem; margin: .4rem 0; min-height: 1.7em; }
.turn-banner.mine { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 700; }
.timerbar { height: 4px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; margin: .3rem auto; max-width: 360px; }
.timerbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--gold), var(--red)); transform-origin: left; }

/* standard playing cards */
.pcard {
  --w: 64px; width: var(--w); height: calc(var(--w) * 1.42); border-radius: calc(var(--w) * .1); position: relative; flex: none;
  background: linear-gradient(160deg, #fff, #eef0f5); color: #1b2233; box-shadow: 0 6px 14px rgba(0,0,0,.35), inset 0 0 0 1px rgba(0,0,0,.08);
  font-family: Georgia, "Times New Roman", serif; user-select: none; transition: transform .15s, box-shadow .15s, filter .2s;
}
.pcard.red { color: #d42a3c; }
.pcard .corner { position: absolute; font-weight: 700; line-height: .95; text-align: center; font-size: calc(var(--w) * .22); }
.pcard .tl { top: 5%; left: 7%; }
.pcard .br { bottom: 5%; right: 7%; transform: rotate(180deg); }
.pcard .pip { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--w) * .55); }
.pcard .pip.face { font-size: calc(var(--w) * .5); font-weight: 700; background: radial-gradient(circle, rgba(212,42,60,.08), transparent 65%); }
.pcard.back { background: repeating-linear-gradient(45deg, #3b2fa0 0 6px, #4f42c4 6px 12px); box-shadow: 0 6px 14px rgba(0,0,0,.35), inset 0 0 0 3px #fff, inset 0 0 0 5px #3b2fa0; }
.pcard.sm { --w: 44px; }
.pcard.lg { --w: 80px; }
.pcard.playable { cursor: pointer; }
.pcard.playable:hover { transform: translateY(-10px); box-shadow: 0 14px 24px rgba(0,0,0,.45), 0 0 0 2px var(--accent-2); }
.pcard.sel { transform: translateY(-16px); box-shadow: 0 14px 24px rgba(0,0,0,.45), 0 0 0 3px var(--gold); }
.pcard.dim { filter: brightness(.55); }

/* ---------- toasts, misc ---------- */
#toasts { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .45rem; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { padding: .6rem 1rem; border-radius: 14px; background: rgba(14, 20, 36, .92); border: 1px solid var(--line); box-shadow: 0 14px 34px rgba(0,0,0,.4); animation: up .25s ease-out; display: flex; gap: .5rem; align-items: center; backdrop-filter: blur(10px); }
.toast.error { border-color: var(--red); }
.toast.good { border-color: var(--green); }
.toast.out { opacity: 0; transform: translateY(8px); transition: .3s; }
@keyframes up { from { transform: translateY(12px); opacity: 0; } }
#offline { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 200; background: var(--red); color: #fff; padding: .35rem .9rem; border-radius: 99px; font-size: .85rem; font-weight: 600; }
.confetti { position: fixed; top: -20px; width: 9px; height: 14px; z-index: 300; pointer-events: none; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(900deg); } }

@media (max-width: 1000px) {
  .home { grid-template-columns: 1fr; }
  .friends-panel { position: static; max-height: none; order: 1; }
  .chat { position: fixed; right: 10px; bottom: 10px; top: auto; width: min(340px, calc(100vw - 20px)); height: 60vh; margin: 0; z-index: 40; }
}
@media (max-width: 760px) {
  .auth { grid-template-columns: 1fr; gap: 1.5rem; }
  .lobby-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr 1fr; gap: .5rem; }
  .stage-area { padding: 8px; }
  .me-link > span:not(.avatar), .brand span { display: none; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .tile-art { height: 84px; }
  .pcard { --w: 52px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01s !important; transition-duration: .01s !important; } }

/* ---------- home: table hero ---------- */
.welcome { position: relative; overflow: hidden; }
.welcome-art { display: grid; grid-template-columns: repeat(3, 54px); gap: .6rem; }
.welcome-art span { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; background: rgba(255,255,255,.07); border: 1px solid var(--line); animation: float 5s ease-in-out infinite; animation-delay: calc(var(--k) * -.8s); }
.welcome-art svg { width: 30px; height: 30px; fill: rgba(255,255,255,.85); }
#newtable svg { width: 20px; height: 20px; fill: currentColor; vertical-align: -4px; margin-right: .2rem; }
.room-card.live { border-left-color: var(--green, #3ddc84); }
.room-card .stack { display: flex; } .room-card .stack .avatar:not(:first-child) { margin-left: -12px; }
.room-card .btn { margin-left: auto; }
.room-card > div:not(.stack) { min-width: 0; }
@media (max-width: 760px) { .welcome-art { display: none; } }

/* ---------- the table (lobby) ---------- */
.table { display: flex; flex-direction: column; gap: 1rem; max-width: 1200px; margin: 0 auto; }
.table-head { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.2rem; flex-wrap: wrap;
  background: linear-gradient(120deg, rgba(124,92,255,.22), rgba(33,212,253,.08)), var(--glass); }
.th-people { display: flex; } .th-people .avatar:not(:first-child) { margin-left: -14px; } .th-people .avatar { box-shadow: 0 0 0 3px #141a2e; }
.th-name { margin: 0; display: flex; align-items: center; gap: .4rem; }
.table-head .share { display: flex; gap: .4rem; align-items: center; }
.table-head .share input { width: 230px; font-size: .8rem; }
.mono { font-family: ui-monospace, monospace; letter-spacing: .1em; }
.eyebrow { text-transform: uppercase; letter-spacing: .16em; font-size: .7rem; font-weight: 700; color: var(--accent-2); }
.table-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
.table-main { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.table-side { display: flex; flex-direction: column; gap: 1rem; }
.now-playing { --tc: #7c5cff; display: flex; gap: 1.2rem; padding: 1.2rem; align-items: flex-start; flex-wrap: wrap;
  background: linear-gradient(135deg, color-mix(in srgb, var(--tc) 30%, transparent), transparent 60%), var(--glass); }
.np-art { width: 96px; height: 96px; border-radius: 24px; display: grid; place-items: center; background: var(--tc); box-shadow: 0 16px 40px color-mix(in srgb, var(--tc) 50%, transparent); flex: none; }
.np-art svg { width: 62px; height: 62px; fill: #fff; }
.now-playing h2 { font-size: 1.8rem; margin: .1rem 0; }
.now-playing .settings { margin-top: .8rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .5rem; }
.np-actions { display: flex; flex-direction: column; gap: .4rem; align-items: stretch; min-width: 190px; }
.np-actions p { margin: 0; text-align: center; }
.pick-hero { display: flex; align-items: center; gap: 1rem; padding: 1.3rem; flex-wrap: wrap;
  background: radial-gradient(circle at 90% 50%, rgba(246,196,83,.22), transparent 50%), var(--glass); }
.pick-hero h2 { font-size: 1.8rem; margin: .1rem 0; }
.spin-btn { background: linear-gradient(135deg, #f6c453, #ff7a59); color: #2a1300; }
.spin-btn svg { width: 22px; height: 22px; fill: currentColor; vertical-align: -5px; margin-right: .2rem; }
button.ghost.spin-btn { background: rgba(246,196,83,.12); color: var(--gold, #f6c453); border-color: rgba(246,196,83,.35); }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem; }
.pg { --tc: #7c5cff; position: relative; display: flex; gap: .6rem; align-items: center; padding: .6rem; border-radius: 16px; cursor: pointer;
  background: var(--glass); border: 1px solid var(--line); transition: transform .12s, border-color .12s, box-shadow .12s; }
.pg:hover { transform: translateY(-2px); border-color: var(--tc); }
.pg.voted { border-color: var(--tc); box-shadow: 0 0 0 2px var(--tc), 0 8px 24px color-mix(in srgb, var(--tc) 35%, transparent); }
.pg.current { background: linear-gradient(135deg, color-mix(in srgb, var(--tc) 25%, transparent), transparent), var(--glass); }
.pg.nofit { opacity: .42; }
.pg-art { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: var(--tc); flex: none; }
.pg-art svg { width: 30px; height: 30px; fill: #fff; }
.pg-body { min-width: 0; flex: 1; } .pg-body b { display: block; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .pg-body small { color: var(--muted); font-size: .74rem; }
.pg-votes { display: flex; min-height: 20px; margin-top: .2rem; } .pg-votes .avatar:not(:first-child) { margin-left: -6px; }
.pg-play { position: absolute; right: .5rem; top: .5rem; opacity: 0; transition: opacity .12s; padding: .25rem .6rem; }
.pg:hover .pg-play, .pg.voted .pg-play { opacity: 1; }
@media (hover: none) { .pg-play { opacity: 1; } }
.members li.out { opacity: .6; }
.tally { list-style: none; padding: 0; margin: 0 0 .6rem; display: flex; flex-direction: column; gap: .35rem; }
.tally li { display: flex; align-items: center; gap: .5rem; }
.tally .rk { width: 1.3em; text-align: center; color: var(--muted); font-weight: 700; }
.tally b { font-family: var(--font-head); font-size: 1.1rem; }
.hist { list-style: none; padding: .5rem 0 0; margin: 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: .3rem; font-size: .84rem; }
.hist li { display: flex; align-items: center; gap: .4rem; } .hist svg { width: 16px; height: 16px; fill: var(--muted); } .hist small { margin-left: auto; }
@media (max-width: 1000px) { .table-grid { grid-template-columns: 1fr; } .table-head .share input { width: 100%; } .table-head .share { width: 100%; } }
@media (max-width: 760px) { .np-actions { width: 100%; } .picker-grid { grid-template-columns: 1fr 1fr; } .pg-art { width: 38px; height: 38px; } }

/* ---------- the wheel ---------- */
.spin-overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(5,8,18,.7); backdrop-filter: blur(6px); animation: fade-in .25s; }
.spin-box { padding: 1.4rem; width: min(760px, 94vw); text-align: center; }
.reel { position: relative; overflow: hidden; margin: 1rem 0; height: 150px; border-radius: 18px; background: rgba(0,0,0,.35); border: 1px solid var(--line);
  mask-image: linear-gradient(90deg, transparent, #000 20%, #000 80%, transparent); -webkit-mask-image: linear-gradient(90deg, transparent, #000 20%, #000 80%, transparent); }
.reel-strip { display: flex; height: 100%; will-change: transform; }
.reel-item { --tc: #7c5cff; flex: none; width: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; }
.reel-item svg { width: 64px; height: 64px; padding: 12px; border-radius: 20px; background: var(--tc); fill: #fff; }
.reel-item span { font-size: .8rem; font-weight: 600; }
.reel-item.won svg { animation: won-pop .6s cubic-bezier(.2,1.6,.4,1); box-shadow: 0 0 0 4px #fff, 0 0 40px var(--tc); }
@keyframes won-pop { 50% { transform: scale(1.25); } }
.reel-marker { position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; transform: translateX(-50%); background: linear-gradient(var(--gold, #f6c453), transparent 30%, transparent 70%, var(--gold, #f6c453)); }
.spin-result { font-size: 2rem; animation: won-pop .6s; }
@keyframes fade-in { from { opacity: 0; } }

/* ---------- dice ---------- */
.die { --d: 48px; width: var(--d); height: var(--d); border-radius: calc(var(--d) * .2); padding: calc(var(--d) * .14); display: grid; grid-template-columns: repeat(3, 1fr); gap: calc(var(--d) * .05);
  background: linear-gradient(145deg, #ffffff, #e4e4ee); box-shadow: inset 0 -4px 0 rgba(0,0,0,.12), 0 6px 14px rgba(0,0,0,.35); flex: none; }
.die i { border-radius: 50%; }
.die i.on { background: radial-gradient(circle at 40% 35%, #444, #111); }
.die.red { background: linear-gradient(145deg, #ff6b6b, #c92a2a); } .die.red i.on { background: #fff; }
.die.hidden { background: linear-gradient(145deg, #4a3f8f, #2d2566); } 
.die.sm { --d: 28px; } .die.lg { --d: 64px; }
.die.roll { animation: die-roll .55s cubic-bezier(.3,1.4,.5,1); }
@keyframes die-roll { 0% { transform: rotate(-200deg) scale(.5) translateY(-30px); opacity: .3; } }
.die.match { box-shadow: 0 0 0 3px var(--gold), 0 0 18px var(--gold); }
