:root {
  --azure: #3b86ff;
  --crimson: #ff4d48;
  --glass: rgba(10, 16, 28, 0.62);
  --glass-strong: rgba(10, 16, 28, 0.82);
  --line: rgba(255, 255, 255, 0.12);
  --text: #eef3fa;
  --muted: #9aa8bd;
  --accent: #ffc23d;
  --fire: #ff5a2a;
  --radius: 14px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --ui: 'Rajdhani', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Russo One', 'Rajdhani', system-ui, sans-serif;
}

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

#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; }
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }

/* ---------------- tank labels & popups ---------------- */
.tank-label { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; will-change: transform; }
.tl-name { font-weight: 700; font-size: 13px; letter-spacing: .04em; text-shadow: 0 1px 3px #000, 0 0 8px rgba(0,0,0,.6); white-space: nowrap; }
.tl-name i { font-style: normal; font-size: 10px; opacity: .7; margin-left: 2px; }
.tl-hp { width: 46px; height: 6px; border-radius: 4px; background: rgba(0,0,0,.55); overflow: hidden; box-shadow: 0 0 0 1px rgba(255,255,255,.18); }
.tl-hp i { display: block; height: 100%; width: 100%; border-radius: 4px; transition: background .3s; }
.team-0 .tl-hp i { background: linear-gradient(90deg, #2a6fe8, #6aa8ff); }
.team-1 .tl-hp i { background: linear-gradient(90deg, #d8302b, #ff7a6a); }
.tank-label.low .tl-hp i { background: linear-gradient(90deg, #ff3b2f, #ffb03b); animation: pulse .8s infinite alternate; }
.tl-status { display: flex; gap: 3px; }
.tl-status .st { font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: .06em; padding: 0 5px; border-radius: 6px; background: rgba(0,0,0,.6); }
.st.shield { color: #8fd4ff; } .st.burn { color: #ffb070; } .st.frozen { color: #bfefff; } .st.emp { color: #9db8ff; }
.tl-pin { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; margin-top: 1px;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.7)); }
.team-0 .tl-pin { border-top: 8px solid #4f95ff; }
.team-1 .tl-pin { border-top: 8px solid #ff5a55; }
.tl-aim { display: none; font-weight: 700; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--glass-strong); border: 1px solid var(--line); white-space: nowrap; }
.tank-label.active .tl-aim { display: block; }
.tank-label.active .tl-name::before { content: '▼ '; color: var(--accent); }
@keyframes pulse { to { opacity: .55; } }

.popup { position: absolute; left: 0; top: 0; font-family: var(--display); font-size: 20px; color: #fff; white-space: nowrap;
  text-shadow: 0 2px 0 rgba(0,0,0,.6), 0 0 12px rgba(0,0,0,.5); will-change: transform, opacity; animation: pop .25s ease-out; }
.popup.hit { color: #ffd84a; }
.popup.crit { color: #ff6a3d; font-size: 26px; }
.popup.fall { color: #ffb28a; font-size: 17px; }
.popup.heal { color: #6dff8f; }
.popup.shield { color: #8fd4ff; font-size: 16px; }
.popup.big { font-size: 24px; letter-spacing: .05em; color: #fff; margin-top: -34px; }
@keyframes pop { from { scale: .3; } 70% { scale: 1.25; } to { scale: 1; } }

#aimline { position: fixed; left: 0; top: 0; height: 3px; display: none; transform-origin: 0 50%; pointer-events: none; z-index: 3;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.9) 0 8px, transparent 8px 14px); border-radius: 2px; filter: drop-shadow(0 0 3px rgba(0,0,0,.8)); }
#flash { position: fixed; inset: 0; background: #fff8e0; opacity: 0; pointer-events: none; z-index: 4; }
#flash.go { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }

/* ---------------- HUD ---------------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
#hud #hint { pointer-events: none; }

.topbar { position: absolute; top: calc(8px + var(--sat)); left: calc(10px + var(--sal)); right: calc(10px + var(--sar));
  display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 10px; align-items: start; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.team { background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 6px 10px 7px; min-width: 0; max-width: 260px; }
.team-1 { justify-self: end; text-align: right; width: 100%; }
.team-0 { width: 100%; }
.team-name { font-family: var(--display); font-size: 13px; letter-spacing: .12em; }
.team-0 .team-name { color: #7fb1ff; }
.team-1 .team-name { color: #ff8a84; }
.team-bar { height: 7px; border-radius: 5px; background: rgba(255,255,255,.1); margin: 4px 0 4px; overflow: hidden; }
.team-bar i { display: block; height: 100%; width: 100%; transition: width .5s; }
.team-0 .team-bar i { background: linear-gradient(90deg, #2a6fe8, #6aa8ff); }
.team-1 .team-bar i { background: linear-gradient(270deg, #d8302b, #ff7a6a); margin-left: auto; }
.team-dots { display: flex; gap: 4px; }
.team-1 .team-dots { justify-content: flex-end; }
.team-dots i { width: 9px; height: 9px; border-radius: 50%; background: currentColor; opacity: .9; transition: .3s; }
.team-0 .team-dots i { color: var(--azure); }
.team-1 .team-dots i { color: var(--crimson); }
.team-dots i.dead { opacity: .2; }
.team-dots i.active { box-shadow: 0 0 0 2px #fff; }

.turn-box { background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 6px 14px; text-align: center; min-width: 230px; }
#turn-name { font-weight: 700; font-size: 16px; white-space: nowrap; }
#turn-name small { color: var(--muted); font-weight: 600; font-size: 12px; margin-left: 4px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot.team-0 { background: var(--azure); box-shadow: 0 0 8px var(--azure); }
.dot.team-1 { background: var(--crimson); box-shadow: 0 0 8px var(--crimson); }
#minimap { display: block; width: 100%; height: 34px; margin-top: 5px; border-radius: 6px; background: rgba(0,0,0,.25); cursor: pointer; touch-action: none; }
.double-tag { font-size: 11px; color: #1b1300; background: linear-gradient(180deg, #ffcf5a, #ffae2a); padding: 1px 6px; border-radius: 6px; margin-left: 6px; letter-spacing: .06em; vertical-align: 2px; }
#hud.double #fire-btn { background: linear-gradient(180deg, #ffcf5a, #ff8a1a); }
#wind { display: flex; align-items: center; gap: 8px; margin-top: 3px; font-weight: 700; font-size: 12px; }
.wind-label { color: var(--muted); letter-spacing: .1em; }
#wind-val { min-width: 54px; text-align: left; color: #cfe6ff; }
.wind-gauge { position: relative; width: 96px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.1); overflow: hidden; }
.wind-gauge b { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: rgba(255,255,255,.55); }
.wind-fill { position: absolute; top: 0; bottom: 0; left: 50%; width: 0; background: linear-gradient(90deg, #7fd0ff, #d8f1ff); transition: width .4s, left .4s; }

.icon-btn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(10px);
  display: grid; place-items: center; }
.icon-btn svg { width: 18px; height: 18px; fill: #fff; }

#hint { position: absolute; left: 50%; top: calc(96px + var(--sat)); translate: -50% 0; background: var(--glass-strong); border: 1px solid var(--line);
  border-radius: 20px; padding: 7px 16px; font-weight: 600; font-size: 14px; opacity: 0; transition: opacity .4s; white-space: nowrap; }
#hint.show { opacity: 1; }

/* controls */
#controls { position: absolute; left: calc(10px + var(--sal)); right: calc(10px + var(--sar)); bottom: calc(10px + var(--sab));
  display: grid; grid-template-columns: auto minmax(120px, 220px) auto minmax(200px, 1fr) auto; gap: 10px; align-items: stretch; transition: opacity .3s, translate .3s; }
#hud.waiting #controls { opacity: .35; pointer-events: none; translate: 0 8px; }
.ctrl { display: flex; align-items: center; gap: 6px; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; position: relative; }
.ctrl label { position: absolute; top: -8px; left: 12px; font-size: 10px; font-weight: 700; letter-spacing: .12em; color: var(--muted);
  background: rgba(10,16,28,.9); padding: 0 6px; border-radius: 6px; }
.btn-sq { width: 44px; height: 44px; flex: none; border-radius: 10px; border: 1px solid rgba(255,255,255,.14);
  background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.04)); font-size: 24px; font-weight: 700; line-height: 1;
  display: grid; place-items: center; transition: background .15s, transform .08s; }
.btn-sq:active, .btn-sq.held { transform: scale(.94); background: rgba(255,255,255,.22); }
.btn-sq svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.ctrl output { font-family: var(--display); font-size: 20px; min-width: 64px; text-align: center; }
#fuel { position: relative; width: 52px; height: 10px; border-radius: 5px; background: rgba(255,255,255,.1); overflow: hidden; }
#fuel i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #ffb53d, #ffe08a); width: 100%; transition: width .1s; }
#fuel span { position: absolute; inset: -16px 0 auto; text-align: center; font-size: 9px; font-weight: 700; letter-spacing: .14em; color: var(--muted); }

.power-wrap { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 110px; }
.power-wrap output { min-width: 40px; }
#power { flex: 1; -webkit-appearance: none; appearance: none; height: 10px; border-radius: 6px; min-width: 60px;
  background: linear-gradient(90deg, #3bd16f, #ffd23d 55%, #ff5a2a); outline: none; }
#power::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 3px solid #1a2233; box-shadow: 0 2px 8px rgba(0,0,0,.5); }
#power::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 3px solid #1a2233; }

#weapon-btn { display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 8px; text-align: left; border-radius: var(--radius);
  background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line); min-width: 0; --wc: #ddd; }
#weapon-btn .w-icon { width: 42px; height: 42px; flex: none; border-radius: 10px; display: grid; place-items: center; color: var(--wc);
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--wc) 35%, transparent), rgba(255,255,255,.04)); border: 1px solid rgba(255,255,255,.12); }
#weapon-btn .w-icon svg { width: 26px; height: 26px; filter: drop-shadow(0 0 4px var(--wc)); }
.w-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.w-name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-ammo { font-size: 13px; color: var(--muted); font-weight: 700; }
.w-caret { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2.5; flex: none; }

#fire-btn { font-family: var(--display); font-size: 24px; letter-spacing: .1em; min-width: 132px; border-radius: 18px; border: 0; padding: 0 22px;
  background: linear-gradient(180deg, #ff7a3d, #e5341f); box-shadow: 0 6px 22px rgba(255,80,30,.45), inset 0 1px 0 rgba(255,255,255,.35), inset 0 -3px 0 rgba(0,0,0,.2);
  text-shadow: 0 2px 0 rgba(0,0,0,.25); transition: transform .08s, filter .2s; }
#fire-btn:active { transform: scale(.95); filter: brightness(1.15); }
#hud:not(.waiting) #fire-btn { animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 6px 32px rgba(255,90,40,.75), inset 0 1px 0 rgba(255,255,255,.35), inset 0 -3px 0 rgba(0,0,0,.2); } }

/* weapon drawer */
#weapon-drawer { position: absolute; inset: 0; background: rgba(4,8,16,.45); display: flex; align-items: flex-end; justify-content: center;
  padding: 10px 10px calc(84px + var(--sab)); animation: fade .2s; }
.drawer-panel { width: min(720px, 100%); max-height: calc(100% - 70px); overflow: auto; background: var(--glass-strong); backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: 18px; padding: 12px; animation: rise .25s ease-out; touch-action: pan-y; }
.drawer-panel h3 { margin: 2px 6px 10px; font-family: var(--display); font-weight: 400; letter-spacing: .1em; font-size: 15px; color: var(--muted); }
#weapon-list h4 { margin: 14px 6px 6px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
#weapon-list h4:first-child { margin-top: 0; }
.wc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
#arsenal-count { font-family: var(--ui); font-weight: 700; font-size: 12px; letter-spacing: .08em; margin-left: 6px; opacity: .7; }
.drawer-panel { max-height: min(78vh, calc(100% - 70px)); }
.weapon-card { --wc: #fff; display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; text-align: left; position: relative;
  border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.04); transition: background .15s, border-color .15s; }
.weapon-card:hover { background: rgba(255,255,255,.08); }
.weapon-card.on { border-color: var(--wc); background: color-mix(in srgb, var(--wc) 14%, transparent); }
.weapon-card:disabled { opacity: .35; cursor: not-allowed; }
.wc-icon { width: 40px; height: 40px; flex: none; display: grid; place-items: center; color: var(--wc); border-radius: 10px; background: rgba(0,0,0,.25); }
.wc-icon svg { width: 26px; height: 26px; filter: drop-shadow(0 0 4px var(--wc)); }
.wc-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.wc-text b { font-size: 15px; }
.wc-text small { font-size: 12px; color: var(--muted); font-weight: 500; line-height: 1.15; }
.wc-ammo { font-family: var(--display); font-size: 15px; }
.weapon-card kbd { position: absolute; top: 4px; right: 6px; font-size: 9px; color: var(--muted); font-family: var(--ui); opacity: .7; }
@media (pointer: coarse) { .weapon-card kbd { display: none; } }

/* banner */
#banner { position: fixed; left: 50%; top: 32%; translate: -50% -50%; text-align: center; pointer-events: none; opacity: 0; z-index: 6; }
#banner.show { animation: banner 2.4s ease-out forwards; }
#banner h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(30px, 6vw, 64px); letter-spacing: .06em; text-transform: uppercase;
  text-shadow: 0 4px 0 rgba(0,0,0,.35), 0 0 30px rgba(0,0,0,.5); white-space: nowrap; }
#banner h2 span { color: var(--accent); font-size: .6em; margin: 0 .3em; }
#banner p { margin: 4px 0 0; font-weight: 700; font-size: 18px; letter-spacing: .25em; text-transform: uppercase; color: #dfe7f3; text-shadow: 0 2px 6px #000; }
#banner[data-team="0"] h2 { color: #8fbcff; }
#banner[data-team="1"] h2 { color: #ff938d; }
@keyframes banner { 0% { opacity: 0; scale: 1.3; } 12% { opacity: 1; scale: 1; } 80% { opacity: 1; } 100% { opacity: 0; scale: .96; } }

/* ---------------- overlays / menu ---------------- */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
  background: radial-gradient(ellipse at center, rgba(5,10,20,.25), rgba(5,10,20,.7)); overflow: auto; touch-action: pan-y; animation: fade .3s; }
#menu { background: linear-gradient(90deg, rgba(5,10,20,.82) 0%, rgba(5,10,20,.55) 45%, rgba(5,10,20,0) 75%); justify-items: start; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { translate: 0 20px; opacity: 0; } }
.menu-card { width: min(460px, 100%); background: var(--glass-strong); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border: 1px solid var(--line);
  border-radius: 22px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.45); animation: rise .4s ease-out; margin: auto 0; }
#menu .menu-card { margin-left: clamp(0px, 5vw, 80px); }
.menu-card.small { width: min(320px, 100%); display: flex; flex-direction: column; gap: 10px; text-align: center; }
.menu-card h2 { font-family: var(--display); font-weight: 400; font-size: 34px; margin: 0 0 4px; letter-spacing: .06em; text-transform: uppercase; text-align: center; }
.logo { text-align: center; margin-bottom: 16px; }
.logo h1 { font-family: var(--display); font-weight: 400; font-size: clamp(40px, 8vw, 56px); margin: 0; letter-spacing: .08em; line-height: 1;
  background: linear-gradient(180deg, #fff 30%, #ffc23d 75%, #ff7a3d); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,.4)); }
.logo p { margin: 6px 0 0; color: var(--muted); font-weight: 700; letter-spacing: .35em; text-transform: uppercase; font-size: 13px; }
.logo-mark { color: var(--accent); width: 72px; margin: 0 auto 6px; }
.logo-mark svg { width: 100%; fill: currentColor; }
.opts { display: flex; flex-direction: column; gap: 9px; margin-bottom: 18px; }
.opt { display: grid; grid-template-columns: 82px 1fr; align-items: center; gap: 10px; transition: opacity .2s; }
.opt.dim { opacity: .35; pointer-events: none; }
.opt > span { font-weight: 700; color: var(--muted); font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
.seg { display: flex; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 3px; }
.seg.wrap { flex-wrap: wrap; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 8px; padding: 7px 6px; font-weight: 700; font-size: 14px; color: #c6d1e0; white-space: nowrap; transition: background .15s, color .15s; }
.seg button:hover { color: #fff; }
.seg button.on { background: linear-gradient(180deg, #ffcf5a, #ffae2a); color: #1b1300; box-shadow: 0 2px 10px rgba(255,180,40,.35); }
.sel { width: 100%; font: 700 14px var(--ui); color: var(--text); background: rgba(255,255,255,.05) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%23c6d1e0' stroke-width='2.5'/%3E%3C/svg%3E") no-repeat right 10px center / 16px;
  border: 1px solid var(--line); border-radius: 11px; padding: 9px 34px 9px 12px; appearance: none; -webkit-appearance: none; cursor: pointer; }
.sel option { background: #141c2c; color: var(--text); }
.btn-primary, .btn-secondary { display: block; width: 100%; border-radius: 14px; font-family: var(--display); letter-spacing: .12em; border: 0; transition: transform .08s, filter .2s; }
.btn-primary { font-size: 22px; padding: 14px; background: linear-gradient(180deg, #ff7a3d, #e5341f); box-shadow: 0 8px 26px rgba(255,80,30,.4), inset 0 1px 0 rgba(255,255,255,.35); }
.btn-secondary { font-size: 16px; padding: 11px; background: rgba(255,255,255,.08); border: 1px solid var(--line); margin-top: 8px; }
.btn-primary:active, .btn-secondary:active { transform: scale(.97); }
.btn-primary:hover, .btn-secondary:hover { filter: brightness(1.1); }
.menu-links { display: flex; justify-content: center; gap: 18px; margin-top: 12px; }
.btn-link { background: none; border: 0; color: var(--muted); font-weight: 700; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
#howto ul { margin: 12px 0 0; padding-left: 18px; color: #cdd7e5; font-size: 14px; line-height: 1.4; font-weight: 500; }
#howto li { margin-bottom: 4px; }

#go-title { font-size: 46px; }
#go-title.win { color: #ffd04a; }
#go-title.lose { color: #ff6a5a; }
#go-title.team-0 { color: #8fbcff; }
#go-title.team-1 { color: #ff938d; }
#go-sub { text-align: center; color: var(--muted); margin: 0 0 14px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: 13px; }
#go-stats { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 15px; }
#go-stats th { font-size: 11px; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; text-align: right; padding: 4px 6px; font-weight: 700; }
#go-stats td { text-align: right; padding: 6px; border-top: 1px solid var(--line); font-weight: 600; }
#go-stats th:first-child, #go-stats td:first-child { text-align: left; }
#go-stats tr.dead td { opacity: .5; }
#go-stats small { color: var(--muted); font-size: 11px; }

#loading { position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 14px; background: #0b1220; color: var(--muted); font-weight: 700; letter-spacing: .1em; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255,255,255,.12); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }

@media (min-width: 900px), (min-width: 700px) and (max-height: 500px) {
  #menu .menu-card { width: min(860px, 100%); }
  #menu .opts { display: grid; grid-template-columns: 1fr 1fr; column-gap: 22px; row-gap: 9px; }
  #menu .opt:has([data-opt="map"]) { grid-column: 1 / -1; }
  #menu .opt { grid-template-columns: 78px 1fr; }
  #menu .btn-primary { max-width: 420px; margin: 0 auto; }
  #menu .seg button { min-width: 0; white-space: normal; line-height: 1.1; }
}
@media (max-width: 960px) and (min-width: 700px) {
  #menu { justify-items: center; }
  #menu .menu-card { margin-left: 0; }
}
@media (min-width: 900px) and (max-height: 640px) {
  .logo { margin-bottom: 8px; } .logo h1 { font-size: 40px; } .logo-mark { width: 52px; }
}

/* ---------------- responsive ---------------- */
@media (max-width: 860px) {
  #controls { grid-template-columns: auto 1fr auto; grid-template-areas: "move weapon fire" "angle power fire"; gap: 8px; }
  .ctrl.move { grid-area: move; } #weapon-btn { grid-area: weapon; } .ctrl.angle { grid-area: angle; } .ctrl.power { grid-area: power; } #fire-btn { grid-area: fire; }
  #fire-btn { min-width: 110px; font-size: 22px; }
}
/* short landscape phones: one compact row */
@media (max-height: 500px) and (orientation: landscape) {
  .topbar { top: calc(6px + var(--sat)); gap: 6px; }
  .team { padding: 4px 8px 5px; max-width: 200px; }
  .team-name { font-size: 11px; }
  .turn-box { padding: 4px 10px; min-width: 160px; }
  #turn-name { font-size: 14px; }
  #minimap { height: 24px; margin-top: 3px; }
  .icon-btn { width: 38px; height: 38px; }
  #hint { top: calc(70px + var(--sat)); font-size: 13px; }
  #controls { grid-template-columns: auto auto auto 1fr auto; grid-template-areas: "move weapon angle power fire"; gap: 6px; bottom: calc(6px + var(--sab)); }
  .btn-sq { width: 38px; height: 38px; font-size: 20px; }
  .ctrl { padding: 4px; gap: 4px; }
  .ctrl output { font-size: 17px; min-width: 52px; }
  #weapon-btn { padding: 4px 8px 4px 4px; max-width: 170px; }
  #weapon-btn .w-caret { display: none; }
  #weapon-btn .w-icon { width: 36px; height: 36px; }
  .w-name { font-size: 14px; }
  #fuel { width: 36px; }
  #fire-btn { min-width: 92px; font-size: 19px; padding: 0 12px; }
  #weapon-drawer { padding-bottom: calc(64px + var(--sab)); }
  #banner h2 { font-size: 34px; }
  .menu-card { padding: 16px; }
  .logo { margin-bottom: 8px; } .logo h1 { font-size: 30px; } .logo-mark { display: none; } .logo p { margin-top: 2px; font-size: 11px; }
  #menu .opt { grid-template-columns: 64px 1fr; } .opt > span { font-size: 11px; }
  .sel { padding: 6px 30px 6px 10px; font-size: 13px; }
  .opts { gap: 6px; margin-bottom: 12px; }
  .seg button { padding: 5px 6px; font-size: 13px; }
  .btn-primary { padding: 10px; font-size: 19px; }
}
@media (max-height: 500px) and (orientation: landscape) and (max-width: 760px) {
  #weapon-btn .w-name { display: none; }
  .ctrl.angle output { min-width: 46px; font-size: 15px; }
  .power-wrap { min-width: 80px; }
  #fuel { display: none; }
}
/* portrait phones */
@media (max-width: 600px) {
  .topbar { grid-template-columns: 1fr 1fr auto; grid-template-areas: "t0 t1 pause" "turn turn turn"; gap: 6px; }
  .team-0 { grid-area: t0; } .team-1 { grid-area: t1; } .turn-box { grid-area: turn; justify-self: center; } #btn-pause { grid-area: pause; }
  .team { max-width: none; }
  #hint { top: calc(118px + var(--sat)); white-space: normal; text-align: center; width: max-content; max-width: 90vw; }
  #controls { grid-template-columns: 1fr 1fr; grid-template-areas: "weapon weapon" "angle angle" "power power" "move fire"; }
  .ctrl.angle { justify-content: space-between; }
  .ctrl.angle output { flex: 1; }
  #fire-btn { min-height: 56px; }
  .ctrl.move { justify-content: space-between; }
  #weapon-drawer { padding-bottom: calc(10px + var(--sab)); align-items: center; }
  .wc-grid { grid-template-columns: 1fr; }
  #menu { background: rgba(5,10,20,.55); justify-items: center; }
  #menu .menu-card { margin-left: 0; }
  .opt { grid-template-columns: 70px 1fr; }
  .seg button { font-size: 13px; padding: 7px 3px; }
}

/* ---- Brawl mode ---- */
.mode-desc { grid-column: 2; margin: -4px 2px 0; font-size: 13px; line-height: 1.35; color: var(--muted); min-height: 2.7em; }
#fire-btn { position: relative; overflow: hidden; }
#fire-btn.reloading { filter: grayscale(.75) brightness(.7); animation: none; }
#fire-btn.reloading::after { content: ''; position: absolute; left: 0; bottom: 0; height: 5px; width: calc(var(--reload, 1) * 100%); background: #ffd45a; box-shadow: 0 0 10px rgba(255,212,90,.8); }
#fire-btn.nope { animation: nope .3s; }
@keyframes nope { 25% { translate: -5px 0; } 75% { translate: 5px 0; } }
#mode-desc { min-height: 0; }
