@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=VT323&family=Rajdhani:wght@400;600;700&display=swap');

/* ═══════════════════════════════════════════
   RESET + VARS
═══════════════════════════════════════════ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg:     #0a0a0a;
  --accent: #f5c518;
  --red:    #e63946;
  --green:  #2dc653;
  --blue:   #4cc9f0;
  --text:   #f0ead6;
  --dim:    #666;
  --panel:  #111118;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Rajdhani', sans-serif;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ═══════════════════════════════════════════
   TOP HUD
═══════════════════════════════════════════ */
#hud {
  background: var(--panel);
  border-bottom: 2px solid var(--accent);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 24px;
  font-family: 'VT323', monospace;
  font-size: 18px;
  flex-shrink: 0;
}
#hud .title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  color: var(--accent);
  letter-spacing: 3px;
}
.hud-stat { display: flex; gap: 6px; align-items: center; }
.hud-stat .label { color: var(--dim); font-size: 14px; }
.hud-stat .val { color: var(--accent); }
#wanted-stars { color: var(--red); letter-spacing: 2px; }
.hud-lb-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--blue);
  color: var(--blue);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 15px;
  letter-spacing: 2px;
  padding: 3px 12px;
  cursor: pointer;
}
.hud-lb-btn:hover { background: var(--blue); color: #000; }

/* ═══════════════════════════════════════════
   EVENT TICKER
═══════════════════════════════════════════ */
#ticker-wrap {
  background: #0d0d14;
  border-bottom: 2px solid #1a1a2a;
  overflow: hidden;
  height: 32px;
  flex-shrink: 0;
  position: relative;
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 1px;
}
#ticker-live {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: #e63946;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 14px;
  letter-spacing: 3px;
  color: #fff;
  white-space: nowrap;
}
#ticker-live::after {
  content: '';
  position: absolute;
  right: -10px; top: 0; bottom: 0;
  width: 10px;
  background: linear-gradient(to right, #e63946, transparent);
}
#ticker-fade-left {
  position: absolute;
  left: 62px; top: 0; bottom: 0;
  width: 20px;
  z-index: 1;
  background: linear-gradient(to right, #0d0d14, transparent);
  pointer-events: none;
}
#ticker-track {
  display: flex;
  align-items: center;
  white-space: nowrap;
  height: 100%;
  padding-left: 80px;
  animation: tickerScroll 28s linear infinite;
}
#ticker-track.paused { animation-play-state: paused; }
@keyframes tickerScroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.ticker-item {
  display: inline-flex;
  align-items: center;
  margin-right: 48px;
  color: #e0d5b0;
  font-size: 16px;
  letter-spacing: 1px;
}
.ticker-item.event-hot     { color: #ff8c42; }
.ticker-item.event-cold    { color: #999; }
.ticker-item.event-neutral { color: #e0d5b0; }
.ticker-sep { color: #444; margin-right: 48px; font-size: 14px; }

/* ═══════════════════════════════════════════
   MAIN LAYOUT
═══════════════════════════════════════════ */
#main { display: flex; flex: 1; overflow: hidden; }

#map-wrap { position: relative; flex: 1; overflow: hidden; background: #0f0f12; }
#map { position: absolute; cursor: pointer; }

#loc-label {
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 18px;
  letter-spacing: 4px;
  color: var(--accent);
  text-shadow: 0 0 20px #f5c51888;
  pointer-events: none;
}

#chase-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 4px;
  background: var(--red);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s;
}

/* ═══════════════════════════════════════════
   CHASE POPUP
═══════════════════════════════════════════ */
#chase-popup {
  display: none;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10,10,15,0.97);
  border: 2px solid var(--red);
  padding: 24px 32px;
  text-align: center;
  z-index: 50;
  min-width: 280px;
}
.chase-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 28px;
  color: var(--red);
  letter-spacing: 4px;
  margin-bottom: 4px;
}
.chase-sub {
  font-size: 13px;
  color: var(--dim);
  margin-bottom: 20px;
  font-family: 'VT323', monospace;
}
.chase-btns { display: flex; gap: 12px; justify-content: center; }
.chase-btn {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 18px;
  letter-spacing: 2px;
  padding: 10px 20px;
  background: transparent;
  cursor: pointer;
}
.chase-btn.accent { border: 2px solid var(--accent); color: var(--accent); }
.chase-btn.red    { border: 2px solid var(--red);    color: var(--red);    }
#chase-fight-note {
  font-size: 11px;
  color: var(--dim);
  margin-top: 10px;
  font-family: 'VT323', monospace;
}

