* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b1e2b; color: #f3f4f8; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; }
.overlay { background: radial-gradient(ellipse at top, #3b2f6b 0%, #1b1e2b 70%); display: flex; align-items: center; justify-content: center; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); overflow: auto; }
.card { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 20px; padding: 28px 24px; width: min(92vw, 380px); text-align: center; backdrop-filter: blur(10px); }
.logo { font-size: 44px; margin: 0 0 4px; letter-spacing: -1px; }
.logo span { color: #ffd23c; }
.sub { margin: 0 0 20px; color: #b8bcd0; }
input { width: 100%; font-size: 18px; padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(255,255,255,.2); background: rgba(0,0,0,.3); color: #fff; margin-bottom: 12px; outline: none; }
.btn { font-size: 16px; padding: 12px 18px; border-radius: 12px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.1); color: #fff; cursor: pointer; transition: transform .08s, background .15s; }
.btn:hover { background: rgba(255,255,255,.18); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, #ff4b4b, #ff8a3d); border-color: transparent; font-weight: 700; }
.btn.big { width: 100%; font-size: 20px; padding: 16px; }
.btn.sm { font-size: 14px; padding: 8px 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; margin-top: 10px; }
.row .btn { flex: 1; }
.muted { color: #9ea3ba; font-size: 14px; }
.pill { display: inline-block; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.1); font-size: 14px; margin-left: 6px; }
.pill.gold { background: rgba(255,210,60,.18); color: #ffd23c; }
.menu-wrap { width: min(96vw, 820px); max-height: 96vh; display: flex; flex-direction: column; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); border-radius: 22px; padding: 18px 20px; }
.menu-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.menu-head h2 { margin: 0; }
.who .name { font-size: 22px; font-weight: 700; cursor: pointer; border-bottom: 1px dashed rgba(255,255,255,.3); }
.menu-body { display: flex; gap: 18px; align-items: flex-start; flex: 1; min-height: 0; }
.menu-body canvas { width: 260px; height: 300px; border-radius: 16px; background: rgba(0,0,0,.25); flex: none; }
.menu-right { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.menu-right h3 { margin: 0; font-size: 15px; color: #b8bcd0; text-transform: uppercase; letter-spacing: 1px; }
.levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.level { padding: 10px 12px; border-radius: 12px; border: 2px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06); cursor: pointer; text-align: left; color: #fff; }
.level b { display: block; }
.level small { color: #9ea3ba; }
.level.active { border-color: #ffd23c; background: rgba(255,210,60,.12); }
.check { display: flex; gap: 8px; align-items: center; justify-content: flex-start; color: #b8bcd0; font-size: 14px; }
.check input { flex: none; width: 20px; height: 20px; margin: 0; }
.hats { display: flex; flex-direction: column; gap: 8px; }
.hat { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-radius: 12px; border: 2px solid rgba(255,255,255,.1); background: rgba(255,255,255,.05); cursor: pointer; }
.hat.active { border-color: #ffd23c; }
.hat .price { color: #ffd23c; font-weight: 600; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tab { flex: 1; padding: 10px; border-radius: 10px; border: none; background: rgba(255,255,255,.08); color: #b8bcd0; cursor: pointer; }
.tab.active { background: rgba(255,210,60,.18); color: #ffd23c; font-weight: 600; }
.scroll { overflow: auto; flex: 1; min-height: 0; max-height: 60vh; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.08); white-space: nowrap; }
th { color: #9ea3ba; font-weight: 500; font-size: 12px; text-transform: uppercase; }
tr.me { background: rgba(255,210,60,.12); }
td.num, th.num { text-align: right; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.pos { color: #43d17a; } .neg { color: #ff6b6b; }
.podium { display: flex; gap: 10px; margin-bottom: 12px; }
.podium .team { flex: 1; padding: 12px; border-radius: 14px; text-align: center; color: #111; font-weight: 700; }
.podium .team small { display: block; font-weight: 500; opacity: .8; }
.spinner { width: 44px; height: 44px; margin: 14px auto; border-radius: 50%; border: 4px solid rgba(255,255,255,.15); border-top-color: #ffd23c; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#toast { position: fixed; left: 50%; bottom: 12%; transform: translateX(-50%); background: rgba(0,0,0,.75); padding: 12px 18px; border-radius: 12px; z-index: 50; pointer-events: none; }

/* HUD */
#hud { pointer-events: none; }
#hud button, #hud #joystick { pointer-events: auto; }
#hud-top { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(70vw, 460px); text-align: center; }
#hud-bar { display: flex; height: 14px; border-radius: 8px; overflow: hidden; background: rgba(0,0,0,.35); }
#hud-bar .seg { transition: width .3s; }
#hud-timer { font-size: 28px; font-weight: 800; text-shadow: 0 2px 6px rgba(0,0,0,.5); margin-top: 4px; }
#hud-board { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(50px + env(safe-area-inset-right)); background: rgba(0,0,0,.35); border-radius: 10px; padding: 6px 10px; font-size: 12px; min-width: 150px; }
#hud-board div { display: flex; justify-content: space-between; gap: 8px; }
#hud-board .me { color: #ffd23c; font-weight: 700; }
#hud-feed { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: calc(10px + env(safe-area-inset-left)); font-size: 13px; text-shadow: 0 1px 3px #000; max-width: 45vw; }
#hud-feed div { opacity: .95; margin-bottom: 3px; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 4px #000; }
#hud-hp { position: absolute; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: 200px; height: 16px; border-radius: 8px; background: rgba(0,0,0,.45); overflow: hidden; }
#hud-hp-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #43d17a, #8ff0b0); transition: width .15s; }
#hud-hp-text { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 16px; font-weight: 700; text-shadow: 0 1px 2px #000; }
#hud-status { position: absolute; left: 50%; bottom: calc(46px + env(safe-area-inset-bottom)); transform: translateX(-50%); font-size: 13px; color: #ffd23c; text-shadow: 0 1px 3px #000; }
#joystick { position: absolute; width: 130px; height: 130px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); background: rgba(255,255,255,.08); transform: translate(-50%, -50%); }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: rgba(255,255,255,.7); }
#fire-btn { position: absolute; right: calc(28px + env(safe-area-inset-right)); bottom: calc(40px + env(safe-area-inset-bottom)); width: 92px; height: 92px; border-radius: 50%; border: 3px solid rgba(255,255,255,.5); background: rgba(255,75,75,.55); font-size: 38px; color: #fff; }
#fire-btn:active { background: rgba(255,75,75,.9); }
#leave-btn { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(0,0,0,.4); color: #fff; font-size: 16px; }
#respawn { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(20,0,30,.45); font-size: 26px; font-weight: 800; text-shadow: 0 2px 8px #000; }
#respawn-timer { font-size: 64px; }
#hint { position: absolute; bottom: calc(6px + env(safe-area-inset-bottom)); left: 10px; font-size: 11px; color: rgba(255,255,255,.6); }
.touch-only { display: none; }
@media (pointer: coarse) { .touch-only { display: block; } .desktop-only { display: none; } }
@media (max-width: 640px) {
  .menu-body { flex-direction: column; align-items: stretch; }
  .menu-body canvas { width: 100%; height: 180px; }
  .menu-wrap { padding: 14px; }
  .podium .team { padding: 8px; font-size: 13px; }
  table { font-size: 12px; } th, td { padding: 6px 5px; }
  #hud-board { display: none; }
  #hud-feed { top: calc(64px + env(safe-area-inset-top)); font-size: 11px; max-width: 60vw; }
  #hud-top { width: 60vw; }
}

.modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(10, 8, 24, .7); backdrop-filter: blur(6px); }
.modal .card { animation: pop .18s ease-out; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Карты-апгрейды */
#hud-cards { position: absolute; left: calc(10px + env(safe-area-inset-left)); bottom: calc(24px + env(safe-area-inset-bottom)); display: flex; gap: 6px; }
#hud-cards span { width: 40px; height: 40px; border-radius: 10px; background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.25); display: flex; align-items: center; justify-content: center; font-size: 22px; }
#cards-offer { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); width: min(94vw, 640px); text-align: center; pointer-events: none; }
.offer-title { font-size: 18px; font-weight: 800; text-shadow: 0 2px 6px #000; margin-bottom: 10px; }
.offer-list { display: flex; gap: 10px; justify-content: center; }
.cardpick { pointer-events: auto; flex: 1; max-width: 200px; min-height: 150px; padding: 14px 10px; border-radius: 16px; border: 2px solid rgba(255,255,255,.35); background: linear-gradient(160deg, rgba(60,40,110,.92), rgba(25,20,50,.95)); color: #fff; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; animation: pop .25s ease-out; transition: transform .1s, border-color .15s; }
.cardpick:hover { transform: translateY(-4px) scale(1.03); border-color: #ffd23c; }
.cardpick .ico { font-size: 40px; }
.cardpick b { font-size: 15px; }
.cardpick small { color: #c9cce0; font-size: 12px; line-height: 1.3; }
.catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; max-height: 65vh; }
.catalog .cardrow { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,.06); }
.catalog .ico { font-size: 26px; width: 34px; text-align: center; }
.catalog small { color: #9ea3ba; display: block; }
.cardicons { font-size: 15px; letter-spacing: 2px; }
@media (max-width: 640px) {
  .cardpick { min-height: 120px; padding: 10px 6px; } .cardpick .ico { font-size: 30px; } .cardpick b { font-size: 13px; } .cardpick small { font-size: 11px; }
  #hud-cards { bottom: calc(150px + env(safe-area-inset-bottom)); }
}

.cardpick { position: relative; }
.cardpick .key { position: absolute; top: 6px; left: 8px; width: 22px; height: 22px; border-radius: 6px; background: rgba(255,255,255,.18); font-size: 12px; font-weight: 700; line-height: 22px; }
.offer-hint { margin-top: 8px; font-size: 13px; color: #e6e8f5; text-shadow: 0 1px 4px #000; }
