/* The table games (Rack 'Em, Pin Drop, Paddle Battle, Puck Rush): what their pages share. Each
   game's own stylesheet sets the theme variables below and styles its table's HUD. */

:root {
  --bg0: #10131c; --bg1: #171b28; --bg2: #07080d;
  --accent: #ffd23c; --accent2: #ff9a1f; --accent-ink: #2b1b00; --accent-shadow: #9a5a00;
  --panel: rgba(14, 17, 26, 0.78); --panel2: #141824; --line: rgba(255, 255, 255, 0.13);
  --txt: #f4f6fb; --dim: #9ea6bb; --good: #3ddc84; --bad: #ff5468;
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Russo One', 'Arial Black', Impact, system-ui, sans-serif;
  --vh: 100dvh;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; color: var(--txt); font-family: var(--font); font-weight: 800; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
body { background: radial-gradient(130% 90% at 50% 10%, var(--bg1) 0%, var(--bg0) 45%, var(--bg2) 100%) fixed var(--bg0); -webkit-user-select: none; user-select: none; touch-action: manipulation; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; }
input, select { font: inherit; }
b, strong { font-weight: 900; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- shared bits */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 18px; border-radius: 14px; background: rgba(255, 255, 255, 0.09); border: 1px solid var(--line); font-weight: 900; font-size: 15px; text-align: center; transition: transform 0.12s, background 0.2s, filter 0.2s; }
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.15); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; }
.btn.big { min-height: 56px; font-size: 18px; width: 100%; border-radius: 16px; }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: 14px; border-radius: 12px; }
.btn.primary { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 70%, #fff), var(--accent) 55%, var(--accent2)); border: 0; color: var(--accent-ink); box-shadow: 0 5px 0 var(--accent-shadow), 0 12px 26px color-mix(in srgb, var(--accent) 30%, transparent); text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 70%, #fff), var(--accent) 55%, var(--accent2)); }
.btn.primary:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--accent-shadow); }
.btn.primary:disabled { background: rgba(0, 0, 0, 0.2); border: 2px dashed rgba(255, 255, 255, 0.25); color: var(--dim); box-shadow: none; text-shadow: none; opacity: 1; }
.btn.danger { color: #ffb3bd; border-color: rgba(255, 84, 104, 0.35); }
.btn.ghost { background: none; border-color: transparent; color: var(--dim); }
.iconbtn { width: 44px; height: 44px; flex: none; border-radius: 13px; background: var(--panel); border: 1px solid var(--line); font-size: 19px; display: grid; place-items: center; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.hint { color: var(--dim); font-size: 13.5px; font-weight: 700; line-height: 1.45; margin: 6px 0 0; }
.wait { color: var(--dim); text-align: center; margin: 8px 0; }
.spin { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: rot 0.8s linear infinite; margin: 0 auto; }
@keyframes rot { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
@keyframes fade { from { opacity: 0; } }

/* ---------------------------------------------------------------- title, setup, host, join */
#screen { position: fixed; inset: 0; z-index: 10; overflow-y: auto; }
#screen.menu { display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
#screen.full { overflow: hidden; }
.title { width: min(560px, 100%); display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 4px 0 10px; animation: rise 0.4s both; }
.title-top { align-self: stretch; display: flex; justify-content: flex-start; }
.title-art { margin: 8px 0 2px; }
.tag { margin: 0; max-width: 470px; font-size: clamp(15px, 3.8vw, 18px); line-height: 1.4; color: #fff; opacity: 0.92; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); }
.megas { width: 100%; display: grid; gap: 10px; margin-top: 6px; }
.mega-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mega { display: flex; align-items: center; gap: 14px; text-align: left; padding: 16px 18px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3), 0 14px 30px rgba(0, 0, 0, 0.25); transition: transform 0.15s, border-color 0.2s; min-width: 0; }
.mega:hover { transform: translateY(-2px); border-color: var(--accent); }
.mega:active { transform: translateY(1px); }
.mega .mi { font-size: 32px; flex: none; }
.mega b { display: block; font-size: 19px; font-weight: 900; }
.mega small { color: var(--dim); font-size: 13px; font-weight: 700; line-height: 1.3; display: block; }
.mega.hot { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 26%, var(--panel)), var(--panel)); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.mega.rejoin { border-color: var(--good); }
.mega-row .mega { padding: 14px; gap: 10px; }
.mega-row .mega .mi { font-size: 26px; }
.mega-row .mega b { font-size: 17px; }
@media (max-width: 380px) { .mega-row { grid-template-columns: 1fr; } }
.title-foot { display: flex; gap: 6px; }
.panel { width: min(440px, 100%); display: grid; gap: 12px; padding: 22px; border-radius: 24px; background: var(--panel); border: 1px solid var(--line); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); animation: rise 0.35s both; }
.panel.wide { width: min(560px, 100%); }
.panel.center { text-align: center; }
.panel h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 28px; letter-spacing: 0.02em; }
.back { justify-self: start; color: var(--dim); font-weight: 900; padding: 6px 2px; }
.field { display: grid; gap: 6px; }
.field span { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--dim); }
.field input { font-size: 19px; font-weight: 900; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); background: rgba(0, 0, 0, 0.3); color: #fff; -webkit-user-select: text; user-select: text; width: 100%; }
.field input:focus { outline: none; border-color: var(--accent); }
.field input.code { text-transform: uppercase; letter-spacing: 0.4em; text-align: center; font-size: 30px; }
.field.small input { font-size: 16px; padding: 10px 12px; }
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.setup-rows { display: grid; gap: 2px; }
.setup-rows .opt.sub { padding-left: 12px; }

