:root {
  --sea: #1d8fb3; --sea-d: #0b5d7a; --sand: #f3dfaa; --sand-d: #d9b96a; --red: #e70013; --ink: #1d2b36;
  --blue: #1a4fa0; --white: #fffdf6;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b5d7a; font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif; color: var(--ink); user-select: none; -webkit-user-select: none; touch-action: none; }
#cv, #gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; z-index: 5; background: radial-gradient(ellipse at 50% 30%, rgba(29,143,179,.55), rgba(8,60,86,.92)); }
.zellige { position: fixed; top: 0; left: 0; right: 0; height: 18px; background:
  conic-gradient(from 45deg at 50% 50%, var(--red) 0 25%, var(--white) 0 50%, var(--blue) 0 75%, var(--white) 0) 0 0/36px 36px; opacity: .95; box-shadow: 0 3px 10px rgba(0,0,0,.35); }
.card { background: var(--sand); border: 4px solid var(--white); border-radius: 22px; padding: 22px 24px; width: min(440px, 100%); box-shadow: 0 12px 40px rgba(0,0,0,.45), inset 0 0 0 3px var(--sand-d); text-align: center; max-height: 100%; overflow: auto; }
.card.wide { width: min(560px, 100%); }
.logo { font-family: Impact, "Arial Black", sans-serif; font-size: clamp(38px, 9vw, 58px); margin: 0 0 4px; letter-spacing: 1px; color: var(--red); text-shadow: 3px 3px 0 var(--white), 5px 5px 0 var(--blue); transform: rotate(-2deg); }
.logo span { color: var(--blue); text-shadow: 3px 3px 0 var(--white), 5px 5px 0 var(--red); }
.logo b { color: var(--red); font-size: 1.25em; }
.tag { margin: 6px 0 14px; font-weight: 600; } .tag small { font-weight: 400; opacity: .8; } .tag.small { font-size: 14px; margin: 6px 0; }
label { display: block; text-align: left; font-weight: 700; margin-bottom: 10px; }
input[type=text], input:not([type]), #name, #code { width: 100%; font: inherit; font-size: 18px; padding: 10px 12px; border-radius: 12px; border: 3px solid var(--sand-d); background: var(--white); margin-top: 4px; outline: none; }
#name:focus, #code:focus { border-color: var(--blue); }
#code { text-transform: uppercase; text-align: center; letter-spacing: 6px; font-weight: 800; margin: 0; flex: 1; min-width: 0; }
.row { display: flex; gap: 10px; margin: 10px 0; }
.row > * { flex: 1; }
button { font: inherit; font-weight: 800; cursor: pointer; border: 3px solid var(--ink); border-radius: 14px; background: var(--white); color: var(--ink); padding: 10px 14px; box-shadow: 0 4px 0 var(--ink); transition: transform .08s, box-shadow .08s; }
button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
button.big { font-size: 19px; padding: 12px 16px; }
button.primary { background: var(--red); color: var(--white); }
button.small { font-size: 13px; padding: 5px 10px; margin-left: 8px; box-shadow: 0 3px 0 var(--ink); }
button:disabled { opacity: .45; cursor: not-allowed; }
.or { font-weight: 800; opacity: .6; margin: 4px 0; }
.err { color: var(--red); font-weight: 700; min-height: 1.2em; margin: 6px 0 0; }
.how { text-align: left; margin-top: 8px; font-size: 14px; } .how summary { cursor: pointer; font-weight: 800; }
.how li { margin: 6px 0; } kbd { background: var(--white); border: 2px solid var(--ink); border-radius: 5px; padding: 0 5px; font-size: 12px; }
h2 { margin: 0 0 4px; font-size: 26px; } h3 { margin: 12px 0 6px; }
.code { font-family: monospace; background: var(--white); border: 3px dashed var(--red); border-radius: 10px; padding: 0 10px; letter-spacing: 5px; color: var(--red); }

.plist { list-style: none; padding: 0; margin: 10px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.plist li { display: flex; align-items: center; gap: 8px; background: var(--white); border-radius: 12px; padding: 8px 10px; border: 3px solid var(--sand-d); text-align: left; font-weight: 700; min-height: 54px; }
.plist li.empty { opacity: .45; border-style: dashed; font-weight: 400; }
.plist .dot { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--ink); flex: none; display: grid; place-items: center; font-size: 16px; }
.plist .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist .mic { font-size: 16px; opacity: .35; } .plist .mic.on { opacity: 1; } .plist .mic.talk { animation: pulse .5s infinite alternate; filter: drop-shadow(0 0 4px #2ecc71); }
@keyframes pulse { to { transform: scale(1.35); } }
.levels { display: grid; gap: 8px; }
.lvl { text-align: left; padding: 8px 12px; border: 3px solid var(--sand-d); border-radius: 12px; background: var(--white); cursor: pointer; box-shadow: none; font-weight: 700; }
.lvl small { display: block; font-weight: 400; opacity: .75; }
.lvl.sel { border-color: var(--red); background: #ffe9e9; }
.lvl:disabled { cursor: default; opacity: .8; } .lvl.sel:disabled { opacity: 1; }
.voice-box { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 10px 0; font-weight: 700; font-size: 14px; }
.vol { margin: 0; display: flex; align-items: center; gap: 4px; } .vol input { width: 90px; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 3; font-weight: 800; color: var(--white); text-shadow: 0 2px 0 rgba(0,0,0,.45); }
#hud button { pointer-events: auto; }
#hud-top { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; flex-wrap: wrap; max-width: 60%; }
.pill { background: rgba(10,40,60,.65); border: 2px solid rgba(255,255,255,.6); border-radius: 999px; padding: 3px 12px; font-size: 16px; }
#progress { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); width: min(34vw, 380px); min-width: 150px; height: 14px; background: rgba(10,40,60,.65); border: 2px solid rgba(255,255,255,.7); border-radius: 99px; }
#prog-fill { height: 100%; width: 0; background: linear-gradient(90deg, #ffd34e, #ff7a3d); border-radius: 99px; }
#prog-marks i { position: absolute; top: -3px; width: 3px; height: 14px; background: #fff; border-radius: 2px; opacity: .8; }
#prog-raft { position: absolute; top: -12px; left: 0; font-size: 22px; transform: translateX(-50%); text-shadow: none; }
#hud-left { position: absolute; top: 56px; left: 10px; }
#hud-players { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
#hud-players li { display: flex; align-items: center; gap: 6px; background: rgba(10,40,60,.55); padding: 3px 10px 3px 4px; border-radius: 99px; font-size: 14px; }
#hud-players .dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; } #hud-players .me { outline: 2px solid #ffd34e; }
#hud-players .mic.talk { filter: drop-shadow(0 0 4px #2ecc71); animation: pulse .5s infinite alternate; }
#hud-bars { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); width: min(420px, 90vw); display: grid; gap: 6px; }
.bar-wrap { display: flex; align-items: center; gap: 8px; } .bar-wrap span { width: 38px; font-size: 14px; }
.bar { flex: 1; height: 18px; background: rgba(10,40,60,.7); border: 2px solid #fff; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; transition: width .1s; }
.bar.hp i { background: linear-gradient(#ff6a5a, #d6261b); } .bar.gas i { background: linear-gradient(#b7e35a, #5a9d1e); }
#boost { text-align: center; font-size: 20px; color: #ffd34e; animation: pulse .4s infinite alternate; }
#banner { position: absolute; top: 28%; left: 0; right: 0; text-align: center; font-family: Impact, "Arial Black", sans-serif; font-size: clamp(36px, 9vw, 96px); letter-spacing: 2px; text-shadow: 4px 4px 0 var(--red), 7px 7px 0 rgba(0,0,0,.4); opacity: 0; transition: opacity .25s; padding: 0 10px; }
#banner.show { opacity: 1; }
#hud-btns { position: absolute; top: 10px; right: 10px; display: flex; gap: 8px; }
.round { width: 42px; height: 42px; border-radius: 50%; padding: 0; font-size: 20px; text-shadow: none; }
.round.off { background: #bbb; opacity: .8; }
#emotes { position: absolute; right: 10px; bottom: 14px; display: flex; flex-direction: column; gap: 4px; pointer-events: auto; }
#emotes button { font-size: 12px; padding: 3px 8px; box-shadow: 0 2px 0 var(--ink); text-align: left; opacity: .85; }
#emotes button kbd { margin-right: 4px; }
@media (max-width: 700px) { #emotes { flex-direction: row; flex-wrap: wrap; width: 46vw; bottom: 54px; right: 6px; justify-content: flex-end; } #emotes button { font-size: 11px; } #hud-top { max-width: 100%; } #progress { top: 50px; width: 70vw; } #hud-left { top: 84px; } }

.stars { font-size: 48px; letter-spacing: 8px; margin: 4px 0; filter: drop-shadow(0 3px 0 rgba(0,0,0,.25)); }
#res-table { width: 100%; margin: 10px 0; border-collapse: collapse; background: var(--white); border-radius: 12px; overflow: hidden; }
#res-table td { padding: 7px 12px; border-bottom: 2px solid var(--sand); text-align: left; } #res-table td:last-child { text-align: right; font-weight: 800; }
#toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 16px; border-radius: 99px; font-weight: 700; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 20; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; }

/* 3D labels (projected from world space) */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.lbl, .bub, .pop { position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform; }
.lbl { display: flex; align-items: center; gap: 5px; background: rgba(10,30,45,.72); color: #fff; font-weight: 800; font-size: 14px; padding: 2px 10px 2px 6px; border-radius: 99px; border: 2px solid rgba(255,255,255,.55); text-shadow: none; }
.lbl.me { color: #ffd34e; border-color: #ffd34e; }
.lbl i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; flex: none; }
.lbl .mic { display: none; } .lbl.talk .mic { display: inline; animation: pulse .5s infinite alternate; }
.bub { background: #fff; color: #1d2b36; border: 3px solid #999; border-radius: 14px; padding: 4px 12px; font-weight: 800; font-size: 17px; margin-top: -10px; }
.bub::after { content: ''; position: absolute; left: 50%; bottom: -9px; width: 11px; height: 11px; background: #fff; border-right: 3px solid; border-bottom: 3px solid; border-color: inherit; transform: translateX(-50%) rotate(45deg); }
.pop { font-family: Impact, "Arial Black", sans-serif; text-shadow: 0 0 5px #000, 2px 2px 0 rgba(0,0,0,.6); -webkit-text-stroke: 1px rgba(0,0,0,.55); }
@media (max-width: 700px) { #h-lvl { display: none; } .pill { font-size: 14px; padding: 2px 9px; } }

/* 3D-only overlays: soft vignette + event flash (white on sink, gold on brik) */
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 1; background: radial-gradient(ellipse at 50% 45%, rgba(0,0,0,0) 52%, rgba(5,20,35,.38) 100%); }
#flash { position: fixed; inset: 0; pointer-events: none; z-index: 2; opacity: 0; background: #fff; }
#gl.hidden ~ #vignette, #gl.hidden ~ #flash { display: none; }
