/* Futevôlei no Ibira — dusk palette from the Ibirapuera scene. The page is always the night scene, so
   the dark tokens are the only theme; :root and the dark-mode blocks share them on purpose. */
:root, :root[data-theme="dark"] {
  --bg: #0b0d24;
  --ink: #fff6ec;
  --ink-2: rgba(255, 240, 226, .78);
  --ink-3: rgba(255, 240, 226, .55);
  --card: rgba(18, 16, 40, .72);
  --card-2: rgba(30, 26, 60, .78);
  --line: rgba(255, 220, 200, .16);
  --warm: #ffd7a6;
  --pink: #f49a94;
  --t0: #be92ff;
  --t1: #40d6c4;
  --btn: rgba(255, 246, 236, .1);
  --btn-on: rgba(255, 246, 236, .2);
  --primary: #ffcf9a;
  --primary-ink: #2a1630;
  --sans: 'Inter Tight', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bg: #0b0d24; } }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--sans); }
body { overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* Follow invitation covers every entry, including private links and the local relax mode. */
#followGate{position:fixed;inset:0;z-index:100;display:grid;place-items:center;padding:22px;background:rgba(6,5,18,.58);backdrop-filter:blur(7px)}
.follow-card{width:min(420px,100%);padding:28px 24px;text-align:center;border:1px solid var(--line);border-radius:24px;background:rgba(24,18,43,.92);box-shadow:0 24px 70px #0007}
.follow-card h1{font-size:clamp(24px,6vw,30px);font-weight:400;letter-spacing:-.03em;line-height:1.1;margin:18px 0}
.follow-card p{color:var(--ink-2);font-size:17px;line-height:1.4;margin:0 0 22px}
.follow-card strong{color:var(--warm)}
#follow{display:block;border-radius:16px;padding:15px 10px;background:linear-gradient(110deg,#a23490,#d45878,#c07849);color:#fff;text-decoration:none;font-weight:700;font-size:16px}
#follow:focus-visible{outline:3px solid var(--warm);outline-offset:4px}
.follow-card small{display:block;color:var(--ink-3);font-size:12px;line-height:1.5;margin-top:18px}
body.locked #menu,body.locked #tvctl{visibility:hidden}

#app { position: fixed; inset: 0; overflow: hidden; }
#bg, #fg { position: absolute; left: 0; top: 0; }
#fg { pointer-events: none; z-index: 3; }
#tv { position: absolute; z-index: 2; border: 0; background: #06070c; display: block; transition: left .35s ease, top .35s ease, width .35s ease, height .35s ease; }
#tv.zoom { z-index: 30; box-shadow: 0 20px 80px rgba(0, 0, 0, .7); border-radius: 10px; }
#tvshade { position: absolute; inset: 0; z-index: 29; background: rgba(6, 5, 16, .72); backdrop-filter: blur(3px); }
#tvctl { position: absolute; z-index: 4; display: flex; gap: 4px; align-items: center; transform: translateX(-50%); }
#tvctl.zoomed { z-index: 31; }
#tvctl.side { flex-direction: column; transform: translateY(-50%); }
#tvctl.side #tvch { display: none; }
#tvctl button { width: 30px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: rgba(14, 12, 24, .82); font-size: 16px; line-height: 1; display: grid; place-items: center; }
#tvctl button:active { background: var(--btn-on); }
#tvch { font: 600 10px/1 var(--mono); letter-spacing: .08em; color: var(--ink-2); padding: 0 6px; min-width: 90px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }

/* ---------------------------------------------------------------- HUD */
#hud { position: absolute; z-index: 10; left: 0; right: 0; top: 0; height: 52px; padding: calc(env(safe-area-inset-top) + 8px) 10px 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; pointer-events: none; }
#hud > * { pointer-events: auto; }
.chip { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: 17px; border: 1px solid var(--line); background: var(--card); backdrop-filter: blur(8px); }
.chip .lbl { font: 600 10px var(--mono); letter-spacing: .12em; color: var(--ink-3); }
.chip b { font: 700 14px var(--mono); letter-spacing: .14em; color: var(--warm); }
.chip svg { width: 15px; height: 15px; color: var(--ink-2); }
#score { position: relative; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: 17px; background: var(--card); border: 1px solid var(--line); backdrop-filter: blur(8px); }
#score .team { display: flex; align-items: center; gap: 6px; }
#score i { width: 8px; height: 8px; border-radius: 50%; background: var(--t0); box-shadow: 0 0 8px var(--t0); }
#score .t1 i { background: var(--t1); box-shadow: 0 0 8px var(--t1); }
#score em { font-style: normal; font-size: 12px; color: var(--ink-2); }
#score b { font: 700 18px var(--mono); min-width: 1.3em; text-align: center; }
#score .x { color: var(--ink-3); font-size: 12px; }
#score .serve::after { content: '•'; color: var(--warm); margin-left: -2px; }
#touches { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 4px; font: 600 9px var(--mono); letter-spacing: .1em; color: var(--ink-2); white-space: nowrap; background: rgba(14, 12, 28, .72); border-radius: 8px; padding: 2px 7px; }
#touches:empty { display: none; }
#touches b { color: var(--warm); font-weight: 700; letter-spacing: .3em; }
.right { display: flex; gap: 6px; }
.icon { width: 34px; height: 34px; border-radius: 17px; border: 1px solid var(--line); background: var(--card); backdrop-filter: blur(8px); display: grid; place-items: center; font-size: 15px; line-height: 1; }
.icon.off { color: var(--ink-3); text-decoration: line-through; }

#banner { position: absolute; z-index: 9; left: 50%; transform: translate(-50%, -10px); opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; text-align: center; white-space: nowrap; }
#banner.show { opacity: 1; transform: translate(-50%, 0); }
#banner .k { font: 700 11px var(--mono); letter-spacing: .4em; text-indent: .4em; color: var(--warm); }
#banner .t { font-weight: 300; font-size: clamp(26px, 6vw, 44px); letter-spacing: -.02em; text-shadow: 0 0 30px rgba(255, 170, 200, .4), 0 4px 22px rgba(6, 4, 20, .8); }
#banner .s { font: 500 11px var(--mono); letter-spacing: .2em; color: var(--ink-2); margin-top: 2px; }
#hint { position: absolute; z-index: 9; left: 50%; transform: translateX(-50%); font: 500 12px var(--sans); color: var(--ink); background: var(--card); border: 1px solid var(--line); padding: 6px 12px; border-radius: 14px; pointer-events: none; white-space: nowrap; opacity: 0; transition: opacity .2s; }
#hint.show { opacity: 1; }

/* ---------------------------------------------------------------- lobby sheet */
#lobby { position: absolute; z-index: 12; left: 50%; transform: translateX(-50%); width: min(420px, calc(100vw - 20px)); padding: 10px 12px; border-radius: 18px; background: var(--card-2); border: 1px solid var(--line); backdrop-filter: blur(12px); box-shadow: 0 12px 40px rgba(0, 0, 0, .45); }
#lobby .row { display: flex; align-items: center; gap: 10px; }
#lobby .top { justify-content: space-between; }
#lobby .top > div { flex: 1; min-width: 0; }
.kicker { font: 700 10px var(--mono); letter-spacing: .22em; color: var(--warm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bigcode { font: 700 30px/1.1 var(--mono); letter-spacing: .26em; }
#lobby .fold { flex: none; }
#lobby.folded .body { display: none; }
#lobby .slots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 6px; }
#lobby .side { padding: 8px; border-radius: 12px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); }
#lobby .side.t0 { border-color: color-mix(in srgb, var(--t0) 45%, transparent); }
#lobby .side.t1 { border-color: color-mix(in srgb, var(--t1) 45%, transparent); }
#lobby .tn { font: 600 10px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
#lobby .slot { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-top: 5px; color: var(--ink-2); }
#lobby .slot i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; flex: none; }
#lobby .t0 .slot i { color: var(--t0); } #lobby .t1 .slot i { color: var(--t1); }
#lobby .slot.h i, #lobby .slot.me i { background: currentColor; }
#lobby .slot.me { color: var(--ink); font-weight: 600; }
#lobby .slot.b, #lobby .slot.e, #lobby .slot.away { color: var(--ink-3); }
#lobby .opts { justify-content: space-between; margin-bottom: 8px; font-size: 13px; color: var(--ink-2); }
.toggle { display: flex; align-items: center; gap: 6px; }
.toggle input { accent-color: var(--primary); width: 16px; height: 16px; }
.sel select { margin-left: 4px; background: var(--btn); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px; font: inherit; }
#lobby .actions .btn { flex: 1; margin: 0; }
.note { margin: 8px 0 0; font-size: 12px; color: var(--ink-3); text-align: center; }

/* ---------------------------------------------------------------- buttons */
.btn { display: block; width: 100%; margin: 8px 0 0; height: 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--btn); font-weight: 600; font-size: 15px; }
.btn:active { background: var(--btn-on); }
.btn.primary { background: linear-gradient(180deg, #ffd9ad, #f6b48a); color: var(--primary-ink); border-color: transparent; box-shadow: 0 6px 24px rgba(255, 170, 130, .25); }
.btn.ghost { background: transparent; }
.btn.small { width: auto; height: 36px; padding: 0 14px; margin: 0; font-size: 14px; }
.btn:disabled { opacity: .5; }

/* ---------------------------------------------------------------- touch controls */
#controls { position: absolute; z-index: 8; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end; padding: 0 14px calc(env(safe-area-inset-bottom) + 14px); pointer-events: none; }
#controls > * { pointer-events: auto; touch-action: none; }
#pad { display: flex; width: 150px; height: 78px; border-radius: 39px; background: rgba(14, 12, 28, .5); border: 1px solid var(--line); backdrop-filter: blur(6px); }
#pad span { flex: 1; display: grid; place-items: center; font-size: 22px; color: var(--ink-2); transition: color .1s, background .1s; }
#pad .l { border-radius: 39px 0 0 39px; } #pad .r { border-radius: 0 39px 39px 0; }
#pad[data-dir="-1"] .l, #pad[data-dir="1"] .r { background: rgba(255, 246, 236, .16); color: var(--ink); }
#controls .btns { display: flex; gap: 12px; align-items: flex-end; }
#controls .btns button { border-radius: 50%; border: 1px solid var(--line); background: rgba(14, 12, 28, .5); backdrop-filter: blur(6px); font: 700 11px var(--mono); letter-spacing: .08em; }
#bjump { width: 64px; height: 64px; margin-bottom: 30px; }
#bkick { width: 86px; height: 86px; background: rgba(255, 190, 140, .22) !important; border-color: rgba(255, 210, 170, .45) !important; color: var(--warm); }
#controls .btns button.on { background: rgba(255, 246, 236, .28) !important; transform: scale(.96); }

#emobar { position: absolute; z-index: 9; }
#emotray { position: absolute; bottom: 42px; left: 50%; transform: translateX(-50%); display: grid; grid-template-columns: repeat(4, 40px); gap: 6px; padding: 8px; border-radius: 16px; background: var(--card-2); border: 1px solid var(--line); backdrop-filter: blur(10px); }
#emotray button { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--btn); font-size: 22px; line-height: 1; }

/* ---------------------------------------------------------------- menu */
#menu { position: absolute; z-index: 20; inset: 0; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at 50% 60%, rgba(8, 6, 24, .25), rgba(8, 6, 24, .65)); }
#menu .card { width: min(400px, 100%); padding: 22px 20px 16px; border-radius: 22px; background: var(--card); border: 1px solid var(--line); backdrop-filter: blur(14px); box-shadow: 0 20px 60px rgba(0, 0, 0, .5); text-align: center; }
#menu .kicker { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 9.5px; letter-spacing: .32em; }
#menu .kicker i { width: 26px; height: 1px; background: rgba(255, 215, 166, .55); }
#menu h1 { margin: 8px 0 4px; font-weight: 300; font-size: clamp(30px, 8.5vw, 40px); letter-spacing: -.025em; line-height: 1.08; text-shadow: 0 0 34px rgba(255, 170, 190, .32); }
#menu .sub { margin: 0 0 14px; color: var(--ink-2); font-size: 14px; line-height: 1.4; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(255, 255, 255, .05); border: 1px solid var(--line); }
.seg button { height: 36px; border: 0; border-radius: 10px; background: transparent; font: 700 14px var(--mono); letter-spacing: .1em; color: var(--ink-2); }
.seg button[aria-checked="true"] { background: var(--btn-on); color: var(--ink); }
#joinForm { display: flex; gap: 8px; margin-top: 8px; }
#codeIn { flex: 1; min-width: 0; height: 46px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0, 0, 0, .25); color: var(--ink); text-align: center; font: 700 22px var(--mono); letter-spacing: .4em; text-transform: uppercase; -webkit-user-select: text; user-select: text; }
#joinForm .btn { height: 46px; }
.how { margin: 12px 0 0; font-size: 12px; color: var(--ink-3); line-height: 1.5; }
.foot { margin: 6px 0 0; font: 500 9.5px var(--mono); letter-spacing: .14em; color: var(--ink-3); text-transform: uppercase; }

#chill { position: absolute; z-index: 20; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 22px); transform: translateX(-50%); width: auto; padding: 0 22px; }
#toast { position: absolute; z-index: 40; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 120px); transform: translateX(-50%); padding: 10px 16px; border-radius: 14px; background: rgba(20, 16, 36, .92); border: 1px solid var(--line); font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100vw - 32px); text-align: center; }
#toast.show { opacity: 1; }

@media (max-width: 560px) {
  #score em, .chip .lbl { display: none; }
  #score { gap: 6px; padding: 0 10px; }
  #tvch { display: none; }
  .bigcode { font-size: 24px; }
}
@media (max-width: 340px) { .chip svg { display: none; } }
@media (prefers-reduced-motion: reduce) { #tv, #banner { transition: none; } }

#menu .foot a{color:var(--warm)}
/* Reserve the switcher's corner on touch/compact screens, keeping the pad clear. */
body.rooms-top #hud{padding-left:174px}
body.rooms-top #roomchip{position:absolute;left:12px;top:calc(env(safe-area-inset-top) + 172px)}
@media (max-width:600px),(max-height:480px){
  body.rooms-top #hud{padding-left:110px}
  body.rooms-top #roomchip{top:calc(env(safe-area-inset-top) + 52px)}
}
#connection{position:fixed;z-index:40;left:50%;top:64px;transform:translateX(-50%);padding:9px 14px;border-radius:20px;background:#0b0d24e8;color:#f1d5ae;font:500 12px 'Inter Tight',sans-serif;text-align:center;white-space:nowrap}