/* ═══════════════════════════════════════════
   COMBAT HUD
═══════════════════════════════════════════ */
#combat-hud {
  position: absolute;
  top: 10px; right: 10px;
  font-family: 'VT323', monospace;
  font-size: 16px;
  color: var(--red);
  display: none;
  pointer-events: none;
  text-align: right;
  line-height: 1.6;
}
#player-hp-bar-wrap {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: none;
  pointer-events: none;
  z-index: 50;
  padding: 6px 16px 8px;
  background: rgba(10,10,15,0.82);
  backdrop-filter: blur(4px);
}
#combat-stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 16px;
  letter-spacing: 2px;
  margin-bottom: 5px;
}
#hp-label { color: var(--text); }
#hp-text  { color: var(--green); font-size: 20px; }
#hp-max-text { color: #666; font-size: 14px; }
#combat-armor-pips { font-size: 15px; letter-spacing: 1px; }
#player-hp-bar-bg {
  background: #1a1a1a;
  height: 10px;
  width: 100%;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid #333;
}
#player-hp-bar {
  background: var(--green);
  height: 100%;
  border-radius: 5px;
  transition: width 0.12s, background 0.2s;
}
#crosshair { position: fixed; pointer-events: none; display: none; transform: translate(-50%, -50%); z-index: 99; }

