/* css/style.css - Methland - The Game Style & Retro Theme */
@import url('https://fonts.googleapis.com/css2?family=Anton&family=DM+Mono:wght@400;500&display=swap');

:root {
  --bg-main: #0c0906;
  --bg-panel: #17130e;
  --bg-card: #221c15;
  --border-main: #3a2e20;
  --border-gold: #f5b030;
  --pils-gold: #f5b030;
  --pils-amber: #d4920a;
  --pils-glow: rgba(245, 176, 48, 0.35);
  --neon-cyan: #00e5ff;
  --crt-green: #33ff66;
  --alert-red: #ff3b30;
  --text-main: #f5eedc;
  --text-dim: #9c8e7c;
  --font-title: 'Anton', impact, sans-serif;
  --font-mono: 'DM Mono', monospace;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.4;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* CRT Scanline Overlay */
.crt::after {
  content: " ";
  display: block;
  position: fixed;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.04), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.04));
  z-index: 999;
  background-size: 100% 3px, 6px 100%;
  pointer-events: none;
  opacity: 0.8;
}

/* Header */
header {
  background: #140f0a;
  border-bottom: 2px solid var(--border-gold);
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-title {
  font-family: var(--font-title);
  font-size: 1.8rem;
  letter-spacing: 0.08em;
  color: var(--pils-gold);
  text-shadow: 0 0 10px var(--pils-glow);
}

.logo-subtitle {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.top-controls {
  display: flex;
  gap: 0.5rem;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  color: var(--text-main);
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  transition: all 0.2s;
}

.btn-icon:hover {
  border-color: var(--pils-gold);
  color: var(--pils-gold);
}

/* App Main Container */
main {
  flex: 1;
  max-width: 1260px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* Status Bar */
.status-bar {
  background: var(--bg-panel);
  border: 1px solid var(--border-main);
  border-radius: 6px;
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  align-items: center;
  justify-content: space-between;
  box-shadow: inset 0 0 15px rgba(0,0,0,0.5);
}

.status-player-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.player-avatar {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: var(--pils-amber);
  color: #0c0906;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title);
  font-size: 1.4rem;
  font-weight: bold;
}

.player-names h3 {
  font-family: var(--font-title);
  font-size: 1.2rem;
  color: var(--pils-gold);
  letter-spacing: 0.05em;
}

.player-rank {
  color: var(--crt-green);
  font-size: 0.8rem;
}

.status-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
}

.stat-box {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-val {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-main);
}

.stat-cash { color: var(--crt-green); }
.stat-ap { color: var(--neon-cyan); }

.end-turn-btn {
  background: var(--pils-gold);
  color: #0c0906;
  font-family: var(--font-title);
  font-size: 1.05rem;
  letter-spacing: 0.05em;
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.1s, filter 0.2s;
}

.end-turn-btn:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

/* Mission Ticker (First 60 Seconds Onboarding) */
.mission-ticker {
  background: linear-gradient(90deg, #26190b 0%, #15110c 100%);
  border: 1px solid var(--border-gold);
  border-left: 5px solid var(--pils-gold);
  border-radius: 4px;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 0 15px rgba(245, 176, 48, 0.15);
}

.mission-badge {
  font-family: var(--font-title);
  font-size: 0.9rem;
  color: var(--pils-gold);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.mission-text {
  font-size: 0.85rem;
  color: var(--text-main);
}

/* Grid & Layout */
.game-grid {
  display: grid;
  grid-template-columns: 820px 1fr;
  gap: 1rem;
  flex: 1;
}

@media (max-width: 1200px) {
  .game-grid {
    grid-template-columns: 1fr;
  }
}

/* Map View Container */
.map-view-container {
  background: var(--bg-panel);
  border: 1px solid var(--border-main);
  border-radius: 6px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.6);
}

.map-hud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-main);
}

.hud-steps {
  background: rgba(0, 229, 255, 0.12);
  color: var(--neon-cyan);
  border: 1px solid rgba(0, 229, 255, 0.35);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: bold;
}

.canvas-wrapper {
  position: relative;
  background: #000;
  border: 2px solid var(--border-main);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 20px rgba(0,0,0,0.8);
  display: flex;
  justify-content: center;
}

#city-canvas {
  width: 100%;
  max-width: 800px;
  height: auto;
  aspect-ratio: 800 / 500;
  display: block;
  image-rendering: pixelated;
  cursor: crosshair;
}

/* Map Footer & Controls */
.map-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  padding-top: 0.4rem;
}

.d-pad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 150px;
}

