:root {
  --bg1: #1b1446; --bg2: #3a1c71; --bg3: #0b6e8a;
  --card: rgba(255, 255, 255, .08); --card-b: rgba(255, 255, 255, .16);
  --text: #fff; --muted: rgba(255, 255, 255, .72); --gold: #ffd84d; --pink: #ff5fa2; --green: #34d399; --red: #ff6b6b;
  --radius: 22px; --shadow: 0 14px 40px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html { background: #1b1446; }
body {
  min-height: 100vh; color: var(--text); font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif; font-weight: 700;
  background: radial-gradient(1200px 700px at 10% -10%, #6a3df0 0%, transparent 60%), radial-gradient(900px 600px at 110% 10%, #ff4f9a 0%, transparent 55%),
    radial-gradient(900px 700px at 50% 120%, var(--bg3) 0%, transparent 60%), linear-gradient(160deg, var(--bg1), var(--bg2));
  background-attachment: fixed; overflow-x: hidden;
}
a { color: var(--gold); }
button, input, select { font: inherit; }
.wrap { width: min(1100px, 100%); margin: 0 auto; padding: 18px 16px 60px; }
.topbar { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-family: 'Lilita One', 'Nunito', sans-serif; font-size: 22px; letter-spacing: .5px; }
.brand .logo { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: linear-gradient(135deg, var(--gold), var(--pink)); box-shadow: 0 6px 18px rgba(255, 95, 162, .45); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.lang { display: inline-flex; background: rgba(0, 0, 0, .25); border: 1px solid var(--card-b); border-radius: 999px; padding: 3px; }
.lang button { border: 0; background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 999px; cursor: pointer; font-weight: 800; }
.lang button.on { background: #fff; color: #2a1b5e; }
.chip-btn { border: 1px solid var(--card-b); background: rgba(0, 0, 0, .22); color: #fff; border-radius: 999px; padding: 7px 14px; cursor: pointer; text-decoration: none; font-weight: 800; font-size: 14px; }
.chip-btn:hover { background: rgba(255, 255, 255, .14); }

/* hero */
.hero { text-align: center; padding: 26px 0 10px; }
.hero h1 { font-family: 'Lilita One', 'Nunito', sans-serif; font-weight: 400; font-size: clamp(40px, 9vw, 76px); margin: 6px 0 4px; line-height: 1;
  background: linear-gradient(90deg, #fff, var(--gold) 45%, var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: 0 10px 40px rgba(255, 95, 162, .25); }
.hero p { color: var(--muted); font-size: clamp(15px, 3.6vw, 19px); margin: 6px auto 20px; max-width: 640px; }
.floaties { font-size: 30px; letter-spacing: 10px; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.cta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; max-width: 680px; margin: 0 auto 28px; }
.big-btn { display: flex; align-items: center; gap: 14px; justify-content: center; text-decoration: none; border: 0; border-radius: var(--radius); padding: 20px 18px; cursor: pointer;
  color: #1b1446; font-size: clamp(18px, 4.4vw, 24px); font-weight: 900; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; text-align: left; }
.big-btn:hover { transform: translateY(-3px) scale(1.01); }
.big-btn:active { transform: translateY(1px); }
.big-btn .ic { font-size: 34px; }
.big-btn small { display: block; font-size: 13px; font-weight: 700; opacity: .75; }
.btn-join { background: linear-gradient(135deg, #7dffb2, #34d399); }
.btn-host { background: linear-gradient(135deg, var(--gold), #ffad3b); }
@media (max-width: 520px) { .cta { grid-template-columns: 1fr; } }

h2.sec { font-size: 20px; margin: 26px 4px 12px; display: flex; align-items: center; gap: 10px; }
h2.sec .count { font-size: 13px; background: rgba(255, 255, 255, .14); padding: 3px 10px; border-radius: 999px; }

/* game cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.game { position: relative; text-align: left; border: 1px solid var(--card-b); border-radius: var(--radius); padding: 18px 16px 16px; background: var(--card);
  color: #fff; cursor: pointer; overflow: hidden; transition: transform .18s, border-color .18s, background .18s; backdrop-filter: blur(6px); min-height: 170px; display: flex; flex-direction: column; }
.game::before { content: ''; position: absolute; inset: -40% -40% auto auto; width: 160px; height: 160px; border-radius: 50%; background: var(--c, #888); opacity: .35; filter: blur(14px); transition: opacity .2s; }
.game:hover, .game:focus-visible { transform: translateY(-4px); border-color: var(--c); background: rgba(255, 255, 255, .12); outline: none; }
.game:hover::before { opacity: .6; }
.game .em { font-size: 44px; line-height: 1; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .35)); position: relative; }
.game h3 { margin: 12px 0 4px; font-size: 20px; position: relative; }
.game p { margin: 0 0 12px; color: var(--muted); font-size: 14px; font-weight: 600; position: relative; flex: 1; }
.game .meta { display: flex; gap: 6px; flex-wrap: wrap; position: relative; }
.pill { font-size: 12px; padding: 4px 9px; border-radius: 999px; background: rgba(0, 0, 0, .3); border: 1px solid rgba(255, 255, 255, .12); white-space: nowrap; }
.pill.live { background: rgba(52, 211, 153, .2); border-color: rgba(52, 211, 153, .6); color: #b6ffd9; }
.pill.off { background: rgba(255, 107, 107, .2); border-color: rgba(255, 107, 107, .6); }
.game.small { min-height: 0; padding: 14px; flex-direction: row; align-items: center; gap: 12px; }
.game.small .em { font-size: 34px; }
.game.small h3 { margin: 0; font-size: 17px; }
.game.small p { display: none; }

/* cards & forms */
.panel { background: rgba(15, 10, 45, .55); border: 1px solid var(--card-b); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); backdrop-filter: blur(8px); }
.narrow { max-width: 460px; margin: 18px auto; }
label.f { display: block; margin: 14px 0 6px; color: var(--muted); font-size: 14px; }
input.f, select.f { width: 100%; border: 2px solid rgba(255, 255, 255, .2); background: rgba(0, 0, 0, .3); color: #fff; padding: 14px 16px; border-radius: 14px; font-size: 18px; font-weight: 800; outline: none; }
input.f:focus { border-color: var(--gold); }
input.code { text-align: center; letter-spacing: 8px; text-transform: uppercase; font-size: 32px; font-family: 'Lilita One', 'Nunito', monospace; }
input.code::placeholder { letter-spacing: 4px; font-size: 22px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 13px 18px; cursor: pointer; font-weight: 900; font-size: 16px; color: #1b1446; background: var(--gold); text-decoration: none; transition: transform .12s, filter .12s; }
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.wide { width: 100%; margin-top: 18px; font-size: 20px; padding: 16px; }
.btn.green { background: var(--green); }
.btn.ghost { background: rgba(255, 255, 255, .1); color: #fff; border: 1px solid var(--card-b); }
.btn.danger { background: var(--red); color: #fff; }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 11px; }
.err { color: #ffb4b4; min-height: 22px; margin: 10px 0 0; font-size: 15px; }
.ok { color: #b6ffd9; }
.hint { color: var(--muted); font-size: 14px; font-weight: 600; }
.center { text-align: center; }
.hidden { display: none !important; }

/* rooms */
.rooms { display: grid; gap: 10px; }
.room { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--card-b); }
.room .em { font-size: 30px; }
.room .code { font-family: 'Lilita One', monospace; font-size: 24px; letter-spacing: 3px; color: var(--gold); }
.room .sub { color: var(--muted); font-size: 13px; font-weight: 600; }
.room .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 600px) { .room { grid-template-columns: auto 1fr; } .room .acts { grid-column: 1 / -1; justify-content: stretch; } .room .acts .btn { flex: 1; } }
.empty { text-align: center; color: var(--muted); padding: 24px; border: 2px dashed rgba(255, 255, 255, .18); border-radius: 18px; font-weight: 700; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(5, 3, 20, .66); display: grid; place-items: end center; padding: 0; animation: fade .15s; }
@media (min-width: 640px) { .modal { place-items: center; padding: 20px; } }
.sheet { width: min(520px, 100%); background: linear-gradient(170deg, #2b1a66, #1b1446); border: 1px solid var(--card-b); border-radius: 26px 26px 0 0; padding: 22px 20px 26px; box-shadow: var(--shadow); animation: up .2s ease-out; max-height: 92vh; overflow: auto; }
@media (min-width: 640px) { .sheet { border-radius: 26px; } }
.sheet .head { display: flex; gap: 14px; align-items: center; }
.sheet .head .em { font-size: 52px; }
.sheet h3 { margin: 0; font-size: 24px; }
.sheet .acts { display: grid; gap: 10px; margin-top: 18px; }
.x { position: sticky; float: right; top: 0; border: 0; background: rgba(255, 255, 255, .12); color: #fff; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.qr { background: #fff; border-radius: 16px; padding: 10px; width: 220px; height: 220px; margin: 14px auto; display: block; }
.linkbox { display: flex; gap: 8px; margin-top: 8px; }
.linkbox input { flex: 1; min-width: 0; font-size: 14px; padding: 10px 12px; }
.bigcode { font-family: 'Lilita One', monospace; font-size: 54px; letter-spacing: 8px; text-align: center; color: var(--gold); margin: 6px 0; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.tabs button { border: 1px solid var(--card-b); background: rgba(0, 0, 0, .2); color: var(--muted); border-radius: 999px; padding: 9px 16px; cursor: pointer; font-weight: 800; }
.tabs button.on { background: #fff; color: #2a1b5e; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 14px; }
.kv b { color: var(--muted); font-weight: 700; }
.kv span { word-break: break-all; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--red); margin-right: 6px; }
.dot.on { background: var(--green); }
.dot.wait { background: var(--gold); }
.foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 40px; font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #fff; color: #1b1446; padding: 12px 18px; border-radius: 14px; font-weight: 800; z-index: 60; box-shadow: var(--shadow); animation: up .2s; }