/* ═══════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════ */
#sidebar {
  width: 260px;
  background: var(--panel);
  border-left: 2px solid #222;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: #333 #111;
}
#sidebar::-webkit-scrollbar       { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: #111; }
#sidebar::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.sb-section { border-bottom: 1px solid #222; padding: 10px 12px; flex-shrink: 0; }
.sb-title {
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 2px;
  font-size: 17px;
  color: var(--accent);
  margin-bottom: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
.sb-title:hover { color: #fff; }
.sb-toggle { font-size: 13px; color: var(--dim); }

#market-list { font-size: 14px; width: 100%; }
#market-list tr:hover td { background: #1a1a25; }
#market-list td { padding: 3px 4px; }

#inv-list { font-size: 14px; color: #bbb; line-height: 1.8; }
#inv-list span { color: var(--text); }

.act-btn {
  display: block;
  width: 100%;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: 'VT323', monospace;
  font-size: 21px;
  padding: 7px 10px;
  cursor: pointer;
  text-align: left;
  transition: all 0.1s;
  margin-bottom: 5px;
  letter-spacing: 1px;
}
.act-btn:hover        { background: var(--accent); color: #000; }
.act-btn.red          { border-color: var(--red); color: var(--red); }
.act-btn.red:hover    { background: var(--red); color: #fff; }
.act-btn:disabled     { border-color: #333; color: #333; cursor: not-allowed; }

.combat-note { font-size: 13px; color: var(--dim); margin-bottom: 6px; }

#log {
  min-height: 120px;
  max-height: 220px;
  overflow-y: auto;
  padding: 8px 10px;
  font-family: 'VT323', monospace;
  font-size: 17px;
  line-height: 1.6;
  flex-shrink: 0;
}
#log div  { margin-bottom: 3px; border-left: 2px solid #333; padding-left: 6px; }
#log .good { border-color: var(--green); color: var(--green); }
#log .bad  { border-color: var(--red);   color: var(--red);   }
#log .warn { border-color: var(--accent);color: var(--accent);}
#log .info { border-color: var(--blue);  color: var(--blue);  }

/* ═══════════════════════════════════════════
   TRADE MODAL
═══════════════════════════════════════════ */
#modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
#modal-box {
  background: var(--panel);
  border: 2px solid var(--accent);
  padding: 24px;
  min-width: 280px;
  max-width: 380px;
}
#modal-box h2 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 24px;
  color: var(--accent);
  letter-spacing: 3px;
  margin-bottom: 12px;
}
#modal-box p { font-size: 14px; color: var(--dim); margin-bottom: 16px; line-height: 1.6; }
.modal-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.modal-row input {
  flex: 1;
  background: #0a0a12;
  border: 1px solid #333;
  color: var(--text);
  font-family: 'VT323', monospace;
  font-size: 20px;
  padding: 4px 8px;
  outline: none;
}
.modal-row input:focus { border-color: var(--accent); }
.modal-btns { display: flex; gap: 8px; }
.modal-btns button {
  flex: 1;
  padding: 8px;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 16px;
  letter-spacing: 2px;
  cursor: pointer;
  border: none;
}
#modal-confirm { background: var(--accent); color: #000; }
#modal-cancel  { background: #333; color: var(--text); }

/* ═══════════════════════════════════════════
   SHOP MODAL
═══════════════════════════════════════════ */
#shop-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.shop-inner {
  background: var(--panel);
  border: 2px solid var(--red);
  padding: 24px;
  min-width: 320px;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
}
.shop-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  color: var(--red);
  letter-spacing: 3px;
  margin-bottom: 4px;
}
.shop-cash-line { font-size: 13px; color: var(--dim); margin-bottom: 14px; }
.shop-cash-line span { color: var(--accent); }
.shop-close-btn {
  margin-top: 14px;
  width: 100%;
  padding: 8px;
  background: #222;
  border: 1px solid #444;
  color: var(--text);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 15px;
  letter-spacing: 2px;
  cursor: pointer;
}
.shop-close-btn:hover { background: #333; }

/* ═══════════════════════════════════════════
   GAME OVER
═══════════════════════════════════════════ */
#gameover {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  z-index: 200;
}
#gameover h1 { font-family: 'Bebas Neue', sans-serif; font-size: 60px; letter-spacing: 8px; color: var(--red); }
#gameover .sub   { font-size: 18px; color: var(--dim); }
#gameover .score { font-family: 'VT323', monospace; font-size: 28px; color: var(--accent); text-align: center; line-height: 1.5; }
.go-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 4px; }
.go-name-input {
  background: #0a0a12;
  border: 2px solid var(--accent);
  color: var(--accent);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 3px;
  padding: 8px 16px;
  text-align: center;
  outline: none;
  width: 260px;
}
.go-name-input::placeholder { color: #444; }
.go-btns { display: flex; gap: 10px; }
.go-btn-primary {
  background: var(--accent); color: #000; border: none;
  font-family: 'Bebas Neue', sans-serif; font-size: 20px;
  letter-spacing: 3px; padding: 10px 24px; cursor: pointer;
}
.go-btn-primary:hover { background: #ffdd44; }
.go-btn-secondary {
  background: transparent; color: var(--dim); border: 1px solid #444;
  font-family: 'Bebas Neue', sans-serif; font-size: 20px;
  letter-spacing: 3px; padding: 10px 24px; cursor: pointer;
}
.go-btn-secondary:hover { border-color: #888; color: #aaa; }
.go-btn-lb {
  background: transparent; color: var(--blue); border: 1px solid var(--blue);
  font-family: 'Bebas Neue', sans-serif; font-size: 17px;
  letter-spacing: 2px; padding: 7px 20px; cursor: pointer;
}
.go-btn-lb:hover { background: var(--blue); color: #000; }

/* ═══════════════════════════════════════════
   LEADERBOARD
═══════════════════════════════════════════ */
#lb-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.93);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.lb-inner {
  background: #0f1018;
  border: 2px solid var(--accent);
  width: min(680px, 96vw);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
}
.lb-header {
  padding: 16px 24px;
  border-bottom: 1px solid #222;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.lb-title { font-family: 'Bebas Neue', sans-serif; font-size: 24px; color: var(--accent); letter-spacing: 4px; }
.lb-close { background: transparent; border: none; color: var(--dim); font-size: 22px; cursor: pointer; line-height: 1; }
.lb-close:hover { color: #fff; }
#lb-body {
  overflow-y: auto;
  flex: 1;
  font-family: 'VT323', monospace;
  font-size: 16px;
  scrollbar-width: thin;
  scrollbar-color: #333 #0f1018;
}

/* ═══════════════════════════════════════════
   MOBILE — portrait phones (<= 768px)
═══════════════════════════════════════════ */
@media (max-width: 768px) {

  /* HUD: two compact rows */
  #hud {
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 6px 10px;
    font-size: 15px;
  }
  #hud .title {
    font-size: 18px;
    width: 100%;
    margin-bottom: 2px;
  }
  .hud-stat .label { font-size: 11px; }
  .hud-lb-btn {
    margin-left: 0;
    padding: 2px 10px;
    font-size: 13px;
  }

  /* Stack map on top, sidebar below */
  #main {
    flex-direction: column;
  }

  #map-wrap {
    flex: none;
    height: 52vw;   /* ~half the viewport height on phones */
    min-height: 220px;
    width: 100%;
  }

  #sidebar {
    width: 100%;
    max-height: 45vh;
    border-left: none;
    border-top: 2px solid #222;
    flex-shrink: 0;
  }

  /* Bigger tap targets for district circles on canvas */
  /* (handled in JS — hitRadius bumped on touch devices) */

  /* Action buttons: 2-column grid on mobile */
  #actions-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
  }
  .act-btn { margin-bottom: 0; font-size: 17px; padding: 9px 6px; }

  /* Combat section: same grid */
  #combat-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
  }
  .combat-note { grid-column: 1 / -1; }

  /* Modal fits screen */
  #modal-box {
    width: 92vw;
    max-width: 92vw;
    padding: 18px;
  }
  .shop-inner {
    width: 92vw;
    max-width: 92vw;
    padding: 16px;
  }

  /* Leaderboard */
  .lb-inner { width: 98vw; max-height: 88vh; }

  /* Game over */
  #gameover h1 { font-size: 44px; }
  .go-name-input { width: 90vw; font-size: 18px; }

  /* Virtual D-pad (shown only during combat on touch) */
  #dpad {
    display: flex;
  }

  /* Chase popup */
  #chase-popup { width: 88vw; padding: 18px 16px; }
}