.d-mid {
  display: flex;
  gap: 4px;
}

.d-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  color: var(--pils-gold);
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  border-radius: 6px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s, transform 0.1s;
}

.d-btn:hover, .d-btn:active {
  background: var(--pils-amber);
  color: #0c0906;
  border-color: var(--pils-gold);
}

.d-btn:active {
  transform: scale(0.92);
}

.map-legend {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.8rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: bold;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  min-width: 18px;
  text-align: center;
}

/* Side Panel */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel-box {
  background: var(--bg-panel);
  border: 1px solid var(--border-main);
  border-radius: 6px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.panel-title {
  font-family: var(--font-title);
  font-size: 1.05rem;
  letter-spacing: 0.05em;
  color: var(--pils-gold);
  border-bottom: 1px solid var(--border-main);
  padding-bottom: 0.35rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.quick-locations-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  max-height: 220px;
  overflow-y: auto;
}

.quick-loc-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  color: var(--text-main);
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: all 0.15s;
}

.quick-loc-btn:hover {
  border-color: var(--pils-gold);
  background: #2b2319;
  transform: translateX(2px);
}

.log-stream {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-right: 0.25rem;
}

.log-entry {
  font-size: 0.75rem;
  padding: 0.3rem 0.45rem;
  border-left: 3px solid var(--border-main);
  background: rgba(0,0,0,0.25);
  border-radius: 0 4px 4px 0;
}

.log-entry.success { border-left-color: var(--crt-green); }
.log-entry.warning { border-left-color: var(--alert-red); color: #ff9999; }
.log-entry.highlight { border-left-color: var(--pils-gold); font-weight: bold; }
.log-entry.system { border-left-color: var(--neon-cyan); }

.log-time {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-right: 0.3rem;
}

/* Market Table (Drug Wars) */
.market-table-container {
  overflow-x: auto;
}

.market-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
}

.market-table th {
  text-align: left;
  padding: 0.65rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-main);
}

.market-table td {
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.market-btn {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: bold;
  padding: 0.45rem 0.85rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.btn-buy {
  background: rgba(245, 176, 48, 0.15);
  color: var(--pils-gold);
  border-color: rgba(245, 176, 48, 0.4);
}
.btn-buy:hover:not(:disabled) { background: var(--pils-gold); color: #0c0906; }

.btn-sell {
  background: rgba(51, 255, 102, 0.15);
  color: var(--crt-green);
  border-color: rgba(51, 255, 102, 0.4);
}
.btn-sell:hover:not(:disabled) { background: var(--crt-green); color: #0c0906; }

.market-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Tactical Gang Battle Arena */
.battle-arena {
  display: grid;
  grid-template-columns: 1fr 60px 1fr;
  gap: 1rem;
  background: #110d09;
  border: 2px solid var(--border-main);
  border-radius: 6px;
  padding: 1rem;
  margin: 1rem 0;
}

.squad-column {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.squad-header {
  font-family: var(--font-title);
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-main);
  padding-bottom: 0.3rem;
}

.squad-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 200px;
  overflow-y: auto;
}

.fighter-card {
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
}

.fighter-card.ko {
  opacity: 0.35;
  filter: grayscale(1);
  text-decoration: line-through;
}

.fighter-hp {
  color: var(--crt-green);
  font-weight: bold;
}

.battle-log {
  background: #090705;
  border: 1px solid var(--border-main);
  border-radius: 4px;
  padding: 0.6rem;
  height: 100px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.75rem;
}

/* Modal Windows */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
}

.modal-backdrop.hidden {
  display: none;
}

.modal-window {
  background: #19140e;
  border: 2px solid var(--pils-gold);
  border-radius: 8px;
  max-width: 650px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8), 0 0 20px var(--pils-glow);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--pils-gold);
}

.modal-title {
  font-family: var(--font-title);
  font-size: 1.8rem;
  color: var(--pils-gold);
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
  border-left: 2px solid var(--border-gold);
  padding-left: 0.75rem;
}

.actions-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.action-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: 6px;
  padding: 0.75rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.action-btn:hover:not(:disabled) {
  border-color: var(--pils-gold);
  background: #2c2317;
  transform: translateX(3px);
}

.action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.8);
}

.action-left {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.action-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
}

