/* ============================================================
   GANGSTER WARS — UI STYLES
   Aesthetic: 1920s noir, sepia + blood red + brass gold
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Limelight&family=Special+Elite&family=Oswald:wght@400;500;700&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0805;
  font-family: 'Oswald', 'Arial Narrow', sans-serif;
  color: #f4e6c1;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game-root {
  position: fixed;
  inset: 0;
  background: #1a120a;
  overflow: hidden;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #2a1f12;
  touch-action: none;
  cursor: crosshair;
}

.hidden { display: none !important; }

/* ============================================================
   OVERLAYS
   ============================================================ */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  background:
    radial-gradient(ellipse at center, rgba(28, 16, 6, 0.95), rgba(0, 0, 0, 0.985)),
    repeating-linear-gradient(45deg, rgba(255,200,100,0.025) 0 2px, transparent 2px 4px);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.18s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes titleIn {
  from { opacity: 0; transform: translateY(15px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   START SCREEN
   ============================================================ */
.title-block {
  text-align: center;
  margin-bottom: 38px;
  animation: titleIn 0.45s cubic-bezier(.2,.8,.2,1) both;
}

.title-kicker {
  font-family: 'Special Elite', monospace;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: #d4a154;
  font-size: clamp(11px, 2.2vw, 14px);
  margin-bottom: 16px;
  opacity: 0.9;
}

.title {
  font-family: 'Limelight', serif;
  font-size: clamp(54px, 11vw, 128px);
  line-height: 0.9;
  letter-spacing: 0.04em;
  color: #f4e6c1;
  text-shadow:
    0 0 1px #f4e6c1,
    3px 3px 0 #8b1f1f,
    6px 6px 0 #1a0a0a,
    8px 10px 25px rgba(0,0,0,0.8);
  margin-bottom: 18px;
}

.title span {
  display: block;
  color: #c83838;
  margin-top: -0.05em;
}

.title-sub {
  font-family: 'Special Elite', monospace;
  color: #c9b889;
  font-size: clamp(13px, 2.2vw, 17px);
  max-width: 500px;
  line-height: 1.5;
  margin: 0 auto;
  opacity: 0.85;
}

.start-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
  width: min(320px, 80vw);
  margin-bottom: 30px;
}

.start-foot {
  font-family: 'Special Elite', monospace;
  font-size: 11px;
  color: #6b5a3e;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.big-btn {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 16px 30px;
  border: none;
  cursor: pointer;
  border-radius: 2px;
  transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s ease;
  position: relative;
  overflow: hidden;
}

.big-btn:active { transform: translateY(2px); }

.big-btn.primary {
  background: linear-gradient(180deg, #c83838 0%, #8b1f1f 100%);
  color: #fff;
  border: 2px solid #f4c25c;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.25),
    0 4px 0 #4a0d0d,
    0 6px 16px rgba(0,0,0,0.5);
  text-shadow: 0 2px 0 rgba(0,0,0,0.4);
}
.big-btn.primary:hover {
  background: linear-gradient(180deg, #d84a4a 0%, #9c2b2b 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.3),
    0 4px 0 #4a0d0d,
    0 8px 24px rgba(200,56,56,0.5);
}

.big-btn.ghost {
  background: rgba(20, 12, 5, 0.6);
  color: #d4a154;
  border: 2px solid #6b5a3e;
  box-shadow: 0 4px 0 #1a0e05;
}
.big-btn.ghost:hover {
  background: rgba(40, 25, 12, 0.8);
  border-color: #d4a154;
  color: #f4e6c1;
}

/* ============================================================
   PANEL (modal box)
   ============================================================ */
.panel {
  background: linear-gradient(180deg, #2a1d10 0%, #1a120a 100%);
  border: 3px solid #6b5a3e;
  border-radius: 4px;
  padding: 32px 30px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  position: relative;
  box-shadow:
    inset 0 0 0 1px rgba(244, 194, 92, 0.25),
    0 12px 40px rgba(0,0,0,0.7);
}

.panel.wide { max-width: 720px; }

.panel::before, .panel::after {
  content: '';
  position: absolute;
  width: 24px; height: 24px;
  border: 2px solid #d4a154;
}
.panel::before {
  top: -3px; left: -3px;
  border-right: none; border-bottom: none;
}
.panel::after {
  bottom: -3px; right: -3px;
  border-left: none; border-top: none;
}

.panel h2 {
  font-family: 'Limelight', serif;
  font-size: clamp(26px, 6vw, 42px);
  color: #f4c25c;
  letter-spacing: 0.05em;
  margin-bottom: 22px;
  text-shadow: 2px 2px 0 #4a0d0d;
}

.panel .big-btn { width: 100%; margin-top: 8px; }

/* ============================================================
   HOW TO PLAY rules
   ============================================================ */
.rules {
  list-style: none;
  text-align: left;
  margin-bottom: 22px;
  font-family: 'Special Elite', monospace;
  color: #d4c098;
  font-size: 14px;
  line-height: 1.7;
}
.rules li {
  padding: 6px 0 6px 24px;
  position: relative;
  border-bottom: 1px dashed #4a3a22;
}
.rules li:last-child { border-bottom: none; }
.rules li::before {
  content: '★';
  position: absolute;
  left: 0; top: 6px;
  color: #c83838;
}
.rules strong { color: #f4c25c; font-weight: 700; }
.rules em { color: #f4e6c1; font-style: normal; background: rgba(200,56,56,0.2); padding: 1px 6px; border-radius: 2px; }

/* ============================================================
   GAME OVER stats
   ============================================================ */
.stats {
  display: flex;
  justify-content: space-around;
  gap: 12px;
  margin: 8px 0 22px;
}
.stat {
  flex: 1;
  padding: 14px 8px;
  background: rgba(0,0,0,0.35);
  border: 1px solid #4a3a22;
  border-radius: 3px;
}
.stat-num {
  font-family: 'Limelight', serif;
  font-size: clamp(28px, 7vw, 40px);
  color: #f4c25c;
  line-height: 1;
}
.stat-lbl {
  font-family: 'Special Elite', monospace;
  font-size: 11px;
  color: #8b7a5a;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 6px;
}

/* ============================================================
   SHOP
   ============================================================ */
.shop-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
  text-align: left;
}
.shop-head h2 { margin-bottom: 0; }
.shop-eyebrow {
  font-family: 'Special Elite', monospace;
  font-size: 12px;
  color: #d4a154;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.shop-money {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Limelight', serif;
  font-size: 22px;
  color: #f4c25c;
  background: rgba(0,0,0,0.4);
  padding: 8px 14px;
  border: 1px solid #6b5a3e;
  border-radius: 3px;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.shop-item {
  background: rgba(20, 12, 5, 0.7);
  border: 2px solid #4a3a22;
  border-radius: 3px;
  padding: 14px 10px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
}
.shop-item:hover:not(.disabled) {
  border-color: #d4a154;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(212, 161, 84, 0.2);
}
.shop-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.shop-item.owned {
  border-color: #6b9b3a;
}
.shop-item.owned::after {
  content: 'OWNED';
  position: absolute;
  top: 4px; right: 4px;
  font-size: 9px;
  background: #6b9b3a;
  color: #fff;
  padding: 2px 6px;
  border-radius: 2px;
  letter-spacing: 0.1em;
}

.shop-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 8px;
  background: rgba(0,0,0,0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #4a3a22;
  background-size: 75%;
  background-repeat: no-repeat;
  background-position: center;
}
.shop-name {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: #f4e6c1;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.shop-desc {
  font-family: 'Special Elite', monospace;
  font-size: 10px;
  color: #8b7a5a;
  margin: 4px 0 8px;
  min-height: 24px;
  line-height: 1.3;
}
.shop-price {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: #f4c25c;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0,0,0,0.4);
  padding: 4px 10px;
  border-radius: 2px;
}

/* ============================================================
   HUD (in-game)
   ============================================================ */
#hud {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

#hud > * { pointer-events: auto; }
#hud > .hud-top, #hud > .hud-bottom { pointer-events: none; }
#hud > .hud-top > *, #hud > .hud-bottom > * { pointer-events: auto; }

.hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 16px;
  gap: 10px;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.portrait {
  width: 56px; height: 56px;
  background: url('assets/ui/head.png') center/cover, #1a0e05;
  border: 2px solid #d4a154;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #1a0e05, 0 3px 8px rgba(0,0,0,0.6);
  flex-shrink: 0;
}

.hp-wrap { min-width: 140px; }
.hp-bar {
  height: 14px;
  background: rgba(0,0,0,0.6);
  border: 2px solid #4a3a22;
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
#hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(180deg, #ff5a5a 0%, #c83838 50%, #8b1f1f 100%);
  transition: width 0.3s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25);
}
.hp-label {
  font-family: 'Special Elite', monospace;
  font-size: 11px;
  color: #c9b889;
  letter-spacing: 0.1em;
  margin-top: 3px;
  text-shadow: 1px 1px 0 #000;
}

.hud-center {
  text-align: center;
  flex: 1;
  max-width: 280px;
}

.wave-pill {
  font-family: 'Limelight', serif;
  font-size: 22px;
  color: #f4c25c;
  letter-spacing: 0.1em;
  text-shadow: 2px 2px 0 #4a0d0d, 0 0 10px rgba(0,0,0,0.8);
  margin-bottom: 4px;
}
.wave-pill span { color: #fff; }

.wave-bar {
  height: 6px;
  background: rgba(0,0,0,0.6);
  border: 1px solid #4a3a22;
  border-radius: 1px;
  overflow: hidden;
}
#wave-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #d4a154, #f4c25c);
  transition: width 0.4s ease;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.money-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.7);
  border: 2px solid #d4a154;
  border-radius: 2px;
  padding: 6px 12px;
  font-family: 'Limelight', serif;
  color: #f4c25c;
  font-size: 18px;
  text-shadow: 1px 1px 0 #000;
}
.coin-icon {
  display: inline-block;
  width: 22px; height: 22px;
  background: url('assets/ui/coin.png') center/contain no-repeat;
}

.icon-btn {
  width: 44px; height: 44px;
  background: rgba(0,0,0,0.7);
  border: 2px solid #d4a154;
  color: #f4c25c;
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s ease;
}
.icon-btn:hover { background: rgba(40,25,12,0.9); }
.icon-btn:active { transform: translateY(1px); }

/* ===== BOTTOM HUD ===== */
.hud-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 16px 20px env(safe-area-inset-bottom, 16px) 20px;
  gap: 16px;
}

.ammo-display {
  background: rgba(0,0,0,0.7);
  border: 2px solid #4a3a22;
  border-radius: 3px;
  padding: 8px 14px;
  min-width: 200px;
}
.gun-name {
  font-family: 'Limelight', serif;
  font-size: 14px;
  color: #f4c25c;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}
.ammo-row { display: flex; align-items: center; gap: 8px; }
.ammo-bar {
  flex: 1;
  height: 8px;
  background: rgba(0,0,0,0.6);
  border: 1px solid #4a3a22;
  border-radius: 1px;
  overflow: hidden;
}
#ammo-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #d4a154, #f4c25c);
  transition: width 0.15s ease;
}
.ammo-text {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: #f4e6c1;
  min-width: 50px;
  text-align: right;
}

.action-btns {
  display: flex;
  gap: 12px;
}

.action-btn {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.15em;
  padding: 14px 20px;
  border: 2px solid;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.12s ease;
  min-width: 90px;
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
}
.action-btn:active { transform: translateY(2px); }

.action-btn.shoot {
  background: linear-gradient(180deg, #c83838 0%, #8b1f1f 100%);
  border-color: #f4c25c;
  color: #fff;
  box-shadow: 0 3px 0 #4a0d0d;
}
.action-btn.shoot:hover { background: linear-gradient(180deg, #d84a4a 0%, #9c2b2b 100%); }

.action-btn.reload {
  background: linear-gradient(180deg, #4a3a22 0%, #2a1d10 100%);
  border-color: #d4a154;
  color: #f4c25c;
  box-shadow: 0 3px 0 #1a0e05;
}
.action-btn.reload:hover { background: linear-gradient(180deg, #5a4a32 0%, #3a2d20 100%); }
.action-btn.reload.active {
  background: linear-gradient(180deg, #f4c25c 0%, #d4a154 100%);
  color: #1a0e05;
  animation: pulse 0.7s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 3px 0 #1a0e05; }
  50%      { box-shadow: 0 3px 0 #1a0e05, 0 0 18px rgba(244,194,92,0.7); }
}

/* ===== CROSSHAIR ===== */
#crosshair {
  position: absolute;
  width: 32px; height: 32px;
  pointer-events: none;
  transform: translate(-50%, -50%);
  display: none;
  z-index: 60;
}
#crosshair::before, #crosshair::after {
  content: '';
  position: absolute;
  background: #c83838;
  box-shadow: 0 0 4px rgba(0,0,0,0.8);
}
#crosshair::before {
  left: 50%; top: 0; bottom: 0;
  width: 2px; transform: translateX(-50%);
}
#crosshair::after {
  top: 50%; left: 0; right: 0;
  height: 2px; transform: translateY(-50%);
}

/* ===== LOADING ===== */
.loader { text-align: center; }
.loader-title {
  font-family: 'Limelight', serif;
  font-size: 32px;
  color: #f4c25c;
  letter-spacing: 0.4em;
  margin-bottom: 22px;
  text-shadow: 2px 2px 0 #4a0d0d;
  animation: blink 1s infinite;
}
@keyframes blink { 0%, 70% { opacity: 1; } 71%, 100% { opacity: 0.4; } }

.loader-bar {
  width: 280px;
  height: 14px;
  background: rgba(0,0,0,0.6);
  border: 2px solid #6b5a3e;
  border-radius: 2px;
  overflow: hidden;
  margin: 0 auto;
}
#loader-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #c83838, #f4c25c);
  transition: width 0.2s ease;
}
.loader-pct {
  font-family: 'Special Elite', monospace;
  margin-top: 12px;
  color: #c9b889;
  font-size: 13px;
  letter-spacing: 0.2em;
}

/* ============================================================
   ROTATE DEVICE OVERLAY (portrait mobile only)
   ============================================================ */
#rotate-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(180deg, #1a0e05 0%, #0a0502 100%);
  align-items: center;
  justify-content: center;
  padding: 30px;
  text-align: center;
}

@media (max-width: 900px) and (orientation: portrait) {
  #rotate-screen { display: flex; }
}

.rotate-inner {
  max-width: 320px;
  animation: rotateBob 2s ease-in-out infinite;
}
@keyframes rotateBob {
  0%, 100% { transform: rotate(-3deg); }
  50%      { transform: rotate(3deg); }
}
.rotate-icon {
  color: #d4a154;
  width: 110px;
  height: 110px;
  margin: 0 auto 24px;
}
.rotate-icon svg { width: 100%; height: 100%; }
.rotate-title {
  font-family: 'Limelight', serif;
  font-size: 24px;
  color: #f4c25c;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
  text-shadow: 2px 2px 0 #4a0d0d;
}
.rotate-sub {
  font-family: 'Special Elite', monospace;
  color: #c9b889;
  font-size: 14px;
  line-height: 1.5;
}

/* ============================================================
   MOBILE RESPONSIVENESS
   ============================================================ */
@media (max-width: 720px) {
  .hud-top { padding: 8px 10px; gap: 6px; }
  .portrait { width: 44px; height: 44px; }
  .hp-wrap { min-width: 100px; }
  .hp-label { font-size: 9px; }
  .wave-pill { font-size: 16px; }
  .money-pill { font-size: 14px; padding: 4px 8px; }
  .coin-icon { width: 18px; height: 18px; }
  .icon-btn { width: 38px; height: 38px; font-size: 14px; }

  .hud-bottom { padding: 10px 12px env(safe-area-inset-bottom, 10px) 12px; gap: 8px; }
  .ammo-display { min-width: 130px; padding: 6px 10px; }
  .gun-name { font-size: 11px; }
  .ammo-text { font-size: 12px; min-width: 40px; }
  .action-btn { padding: 12px 14px; font-size: 12px; min-width: 70px; }

  .panel { padding: 22px 18px; }
  .shop-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
  .shop-icon { width: 50px; height: 50px; }
}

@media (max-width: 480px) and (orientation: portrait) {
  .hp-label { display: none; }
}

/* On really tall portrait phones, the cars/sprites can look small.
   Canvas is internally 1280x800 and we letterbox to fit. */

/* On desktop hide the on-screen FIRE/RELOAD if user prefers — actually
   keep them visible as fallback, they don't get in the way */
@media (min-width: 1024px) and (hover: hover) {
  /* Show the crosshair on desktop */
}
