* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b1f17; color: #e8e6d9; font-family: system-ui, 'Segoe UI', Roboto, sans-serif; user-select: none; }
#game { position: fixed; inset: 0; }
#game canvas { display: block; width: 100% !important; height: 100% !important; }
.hidden { display: none !important; }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(30,36,24,.75), rgba(10,12,8,.92)); z-index: 20; padding: 16px; }
.panel { background: rgba(28,32,24,.95); border: 1px solid #4b5a35; border-radius: 10px; padding: 28px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
h1 { margin: 0; font-size: clamp(30px, 9vw, 40px); letter-spacing: 4px; color: #d9c98a; white-space: nowrap; }
h1 span { color: #8fae5a; margin-left: 8px; font-size: 0.6em; letter-spacing: 3px; }
h2 { margin-top: 0; }
.sub { margin: 4px 0 22px; color: #9aa38a; }
label { font-size: 13px; color: #9aa38a; display: block; margin-bottom: 6px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.small { margin-top: 16px; }
.row.small label { margin: 0; white-space: nowrap; }
input, select { flex: 1; padding: 10px 12px; font-size: 16px; background: #12150f; color: #e8e6d9; border: 1px solid #4b5a35; border-radius: 6px; outline: none; min-width: 0; }
input:focus { border-color: #8fae5a; }
button { cursor: pointer; font: inherit; border-radius: 6px; border: 1px solid #4b5a35; background: #232a1c; color: #e8e6d9; padding: 10px 14px; }
button:hover { filter: brightness(1.2); }
button.primary { display: block; width: 100%; margin-top: 18px; padding: 16px; font-size: 22px; font-weight: 700; letter-spacing: 4px; background: linear-gradient(#a8862f, #7a5f1c); border-color: #d9b04a; color: #fff8e0; }
button.wide { display: block; width: 100%; margin-top: 10px; }
button:disabled { opacity: .5; cursor: wait; }
.error { color: #ff7b6b; min-height: 1em; font-size: 14px; }
.help { margin-top: 10px; font-size: 12px; color: #8a9278; line-height: 1.7; }
.help b { color: #cfc79a; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#topbar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 16px; align-items: center; }
.team { text-align: center; min-width: 90px; padding: 4px 12px; border-radius: 6px; background: rgba(0,0,0,.45); }
.team span { font-size: 28px; font-weight: 700; display: block; line-height: 1; }
.team small { font-size: 10px; letter-spacing: 1px; opacity: .8; }
.team.a span { color: #7fd36a; } .team.b span { color: #ff6b5b; }
#timer { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; background: rgba(0,0,0,.45); padding: 6px 14px; border-radius: 6px; }
#phaseMsg { position: absolute; top: 22%; width: 100%; text-align: center; font-size: 34px; font-weight: 700; text-shadow: 0 2px 8px #000; padding: 0 16px; }
#phaseMsg small { display: block; font-size: 18px; font-weight: 400; opacity: .85; margin-top: 6px; }

#crosshair { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: rgba(255,255,255,.6); }
#reticle { position: absolute; left: 0; top: 0; width: 46px; height: 46px; margin: -23px 0 0 -23px; will-change: transform; }
#reticle svg { width: 100%; height: 100%; transform: rotate(-90deg); }
#reticle circle { fill: none; stroke-width: 5; }
#reticle .bg { stroke: rgba(0,0,0,.4); }
#reticle .fg { stroke: #9ef07a; stroke-dasharray: 276.5; stroke-dashoffset: 0; }
#reticle.reloading .fg { stroke: #ffb347; }
#sniperMask { position: absolute; inset: 0; background: radial-gradient(circle at center, transparent 38vmin, rgba(0,0,0,.85) 39vmin); }

#feed { position: absolute; top: 12px; right: 12px; text-align: right; font-size: 14px; }
#feed div { background: rgba(0,0,0,.5); margin-bottom: 4px; padding: 3px 8px; border-radius: 4px; }
#messages { position: absolute; top: 60%; width: 100%; text-align: center; font-size: 22px; font-weight: 700; text-shadow: 0 2px 6px #000; }
#messages div { animation: fadeup 1.6s forwards; }
@keyframes fadeup { 0% { opacity: 1; transform: translateY(0); } 70% { opacity: 1; } 100% { opacity: 0; transform: translateY(-30px); } }
#dmgFlash { position: absolute; inset: 0; box-shadow: inset 0 0 120px rgba(255,0,0,.7); opacity: 0; transition: opacity .5s; }
#dmgFlash.on { opacity: 1; transition: none; }

#chat { position: absolute; left: 14px; bottom: 162px; width: min(380px, calc(100vw - 230px)); font-size: 14px; }
#chatLog { display: flex; flex-direction: column; gap: 2px; max-height: 210px; overflow: hidden; }
#chatLog .line { background: rgba(0,0,0,.45); padding: 3px 8px; border-radius: 4px; overflow-wrap: anywhere; opacity: 0; transition: opacity .6s; text-shadow: 0 1px 2px #000; }
#chatLog .line.fresh, #chat.open #chatLog .line { opacity: 1; }
#chat.open #chatLog { overflow-y: auto; pointer-events: auto; }
#chatLog .line b { margin-right: 6px; }
#chatLog .line.tip { background: rgba(40,34,10,.7); border-left: 3px solid #ffd76a; color: #f3ecd2; }
#chatLog .line.tip > b:first-child { color: #ffd76a; }
#chatLog .line.tip b + b, #chatLog .line.tip b:not(:first-child) { margin-right: 0; color: #fff; }
#chatBox { display: flex; align-items: center; gap: 8px; margin-top: 6px; background: rgba(0,0,0,.65); border: 1px solid #8fae5a; border-radius: 6px; padding: 4px 8px; pointer-events: auto; }
#chatBox span { font-size: 12px; color: #cfc79a; white-space: nowrap; }
#chatBox input { padding: 6px 4px; font-size: 14px; background: transparent; border: none; }
#spectate { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); background: rgba(0,0,0,.6); border: 1px solid rgba(255,255,255,.15); border-radius: 8px; padding: 8px 16px; text-align: center; white-space: nowrap; max-width: calc(100vw - 32px); }
#spectate .who { font-size: 16px; }
#spectate .tm { font-size: 12px; opacity: .7; margin-left: 4px; }
#spectate .hp { font-size: 13px; margin-left: 10px; color: #e8e6d9; }
#spectate .hint { font-size: 12px; opacity: .75; margin-top: 3px; }
#spectate .hint b { color: #cfc79a; }
body.touch #spectate { bottom: 130px; padding: 6px 10px; }
body.touch #spectate .who { font-size: 13px; }
#bottomLeft { position: absolute; left: 14px; bottom: 14px; background: rgba(0,0,0,.5); padding: 10px 12px; border-radius: 8px; width: 230px; }
#tankName { font-weight: 700; color: #d9c98a; margin-bottom: 6px; }
#hpBar { position: relative; height: 20px; background: #3a1a17; border-radius: 4px; overflow: hidden; }
#hpFill { height: 100%; width: 100%; background: linear-gradient(#7fd36a, #4c9a3c); transition: width .2s; }
#hpText { position: absolute; inset: 0; text-align: center; font-size: 13px; line-height: 20px; font-weight: 700; text-shadow: 0 1px 2px #000; }
#reloadText, #speedText { font-size: 13px; margin-top: 5px; color: #c9c7b8; }
#cruise { display: flex; gap: 2px; margin-top: 5px; }
#cruise span { flex: 1; text-align: center; font-size: 10px; line-height: 16px; border-radius: 3px; background: rgba(255,255,255,.08); color: rgba(255,255,255,.35); letter-spacing: -1px; }
#cruise span.on.r { background: #b8552f; color: #fff; }
#cruise span.on.n { background: rgba(255,255,255,.25); color: #fff; }
#cruise span.on.f { background: #4c9a3c; color: #fff; }
body.touch #cruise { display: none; }
#minimap { position: absolute; right: 14px; bottom: 14px; width: 180px; height: 180px; border: 2px solid #4b5a35; border-radius: 6px; background: #2b3322; }
#bigmap { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(720px, calc(100vw - 32px), calc(100vh - 32px)); height: auto; aspect-ratio: 1; border: 2px solid #4b5a35; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
#ping { position: absolute; right: 14px; bottom: 200px; font-size: 12px; opacity: .7; }
.attr { margin: 14px 0 0; font-size: 11px; color: #7d856c; }
.attr a { color: #a9b38f; }
#osmAttr { position: absolute; right: 14px; bottom: 2px; font-size: 9px; opacity: .6; }
#clickToPlay { position: absolute; top: 50%; left: 50%; transform: translate(-50%, 40px); background: rgba(0,0,0,.6); padding: 8px 14px; border-radius: 6px; }

#scoreboard { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(15,18,12,.92); border: 1px solid #4b5a35; border-radius: 8px; padding: 16px; display: flex; gap: 24px; max-width: calc(100vw - 32px); }
#scoreboard table { border-collapse: collapse; font-size: 14px; min-width: 200px; }
#scoreboard th { text-align: left; padding: 4px 8px; font-size: 12px; opacity: .7; }
#scoreboard td { padding: 4px 8px; }
#scoreboard .me td { color: #ffd76a; font-weight: 700; }
#scoreboard .dead td { opacity: .45; text-decoration: line-through; }
#scoreboard small.bot { font-size: 9px; padding: 1px 4px; border-radius: 3px; background: rgba(255,255,255,.15); opacity: .8; vertical-align: middle; }
#scoreboard h3 { margin: 0 0 6px; }
#scoreboard .ta h3 { color: #7fd36a; } #scoreboard .tb h3 { color: #ff6b5b; }

@media (max-width: 640px) {
  #bottomLeft { width: 170px; }
  #chat { bottom: 152px; width: calc(100vw - 28px); font-size: 13px; }
  #chatLog { max-height: 120px; }
  #minimap { width: 120px; height: 120px; }
  #ping { bottom: 140px; }
  #scoreboard { flex-direction: column; gap: 8px; }
}

/* ---------- telefony i tablety: sterowanie dotykiem ---------- */
body.touch .desktop-only, body:not(.touch) .touch-only { display: none !important; }
body.touch { -webkit-touch-callout: none; -webkit-user-select: none; }
body.touch #game canvas { touch-action: none; }
#touchUI { position: absolute; inset: 0; pointer-events: none; }
#touchUI button { pointer-events: auto; touch-action: none; -webkit-tap-highlight-color: transparent; color: #fff; padding: 0; }
#touchUI button:hover { filter: none; }
#joyBase { position: absolute; left: 0; top: 0; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); background: rgba(0,0,0,.18); opacity: .45; transition: opacity .15s; }
#joyBase.on { opacity: 1; transition: none; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255,255,255,.55); box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.tbtn { position: absolute; border-radius: 50%; border: 2px solid rgba(255,255,255,.45); background: rgba(0,0,0,.35); font-size: 24px; display: flex; align-items: center; justify-content: center; }
#tFire { right: calc(18px + env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom)); width: 96px; height: 96px; background: conic-gradient(rgba(255,140,60,.9) calc(var(--p, 1) * 360deg), rgba(0,0,0,.45) 0); }
#tFire span { width: 80px; height: 80px; border-radius: 50%; background: rgba(45,22,10,.8); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; letter-spacing: 1px; }
#tFire.ready { border-color: #ffd27a; box-shadow: 0 0 14px rgba(255,190,90,.5); }
#tFire.on span { background: rgba(140,60,20,.95); }
#tSniper { right: calc(132px + env(safe-area-inset-right)); bottom: calc(28px + env(safe-area-inset-bottom)); width: 60px; height: 60px; }
#tSniper.on { background: rgba(158,240,122,.35); border-color: #9ef07a; }
#tZoom { right: calc(137px + env(safe-area-inset-right)); bottom: calc(100px + env(safe-area-inset-bottom)); width: 50px; height: 50px; font-size: 14px; font-weight: 700; }
#tTop { position: absolute; left: calc(8px + env(safe-area-inset-left)); top: 76px; display: flex; gap: 6px; }
#tTop button { width: 42px; height: 42px; font-size: 19px; border-radius: 8px; background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.25); }

body.touch #bottomLeft { left: calc(8px + env(safe-area-inset-left)); top: 8px; bottom: auto; width: 150px; padding: 6px 8px; }
body.touch #tankName { display: none; }
body.touch #hpBar { height: 16px; }
body.touch #hpText { font-size: 11px; line-height: 16px; }
body.touch #reloadText, body.touch #speedText { font-size: 11px; margin-top: 3px; }
body.touch #minimap { top: 8px; bottom: auto; right: calc(8px + env(safe-area-inset-right)); width: 104px; height: 104px; }
body.touch #ping { top: 10px; bottom: auto; right: calc(118px + env(safe-area-inset-right)); font-size: 10px; }
body.touch #feed { top: 120px; right: calc(8px + env(safe-area-inset-right)); font-size: 11px; max-width: 40vw; }
body.touch #osmAttr { right: auto; left: 50%; transform: translateX(-50%); }
body.touch #chat { left: calc(8px + env(safe-area-inset-left)); top: 126px; bottom: auto; width: min(340px, 44vw); font-size: 12px; }
body.touch #chatLog { max-height: 92px; }
body.touch #topbar { top: 6px; gap: 8px; }
body.touch .team { min-width: 62px; padding: 3px 8px; }
body.touch .team span { font-size: 20px; }
body.touch .team small { font-size: 8px; }
body.touch #timer { font-size: 18px; padding: 4px 10px; }
body.touch #phaseMsg { top: 20%; font-size: 22px; }
body.touch #phaseMsg small { font-size: 13px; }
body.touch #messages { font-size: 16px; }
body.touch #scoreboard { max-height: calc(100vh - 16px); overflow-y: auto; padding: 10px; gap: 12px; }
body.touch #scoreboard table { font-size: 12px; min-width: 160px; }

#rotateHint { position: fixed; inset: 0; z-index: 30; background: rgba(10,12,8,.95); display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px; font-size: 20px; font-weight: 700; text-align: center; padding: 24px; }
#rotateHint small { font-size: 14px; font-weight: 400; opacity: .7; }
@media (orientation: portrait) { body.touch.ingame #rotateHint { display: flex; } }

/* niskie ekrany (telefon w poziomie): zwarte menu */
.overlay { overflow-y: auto; }
@media (max-height: 520px) {
  .overlay { align-items: flex-start; }
  .panel { padding: 16px 20px; margin: auto; }
  h1 { font-size: 28px; }
  .sub { margin: 2px 0 10px; }
  button.primary { margin-top: 10px; padding: 10px; font-size: 18px; }
  .row.small { margin-top: 8px; }
  .help { font-size: 11px; line-height: 1.5; }
  .attr { margin-top: 8px; }
}

.check { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0 0; cursor: pointer; text-align: left; }
.check input { width: auto; margin-top: 3px; flex: none; }
.check small { opacity: .65; }
.online { margin: 0 0 12px; font-size: 13px; color: #9aa38a; min-height: 1.2em; }
.online b { color: #8ff07a; }
.records { margin: 10px 0 0; font-size: 12px; color: #9aa38a; text-align: center; }
#summary { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 6; background: rgba(15,18,12,.94); border: 1px solid #4b5a35; border-radius: 10px; padding: 18px 22px; font-size: 14px; line-height: 1.6; text-align: left; width: max-content; max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); overflow-y: auto; pointer-events: auto; box-shadow: 0 8px 40px rgba(0,0,0,.6); }
#summary #sumHead { text-align: center; font-size: 34px; font-weight: 700; letter-spacing: 3px; text-shadow: 0 2px 8px #000; }
#summary #sumHead .win { color: #8ff07a; } #summary #sumHead .lose { color: #ff6b5b; } #summary #sumHead .draw { color: #ffd76a; }
#summary .sumsub { text-align: center; margin: 0 0 12px; font-size: 12px; opacity: .6; text-transform: uppercase; letter-spacing: .1em; }
#summary #sumTables { display: flex; gap: 24px; justify-content: center; }
#summary table { border-collapse: collapse; font-size: 14px; min-width: 220px; }
#summary th { text-align: left; padding: 4px 8px; font-size: 12px; opacity: .7; }
#summary td { padding: 4px 8px; }
#summary td:not(:first-child), #summary th:not(:first-child) { text-align: right; }
#summary .me td { color: #ffd76a; font-weight: 700; }
#summary .dead td { opacity: .5; }
#summary small.bot { font-size: 9px; padding: 1px 4px; border-radius: 3px; background: rgba(255,255,255,.15); opacity: .8; vertical-align: middle; }
#summary h3 { margin: 0 0 6px; font-size: 16px; } #summary h3 small { display: block; font-size: 12px; font-weight: 400; opacity: .7; }
#summary .ta h3 { color: #7fd36a; } #summary .tb h3 { color: #ff6b5b; }
#summary #sumAwards { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.12); }
#summary .rec { color: #ffd76a; }
#summary #sumOnline { margin-top: 10px; color: #9aa38a; } #summary #sumOnline b { color: #8ff07a; }
#summary #sumStatus { margin-top: 2px; color: #cfc79a; }
#summary .acts { display: flex; gap: 10px; margin-top: 14px; }
#summary .acts button.primary { margin: 0; flex: 2; padding: 12px; font-size: 18px; }
#summary .acts button.ghost { flex: 1; }
#summary .sumhint { margin-top: 8px; font-size: 12px; opacity: .6; text-align: center; }
@media (max-width: 720px) { #summary #sumTables { flex-direction: column; gap: 8px; } #summary { padding: 12px; } #summary #sumHead { font-size: 26px; } }
body.touch #summary { font-size: 12px; padding: 10px 12px; } body.touch #summary table { font-size: 12px; min-width: 150px; } body.touch #summary #sumTables { gap: 12px; } body.touch #summary #sumHead { font-size: 22px; } body.touch #summary .acts button.primary { font-size: 15px; padding: 8px; }
