:root { --vh: 100vh; --navy: #0b1d3a; --sky: #7cc4ee; --gold: #ffd23f; --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px); --sb: env(safe-area-inset-bottom, 0px); --st: env(safe-area-inset-top, 0px); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1d3a; color: #fff; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body { position: fixed; inset: 0; height: var(--vh); }
#c { position: fixed; left: 0; top: 0; width: 100vw; height: var(--vh); display: block; }
.hidden { display: none !important; }

/* ---------- menus ---------- */
#ui { position: fixed; inset: 0; height: var(--vh); display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(11,29,58,0.55), rgba(5,12,26,0.92)); z-index: 20; padding: calc(10px + var(--st)) calc(14px + var(--sr)) calc(10px + var(--sb)) calc(14px + var(--sl)); overflow: auto; touch-action: pan-y; }
.scr { width: min(760px, 100%); max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.scr h2 { margin: 4px 0; font-size: clamp(20px, 4vh, 30px); letter-spacing: 1px; text-transform: uppercase; font-weight: 900; font-style: italic; }
.logo { display: flex; align-items: baseline; gap: 10px; font-weight: 900; font-style: italic; font-size: clamp(42px, 13vh, 96px); line-height: 1; text-shadow: 0 6px 0 rgba(0,0,0,0.35); }
.logo .tb1 { color: #fff; } .logo .tb2 { color: var(--sky); } .logo small { font-size: 0.2em; letter-spacing: 6px; color: var(--gold); align-self: flex-end; margin-bottom: 0.6em; }
.menu { display: flex; flex-direction: column; gap: 8px; width: min(420px, 100%); }
.menu.row2 { flex-direction: row; flex-wrap: wrap; justify-content: center; width: 100%; }
.menu.row2 .btn { flex: 1 1 140px; max-width: 280px; }
.btn { appearance: none; border: 2px solid rgba(255,255,255,0.18); background: linear-gradient(180deg, #1c3566, #12264d); color: #fff; font: inherit; font-weight: 800; font-size: clamp(15px, 2.6vh, 19px); padding: clamp(8px, 1.7vh, 13px) 16px; border-radius: 12px; cursor: pointer; text-align: center; }
.btn.big { background: linear-gradient(180deg, #8fd0f4, #4aa6dd); color: #062042; border-color: #c8ecff; }
.btn:active { transform: translateY(1px); }
.nv.focus, .btn:hover { outline: 3px solid var(--gold); outline-offset: 2px; }
.panel { width: 100%; background: rgba(8,18,40,0.75); border: 1px solid rgba(255,255,255,0.12); border-radius: 14px; padding: 6px 12px; }
.panel.scroll { max-height: calc(var(--vh) - 150px); overflow: auto; touch-action: pan-y; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: clamp(5px, 1.2vh, 9px) 2px; border-bottom: 1px solid rgba(255,255,255,0.07); border-radius: 8px; }
.row:last-child { border-bottom: 0; }
.row .lab { opacity: 0.85; font-size: 15px; }
.ctl { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; }
.ctl b { min-width: 60px; text-align: center; white-space: nowrap; }
.ctl button, .sm { appearance: none; border: 0; background: rgba(255,255,255,0.12); color: #fff; width: 38px; height: 34px; border-radius: 9px; font-size: 20px; font-weight: 900; cursor: pointer; }
.kit { display: inline-block; width: 16px; height: 16px; border-radius: 4px; border: 3px solid #fff; vertical-align: -2px; margin: 0 6px; }
.ctl small, .row small { opacity: 0.6; }
input { font: inherit; font-size: 17px; padding: 8px 12px; border-radius: 10px; border: 2px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.08); color: #fff; width: 200px; -webkit-user-select: text; user-select: text; touch-action: manipulation; }
.joinrow { display: flex; gap: 8px; } .joinrow input { flex: 1; text-transform: uppercase; letter-spacing: 4px; font-weight: 800; text-align: center; }
.hint { opacity: 0.75; font-size: 13px; text-align: center; }
.small { font-size: 13px; opacity: 0.8; }
.foot { opacity: 0.5; font-size: 12px; }
.err { color: #ff8a8a; min-height: 18px; font-weight: 700; }
.g { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 11px; background: #111827; font-size: 13px; font-weight: 900; border: 1px solid rgba(255,255,255,0.35); margin: 0 2px; vertical-align: middle; }
.gx { color: #7fb2ff; } .go { color: #ff6b6b; } .gs { color: #ff8fd8; } .gt { color: #52e3a5; } .gl { color: #fff; font-size: 10px; border-radius: 6px; } .gk { color: #fff; font-size: 11px; border-radius: 5px; }
.howto table { width: 100%; border-collapse: collapse; font-size: 14px; } .howto td { padding: 5px 4px; border-bottom: 1px solid rgba(255,255,255,0.07); vertical-align: middle; } .howto td:first-child { white-space: nowrap; width: 38%; font-weight: 700; }
.howto h3 { margin: 12px 0 4px; color: var(--sky); font-size: 15px; text-transform: uppercase; }
.sel-head { display: grid; grid-template-columns: 1fr 1fr 1fr; width: 100%; text-align: center; font-weight: 800; align-items: center; }
.sel-head .mode { color: var(--gold); font-size: 13px; letter-spacing: 1px; }
.sel { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.srow { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.srow .cell { min-height: 46px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.05); border-radius: 10px; }
.srow .cell.mid { justify-content: space-between; padding: 0 4px; }
.srow .dev { background: linear-gradient(180deg, #8fd0f4, #4aa6dd); color: #062042; font-weight: 900; padding: 8px 12px; border-radius: 10px; font-size: 14px; white-space: nowrap; }
.srow .dot { opacity: 0.3; }
.sarrow { appearance: none; border: 0; background: rgba(255,255,255,0.12); color: #fff; width: 40px; height: 40px; border-radius: 10px; font-size: 16px; cursor: pointer; }
.ftscore { display: flex; align-items: center; gap: 16px; font-weight: 800; font-size: clamp(14px, 2.6vh, 18px); }
.ftscore b { font-size: clamp(34px, 8vh, 56px); font-style: italic; }
.scorers { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; font-size: 13px; opacity: 0.85; text-align: center; }
.stats { width: min(460px, 100%); }
.st { display: grid; grid-template-columns: 60px 1fr 60px; text-align: center; padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,0.08); font-size: 14px; }
.st span { opacity: 0.7; }
.lobby { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.lside { background: rgba(8,18,40,0.75); border-radius: 12px; padding: 8px 10px; min-height: 70px; }
.lside h4 { margin: 0 0 6px; font-size: 14px; }
.lp { padding: 5px 8px; background: rgba(255,255,255,0.08); border-radius: 8px; margin-bottom: 4px; font-weight: 700; font-size: 14px; }
.lp.off { opacity: 0.45; } .lp.empty { opacity: 0.45; font-style: italic; font-weight: 400; }
.code { background: var(--gold); color: #062042; padding: 0 12px; border-radius: 8px; letter-spacing: 4px; font-style: normal; }
.lcl { font-size: 14px; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 5px solid rgba(255,255,255,0.2); border-top-color: var(--sky); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.softalert { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #111827; padding: 10px 18px; border-radius: 10px; z-index: 50; font-weight: 700; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; height: var(--vh); pointer-events: none; z-index: 16; }
.sb { position: absolute; top: calc(8px + var(--st)); left: calc(10px + var(--sl)); display: flex; align-items: stretch; font-weight: 900; font-size: clamp(13px, 2.6vh, 17px); box-shadow: 0 3px 10px rgba(0,0,0,0.35); border-radius: 6px; overflow: hidden; }
.sb > span { padding: 4px 9px; display: flex; align-items: center; gap: 6px; }
.sb .tm { background: #f4f6fa; color: #0b1d3a; } .sb .score { background: #0b1d3a; min-width: 58px; justify-content: center; } .sb .clk { background: var(--sky); color: #062042; min-width: 46px; justify-content: center; }
.sb .sw { display: inline-block; width: 6px; height: 18px; border-radius: 2px; border: 0 solid; border-left-width: 0; }
.banner { position: absolute; top: 28%; left: 50%; transform: translate(-50%, -50%) skewX(-8deg); background: linear-gradient(90deg, rgba(11,29,58,0.0), rgba(11,29,58,0.92) 15%, rgba(11,29,58,0.92) 85%, rgba(11,29,58,0)); padding: 10px 70px; font-weight: 900; font-style: italic; font-size: clamp(22px, 6vh, 44px); letter-spacing: 2px; text-align: center; white-space: nowrap; animation: pop 0.35s ease-out; }
.banner small { display: block; font-size: 0.4em; letter-spacing: 1px; opacity: 0.85; font-style: normal; }
.banner.goal { color: var(--gold); font-size: clamp(40px, 13vh, 96px); text-shadow: 0 4px 0 rgba(0,0,0,0.4); }
@keyframes pop { from { transform: translate(-50%, -50%) skewX(-8deg) scale(1.6); opacity: 0; } }
.toast { position: absolute; top: calc(52px + var(--st)); left: 50%; transform: translateX(-50%); background: rgba(255,210,63,0.95); color: #062042; padding: 4px 14px; border-radius: 8px; font-weight: 900; font-style: italic; font-size: 15px; }
.plabel { position: absolute; left: 0; top: 0; padding: 1px 6px; border-radius: 5px; color: #062042; font-weight: 900; font-size: 11px; white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,0.4); }
.pbar { position: absolute; left: 0; top: 0; width: 64px; height: 9px; border-radius: 5px; background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.7); overflow: hidden; }
.pbar i { display: block; height: 100%; width: 0; }
.radar { position: absolute; bottom: calc(8px + var(--sb)); left: 50%; transform: translateX(-50%); width: 168px; height: 109px; border-radius: 6px; opacity: 0.9; }
.prompt { position: absolute; bottom: calc(126px + var(--sb)); left: 50%; transform: translateX(-50%); background: rgba(8,18,40,0.85); padding: 6px 14px; border-radius: 10px; font-weight: 800; font-size: 14px; white-space: nowrap; }
.netinfo { position: absolute; top: calc(10px + var(--st)); right: calc(64px + var(--sr)); font-size: 11px; opacity: 0.7; font-weight: 700; }
.pausebtn { position: absolute; top: calc(6px + var(--st)); right: calc(10px + var(--sr)); width: 44px; height: 36px; border-radius: 10px; border: 0; background: rgba(8,18,40,0.7); color: #fff; font-weight: 900; pointer-events: auto; cursor: pointer; }
.replaytag { position: absolute; top: calc(10px + var(--st)); left: 50%; transform: translateX(-50%); background: #d11f2e; padding: 4px 12px; border-radius: 6px; font-weight: 900; letter-spacing: 2px; }
.replaytag small { font-weight: 600; letter-spacing: 0; opacity: 0.85; margin-left: 6px; }

/* ---------- touch controls ---------- */
#touch { position: fixed; inset: 0; height: var(--vh); z-index: 15; touch-action: none; }
.tzone { position: absolute; left: 0; top: 0; bottom: 0; width: 45%; }
.tstick { position: absolute; width: 130px; height: 130px; margin: -65px 0 0 -65px; border-radius: 50%; background: rgba(255,255,255,0.12); border: 2px solid rgba(255,255,255,0.35); pointer-events: none; }
.tknob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; border-radius: 50%; background: rgba(255,255,255,0.55); transform: translate(-50%,-50%); }
.tbtns { position: absolute; right: calc(10px + var(--sr)); bottom: calc(10px + var(--sb)); width: min(330px, 46vw); height: min(240px, 62vh); }
.tbtn { position: absolute; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 12px; color: #fff; border: 3px solid rgba(255,255,255,0.55); background: rgba(10,25,50,0.55); text-shadow: 0 1px 2px #000; touch-action: none; }
.tbtn.on { background: rgba(255,210,63,0.75); color: #062042; text-shadow: none; transform: scale(0.94); }
.tbtn span { pointer-events: none; }
.b-o { width: 31%; aspect-ratio: 1; right: 0; bottom: 4%; border-color: #ff6b6b; }
.b-x { width: 26%; aspect-ratio: 1; right: 34%; bottom: 0; border-color: #7fb2ff; }
.b-s { width: 24%; aspect-ratio: 1; right: 3%; bottom: 47%; border-color: #ff8fd8; }
.b-t { width: 23%; aspect-ratio: 1; right: 31%; bottom: 38%; border-color: #52e3a5; }
.b-r2 { width: 25%; aspect-ratio: 1; right: 64%; bottom: 2%; border-color: #ffd23f; }
.b-l1 { width: 19%; aspect-ratio: 1; right: 60%; bottom: 42%; font-size: 10px; }
.b-l2 { width: 19%; aspect-ratio: 1; right: 14%; bottom: 82%; font-size: 10px; }
.tswipe { position: absolute; right: 0; top: 18%; width: 30%; height: 30%; }
.thint { position: absolute; right: calc(10px + var(--sr)); top: calc(48px + var(--st)); font-size: 10px; opacity: 0.45; max-width: 46vw; text-align: right; }

#rotate { display: none; position: fixed; inset: 0; z-index: 60; background: #0b1d3a; flex-direction: column; align-items: center; justify-content: center; gap: 10px; font-weight: 800; font-size: 20px; text-align: center; }
#rotate.show { display: flex; }
#rotate .rot-icon { font-size: 64px; animation: rot 1.6s ease-in-out infinite; }
@keyframes rot { 50% { transform: rotate(90deg); } }
@media (max-height: 430px) { .radar { width: 132px; height: 86px; } .prompt { bottom: calc(100px + var(--sb)); font-size: 12px; } .scr { gap: 6px; } .logo { font-size: 52px; } }
.ptag { font-style: normal; color: #062042; padding: 1px 6px; border-radius: 6px; margin-right: 6px; font-size: 12px; border: 1px solid rgba(0,0,0,0.3); }
