:root {
  --orange: #ff9d2e;
  --green: #72ff58;
  --red: #ff2e21;
  --steel: #c9c8c0;
  --ink: #f4ead8;
  --panel: rgba(18, 11, 9, 0.94);
  --line: rgba(255, 187, 93, 0.34);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #090505; }
body { color: var(--ink); font-family: "Arial Narrow", system-ui, sans-serif; touch-action: none; user-select: none; }
button, input { font: inherit; }
button { color: var(--ink); border: 1px solid var(--line); background: linear-gradient(#3a2c23, #211711); padding: 11px 18px; border-radius: 5px; letter-spacing: .08em; font-weight: 900; cursor: pointer; text-transform: uppercase; box-shadow: 0 3px 0 #080504; }
button:hover, button:focus-visible { border-color: var(--orange); color: #fff; outline: none; filter: brightness(1.14); }
button:disabled { opacity: .4; cursor: not-allowed; filter: none; }
button.primary { background: linear-gradient(#d96b20, #8b2d10); border-color: #ffb75e; font-size: 1.05rem; }
.danger-button { color: #ff8a7e; border-color: rgba(255, 70, 50, .45); margin-top: 16px; }

#game-shell, #game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; }
#game-canvas { display: block; }
#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(circle, transparent 48%, rgba(0,0,0,.45) 100%); z-index: 3; }
#damage-cracks { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 19; background: repeating-conic-gradient(from 20deg at 50% 50%, transparent 0 14deg, rgba(25,0,0,.72) 15deg 16deg, transparent 17deg 42deg); mask-image: radial-gradient(circle, transparent 0 54%, #000 76%); transition: opacity .18s; }
#damage-cracks.hit { opacity: 1; }

#crosshair { position: fixed; left: 50%; top: 50%; width: 27px; height: 27px; transform: translate(-50%, -50%); z-index: 15; pointer-events: none; filter: drop-shadow(0 1px 2px #000); }
#crosshair::before, #crosshair::after, #crosshair i, #crosshair b { content: ""; position: absolute; background: rgba(255,255,255,.92); }
#crosshair::before { width: 2px; height: 9px; left: 12px; top: 0; }
#crosshair::after { width: 2px; height: 9px; left: 12px; bottom: 0; }
#crosshair i { height: 2px; width: 9px; top: 12px; left: 0; }
#crosshair b { height: 2px; width: 9px; top: 12px; right: 0; }
body:not(.playing) #crosshair { display: none; }

.hidden { display: none !important; }
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 12; font-family: "Arial Narrow", system-ui, sans-serif; text-shadow: 0 2px 3px #000; }
.hud-top-left, .hud-top-right { position: absolute; top: max(14px, env(safe-area-inset-top)); min-width: 150px; padding: 11px 14px; border: 1px solid rgba(255,255,255,.15); background: linear-gradient(90deg, rgba(12,8,5,.8), rgba(12,8,5,.25)); }
.hud-top-left { left: max(14px, env(safe-area-inset-left)); }
.hud-top-right { right: max(14px, env(safe-area-inset-right)); text-align: right; background: linear-gradient(-90deg, rgba(12,8,5,.8), rgba(12,8,5,.25)); }
.hud-line { display: flex; justify-content: space-between; gap: 20px; font-size: 12px; letter-spacing: .1em; }
.hud-line span { color: #bdb2a4; }
.hud-line strong { color: #fff3c7; }
#health { display: flex; gap: 6px; margin-bottom: 8px; }
.heart { width: 27px; height: 12px; transform: skew(-12deg); border: 1px solid #ff766b; background: #c5281c; box-shadow: 0 0 8px rgba(255,46,33,.4); }
.heart.empty { background: rgba(50,20,18,.65); border-color: #5b302c; box-shadow: none; }
#boss-wrap { position: absolute; top: max(16px, env(safe-area-inset-top)); left: 50%; width: min(44vw, 560px); transform: translateX(-50%); text-align: center; }
.boss-title { color: #ffb4ac; letter-spacing: .24em; font-weight: 900; font-size: 14px; }
.boss-track { height: 14px; margin-top: 5px; border: 2px solid rgba(255,255,255,.65); background: #1c0807; transform: skew(-8deg); }
#boss-health { height: 100%; width: 100%; background: linear-gradient(90deg, #7f0906, #ff392b); box-shadow: 0 0 15px rgba(255,30,15,.75); transition: width .14s; }
#weapon-hud { position: absolute; left: 50%; bottom: max(15px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: end; gap: 10px; pointer-events: auto; }
.weapon-slot { min-width: 145px; min-height: 48px; font-size: 11px; padding: 8px; }
.weapon-slot.active { border-color: var(--orange); box-shadow: 0 0 18px rgba(255,157,46,.35), 0 3px 0 #080504; }
.weapon-slot:empty { visibility: hidden; }
.ammo-block { min-width: 130px; text-align: center; padding: 7px 12px; background: rgba(8,5,3,.75); border: 1px solid rgba(255,255,255,.16); }
.ammo-block > strong { font-size: 31px; line-height: 1; color: #fff; }
.ammo-block > span { color: #bfb7aa; }
.ammo-block small { display: block; margin-top: 4px; color: #d0c6b7; font-size: 9px; letter-spacing: .08em; }
.reload-track { height: 3px; margin-top: 5px; background: #241914; }
.reload-track i { display: block; height: 100%; width: 0; background: var(--orange); }
.icon-button { position: absolute; right: max(15px, env(safe-area-inset-right)); bottom: max(15px, env(safe-area-inset-bottom)); pointer-events: auto; width: 44px; height: 42px; padding: 0; }

.screen { position: fixed; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center; padding: 24px; overflow: auto; background: radial-gradient(circle at 50% 40%, rgba(94,41,17,.62), rgba(9,5,4,.96) 68%); }
.screen.active { display: flex; }
.screen.translucent { background: rgba(4,2,2,.77); backdrop-filter: blur(6px); }
#title-screen { flex-direction: column; text-align: center; overflow: hidden; }
.title-smoke { position: absolute; inset: -20%; background: radial-gradient(ellipse at 50% 70%, rgba(255,85,20,.27), transparent 35%), repeating-radial-gradient(ellipse at 50% 85%, rgba(190,190,190,.07) 0 4%, transparent 5% 11%); filter: blur(18px); animation: smoke 12s linear infinite alternate; }
@keyframes smoke { to { transform: translate3d(4%, -3%, 0) scale(1.08); } }
.logo { z-index: 1; display: flex; align-items: center; justify-content: center; color: var(--steel); font-family: "Arial Black", sans-serif; font-size: clamp(64px, 13vw, 178px); line-height: .85; letter-spacing: -.035em; text-shadow: 0 3px 0 #66615b, 0 7px 0 #24211f, 0 11px 20px #000, 0 0 35px rgba(255,75,15,.32); background: linear-gradient(#fff, #817f7a 52%, #d7d1c8 53%, #595653); background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.potato-o { width: .68em; height: .82em; margin: 0 .015em .01em .03em; border-radius: 48% 54% 45% 58%; background: radial-gradient(circle at 31% 30%, #3a1f0e 0 3%, transparent 4%), radial-gradient(circle at 67% 66%, #3a1f0e 0 3%, transparent 4%), radial-gradient(circle at 66% 24%, #3a1f0e 0 2.5%, transparent 3.5%), linear-gradient(145deg, #c48a48, #69401f); box-shadow: inset 9px 5px 12px rgba(255,215,145,.28), inset -8px -8px 15px rgba(31,12,3,.42), 0 7px 0 #24211f, 0 11px 20px #000; transform: rotate(-8deg); -webkit-text-fill-color: initial; }
.tagline { z-index: 1; margin: 24px 0 34px; color: #ffc68b; letter-spacing: clamp(.18em, .8vw, .48em); font-weight: 900; text-shadow: 0 2px 8px #000; }
.title-actions { z-index: 1; display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.best-line, .home-link { z-index: 1; color: #a99f94; letter-spacing: .08em; font-size: 12px; }
.best-line { margin-top: 24px; }
.best-line b { color: #f3ddc1; }
.home-link { margin-top: 20px; text-decoration: none; }
.home-link:hover { color: var(--orange); }

.panel { width: min(720px, 96vw); max-height: 94vh; overflow: auto; padding: 30px; border: 1px solid var(--line); border-top-color: rgba(255,190,105,.7); border-radius: 8px; background: var(--panel); box-shadow: 0 24px 80px #000; text-align: center; }
.wide-panel { width: min(980px, 97vw); }
.compact-panel { width: min(460px, 94vw); display: grid; gap: 14px; }
.panel h2 { margin: 0 0 20px; font-size: clamp(30px, 6vw, 58px); letter-spacing: .06em; color: #e4ddd3; text-shadow: 0 4px 0 #211; }
.panel h3 { margin: 22px 0 10px; color: #e9bb7c; letter-spacing: .12em; font-size: 13px; }
.eyebrow { color: #8dff79; letter-spacing: .18em; font-size: 12px; }
.eyebrow.danger { color: #ff6456; }
.instructions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.instructions-grid > div { padding: 18px; text-align: left; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.035); }
.instructions-grid b { display: block; color: #ffc47d; }
.instructions-grid p { margin: 5px 0 0; color: #bbb0a3; font: 14px system-ui, sans-serif; }
.control-icon { float: left; display: grid; place-items: center; width: 44px; height: 44px; margin-right: 13px; border: 1px solid #8f7d6e; border-radius: 5px; font-weight: 900; }
.instruction-warning { margin: 22px 0; color: #ff8a72; font-weight: 900; letter-spacing: .08em; }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.reward-card { min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.reward-card strong { color: #ffc47d; font-size: 18px; }
.reward-card small { margin-top: 8px; color: #bdb2a4; }
.reward-card.selected { border-color: #79ff5f; background: linear-gradient(#294529, #132416); }
.intermission-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; text-align: left; }
.shop-list { display: grid; gap: 7px; }
.shop-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 45px; padding: 7px 9px; background: rgba(255,255,255,.035); border: 1px solid rgba(255,255,255,.1); }
.shop-row span { font-size: 12px; }
.shop-row button { padding: 7px 10px; font-size: 10px; }
.shop-row.selected { border-color: var(--orange); }
#next-level-button { margin-top: 24px; }

.leaderboard-panel { width: min(650px, 96vw); }
#nickname-form label { display: block; margin-bottom: 7px; color: #c9b69f; letter-spacing: .1em; font-size: 12px; }
#nickname-form > div { display: flex; gap: 7px; }
#nickname-input { flex: 1; min-width: 0; padding: 11px; color: #fff; border: 1px solid #786b5f; background: #0c0907; user-select: text; }
#nickname-message { min-height: 1.2em; color: #ff9b8f; font: 13px system-ui, sans-serif; }
.leaderboard-list { margin: 16px 0; max-height: 48vh; overflow: auto; text-align: left; }
.score-row { display: grid; grid-template-columns: 42px 1fr auto; gap: 10px; align-items: center; padding: 10px; border-bottom: 1px solid rgba(255,255,255,.1); }
.score-row.mine { background: rgba(255,143,45,.12); border-color: rgba(255,143,45,.4); }
.score-rank { color: #92877b; }
.score-name { font-weight: 900; }
.score-stats { text-align: right; color: #ffc47d; }
.score-stats small { display: block; color: #a99f94; font-size: 10px; }
.panel label { display: grid; gap: 7px; text-align: left; color: #d6c8b8; font-size: 12px; letter-spacing: .08em; }
input[type="range"] { width: 100%; }

#rotate-prompt { position: fixed; inset: 0; z-index: 200; display: none; place-items: center; align-content: center; text-align: center; background: #0a0605; padding: 30px; }
.rotate-phone { font-size: 92px; line-height: 1; transform: rotate(90deg); color: var(--orange); }
#rotate-prompt strong { margin-top: 22px; font-size: 24px; letter-spacing: .1em; }
#rotate-prompt p { color: #aa9e91; }
#toast { position: fixed; left: 50%; bottom: 100px; z-index: 100; transform: translate(-50%, 20px); opacity: 0; padding: 10px 16px; border: 1px solid var(--line); background: rgba(10,6,4,.9); transition: .2s; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (orientation: portrait) and (pointer: coarse) { #rotate-prompt { display: grid; } }
@media (max-width: 760px) {
  .hud-top-left, .hud-top-right { min-width: 120px; padding: 7px 9px; }
  .hud-line { font-size: 10px; gap: 10px; }
  #health .heart { width: 20px; height: 9px; }
  #boss-wrap { top: 7px; width: 42vw; }
  .boss-title { font-size: 10px; }
  #weapon-hud { bottom: 7px; gap: 4px; }
  .weapon-slot { min-width: 100px; min-height: 39px; padding: 5px; font-size: 8px; }
  .ammo-block { min-width: 95px; padding: 4px 7px; }
  .ammo-block > strong { font-size: 23px; }
  .ammo-block small { display: none; }
  .icon-button { bottom: 7px; right: 7px; }
  .panel { padding: 18px; }
  .instructions-grid { grid-template-columns: 1fr 1fr; gap: 7px; }
  .instructions-grid > div { padding: 10px; }
  .instructions-grid p { font-size: 11px; }
  .control-icon { width: 34px; height: 34px; }
  .intermission-columns { grid-template-columns: 1fr; gap: 4px; }
}

@media (max-height: 500px) {
  .logo { font-size: min(22vh, 108px); }
  .tagline { margin: 10px 0 16px; }
  .best-line, .home-link { margin-top: 10px; }
  .instructions-panel h2 { font-size: 28px; margin-bottom: 8px; }
  .instruction-warning { margin: 10px 0; }
  .instructions-grid > div { min-height: 62px; }
}
