:root {
  --bg: #14122b;
  --bg2: #1d1a3d;
  --ink: #f4f2ff;
  --muted: #a6a1cf;
  --accent: #7c5cff;
  --accent2: #ff7ab6;
  --felt: #1f8f5f;
  --felt2: #146b46;
  --card: #fffdf7;
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(1200px 600px at 20% -10%, #3a2a7a 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 110%, #5a1f55 0%, transparent 55%), var(--bg);
  background-attachment: fixed;
  overflow-x: hidden;
}
h1, h2, h3, .btn, .card b, .avg b { font-family: Fredoka, Inter, sans-serif; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

.btn {
  border: 0; border-radius: 12px; padding: 10px 16px; font-size: 15px; font-weight: 600;
  background: rgba(255,255,255,.1); color: var(--ink); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px; transition: transform .12s, background .2s, box-shadow .2s;
}
.btn:hover { background: rgba(255,255,255,.18); }
.btn:active { transform: scale(.96); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #a35cff); box-shadow: 0 6px 20px rgba(124,92,255,.45); }
.btn.primary:hover { box-shadow: 0 8px 26px rgba(124,92,255,.65); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.big { padding: 14px 24px; font-size: 18px; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.ghost { background: transparent; color: rgba(255,255,255,.75); }
.btn.icon { padding: 8px 12px; }

/* landing */
#landing { min-height: 100vh; display: grid; place-items: center; padding: 40px 20px; }
.hero { max-width: 760px; text-align: center; }
.hero h1 { font-size: clamp(44px, 8vw, 84px); margin: 10px 0; letter-spacing: -1px;
  background: linear-gradient(90deg, #fff, #d7ccff 40%, var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 19px; line-height: 1.55; color: #d4d0f5; max-width: 600px; margin: 0 auto 30px; }
.hero-cards { display: flex; justify-content: center; height: 110px; }
.hero-cards span {
  width: 64px; height: 92px; background: var(--card); color: #1d1b3a; border-radius: 10px; display: grid; place-items: center;
  font: 700 28px Fredoka, sans-serif; box-shadow: 0 10px 30px rgba(0,0,0,.4); margin: 0 -8px; animation: float 4s ease-in-out infinite;
}
.hero-cards span:nth-child(1) { transform: rotate(-16deg); animation-delay: 0s; }
.hero-cards span:nth-child(2) { transform: rotate(-5deg) translateY(-8px); animation-delay: .4s; }
.hero-cards span:nth-child(3) { transform: rotate(5deg) translateY(-8px); animation-delay: .8s; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.hero-cards span:nth-child(4) { transform: rotate(16deg); animation-delay: 1.2s; }
@keyframes float { 50% { translate: 0 -8px; } }
.create { display: flex; gap: 10px; max-width: 620px; margin: 0 auto; }
.create input, #nameInput, #customEmoji {
  flex: 1; padding: 14px 18px; border-radius: 14px; border: 2px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06);
  color: var(--ink); font-size: 17px; outline: none; transition: border .2s; font-family: inherit;
}
.create input:focus, #nameInput:focus, #customEmoji:focus { border-color: var(--accent); }
.features { list-style: none; padding: 0; margin: 40px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.features li { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); border-radius: 16px; padding: 14px; font-size: 14px; color: var(--muted); text-align: left; }
.features b { display: block; color: var(--ink); margin-bottom: 4px; font-size: 15px; }
.recent { margin-top: 30px; }
.recent h3 { font-size: 15px; color: var(--muted); font-weight: 500; }
#recentList { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.recent-item { color: var(--ink); text-decoration: none; background: rgba(255,255,255,.08); padding: 8px 14px; border-radius: 999px; font-size: 14px; }
.recent-item:hover { background: rgba(255,255,255,.16); }

/* room */
body.in-room { overflow: hidden; }
#room { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.bar { display: flex; align-items: center; gap: 14px; padding: 14px 22px; }
.logo { font-size: 28px; text-decoration: none; }
.title { flex: 1; min-width: 0; }
.title h2 { margin: 0; font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-actions { display: flex; gap: 8px; }
.btn.me { padding: 5px 14px 5px 5px; }
.mini { width: 32px; height: 32px; display: inline-block; }
.mini svg { width: 100%; height: 100%; display: block; }

.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px 20px; }
.table-wrap { width: max(300px, min(900px, 100%, calc((100vh - 340px) * 16 / 9))); }
.table { position: relative; width: 100%; aspect-ratio: 16 / 9; }
.felt {
  position: absolute; inset: 18% 14%; border-radius: 999px;
  background: radial-gradient(ellipse at 50% 40%, var(--felt) 0%, var(--felt2) 75%);
  box-shadow: inset 0 0 0 10px #6b3f1f, inset 0 0 0 14px #8a5a2f, inset 0 10px 40px rgba(0,0,0,.45), 0 25px 60px rgba(0,0,0,.5);
  display: grid; place-items: center;
}
.center { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 20px; }
.waiting { color: #d6f5e3; font-size: 15px; }
.result { display: flex; gap: 18px; align-items: center; }
.avg { background: rgba(0,0,0,.25); border-radius: 16px; padding: 10px 16px; min-width: 96px; }
.avg small { display: block; color: #bfe9d1; font-size: 12px; }
.avg b { font-size: 40px; line-height: 1; }
.bars { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.barrow { display: grid; grid-template-columns: 28px 1fr 30px; align-items: center; gap: 6px; font-size: 13px; }
.barrow span { font-weight: 700; text-align: right; }
.barrow i { height: 10px; border-radius: 6px; background: linear-gradient(90deg, #ffe066, #ffa94d); animation: grow .6s ease-out; }
.barrow em { font-style: normal; color: #bfe9d1; }
@keyframes grow { from { width: 0; } }

.seat { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 4px; transition: left .5s, top .5s; width: 110px; }
.avatar {
  width: 78px; height: 78px; border-radius: 50%; padding: 0; border: 3px solid rgba(255,255,255,.85); background: none; cursor: crosshair;
  box-shadow: 0 8px 20px rgba(0,0,0,.4); transition: transform .15s; overflow: hidden;
}
.avatar svg { width: 100%; height: 100%; display: block; }
.avatar:hover { transform: scale(1.08); }
.avatar.hit, .spec.hit { animation: hit .3s ease-out; }
@keyframes hit { 0% { transform: none; } 30% { transform: translate(var(--hx, 0), var(--hy, 0)) scale(.94); } 65% { transform: translate(calc(var(--hx, 0px) * -.3), calc(var(--hy, 0px) * -.3)); } 100% { transform: none; } }
.av-wrap { position: relative; }
.desk { position: absolute; right: -30px; bottom: -4px; width: 36px; height: 36px; pointer-events: none; display: grid; place-items: end center; filter: drop-shadow(0 3px 3px rgba(0,0,0,.35)); }
.desk svg { width: 100%; height: 100%; display: block; }
.desk-emo { font-size: 28px; line-height: 1; }
.desk.big { width: 70px; height: 70px; right: -40px; bottom: 0; }
.desk.big .desk-emo { font-size: 54px; }
.big-wrap { position: relative; }
.fan-blades { transform-box: view-box; transform-origin: 20px 16px; animation: spin .5s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.steam path { animation: steam 2.2s ease-in-out infinite; }
.steam path:nth-child(2) { animation-delay: 1.1s; }
@keyframes steam { 0% { opacity: 0; transform: translateY(3px); } 40% { opacity: 1; } 100% { opacity: 0; transform: translateY(-4px); } }

.stage-row { display: flex; align-items: center; justify-content: center; gap: 22px; width: 100%; min-height: 0; }
.stage-row .table-wrap { flex: 0 1 auto; min-width: 0; }
.sofa {
  flex: none; width: 76px; padding: 10px 8px 10px 22px; border-radius: 22px 12px 12px 22px;
  border-block: 14px solid #8c3f6a; background: linear-gradient(90deg, #6e2f52 0 16px, #b0578a 16px);
  box-shadow: 0 16px 34px rgba(0,0,0,.45), inset 0 0 0 2px rgba(255,255,255,.07);
}
.sofa.right { padding: 10px 22px 10px 8px; border-radius: 12px 22px 22px 12px; background: linear-gradient(270deg, #6e2f52 0 16px, #b0578a 16px); }
.sofa-seats { display: flex; flex-direction: column; align-items: center; gap: 8px; max-height: 52vh; }
.sofa-seats::before { content: '👀'; font-size: 14px; opacity: .7; }
.sofa.crowded .spec + .spec { margin-top: -18px; }
.spec { width: 46px; height: 46px; border-radius: 50%; padding: 0; border: 2px solid rgba(255,255,255,.85); background: none; overflow: hidden; cursor: crosshair; flex: none; transition: transform .15s; box-shadow: 0 4px 10px rgba(0,0,0,.35); position: relative; }
.spec:hover { transform: scale(1.12); z-index: 1; }
.spec svg { width: 100%; height: 100%; display: block; }
.spec-note { display: none; text-align: center; color: var(--muted); font-size: 15px; padding: 30px 10px; }
.spectating .deck { display: none; }
.spectating .spec-note { display: block; }
.name { font-size: 13px; font-weight: 600; background: rgba(0,0,0,.35); padding: 3px 10px; border-radius: 999px; max-width: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.you { background: var(--accent); border-radius: 6px; padding: 0 5px; font-size: 11px; margin-left: 2px; }
.card-slot { height: 46px; perspective: 400px; }
.pcard { width: 32px; height: 46px; border-radius: 6px; }
.pcard.empty { border: 2px dashed rgba(255,255,255,.2); }
.pcard.back { background: repeating-linear-gradient(45deg, var(--accent) 0 5px, #9b7dff 5px 10px); border: 2px solid #fff; box-shadow: 0 4px 10px rgba(0,0,0,.35); }
.pcard.drop { animation: drop .35s cubic-bezier(.3,1.6,.6,1); }
@keyframes drop { from { transform: translateY(-30px) rotate(-20deg); opacity: 0; } }
.pcard.flip { animation: flip .5s ease-out; background: var(--card); color: #1d1b3a; display: grid; place-items: center; font: 700 17px Fredoka, sans-serif; box-shadow: 0 4px 12px rgba(0,0,0,.35); }
@keyframes flip { from { transform: rotateY(180deg); background: var(--accent); color: transparent; } }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; text-align: center; }

.deck-wrap { padding: 10px 10px 18px; overflow-x: auto; }
.deck { display: flex; justify-content: center; gap: 8px; min-width: max-content; margin: 0 auto; padding-top: 18px; }
.card {
  position: relative; width: 58px; height: 84px; border-radius: 10px; border: 0; background: var(--card); color: #1d1b3a; cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,.35); transition: transform .18s cubic-bezier(.3,1.5,.6,1), box-shadow .2s, background .2s;
}
.card b { font-size: 24px; }
.card .corner { position: absolute; top: 4px; left: 6px; font-size: 10px; font-weight: 700; opacity: .5; }
.card .corner.br { top: auto; left: auto; bottom: 4px; right: 6px; transform: rotate(180deg); }
.card:hover:not(:disabled) { transform: translateY(-10px); }
.card.on { transform: translateY(-18px); background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; box-shadow: 0 12px 28px rgba(124,92,255,.6); }
.card:disabled { opacity: .5; cursor: not-allowed; }

/* modal + editor */
.modal { position: fixed; inset: 0; background: rgba(8,6,24,.7); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { background: var(--bg2); border: 1px solid rgba(255,255,255,.1); border-radius: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.6); animation: up .25s cubic-bezier(.3,1.3,.6,1); max-height: calc(100vh - 32px); }
@keyframes up { from { transform: translateY(20px) scale(.97); opacity: 0; } }
.editor-sheet { display: flex; gap: 26px; padding: 26px; width: min(860px, 100%); overflow: auto; }
.editor-preview { display: flex; flex-direction: column; align-items: center; gap: 14px; position: sticky; top: 0; }
.big-avatar { width: 220px; height: 220px; border-radius: 50%; border: 5px solid #fff; box-shadow: 0 16px 40px rgba(0,0,0,.45); overflow: hidden; }
.big-avatar svg { width: 100%; height: 100%; display: block; }
.big-avatar.pop { animation: pop .25s ease-out; }
@keyframes pop { 50% { transform: scale(1.05) rotate(2deg); } }
.editor-form { flex: 1; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.editor-form h2 { margin: 0; font-size: 28px; }
.options { display: flex; flex-direction: column; gap: 10px; }
.opt { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 10px; }
.opt label { font-size: 13px; color: var(--muted); font-weight: 600; }
.opt-values { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 0; background: rgba(255,255,255,.08); color: var(--ink); padding: 6px 11px; border-radius: 999px; font-size: 13px; cursor: pointer; font-family: inherit; transition: background .15s; }
.chip:hover { background: rgba(255,255,255,.16); }
.chip.on { background: var(--accent); }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); cursor: pointer; padding: 0; transition: transform .12s; }
.swatch:hover { transform: scale(1.15); }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 3px var(--accent); }
.editor-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* throw menu */
.throw-menu { position: fixed; z-index: 40; background: #fff; color: #1d1b3a; border-radius: 18px; padding: 10px; box-shadow: 0 20px 50px rgba(0,0,0,.5); width: 292px; animation: up .18s ease-out; }
.tm-head { display: flex; justify-content: space-between; font: 600 14px Fredoka, sans-serif; padding: 2px 6px 8px; }
.tm-count { color: var(--accent); font-weight: 700; }
.tm-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.tm-item { aspect-ratio: 1; border: 0; background: #f3f0ff; border-radius: 12px; cursor: pointer; display: grid; place-items: center; padding: 0; font-size: 24px; transition: transform .1s, background .15s; }
.tm-item:hover { background: #e5dbff; transform: scale(1.1); }
.tm-item svg { width: 30px; height: 30px; }
.tm-item.tap { animation: tap .2s; }
@keyframes tap { 50% { transform: scale(.8); } }
.tm-item.more { font-size: 22px; color: var(--accent); font-weight: 700; background: #ede7ff; }
.emo { font-size: 34px; line-height: 1; display: block; }
.tm-item .emo { font-size: 24px; }

.projectile { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; margin: -20px 0 0 -20px; filter: drop-shadow(0 6px 6px rgba(0,0,0,.35)); will-change: transform; }
.splat { position: fixed; z-index: 59; width: 60px; height: 60px; margin: -30px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255,255,255,.9) 0 20%, rgba(255,214,102,.6) 30%, transparent 65%); animation: splat .45s ease-out forwards; }
@keyframes splat { from { transform: scale(.2); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }

/* picker */
.picker-sheet { width: min(620px, 100%); height: min(560px, calc(100vh - 32px)); display: flex; flex-direction: column; overflow: hidden; }
.picker-head { display: flex; gap: 8px; align-items: center; padding: 16px 16px 8px; }
.picker-head h2 { margin: 0 8px 0 0; font-size: 20px; white-space: nowrap; }
#customEmoji { padding: 9px 12px; font-size: 16px; min-width: 0; }
.picker-tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid rgba(255,255,255,.08); overflow-x: auto; }
.picker-tabs button { border: 0; background: none; font-size: 22px; padding: 8px 10px; border-radius: 10px 10px 0 0; cursor: pointer; opacity: .55; }
.picker-tabs button.on { opacity: 1; background: rgba(255,255,255,.08); }
.picker-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 2px; padding: 12px; align-content: start; }
.picker-grid button { border: 0; background: none; font-size: 28px; aspect-ratio: 1; border-radius: 10px; cursor: pointer; padding: 0; display: grid; place-items: center; }
.picker-grid button:hover { background: rgba(255,255,255,.12); transform: scale(1.15); }
.picker-grid svg { width: 30px; height: 30px; }

.toast { position: fixed; bottom: 120px; left: 50%; transform: translateX(-50%); background: #fff; color: #1d1b3a; padding: 10px 18px; border-radius: 999px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.4); z-index: 70; }
.toast.show { animation: up .25s ease-out; }
.notfound { min-height: 100vh; display: grid; place-content: center; text-align: center; gap: 10px; padding: 20px; }

@media (max-width: 720px) {
  .editor-sheet { flex-direction: column; padding: 18px; gap: 14px; }
  .editor-preview { position: static; flex-direction: row; justify-content: center; }
  .big-avatar { width: 120px; height: 120px; }
  .opt { grid-template-columns: 1fr; gap: 4px; }
  .table { aspect-ratio: 3 / 4; }
  .table-wrap { width: max(240px, min(100%, calc((100vh - 330px) * 3 / 4))); }
  .desk { width: 28px; height: 28px; right: -22px; }
  .desk-emo { font-size: 22px; }
  .stage-row { gap: 8px; }
  .sofa { width: 54px; padding: 8px 5px 8px 14px; border-block-width: 10px; background: linear-gradient(90deg, #6e2f52 0 10px, #b0578a 10px); }
  .sofa.right { padding: 8px 14px 8px 5px; background: linear-gradient(270deg, #6e2f52 0 10px, #b0578a 10px); }
  .spec { width: 36px; height: 36px; }
  #specBtn { padding: 8px 10px; font-size: 13px; }
  .felt { inset: 16% 18%; }
  .avatar { width: 60px; height: 60px; }
  .seat { width: 84px; }
  .card { width: 46px; height: 68px; }
  .card b { font-size: 19px; }
  .create { flex-direction: column; }
  .result { flex-direction: column; gap: 8px; }
  .bar-actions #meName { display: none; }
  .btn.me { padding: 5px; }
}
