/* tanks.css — поле бою на весь екран, HUD лежить поверх канваса */
body { overscroll-behavior: none; }
body.in-game #site-header { display: none; }
#main-container, #screens-wrapper { min-height: 0; }
.custom-scrollbar::-webkit-scrollbar { width: 6px; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 4px; }
#screen-game *, #screen-game *:focus { -webkit-tap-highlight-color: transparent; outline: none; }
#screen-game { user-select: none; -webkit-user-select: none; }
#screen-game input { user-select: text; -webkit-user-select: text; }

#battlefield { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #0b1220; }
#tanks-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }

.hb { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 34px; min-width: 34px; padding: 0 8px; border-radius: 10px; background: rgba(2, 6, 23, 0.72); border: 1px solid rgba(71, 85, 105, 0.8); color: #e2e8f0; font-size: 14px; font-weight: 700; backdrop-filter: blur(6px); touch-action: none; }
.hb:hover { border-color: #fbbf24; }
.hb svg { width: 18px; height: 18px; }
.hb.sq { width: 36px; height: 36px; padding: 0; }
.chat-badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #ef4444; color: white; font-size: 11px; line-height: 18px; text-align: center; }

/* Верхня панель */
#hud-top { position: absolute; top: 6px; left: 6px; right: 6px; display: flex; align-items: center; gap: 6px; z-index: 10; pointer-events: none; }
#hud-top > * { pointer-events: auto; }
#teams { display: flex; gap: 4px; min-width: 0; flex: 1 1 auto; overflow: hidden; }
.team { --tc: #38bdf8; display: flex; flex-direction: column; gap: 2px; padding: 3px 7px; min-width: 0; flex: 0 1 140px; border-radius: 9px; background: rgba(2, 6, 23, 0.7); border: 1px solid rgba(71, 85, 105, 0.7); border-left: 3px solid var(--tc); backdrop-filter: blur(6px); }
.team.active { border-color: var(--tc); box-shadow: 0 0 10px color-mix(in srgb, var(--tc) 60%, transparent); }
.team.out { opacity: 0.4; }
.team .trow { display: flex; align-items: center; gap: 5px; min-width: 0; }
.team .trow .ad-av { --fi: -1.8px; --fw: 1.6px; }
.team .nm { font-size: 11px; font-weight: 800; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.1; min-width: 0; }
.team .bar { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.12); overflow: hidden; }
.team .bar i { display: block; height: 100%; background: var(--tc); transition: width 0.4s; }
.team .cnt { font-size: 8px; letter-spacing: 1px; color: var(--tc); line-height: 1; }
#turn-box { --tc: #fbbf24; display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: 10px; background: rgba(2, 6, 23, 0.78); border: 1px solid rgba(71, 85, 105, 0.8); font-size: 13px; font-weight: 800; color: #e2e8f0; white-space: nowrap; flex-shrink: 0; }
#turn-box.mine { background: #b45309; border-color: #fbbf24; color: white; box-shadow: 0 0 14px rgba(251, 191, 36, 0.5); }
#turn-timer { font-family: ui-monospace, Consolas, monospace; color: #fde68a; min-width: 26px; text-align: right; }
#turn-timer.low { color: #fca5a5; }
#wind-box { height: 34px; padding: 3px; border-radius: 10px; background: rgba(2, 6, 23, 0.7); border: 1px solid rgba(71, 85, 105, 0.8); flex-shrink: 0; }
#wind-gauge { width: 66px; height: 28px; display: block; }
#game-menu { position: absolute; top: 46px; right: 6px; z-index: 30; display: flex; flex-direction: column; gap: 3px; padding: 6px; border-radius: 12px; background: rgba(2, 6, 23, 0.95); border: 1px solid #334155; width: 210px; }
#game-menu.hidden { display: none; }
.mi { text-align: left; padding: 8px 10px; border-radius: 8px; font-size: 13px; font-weight: 700; color: #e2e8f0; display: flex; justify-content: space-between; }
.mi:hover:not(:disabled) { background: #1e293b; }
.mi:disabled { opacity: 0.35; }
.mi.danger { color: #fca5a5; }
.kbd { font-size: 10px; color: #64748b; border: 1px solid #334155; border-radius: 4px; padding: 0 4px; }
#sd-badge { position: absolute; top: 46px; left: 50%; transform: translateX(-50%); z-index: 9; padding: 2px 10px; border-radius: 999px; background: rgba(2, 6, 23, 0.6); color: #94a3b8; font-size: 11px; font-weight: 700; pointer-events: none; white-space: nowrap; }
#sd-badge.danger { color: #fecaca; background: rgba(127, 29, 29, 0.75); }
#sd-badge.hidden { display: none; }
#event-log { position: absolute; top: 70px; left: 8px; z-index: 9; display: flex; flex-direction: column; gap: 3px; pointer-events: none; max-width: 55%; }
.log-line { font-size: 11px; font-weight: 700; color: #e2e8f0; background: rgba(2, 6, 23, 0.65); border-radius: 6px; padding: 2px 8px; animation: tkIn 0.25s ease-out; transition: opacity 0.6s; width: fit-content; }
.log-line.out { opacity: 0; }
@keyframes tkIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
#hint { position: absolute; bottom: 92px; left: 50%; transform: translateX(-50%); z-index: 12; padding: 5px 12px; border-radius: 10px; background: rgba(2, 6, 23, 0.88); border: 1px solid #334155; color: #e2e8f0; font-size: 12px; opacity: 0; transition: opacity 0.25s; pointer-events: none; max-width: 90%; text-align: center; }
#hint.show { opacity: 1; }
#cam-btns { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 10; }

/* Низ: інфо прицілу й панель зброї */
#bottom-bar { position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); z-index: 10; display: flex; flex-direction: column; align-items: center; gap: 4px; max-width: calc(100% - 12px); transition: opacity 0.2s; }
#bottom-bar.dim { opacity: 0.55; }
#aim-info { display: flex; gap: 10px; align-items: center; font-size: 11px; color: #94a3b8; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: rgba(2, 6, 23, 0.6); }
#aim-info b { color: white; }
#aim-info .fuel i { display: inline-block; width: 60px; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.15); vertical-align: middle; overflow: hidden; }
#aim-info .fuel i b { display: block; height: 100%; background: #38bdf8; }
#weapon-bar { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: rgba(2, 6, 23, 0.72); border: 1px solid rgba(71, 85, 105, 0.7); overflow-x: auto; max-width: 100%; scrollbar-width: none; }
#weapon-bar::-webkit-scrollbar { display: none; }
.ws { --wc: #fbbf24; position: relative; flex-shrink: 0; width: 42px; height: 42px; border-radius: 9px; display: flex; align-items: center; justify-content: center; color: var(--wc); background: rgba(15, 23, 42, 0.9); border: 1px solid #334155; }
.ws svg { width: 22px; height: 22px; }
.ws:hover:not(:disabled) { border-color: var(--wc); }
.ws.sel { border-color: var(--wc); background: color-mix(in srgb, var(--wc) 22%, #0f172a); box-shadow: 0 0 10px color-mix(in srgb, var(--wc) 45%, transparent); }
.ws:disabled { opacity: 0.32; }
.ws .am { position: absolute; right: 2px; bottom: 0; font-size: 9px; font-weight: 900; color: #e2e8f0; }
.ws .key { position: absolute; left: 3px; top: 1px; font-size: 8px; color: #64748b; }

/* Сенсорне керування — лише на дотикових пристроях */
#touch-left, #touch-right { position: absolute; bottom: 92px; z-index: 11; display: none; gap: 8px; align-items: flex-end; }
#touch-left { left: 10px; }
#touch-right { right: 10px; flex-direction: column; align-items: flex-end; }
@media (pointer: coarse) { #touch-left, #touch-right { display: flex; } #cam-btns { left: 8px; right: auto; top: 46px; transform: none; } #event-log { left: 52px; } }
.pad { width: 54px; height: 54px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; background: rgba(2, 6, 23, 0.62); border: 1px solid rgba(100, 116, 139, 0.75); color: #e2e8f0; backdrop-filter: blur(6px); touch-action: none; font-size: 24px; font-weight: 900; }
.pad svg { width: 22px; height: 22px; }
.pad:active:not(:disabled) { background: rgba(180, 83, 9, 0.85); border-color: #fbbf24; }
.pad:disabled { opacity: 0.3; }
.pad.jump { width: 46px; height: 46px; margin-bottom: 26px; }
.pad.sm { width: 40px; height: 40px; border-radius: 11px; }
.fine { display: flex; gap: 6px; }
.fire-wrap { position: relative; width: 84px; height: 84px; }
.fire-ring { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); pointer-events: none; }
.fire-btn { width: 84px; height: 84px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fb7185, #b91c1c 70%); border: 2px solid rgba(254, 202, 202, 0.7); color: white; font-weight: 900; font-size: 13px; letter-spacing: 0.04em; box-shadow: 0 0 22px rgba(220, 38, 38, 0.45); touch-action: none; }
.fire-btn:disabled { filter: grayscale(0.7); opacity: 0.35; box-shadow: none; }
#battlefield:not(.my-turn) #touch-right { opacity: 0.45; }

/* Низький екран (телефон боком) — компактніше */
@media (max-height: 460px) {
    .team { flex-basis: 110px; padding: 2px 6px; }
    #hud-top { top: 4px; }
    .hb { height: 30px; min-width: 30px; }
    #turn-box, #wind-box { height: 30px; }
    #wind-gauge { width: 56px; height: 24px; }
    .ws { width: 36px; height: 36px; }
    .ws svg { width: 19px; height: 19px; }
    #touch-left, #touch-right { bottom: 78px; }
    .pad { width: 46px; height: 46px; }
    .fire-wrap, .fire-btn { width: 70px; height: 70px; }
    #event-log { top: 58px; }
    #sd-badge { top: 40px; }
}
@media (max-width: 520px) {
    #teams .team { flex-basis: 76px; }
    #turn-box { font-size: 12px; padding: 0 7px; }
    #wind-gauge { width: 48px; }
    #aim-info .fuel i { width: 40px; }
}

/* Чат у бою */
.game-chat { position: absolute; top: 0; right: 0; bottom: 0; width: min(340px, 100%); z-index: 60; display: flex; flex-direction: column; background: rgba(15, 23, 42, 0.97); border-left: 1px solid #334155; box-shadow: -10px 0 30px rgba(0,0,0,0.5); }
.gc-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-bottom: 1px solid #334155; }
.gc-list { flex: 1; min-height: 0; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.gc-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid #334155; }
.gc-form input { flex: 1; min-width: 0; background: #020617; border: 1px solid #475569; border-radius: 8px; padding: 7px 10px; color: white; outline: none; }
.gc-form button { padding: 0 14px; border-radius: 8px; background: #d97706; color: white; font-weight: 800; }

/* Кінець бою */
.go-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.go-table th { font-size: 10px; text-transform: uppercase; color: #94a3b8; padding: 4px; text-align: right; }
.go-table th:first-child, .go-table td:first-child { text-align: left; }
.go-table td { padding: 6px 4px; border-top: 1px solid #1e293b; text-align: right; color: #e2e8f0; font-weight: 700; }
.go-table tr.win td { color: #fde047; }
.go-table .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }

/* Кімната на телефоні */
#screen-room { min-height: 0; overflow-y: auto; }
#modal-create-room > div, #modal-leaderboard > div, #modal-rules > div { max-height: calc(100% - 16px); overflow-y: auto; margin: 0 8px; }
@media (max-height: 560px) {
    #modal-create-room > div { padding: 12px 16px; }
    #modal-create-room h2 { font-size: 18px; margin-bottom: 8px; }
    #modal-create-room .mb-4, #modal-create-room .mb-6 { margin-bottom: 8px; }
}
@media (max-width: 520px), (max-height: 460px) { #event-log .log-line:nth-last-child(n+3) { display: none; } .log-line { font-size: 10px; } }
@media (max-height: 460px) { .tk-create { padding: 14px 18px; } .tk-create h2 { font-size: 1.15rem; margin-bottom: 8px; } .tk-create .mb-4 { margin-bottom: 8px; } .tk-create .mb-6 { margin-bottom: 12px; } }
#old-server { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(2, 6, 23, 0.82); }
#old-server .os-box { max-width: 380px; padding: 20px; border-radius: 14px; background: #1e293b; border: 1px solid #f59e0b; color: #e2e8f0; text-align: center; }
#old-server .os-title { font-size: 1.15rem; font-weight: 800; color: #fbbf24; margin-bottom: 8px; }
#old-server .os-text { font-size: 0.9rem; color: #cbd5e1; margin-bottom: 14px; }
#old-server button { padding: 8px 18px; border-radius: 8px; background: #d97706; color: #fff; font-weight: 700; }