/* ═══════════════════════════════════════════
   THUMBSTICKS (created dynamically by JS)
═══════════════════════════════════════════ */
.thumbstick {
  display: none;            /* JS shows during combat */
  position: fixed;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(245,197,24,0.3);
  z-index: 100;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  align-items: center;
  justify-content: center;
}
#stick-left  { bottom: 88px; left: 24px; }
#stick-right { bottom: 88px; right: 24px; }

.thumbstick-knob {
  position: absolute;
  top: 50%; left: 50%;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(245,197,24,0.35);
  border: 2px solid rgba(245,197,24,0.7);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: background 0.1s;
}
#stick-right .thumbstick-knob {
  background: rgba(230,57,70,0.35);
  border-color: rgba(230,57,70,0.7);
}


/* ── Combat fullscreen: stick positions ── */
/* When combat is active the map is fixed/fullscreen,
   so push sticks up a bit from the very bottom edge */
body.in-combat #stick-left  { bottom: 88px; left: 24px; }
body.in-combat #stick-right { bottom: 88px; right: 24px; }

/* Combat mode indicator strip at top */
#combat-mode-bar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  background: rgba(230,57,70,0.85);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 15px;
  letter-spacing: 3px;
  color: #fff;
  text-align: center;
  padding: 4px 0;
  pointer-events: none;
}