/* ---------------------------------------------------------------- the lobby */
.lobby { position: fixed; left: 0; right: 0; top: 0; height: var(--vh); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-width: 720px; margin: 0 auto; }
.lobby-head { display: flex; align-items: center; gap: 12px; padding: max(10px, env(safe-area-inset-top)) 14px 10px; }
.codebox { flex: 1; display: flex; flex-direction: column; align-items: center; line-height: 1; }
.codebox small { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); }
.codebox b { font-family: var(--display); font-weight: 400; font-size: 44px; letter-spacing: 0.12em; color: var(--accent); }
.qr { width: 68px; height: 68px; flex: none; border-radius: 10px; overflow: hidden; background: #fff; padding: 3px; }
.qr svg { width: 100%; height: 100%; display: block; }
.lobby-scroll { overflow-y: auto; padding: 0 14px 10px; display: grid; gap: 12px; align-content: start; }
.lobby-scroll section { padding: 14px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); }
.lobby-scroll h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--dim); display: flex; justify-content: space-between; }
.lobby-scroll h3 em { font-style: normal; color: var(--accent); }
.seats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.seat { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 14px; background: color-mix(in srgb, var(--pc) 16%, rgba(0, 0, 0, 0.3)); border: 2px solid color-mix(in srgb, var(--pc) 70%, transparent); min-width: 0; animation: rise 0.3s both; }
.seat.me { box-shadow: 0 0 0 2px #fff inset; }
.seat.off { opacity: 0.55; }
.seat .av { font-size: 24px; flex: none; }
.seat .sn { flex: 1; min-width: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .sn em { font-style: normal; font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; }
.seat .sn em.q { display: block; letter-spacing: 0.04em; text-transform: none; font-size: 12px; }
.seat .x { width: 28px; height: 28px; border-radius: 50%; background: rgba(0, 0, 0, 0.3); font-size: 12px; flex: none; }
.seat .lvl { flex: none; background: rgba(0, 0, 0, 0.35); color: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 4px 6px; font-size: 12px; font-weight: 800; }
.seat.add { justify-content: center; border: 2px dashed var(--line); background: none; color: var(--dim); font-weight: 900; min-height: 48px; }
.picker { display: grid; gap: 10px; margin-top: 12px; }
.animals, .swatches { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.an { width: 44px; height: 44px; border-radius: 50%; font-size: 25px; background: rgba(255, 255, 255, 0.08); border: 2px solid transparent; transition: transform 0.15s; }
.an.on { border-color: #fff; background: rgba(255, 255, 255, 0.2); transform: scale(1.08); }
.an:disabled { opacity: 0.25; }
.sw { width: 34px; height: 34px; border-radius: 50%; background: var(--c); border: 3px solid rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
.sw.on { border-color: #fff; transform: scale(1.15); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25); }
.sw:disabled { opacity: 0.2; }
.howto ul, .howto ol { margin: 0; padding: 0 0 0 20px; display: grid; gap: 6px; font-weight: 700; font-size: 14.5px; line-height: 1.45; color: #dfe4f0; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.opt:last-child { border-bottom: 0; }
.opt > div:first-child { min-width: 0; }
.opt b { display: block; font-size: 15px; }
.opt small { display: block; color: var(--dim); font-size: 12.5px; font-weight: 700; line-height: 1.35; margin-top: 2px; }
.seg { display: inline-flex; flex: none; padding: 3px; border-radius: 12px; background: rgba(0, 0, 0, 0.32); border: 1px solid var(--line); }
.seg button { padding: 8px 11px; border-radius: 9px; font-size: 13.5px; font-weight: 900; color: var(--dim); white-space: nowrap; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.seg button:disabled:not(.on) { opacity: 0.6; }
.tog { flex: none; width: 54px; height: 32px; border-radius: 99px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); position: relative; transition: background 0.2s; }
.tog i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #cfd6e4; transition: transform 0.2s; }
.tog.on { background: var(--good); }
.tog.on i { transform: translateX(22px); background: #fff; }
.tog:disabled { opacity: 0.6; }
.lobby-foot { padding: 10px 14px max(14px, env(safe-area-inset-bottom)); }
@media (max-width: 560px) {
  .opt { flex-direction: column; align-items: stretch; gap: 8px; }
  .seg { display: flex; }
  .seg button { flex: 1; padding: 9px 4px; }
  .opt:has(.tog) { flex-direction: row; align-items: center; }
}

/* ---------------------------------------------------------------- the sheet (menu, rules) */
#sheet { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 14px; background: rgba(4, 6, 12, 0.6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); animation: fade 0.2s both; }
.sheet-card { width: min(440px, 100%); max-height: calc(var(--vh) - 28px); overflow-y: auto; display: grid; gap: 10px; padding: 18px; border-radius: 22px; background: var(--panel2); border: 1px solid var(--line); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5); animation: rise 0.25s both; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head b { font-family: var(--display); font-weight: 400; font-size: 22px; letter-spacing: 0.03em; }
.sheet-head button { width: 38px; height: 38px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); }
.slider { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 10px; font-size: 14px; color: var(--dim); }
.slider input { width: 100%; accent-color: var(--accent); }
.hostrow { display: flex; gap: 8px; }
.hostrow .btn { flex: 1; padding: 10px 8px; }
.sheet-card.how { width: min(580px, 100%); }
.how h4 { margin: 8px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); }
.how p, .how li { font-weight: 700; font-size: 15px; line-height: 1.5; color: #e2e6f0; margin: 0; }
.how ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }

#toast { position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); z-index: 80; max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 14px; background: #f6f7fb; color: #141824; font-weight: 900; font-size: 15px; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); transform: translate(-50%, 160%); opacity: 0; transition: transform 0.3s cubic-bezier(0.3, 1.4, 0.5, 1), opacity 0.2s; pointer-events: none; }
#toast.show { transform: translate(-50%, 0); opacity: 1; }
#net { position: fixed; top: max(8px, env(safe-area-inset-top)); left: 50%; z-index: 90; padding: 8px 14px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 13px; transform: translate(-50%, -180%); transition: transform 0.3s; pointer-events: none; }
#net.show { transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- effects */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetto { position: absolute; top: -20px; border-radius: 2px; animation: fall linear both; }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--rot)); } }
.emote-float { position: absolute; bottom: 90px; display: flex; flex-direction: column; align-items: center; animation: float-up 2.5s ease-out both; }
.emote-float span { font-size: 44px; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35)); }
.emote-float small { margin-top: -4px; padding: 1px 8px; border-radius: 99px; background: var(--pc, #555); color: #fff; font-size: 11px; }
@keyframes float-up { 0% { opacity: 0; transform: translateY(20px) scale(0.6); } 15% { opacity: 1; transform: translateY(0) scale(1.1); } 100% { opacity: 0; transform: translateY(-46vh) scale(1); } }
.banner { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); text-align: center; font-family: var(--display); font-weight: 400; font-size: clamp(44px, 13vw, 110px); line-height: 0.95; letter-spacing: 0.03em; color: #fff; white-space: nowrap; text-shadow: 0 6px 0 rgba(0, 0, 0, 0.35), 0 0 40px color-mix(in srgb, var(--accent) 60%, transparent); animation: slam 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.banner small { display: block; font-family: var(--font); font-weight: 900; font-size: clamp(15px, 4vw, 22px); letter-spacing: 0.04em; margin-top: 10px; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); }
.banner.out { animation: banner-out 0.5s ease-in both; }
.banner.gold { color: var(--accent); }
.banner.bad { color: #ff8c9a; }
@keyframes slam { from { opacity: 0; transform: translate(-50%, -50%) scale(2.2); } }
@keyframes banner-out { to { opacity: 0; transform: translate(-50%, -60%) scale(0.9); } }

/* ---------------------------------------------------------------- the game stage */
#stage { position: fixed; left: 0; right: 0; top: 0; height: var(--vh); overflow: hidden; z-index: 5; touch-action: none; }
#stage canvas.gl { position: absolute; inset: 0; display: block; touch-action: none; }
.hud { position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; }
.hud > * { pointer-events: auto; }
.hud-top { display: flex; align-items: flex-start; gap: 8px; padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left)); pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.caption { align-self: center; margin-top: 8px; max-width: 92vw; padding: 7px 16px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); font-size: 14.5px; text-align: center; pointer-events: none; transition: opacity 0.3s; }
.caption:empty { opacity: 0; }
.caption b { color: var(--accent); }
.pcard { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 6px 10px 6px 6px; border-radius: 16px; background: var(--panel); border: 2px solid transparent; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); transition: border-color 0.25s, box-shadow 0.25s, opacity 0.25s; }
.pcard.on { border-color: var(--pc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pc) 30%, transparent), 0 0 24px color-mix(in srgb, var(--pc) 40%, transparent); }
.pcard .av { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 21px; background: color-mix(in srgb, var(--pc) 45%, #000); border: 2px solid var(--pc); flex: none; }
.pcard .pn { min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.pcard .pn b { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .pn small { font-size: 11.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* an overlay card over the table: end of the match, pass the phone */
.overlay { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(4, 6, 12, 0.55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fade 0.3s both; pointer-events: auto; }
.ocard { width: min(460px, 100%); max-height: calc(var(--vh) - 32px); overflow-y: auto; display: grid; gap: 12px; padding: 22px; border-radius: 24px; background: var(--panel2); border: 1px solid var(--line); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55); text-align: center; animation: rise 0.35s both; }
.ocard h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(28px, 8vw, 40px); letter-spacing: 0.02em; color: var(--accent); }
.ocard p { margin: 0; color: var(--dim); font-size: 15px; line-height: 1.4; }
.ocard .row { display: flex; gap: 8px; }
.ocard .row .btn { flex: 1; }
.pass .ocard { cursor: pointer; }
.pass .who-big { font-family: var(--display); font-weight: 400; font-size: clamp(30px, 9vw, 46px); color: #fff; }

/* a strip of reaction buttons */
.emotes { display: flex; gap: 2px; padding: 3px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); }
.emotes button { width: 34px; height: 34px; border-radius: 50%; font-size: 18px; display: grid; place-items: center; transition: transform 0.12s; }
.emotes button:active { transform: scale(1.3); }
