:root {
  --aqua: #29c4e8;
  --navy: #123049;
  --yellow: #ffd23f;
  --coral: #ff7a59;
  --cream: #fff6e0;
  --wood: #a0663a;
  --panel: none;
  --button: none;
  --font: "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #0d2233; font-family: var(--font); color: var(--cream); user-select: none; -webkit-user-select: none; }
#stage { position: fixed; inset: 0; }
#game { width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }

.outline { color: var(--cream); text-shadow: -2px -2px 0 var(--navy), 2px -2px 0 var(--navy), -2px 2px 0 var(--navy), 2px 2px 0 var(--navy), 0 2px 0 var(--navy), 2px 0 0 var(--navy), -2px 0 0 var(--navy), 0 -2px 0 var(--navy), 0 5px 0 rgba(0,0,0,0.35); }
.num { font-weight: 900; color: #fff; font-variant-numeric: tabular-nums;
  text-shadow: -2px -2px 0 var(--navy), 2px -2px 0 var(--navy), -2px 2px 0 var(--navy), 2px 2px 0 var(--navy), 0 3px 0 rgba(0,0,0,.35); }
.num.small { font-size: 0.7em; opacity: 0.9; }

/* 9-slice panels and buttons from the game's UI art (set by JS after cropping) */
.panel9 { border-style: solid; border-width: 22px; border-image-source: var(--panel); border-image-slice: 60 fill; border-image-width: 22px; border-image-repeat: stretch; background: transparent; color: var(--navy); }
body.noart .panel9 { background: rgba(255, 246, 224, 0.95); border: 4px solid var(--wood); border-radius: 14px; }
.btn9 { font-family: var(--font); font-weight: 900; font-size: 18px; color: #fff; cursor: pointer; min-height: 48px; min-width: 48px; padding: 4px 22px;
  border-style: solid; border-width: 14px 20px; border-image-source: var(--button); border-image-slice: 45% 30% fill; border-image-width: 14px 20px; border-image-repeat: stretch; background: transparent;
  text-shadow: -2px -2px 0 #8a3d00, 2px -2px 0 #8a3d00, -2px 2px 0 #8a3d00, 2px 2px 0 #8a3d00, 0 3px 0 rgba(0,0,0,.3);
  transition: transform .09s ease-out, filter .12s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; outline: none; }
body.noart .btn9 { background: linear-gradient(#ffe066, #f5a623); border: 3px solid #b8620a; border-radius: 14px; }
.btn9:hover, .btn9.focus { filter: brightness(1.12) drop-shadow(0 0 6px #fff); transform: translateY(-2px) scale(1.04); }
.btn9:active { transform: translateY(2px) scale(0.95); }
.btn9.big { font-size: 26px; min-height: 64px; padding: 6px 40px; }

/* icons drawn in CSS */
.ico-heart, .ico-paw, .ico-crown, .ico-trophy, .ico-shell { display: inline-block; width: 22px; height: 22px; background-size: contain; background-repeat: no-repeat; background-position: center; flex: 0 0 auto; }
.ico-heart { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'><path fill='%23123049' d='M1 1h2v1h2V1h2v1h1v3H7v1H6v1H5v1H3V7H2V6H1V5H0V2h1z'/><path fill='%23ff5a6e' d='M1 2h2v1h2V2h2v3H6v1H5v1H3V6H2V5H1z'/><path fill='%23fff' d='M2 2h1v1H2z'/></svg>"); }
.ico-paw { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'><path fill='%23123049' d='M0 1h2v2H0zM3 0h2v2H3zM6 1h2v2H6zM1 3h6v5H1z'/><path fill='%23ffd23f' d='M1 4h6v3H1zM0 1h1v1H0zM3 0h1v1H3zM6 1h1v1H6z'/></svg>"); }
.ico-crown { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'><path fill='%23123049' d='M0 1h2v2h1V1h2v2h1V1h2v6H0z'/><path fill='%23ffd23f' d='M1 2h0v4h6V2H7v2H6v1H5V3H3v2H2V4H1z'/></svg>"); }
.ico-trophy { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'><path fill='%23fff6e0' d='M1 0h6v1h1v2H7v1H6v1H5v1h1v2H2V6h1V5H2V4H1V3H0V1h1z'/><path fill='%23ffd23f' d='M2 1h4v3H5v1H3V4H2z'/></svg>"); }
.ico-shell { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'><path fill='%23fff6e0' d='M2 0h4v1h1v1h1v3H7v1H6v1H2V6H1V5H0V2h1V1h1z'/><path fill='%23ff9ab0' d='M2 1h1v5H2zM5 1h1v5H5zM1 2h1v3H1zM6 2h1v3H6z'/></svg>"); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hud-panel { position: absolute; background: rgba(18, 48, 73, 0.62); border: 3px solid rgba(255,255,255,0.85); border-radius: 12px; box-shadow: 0 4px 0 rgba(0,0,0,0.25); padding: 6px 12px; }
#hud-tl { left: calc(12px + env(safe-area-inset-left, 0px)); top: 10px; min-width: 210px; }
.hp-row, .ammo-row, .kills-row { display: flex; align-items: center; gap: 8px; }
.hp-bar { flex: 1; height: 16px; background: rgba(0,0,0,0.45); border: 2px solid var(--navy); border-radius: 4px; overflow: hidden; min-width: 110px; }
#hp-fill { height: 100%; width: 100%; background: linear-gradient(#7dffb0, #22c46a); transition: width .15s; }
#hp-fill.low { background: linear-gradient(#ff9a8a, #ff4b3a); }
#hp-num { font-size: 20px; min-width: 40px; text-align: right; }
.ammo-row { margin-top: 4px; }
#ammo-icon { width: 46px; height: 28px; object-fit: contain; filter: drop-shadow(0 2px 0 var(--navy)); }
#ammo-num { font-size: 24px; }
#ammo-num.empty { color: #ff8a7a; }
.speed { margin-left: auto; color: var(--aqua) !important; }
#hud-top { left: 50%; top: 8px; transform: translateX(-50%); text-align: center; padding: 4px 16px; pointer-events: auto; cursor: pointer; }
#timer { font-size: 24px; line-height: 1.05; }
.kills-row { justify-content: center; font-size: 18px; }
.kills-row .sep { opacity: .6; font-weight: 900; }
#killfeed { position: absolute; right: calc(12px + env(safe-area-inset-right, 0px)); top: 64px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; max-width: 46vw; }
.kf { background: rgba(18, 48, 73, 0.7); border-radius: 8px; padding: 3px 10px; font-size: 14px; font-weight: 900; white-space: nowrap; display: flex; align-items: center; gap: 6px; animation: kfIn .25s cubic-bezier(.34,1.56,.64,1); }
.kf.me { background: rgba(255, 210, 63, 0.85); color: var(--navy); }
.kf img { height: 18px; width: 30px; object-fit: contain; }
.kf .hs { color: var(--coral); }
@keyframes kfIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

#crosshair { position: absolute; left: 50%; top: 50%; width: 0; height: 0; --gap: 6px; }
#crosshair i { position: absolute; background: #fff; box-shadow: 0 0 0 1.5px var(--navy); border-radius: 1px; }
#crosshair .ch-t, #crosshair .ch-b { width: 3px; height: 10px; left: -1.5px; }
#crosshair .ch-t { bottom: var(--gap); } #crosshair .ch-b { top: var(--gap); }
#crosshair .ch-l, #crosshair .ch-r { height: 3px; width: 10px; top: -1.5px; }
#crosshair .ch-l { right: var(--gap); } #crosshair .ch-r { left: var(--gap); }
#crosshair .ch-dot { width: 4px; height: 4px; left: -2px; top: -2px; background: var(--yellow); }
#hitmarker { position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; opacity: 0;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 34 34'><g stroke='%23123049' stroke-width='6' stroke-linecap='square'><path d='M5 5l7 7M29 5l-7 7M5 29l7-7M29 29l-7-7'/></g><g stroke='%23fff' stroke-width='3' stroke-linecap='square'><path d='M5 5l7 7M29 5l-7 7M5 29l7-7M29 29l-7-7'/></g></svg>") center/contain no-repeat; }
#hitmarker.show { animation: hm .22s ease-out; }
#hitmarker.head { filter: hue-rotate(-40deg) saturate(4) brightness(1.2); }
#hitmarker.kill { filter: sepia(1) saturate(8) hue-rotate(-20deg); }
@keyframes hm { 0% { opacity: 1; transform: scale(1.4); } 100% { opacity: 0; transform: scale(1); } }
#reload-ring { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; }
#reload-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
#reload-ring circle { fill: none; stroke: rgba(18,48,73,.6); stroke-width: 5; }
#reload-arc { stroke: var(--aqua) !important; stroke-dasharray: 100.5; stroke-dashoffset: 100.5; stroke-linecap: round; }
/* the slam banner: only as wide as its words, centred, so it never sits under the HUD panels */
#announce { position: absolute; left: 0; right: 0; margin: 0 auto; width: fit-content; max-width: 90vw; top: 22%; text-align: center; font-size: 46px; font-weight: 900; line-height: 1.1; color: var(--yellow); pointer-events: none; white-space: nowrap;
  text-shadow: -3px -3px 0 var(--navy), 3px -3px 0 var(--navy), -3px 3px 0 var(--navy), 3px 3px 0 var(--navy), 0 7px 0 rgba(0,0,0,.35); }
#announce.show { animation: slam .9s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes slam { 0% { transform: scale(2.6) rotate(-6deg); opacity: 0; } 25% { transform: scale(1) rotate(-3deg); opacity: 1; } 80% { opacity: 1; } 100% { transform: scale(1.05) rotate(-3deg); opacity: 0; } }
#popups { position: absolute; left: 50%; top: 56%; }
.pop { position: absolute; transform: translateX(-50%); font-size: 22px; font-weight: 900; color: var(--yellow); white-space: nowrap; animation: popUp .9s ease-out forwards;
  text-shadow: -2px -2px 0 var(--navy), 2px -2px 0 var(--navy), -2px 2px 0 var(--navy), 2px 2px 0 var(--navy); }
@keyframes popUp { 0% { transform: translate(-50%, 10px) scale(.6); opacity: 0; } 20% { transform: translate(-50%, 0) scale(1.15); opacity: 1; } 100% { transform: translate(-50%, -50px) scale(1); opacity: 0; } }
#scope { position: absolute; inset: 0; background: radial-gradient(circle at center, transparent 0, transparent 33vh, rgba(8,20,30,.97) calc(33vh + 2px));
}
#scope::before, #scope::after { content: ""; position: absolute; left: 50%; top: 50%; background: rgba(10,20,30,.85); }
#scope::before { width: 66vh; height: 2px; margin-left: -33vh; }
#scope::after { height: 66vh; width: 2px; margin-top: -33vh; }
#speedlines { position: absolute; inset: 0; opacity: 0; transition: opacity .2s;
  background: repeating-conic-gradient(from 0deg at 50% 50%, rgba(255,255,255,0.0) 0deg 7deg, rgba(255,255,255,0.22) 7deg 8deg);
  -webkit-mask-image: radial-gradient(circle at center, transparent 30%, black 75%); mask-image: radial-gradient(circle at center, transparent 30%, black 75%); }
#dmg-vignette { position: absolute; inset: 0; opacity: 0; background: radial-gradient(circle at center, transparent 45%, rgba(255, 70, 60, 0.6) 100%); transition: opacity .35s; }
#respawn { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(18,48,73,.25); }
.resp-box { padding: 6px 26px; text-align: center; min-width: 260px; }
#killed-by { font-size: 18px; font-weight: 900; color: var(--navy); }
.resp-box .big { font-size: 34px; font-weight: 900; color: var(--coral); }
#lock-hint { position: absolute; left: 50%; top: 64%; transform: translateX(-50%); background: rgba(18,48,73,.75); padding: 8px 18px; border-radius: 10px; font-weight: 900; font-size: 16px; }

/* ---------- Scoreboard ---------- */
#scoreboard { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(10,25,40,.35); pointer-events: auto; }
.sb-box { width: min(560px, 92vw); max-height: 86vh; overflow: hidden; padding: 8px 18px; animation: popIn .22s cubic-bezier(.34,1.56,.64,1); }
.sb-title { text-align: center; font-size: 24px; font-weight: 900; color: #fff; margin-bottom: 6px;
  text-shadow: -2px -2px 0 var(--navy), 2px -2px 0 var(--navy), -2px 2px 0 var(--navy), 2px 2px 0 var(--navy), 0 4px 0 rgba(0,0,0,.3); }
.sb-row { display: grid; grid-template-columns: 34px 30px 1fr 52px 52px; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 8px; font-weight: 900; font-size: 16px; color: var(--navy); }
.sb-row:nth-child(odd) { background: rgba(160, 102, 58, 0.14); }
.sb-row.me { background: var(--yellow) !important; }
.sb-row.head { font-size: 13px; opacity: .75; background: none !important; }
.sb-row img { width: 28px; height: 28px; object-fit: contain; }
.sb-row .r { text-align: center; }
@keyframes popIn { from { transform: scale(.75); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Screens ---------- */
.screen { position: fixed; inset: 0; z-index: 20; overflow: hidden; }
.title-bg { position: absolute; inset: 0; background: #7fc8e8 url("../assets/title-bg.webp") center/cover no-repeat; animation: bgZoom 22s ease-in-out infinite alternate; }
.title-bg.dim::after { content: ""; position: absolute; inset: 0; background: linear-gradient(rgba(18,48,73,.55), rgba(18,48,73,.75)); }
@keyframes bgZoom { from { transform: scale(1.02); } to { transform: scale(1.1) translateY(-1%); } }
#title-logo { position: absolute; left: 50%; top: 4%; width: min(62vw, 92vh); max-height: 34vh; object-fit: contain; transform: translateX(-50%); filter: drop-shadow(0 8px 0 rgba(18,48,73,.35));
  animation: logoIn .7s cubic-bezier(.34,1.56,.64,1) both, logoFloat 3.2s ease-in-out .7s infinite; }
@keyframes logoIn { from { transform: translateX(-50%) translateY(-60px) scale(.5); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
@keyframes logoFloat { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-8px) rotate(-1deg); } }
#title-prompt { position: absolute; left: 0; right: 0; bottom: 9%; text-align: center; font-size: 26px; font-weight: 900; color: #fff; animation: pulse 1.4s ease-in-out infinite;
  text-shadow: -3px -3px 0 var(--navy), 3px -3px 0 var(--navy), -3px 3px 0 var(--navy), 3px 3px 0 var(--navy), 0 5px 0 rgba(0,0,0,.3); }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.06); opacity: .8; } }
.title-buttons { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(9% + 46px); display: flex; gap: 14px; }

#loadout .lo-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 12px calc(20px + env(safe-area-inset-right, 0px)) 12px calc(20px + env(safe-area-inset-left, 0px)); gap: 8px; }
.lo-head { display: flex; align-items: baseline; gap: 14px; justify-content: center; padding-right: 50px; }
.lo-map { font-size: 26px; font-weight: 900; color: var(--yellow); text-shadow: -2px -2px 0 var(--navy), 2px -2px 0 var(--navy), -2px 2px 0 var(--navy), 2px 2px 0 var(--navy), 0 4px 0 rgba(0,0,0,.3); }
.lo-mode { font-size: 16px; font-weight: 900; color: #fff; background: var(--coral); padding: 2px 10px; border-radius: 8px; }
.lo-label { font-size: 17px; font-weight: 900; color: #fff; margin: 0 0 4px 4px; text-shadow: -2px -2px 0 var(--navy), 2px -2px 0 var(--navy), -2px 2px 0 var(--navy), 2px 2px 0 var(--navy); }
.lo-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.card { position: relative; border-radius: 14px; background: rgba(255, 246, 224, 0.92); border: 4px solid var(--wood); box-shadow: 0 5px 0 rgba(0,0,0,.3); cursor: pointer; display: flex; flex-direction: column; align-items: center; padding: 4px 4px 6px; transition: transform .12s cubic-bezier(.34,1.56,.64,1), border-color .12s; min-height: 48px; }
.card:active { transform: scale(.95); }
.card.sel { border-color: var(--yellow); background: #fff; transform: translateY(-4px) scale(1.03); box-shadow: 0 0 0 3px var(--navy), 0 0 18px var(--yellow), 0 6px 0 rgba(0,0,0,.3); }
.card.focus { outline: 3px dashed var(--aqua); outline-offset: 2px; }
.card img { width: 100%; object-fit: contain; pointer-events: none; }
.card.char img { height: 17vh; }
.card.wpn img { height: 9vh; }
.card .cname { font-size: 15px; font-weight: 900; color: var(--navy); text-align: center; line-height: 1.15; }
.card .tag { position: absolute; top: 4px; right: 4px; background: var(--coral); color: #fff; font-size: 11px; font-weight: 900; padding: 1px 6px; border-radius: 6px; }
.lo-bottom { display: flex; gap: 14px; align-items: stretch; margin-top: auto; padding-right: 6px; }
#lo-desc { flex: 1; font-size: 15px; font-weight: 800; color: var(--navy); padding: 2px 10px; min-height: 64px; display: flex; flex-direction: column; justify-content: center; }
#lo-desc .stats { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 3px; font-size: 13px; }
#lo-desc .stat { display: flex; align-items: center; gap: 5px; }
#lo-desc .bar { width: 64px; height: 9px; background: rgba(18,48,73,.2); border-radius: 3px; overflow: hidden; }
#lo-desc .bar i { display: block; height: 100%; background: var(--aqua); }
#btn-fight { align-self: center; }

#intro { position: fixed; inset: 0; z-index: 40; background: #000 url("../assets/title-bg.webp") center/cover no-repeat; }
#intro video { width: 100%; height: 100%; object-fit: cover; }
#btn-skip { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: calc(14px + env(safe-area-inset-right, 0px)); }
#subtitle { position: fixed; left: 50%; bottom: 7%; transform: translateX(-50%); z-index: 45; background: rgba(18,48,73,.78); padding: 6px 18px; border-radius: 10px; font-size: 18px; font-weight: 900; max-width: 80vw; text-align: center; pointer-events: none; }
#endbanner { position: fixed; inset: 0; z-index: 35; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(circle, rgba(18,48,73,.3), rgba(18,48,73,.75)); pointer-events: none; }
.eb-title { font-size: 64px; font-weight: 900; color: var(--yellow); animation: slamIn .6s cubic-bezier(.2,1.6,.4,1) both; transform: rotate(-4deg);
  text-shadow: -4px -4px 0 var(--navy), 4px -4px 0 var(--navy), -4px 4px 0 var(--navy), 4px 4px 0 var(--navy), 0 9px 0 rgba(0,0,0,.35); }
.eb-sub { font-size: 24px; font-weight: 900; color: #fff; margin-top: 8px; animation: popIn .4s .3s both; text-shadow: -2px -2px 0 var(--navy), 2px -2px 0 var(--navy), -2px 2px 0 var(--navy), 2px 2px 0 var(--navy); }
@keyframes slamIn { from { transform: scale(3) rotate(-10deg); opacity: 0; } to { transform: rotate(-4deg); opacity: 1; } }
#help { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(10,25,40,.5); }
.help-box { width: min(640px, 92vw); padding: 8px 20px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; animation: popIn .22s cubic-bezier(.34,1.56,.64,1); }
#help-text { font-size: 15px; font-weight: 800; color: var(--navy); line-height: 1.55; white-space: pre-line; }
#fade { position: fixed; inset: 0; z-index: 60; background: #0d2233; opacity: 0; pointer-events: none; transition: opacity .3s; }
#fade.on { opacity: 1; }

@media (max-height: 460px) {
  #hud-tl { min-width: 180px; padding: 4px 10px; }
  #hp-num { font-size: 17px; }
  #ammo-num { font-size: 20px; }
  #timer { font-size: 20px; }
  #announce { font-size: 32px; top: 21%; }
  .card.char img { height: 15vh; }
  .card .cname { font-size: 13px; }
  .lo-map { font-size: 20px; }
  .lo-label { font-size: 14px; }
  #lo-desc { font-size: 13px; min-height: 54px; }
  .btn9.big { font-size: 22px; min-height: 54px; padding: 4px 28px; }
  #title-prompt { font-size: 20px; }
  .eb-title { font-size: 44px; }
}
