/* Mari Duel! host screen (projector / LED wall) */
:root { --bar-h: 64px; }
html, body { height: 100%; overflow: hidden; }
body { --accent: var(--cyan); }

#stage { position: fixed; left: 0; right: 0; top: var(--bar-h); bottom: 0; width: 100%; height: calc(100% - var(--bar-h)); display: block; }

.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--bar-h); z-index: 20;
  display: flex; align-items: center; gap: 10px; padding: 0 18px;
  background: linear-gradient(180deg, rgba(4, 5, 13, .92), rgba(4, 5, 13, .7));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.topbar .logo { font-size: 24px; }
.topbar .spacer { flex: 1; }
.game-chip { display: flex; align-items: center; gap: 8px; margin-left: 10px; font: 800 15px var(--font-display); letter-spacing: .04em; min-width: 0; }
.game-chip #gcName { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-chip .cat { font: 700 11px var(--font-display); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent); padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.code-chip b { color: var(--cyan); letter-spacing: .2em; font-size: 14px; }
.conn { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px var(--red); }
.conn.on { background: var(--green); box-shadow: 0 0 10px var(--green); }

.overlay { position: fixed; left: 0; right: 0; top: var(--bar-h); bottom: 0; z-index: 10; }

/* ---------- Lobby ---------- */
.lobby { display: grid; grid-template-columns: minmax(300px, 30vw) minmax(0, 1fr); gap: 22px; padding: 22px; background: radial-gradient(ellipse at 50% 120%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%); }
.qr-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; min-height: 0; }
.qr-card h2 { margin: 0; font-size: clamp(18px, 2.2vw, 30px); color: var(--cyan); text-shadow: 0 0 20px rgba(62, 242, 255, .5); letter-spacing: .12em; text-transform: uppercase; }
.qr-frame { position: relative; padding: 14px; border-radius: 22px; background: #fff; box-shadow: 0 0 0 3px var(--cyan), 0 0 60px rgba(62, 242, 255, .45); width: min(100%, 52vh); aspect-ratio: 1; }
.qr-frame img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.qr-frame::before, .qr-frame::after { content: ''; position: absolute; width: 34px; height: 34px; border: 4px solid var(--magenta); }
.qr-frame::before { top: -14px; left: -14px; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.qr-frame::after { bottom: -14px; right: -14px; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
.room-code { font: 900 clamp(36px, 5vw, 64px) var(--font-display); letter-spacing: .3em; padding-left: .3em; color: #fff; text-shadow: 0 0 30px rgba(62, 242, 255, .6); line-height: 1; }
.join-url { color: var(--muted); font-weight: 700; font-size: clamp(13px, 1.3vw, 17px); word-break: break-all; }
.reg-toggle { display: flex; gap: 8px; align-items: center; font-weight: 700; color: var(--muted); cursor: pointer; }
.reg-toggle input { width: 18px; height: 18px; accent-color: var(--cyan); }

.lobby-main { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 22px; min-height: 0; }
.game-card { padding: 22px 24px; display: grid; gap: 14px; }
.gc-head { display: flex; gap: 20px; align-items: center; }
.gc-icon { font-size: clamp(56px, 7vw, 92px); line-height: 1; filter: drop-shadow(0 0 22px color-mix(in srgb, var(--accent) 70%, transparent)); animation: float 4s ease-in-out infinite; }
.gc-head .chip { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.gc-head h1 { margin: 8px 0 4px; font-size: clamp(26px, 3.4vw, 46px); line-height: 1.05; }
.gc-head p { margin: 0; color: var(--muted); font-size: clamp(15px, 1.4vw, 19px); }
.howto { margin: 0; padding-left: 22px; display: grid; gap: 4px; font-size: clamp(14px, 1.3vw, 17px); color: var(--text); }
.howto li::marker { color: var(--accent); font-family: var(--font-display); font-weight: 800; }
.gc-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.gc-actions select { width: auto; flex: 1; min-width: 200px; max-width: 360px; }
.gc-actions .btn.big { margin-left: auto; --c: var(--accent); }
#btnStart:not(:disabled) { animation: pulse-glow 1.8s infinite; }

.crowd { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.crowd-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.crowd-head h3 { margin: 0; font-size: clamp(18px, 2vw, 26px); }
.crowd-head h3 b { color: var(--accent); font-size: 1.4em; }
.wall { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; }
.pchip {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px 5px 5px; border-radius: 999px;
  background: color-mix(in srgb, var(--pc) 14%, rgba(8, 12, 40, .8)); border: 1px solid color-mix(in srgb, var(--pc) 60%, transparent);
  font-weight: 700; font-size: clamp(13px, 1.1vw, 16px); animation: pop-in .35s ease-out;
}
.pchip .av { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 17px; background: color-mix(in srgb, var(--pc) 25%, #000); }
.pchip.off { opacity: .4; }
.pchip.more { --pc: var(--cyan); padding: 8px 14px; }

/* ---------- Countdown ---------- */
.count { display: grid; place-items: center; background: rgba(4, 5, 13, .55); z-index: 15; }
.count span { font: 900 min(40vh, 30vw) var(--font-display); color: var(--accent); text-shadow: 0 0 80px var(--accent); animation: pop-in .4s ease-out; }

/* ---------- HUD during play ---------- */
.hud { position: fixed; top: calc(var(--bar-h) + 12px); left: 50%; transform: translateX(-50%); z-index: 12; display: flex; gap: 12px; align-items: center; padding: 8px 10px 8px 18px; border-radius: 999px; background: rgba(8, 12, 40, .78); border: 1px solid var(--line); backdrop-filter: blur(8px); max-width: calc(100vw - 32px); }
.hud-text { font: 800 clamp(14px, 1.4vw, 19px) var(--font-display); letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-timer { font: 900 20px var(--font-display); color: var(--amber); min-width: 3.2ch; text-align: center; font-variant-numeric: tabular-nums; }
.hud-timer.low { color: var(--red); animation: pulse-glow 1s infinite; }
.banner { position: fixed; top: 22%; left: 0; right: 0; margin-inline: auto; z-index: 13; text-align: center; pointer-events: none; animation: pop-in .35s ease-out; width: max-content; max-width: 90vw; }
.banner b { display: block; font: 900 clamp(34px, 6vw, 90px)/1.05 var(--font-display); color: #fff; text-shadow: 0 0 40px var(--accent), 0 0 80px var(--accent); }
.banner span { display: block; margin-top: 8px; font: 700 clamp(16px, 2vw, 28px) var(--font-body); color: var(--muted); }
.mini-qr { position: fixed; right: 16px; bottom: 16px; z-index: 12; display: flex; gap: 12px; align-items: center; padding: 10px 14px 10px 10px; }
.mini-qr img { width: 92px; height: 92px; border-radius: 8px; background: #fff; padding: 4px; }
.mini-qr b { display: block; font: 900 22px var(--font-display); letter-spacing: .2em; color: var(--cyan); }
.mini-qr span { font-size: 13px; color: var(--muted); font-weight: 700; }

/* ---------- Results ---------- */
.results { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 20px 24px; background: radial-gradient(ellipse at 50% 30%, color-mix(in srgb, var(--accent) 16%, rgba(4, 5, 13, .75)), rgba(4, 5, 13, .88)); overflow: auto; }
.results .kicker { margin: 0; font: 800 14px var(--font-display); letter-spacing: .35em; color: var(--accent); text-transform: uppercase; }
.results h1 { margin: 0; font-size: clamp(28px, 4vw, 54px); text-align: center; text-shadow: 0 0 30px var(--accent); }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: clamp(10px, 2vw, 28px); min-height: 0; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 8px; width: clamp(140px, 16vw, 230px); animation: pop-in .5s ease-out both; }
.pod .av { width: clamp(64px, 7vw, 104px); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font-size: clamp(36px, 4vw, 60px); background: color-mix(in srgb, var(--pc) 22%, #000); border: 3px solid var(--pc); box-shadow: 0 0 30px var(--pc); }
.pod .nm { font: 800 clamp(15px, 1.6vw, 22px) var(--font-body); text-align: center; line-height: 1.15; word-break: break-word; }
.pod .sc { color: var(--muted); font-weight: 700; font-size: clamp(13px, 1.2vw, 16px); text-align: center; }
.pod .block { width: 100%; border-radius: 14px 14px 0 0; display: grid; place-items: center; font: 900 clamp(30px, 4vw, 56px) var(--font-display); color: #04050d; }
.pod.p1 { order: 2; animation-delay: .6s; } .pod.p1 .block { height: clamp(90px, 16vh, 170px); background: linear-gradient(180deg, #ffe08a, var(--amber)); box-shadow: 0 0 40px rgba(255, 184, 77, .6); }
.pod.p2 { order: 1; animation-delay: .3s; } .pod.p2 .block { height: clamp(64px, 11vh, 120px); background: linear-gradient(180deg, #f1f5ff, #a9b6d6); }
.pod.p3 { order: 3; } .pod.p3 .block { height: clamp(46px, 8vh, 90px); background: linear-gradient(180deg, #ffc39a, #d9814a); }
.res-list { width: min(900px, 100%); max-height: 26vh; overflow: auto; padding: 8px 16px; flex: none; }
.res-list ol { margin: 0; padding: 0; list-style: none; columns: 2; column-gap: 28px; }
.res-list li { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid rgba(255, 255, 255, .05); break-inside: avoid; font-weight: 700; }
.res-list li .rk { width: 2.6ch; font: 800 13px var(--font-display); color: var(--muted); text-align: right; }
.res-list li.win .rk { color: var(--amber); }
.res-list li .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-list li .sc { color: var(--muted); font-size: 14px; }
.res-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.res-actions .btn:first-child { --c: var(--accent); }

/* ---------- Drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 30; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); z-index: 31; border-radius: 22px 0 0 22px; background: rgba(10, 14, 40, .96); transform: translateX(105%); transition: transform .25s ease; display: flex; flex-direction: column; padding: 16px 18px; gap: 12px; }
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tabs { display: flex; gap: 6px; }
.tabs button { background: none; border: 1px solid var(--line); color: var(--muted); padding: 8px 12px; border-radius: 999px; font: 700 13px var(--font-body); cursor: pointer; }
.tabs button[aria-selected="true"] { color: #04050d; background: var(--cyan); border-color: var(--cyan); }
.pane { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 14px; padding-right: 4px; }
.settings { display: grid; gap: 14px; }
.settings .help { font-weight: 500; font-size: 12px; color: var(--muted); }
.drawer-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.drawer hr { border: 0; border-top: 1px solid var(--line); width: 100%; margin: 4px 0; }
.small { font-size: 13px; }
.players-tools { display: flex; gap: 8px; }
.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; overflow: auto; flex: 1; }
.plist li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 12px; background: rgba(255, 255, 255, .04); }
.plist .av { font-size: 20px; }
.plist .nm { flex: 1; min-width: 0; font-weight: 700; }
.plist .nm small { display: block; color: var(--muted); font-weight: 500; }
.plist .st { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.plist .st.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.plist button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 8px; }
.plist button:hover { color: var(--red); background: rgba(255, 77, 109, .1); }

@media (max-width: 900px) {
  .lobby { grid-template-columns: 1fr; overflow: auto; }
  .qr-frame { width: min(70vw, 320px); }
  .topbar .game-chip .cat, .topbar #playerCount { display: none; }
  .res-list ol { columns: 1; }
}
@media (max-width: 560px) {
  .topbar { gap: 6px; padding: 0 10px; }
  .topbar .logo { font-size: 16px; }
  .game-chip { display: none; }
  .mini-qr { display: none !important; }
}

/* ---------- Plans ---------- */
.plan-chip { border: 1px solid var(--amber); background: rgba(255, 184, 77, .12); color: var(--amber); border-radius: 999px; padding: 6px 12px; font: 800 11px var(--font-display); letter-spacing: .08em; cursor: pointer; white-space: nowrap; }
.plan-chip.free { border-color: var(--magenta); color: #ffd0f1; background: rgba(255, 62, 200, .14); }
.plan-chip:hover { filter: brightness(1.2); }
.lock-note { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-radius: 14px; background: rgba(255, 62, 200, .1); border: 1px solid rgba(255, 62, 200, .45); font-weight: 700; }
.help.lock { color: var(--magenta); }
.blocked { z-index: 25; display: grid; place-items: center; background: rgba(4, 5, 13, .82); backdrop-filter: blur(6px); padding: 20px; }
.blk-card { max-width: 640px; padding: 34px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.blk-card .blk-icon { font-size: 64px; }
.blk-card h1 { margin: 0; font-size: clamp(22px, 3vw, 36px); }
.blk-card p { margin: 0; color: var(--muted); font-size: 18px; line-height: 1.5; }
.blk-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.watermark { position: fixed; left: 16px; bottom: 16px; z-index: 24; pointer-events: none; padding: 8px 16px; border-radius: 999px; font: 900 clamp(12px, 1.2vw, 16px) var(--font-display); letter-spacing: .18em; color: #fff; background: rgba(255, 62, 200, .35); border: 1px solid var(--magenta); box-shadow: 0 0 24px rgba(255, 62, 200, .45); }
.plan-dlg { width: min(1040px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; color: var(--text); padding: 22px 24px; background: rgba(10, 14, 40, .97); }
.plan-dlg::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(4px); }
.plan-dlg h3 { margin: 18px 0 10px; font-size: 14px; letter-spacing: .14em; text-transform: uppercase; color: var(--cyan); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.dlg-head h2 { margin: 0; font-size: 20px; }
.plan-now { display: grid; gap: 4px; margin: 14px 0; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .04); }
.plan-now b { font-size: 18px; }
.act { display: flex; gap: 10px; align-items: flex-end; }
.act .field { flex: 1; }
.act input { font: 800 18px var(--font-display); letter-spacing: .12em; text-transform: uppercase; }
.plan-dlg .err { color: var(--red); font-weight: 700; margin: 8px 0 0; }
.pkgs { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.pkg { padding: 16px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, .03); display: grid; gap: 6px; align-content: start; }
.pkg.current { border-color: var(--amber); box-shadow: 0 0 24px rgba(255, 184, 77, .25); }
.pkg h4 { margin: 0; font: 800 15px var(--font-display); color: var(--cyan); }
.pkg .price { font: 900 26px var(--font-display); }
.pkg ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.pkg ul b { color: var(--text); }
.pkg .chip { justify-self: start; color: var(--amber); border-color: var(--amber); }
.buy { margin-top: 16px; text-align: center; }
