*, ::before, ::after { box-sizing: border-box; border: 0 solid; }
html { line-height: 1.5; -webkit-text-size-adjust: 100%; tab-size: 4; -webkit-tap-highlight-color: transparent; }
h1, h2, p { margin: 0; }
h1, h2 { font-size: inherit; font-weight: inherit; }
button, select { font: inherit; color: inherit; letter-spacing: inherit; border-radius: 0; background: transparent; }
button { appearance: button; }
strong, b { font-weight: bolder; }
small { font-size: 80%; }
svg, canvas { display: block; vertical-align: middle; }
[hidden] { display: none !important; }

:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }

body {
  background:
    radial-gradient(circle at 20% 15%, rgba(82, 122, 95, 0.28), transparent 32rem),
    radial-gradient(circle at 85% 85%, rgba(34, 82, 99, 0.35), transparent 30rem),
    linear-gradient(145deg, #111b1c 0%, #172523 48%, #0b1518 100%);
  color: #f4f1e8;
}

button { font: inherit; }

.game-shell {
  width: 100vw;
  height: 100dvh;
}

.game-card {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #101c1a;
}

.hud {
  position: absolute;
  z-index: 5;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(620px, calc(100% - 150px));
  gap: 1px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 8px 32px rgba(0,0,0,.22);
  transform: translateX(-50%);
}

.hud div { padding: 9px 14px; background: rgba(8, 18, 17, .76); text-align: center; backdrop-filter: blur(10px); }
.hud span { display: block; margin-bottom: 3px; color: #9eaa9a; font-size: .68rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.hud strong { color: #f0e8c9; font-size: 1.2rem; font-variant-numeric: tabular-nums; }

.arena-wrap { position: absolute; inset: 0; background: #172320; }
#game { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }

.sound-toggle {
  position: absolute;
  z-index: 3;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 50%;
  background: rgba(8, 16, 16, .68);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.sound-toggle:hover { background: rgba(34, 50, 45, .9); }

.weapon-status {
  position: absolute;
  z-index: 2;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: max(12px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: auto auto;
  gap: 1px 9px;
  align-items: baseline;
  min-width: 150px;
  padding: 10px 13px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 13px;
  background: rgba(8, 16, 16, .72);
  backdrop-filter: blur(8px);
}

.weapon-status span { grid-column: 1 / -1; color: #8f9d94; font-size: .62rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.weapon-status strong { color: #f2df9c; font-size: .9rem; }
.weapon-status small { color: #b7c4ba; font-weight: 800; text-align: right; }
.weapon-status em { grid-column: 1 / -1; color: #8f9d94; font-size: .65rem; font-style: normal; font-weight: 850; letter-spacing: .1em; }

.power-status {
  position: absolute;
  z-index: 2;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  gap: 7px;
}

.power-status div {
  min-width: 74px;
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 12px;
  background: rgba(8, 16, 16, .72);
  text-align: center;
  backdrop-filter: blur(8px);
}

.power-status span { display: block; color: #8f9d94; font-size: .58rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.power-status strong { color: #87e9ff; font-size: .88rem; }
.power-status div:last-child strong { color: #ffc95c; }

.pickup-toast {
  position: absolute;
  z-index: 4;
  top: 72px;
  left: 50%;
  padding: 9px 15px;
  border: 1px solid rgba(255, 225, 143, .35);
  border-radius: 999px;
  background: rgba(8, 16, 16, .84);
  color: #ffe18f;
  font-size: .8rem;
  font-weight: 850;
  letter-spacing: .08em;
  opacity: 0;
  transform: translate(-50%, -10px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.pickup-toast.show { opacity: 1; transform: translate(-50%, 0); }

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 24px;
  background: linear-gradient(rgba(8, 15, 16, .58), rgba(8, 15, 16, .84));
  text-align: center;
  transition: opacity 180ms ease;
}

.overlay.hidden { pointer-events: none; opacity: 0; }
.eyebrow { margin: 0 0 10px; color: #d2b66f; font-size: .74rem; font-weight: 800; letter-spacing: .25em; }
.overlay h1 { margin: 0; font-size: clamp(2.8rem, 8vw, 6.6rem); line-height: .95; letter-spacing: -.055em; text-transform: uppercase; text-shadow: 0 8px 40px rgba(0, 0, 0, .5); }
.overlay > p:not(.eyebrow):not(.controls-hint) { max-width: 540px; margin: 22px 0; color: #c7cec0; line-height: 1.55; }

#startButton {
  border: 1px solid #dbc27e;
  border-radius: 999px;
  padding: 13px 26px;
  background: #d2b66f;
  color: #101817;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease;
}

#startButton:hover { transform: translateY(-2px); background: #ead18c; }
.controls-hint { margin: 18px 0 0; color: #859289; font-size: .76rem; }

.language-picker { display: flex; align-items: center; gap: 9px; margin-top: 14px; color: #aeb8af; font-size: .72rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.language-picker select { min-width: 118px; padding: 7px 28px 7px 10px; border: 1px solid rgba(255,255,255,.18); border-radius: 9px; background: rgba(11,24,22,.9); color: #f0f2eb; outline: none; cursor: pointer; }
.language-picker select:focus { border-color: #d2b66f; box-shadow: 0 0 0 2px rgba(210,182,111,.16); }

.perk-overlay {
  position: absolute;
  z-index: 9;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 24px;
  background: radial-gradient(circle, rgba(33, 63, 54, .74), rgba(5, 12, 12, .94));
  text-align: center;
  transition: opacity 160ms ease;
}

.perk-overlay.hidden { pointer-events: none; opacity: 0; }
.perk-overlay h2 { margin: 0 0 24px; font-size: clamp(1.8rem, 5vw, 3.4rem); letter-spacing: -.04em; text-transform: uppercase; }
.perk-choices { display: grid; grid-template-columns: repeat(3, minmax(170px, 220px)); gap: 14px; }
.perk-card { min-height: 150px; padding: 18px; border: 1px solid rgba(218, 232, 209, .2); border-radius: 18px; background: rgba(17, 33, 30, .88); color: #eef2e7; cursor: pointer; transition: transform 140ms ease, border-color 140ms ease, background 140ms ease; }
.perk-card:hover { transform: translateY(-4px); border-color: #d2b66f; background: rgba(29, 49, 43, .96); }
.perk-card strong { display: block; margin: 8px 0; color: #ffe19a; font-size: 1.05rem; }
.perk-card span { color: #aebcb2; font-size: .78rem; line-height: 1.45; }
.perk-icon { color: #7ce7b0; font-size: 1.8rem; }

.mobile-controls { display: none; user-select: none; -webkit-user-select: none; }
.joystick-zone { position: relative; width: 48%; height: 100%; touch-action: none; }
.joystick-zone > span { display: none; }
.joystick-base { position: absolute; left: 50%; top: 50%; width: 126px; height: 126px; border: 2px solid rgba(206,232,218,.24); border-radius: 50%; background: radial-gradient(circle, rgba(143,177,158,.18), rgba(9,20,18,.25) 68%); box-shadow: inset 0 0 28px rgba(0,0,0,.32); transform: translate(-50%, -50%); transition: left 150ms ease, top 150ms ease, opacity 120ms ease; }
.joystick-thumb { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; border: 2px solid rgba(238,245,229,.44); border-radius: 50%; background: radial-gradient(circle at 36% 30%, #668976, #284238 72%); box-shadow: 0 8px 20px rgba(0,0,0,.42); transform: translate(-50%, -50%); }
.joystick-zone.active .joystick-base { border-color: rgba(150,239,188,.56); background: radial-gradient(circle, rgba(93,214,144,.2), rgba(9,20,18,.3) 68%); }
.fire { width: 82px; height: 82px; border-color: rgba(255, 138, 91, .5); border-radius: 50%; background: #a8492f; font-weight: 900; letter-spacing: .05em; }
.fire:active { transform: scale(.92); background: #d15b3b; }

@media (max-width: 760px), (pointer: coarse) {
  body { position: fixed; inset: 0; }
  .hud { top: max(7px, env(safe-area-inset-top)); width: min(580px, calc(100% - 104px)); border-radius: 11px; }
  .mobile-controls { position: fixed; z-index: 6; inset: auto 0 0; display: flex; height: min(31dvh, 210px); align-items: center; justify-content: space-between; padding: 8px max(22px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); pointer-events: none; }
  .mobile-controls::before { position: absolute; z-index: -1; inset: -70px 0 0; content: ""; background: linear-gradient(transparent, rgba(5,12,11,.18) 32%, rgba(5,12,11,.45)); pointer-events: none; }
  .joystick-zone, .fire { pointer-events: auto; }
  .joystick-zone { width: 55%; }
  .joystick-base { width: 116px; height: 116px; opacity: .78; }
  .joystick-thumb { width: 54px; height: 54px; }
  .fire { width: 86px; height: 86px; margin-right: 2vw; border: 2px solid rgba(255,170,126,.62); box-shadow: 0 10px 28px rgba(0,0,0,.38), inset 0 0 18px rgba(255,190,140,.12); touch-action: none; opacity: .9; }
  .controls-hint { display: none; }
  .hud div { padding: 6px 3px; }
  .hud span { font-size: .5rem; }
  .hud strong { font-size: .82rem; }
  .weapon-status { bottom: max(8px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%) scale(.78); transform-origin: bottom center; opacity: .9; }
  .power-status { top: calc(max(7px, env(safe-area-inset-top)) + 48px); right: max(7px, env(safe-area-inset-right)); bottom: auto; transform: scale(.76); transform-origin: top right; }
  .sound-toggle { top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); width: 38px; height: 38px; }
  .overlay { z-index: 8; padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); }
  .overlay h1 { font-size: clamp(2.6rem, 15vw, 5.4rem); }
  .perk-overlay { padding: 16px; }
  .perk-overlay h2 { margin-bottom: 14px; font-size: clamp(1.5rem, 7vw, 2.3rem); }
  .perk-choices { width: min(100%, 520px); grid-template-columns: 1fr; gap: 8px; }
  .perk-card { min-height: 0; padding: 11px 14px; border-radius: 13px; text-align: left; }
  .perk-icon { float: left; width: 36px; margin-right: 8px; font-size: 1.35rem; text-align: center; }
  .perk-card strong { margin: 0 0 3px; font-size: .9rem; }
  .perk-card span { font-size: .7rem; }
}

@media (pointer: coarse) and (orientation: landscape) {
  .mobile-controls { height: 52dvh; padding-inline: max(22px, env(safe-area-inset-left)); }
  .joystick-zone { width: 42%; }
  .weapon-status { bottom: max(8px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%) scale(.78); }
  .power-status { top: auto; right: max(8px, env(safe-area-inset-right)); bottom: max(8px, env(safe-area-inset-bottom)); }
  .fire { width: 82px; height: 82px; }
  .joystick-base { width: 108px; height: 108px; }
  .overlay h1 { font-size: clamp(2.5rem, 10vh, 4.8rem); }
  .overlay > p:not(.eyebrow):not(.controls-hint) { margin: 10px 0; }
  .perk-overlay h2 { font-size: 1.5rem; }
  .perk-choices { grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 8px; }
  .perk-card { padding: 10px; text-align: center; }
  .perk-icon { float: none; width: auto; margin: 0; }
}