.action-desc {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.action-cost {
  background: rgba(0, 229, 255, 0.1);
  color: var(--neon-cyan);
  border: 1px solid rgba(0, 229, 255, 0.3);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
  white-space: nowrap;
}

.casino-card {
  width: 55px;
  height: 78px;
  background: #fff;
  border-radius: 5px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px 6px;
  font-weight: bold;
  font-family: var(--font-title);
  font-size: 1rem;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.casino-card.red { color: #d63031; }
.casino-card.black { color: #111; }

.casino-card.hidden-card {
  background: repeating-linear-gradient(45deg, #1e3799, #1e3799 6px, #0c2461 6px, #0c2461 12px);
  color: #fff;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

/* Safe-Cracker */
.safe-box {
  background: #0d0a07;
  border: 2px solid var(--border-main);
  border-radius: 6px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}

.safe-dial-display {
  display: flex;
  gap: 1.5rem;
}

.dial-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.dial-circle {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 3px solid var(--border-main);
  background: radial-gradient(circle, #2a2217 0%, #120e0a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title);
  font-size: 2rem;
  color: var(--pils-gold);
  box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
}

.dial-slot.active .dial-circle {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
}

.dial-slot.solved .dial-circle {
  border-color: var(--crt-green);
  color: var(--crt-green);
  box-shadow: 0 0 15px rgba(51, 255, 102, 0.4);
}

.safe-controls {
  display: flex;
  gap: 0.75rem;
}

/* Setup Screen */
.setup-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 750px;
  margin: 1.5rem auto;
  background: var(--bg-panel);
  border: 2px solid var(--pils-gold);
  border-radius: 8px;
  padding: 1.8rem;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8), 0 0 25px var(--pils-glow);
}

.setup-title {
  font-family: var(--font-title);
  font-size: 2.2rem;
  color: var(--pils-gold);
  text-align: center;
  letter-spacing: 0.05em;
}

.char-selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.char-card {
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: 6px;
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.char-card.selected {
  border-color: var(--pils-gold);
  background: #31261a;
  box-shadow: 0 0 12px var(--pils-glow);
}

.char-card-name {
  font-family: var(--font-title);
  font-size: 1.15rem;
  color: var(--pils-gold);
}

.char-card-title {
  font-size: 0.75rem;
  color: var(--neon-cyan);
}

.char-card-catch {
  font-size: 0.75rem;
  font-style: italic;
  color: var(--text-dim);
}

.start-btn {
  background: var(--pils-gold);
  color: #0c0906;
  font-family: var(--font-title);
  font-size: 1.3rem;
  padding: 0.75rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: filter 0.2s, transform 0.1s;
}

.start-btn:hover {
  filter: brightness(1.2);
  transform: translateY(-2px);
}

/* ── Mobile Responsive Optimizations (< 768px & < 480px) ─────────────────── */
@media (max-width: 768px) {
  body {
    font-size: 13px;
    padding-bottom: 70px; /* Safe space for #pfb-dock */
  }

  header {
    padding: 0.5rem 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .logo-title {
    font-size: 1.4rem;
  }

  .logo-subtitle {
    font-size: 0.65rem;
  }

  .top-controls {
    width: 100%;
    justify-content: flex-end;
  }

  .top-controls .btn-icon {
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
  }

  main {
    padding: 0.5rem;
    gap: 0.6rem;
  }

  .status-bar {
    padding: 0.6rem 0.8rem;
    gap: 0.8rem;
  }

  .status-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    width: 100%;
  }

  .stat-val {
    font-size: 0.9rem;
  }

  .end-turn-btn {
    width: 100%;
    text-align: center;
    padding: 0.7rem;
    font-size: 1.1rem;
    min-height: 48px;
    touch-action: manipulation;
  }

  .mission-ticker {
    padding: 0.5rem 0.75rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .map-view-container {
    padding: 0.5rem;
  }

  .map-footer {
    flex-direction: column;
    align-items: center;
    gap: 1rem;
  }

  .d-pad {
    width: 160px;
    margin: 0.25rem auto;
  }

  .map-legend {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
    width: 100%;
  }

  .quick-locations-list {
    grid-template-columns: 1fr 1fr;
    max-height: 280px;
  }

  .quick-loc-btn {
    padding: 0.5rem;
    font-size: 0.8rem;
    min-height: 44px;
    touch-action: manipulation;
  }

  .char-selection-grid {
    grid-template-columns: 1fr;
  }

  .char-card {
    min-height: 48px;
    padding: 0.85rem;
  }

  .modal-window {
    width: 95%;
    max-width: 95%;
    padding: 1.1rem 0.9rem;
    max-height: 85vh;
  }

  .action-btn {
    padding: 0.75rem;
    min-height: 48px;
    touch-action: manipulation;
  }
}

@media (max-width: 480px) {
  .status-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .quick-locations-list {
    grid-template-columns: 1fr;
  }
}

