/* ==========================================================================
   ASSASSIN'S HUNT: WILD WEST — MASTER STYLESHEET
   Responsive, High-DPI, Wild West Theme
   ========================================================================== */

:root {
  --bg-color: #120e0a;
  --sand-color: #d8a25e;
  --wood-dark: #2c1a0e;
  --wood-mid: #4a2e18;
  --wood-light: #7c4f2c;
  --gold-accent: #f5b041;
  --gold-light: #fbe09e;
  --crimson-alert: #e74c3c;
  --stealth-green: #2ecc71;
  --text-primary: #fff8f0;
  --text-muted: #c4b5a5;
  --hud-bg: rgba(20, 14, 10, 0.85);
  --modal-bg: rgba(26, 17, 12, 0.96);
  --font-title: 'Cinzel', 'Georgia', serif, 'Times New Roman';
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-main: 0 8px 32px rgba(0, 0, 0, 0.65);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-color);
  font-family: var(--font-body);
  color: var(--text-primary);
  touch-action: none;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #17100b; /* Dark leather textured border */
  overflow: hidden;
}

#viewport-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 520px;
  max-height: 760px;
  aspect-ratio: 480 / 700;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.95);
  overflow: hidden;
  background: #1a120b;
}

/* Canvas Viewport */
#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* ==========================================================================
   HEADS-UP DISPLAY (HUD)
   Non-intrusive, High-Contrast, Top Anchored
   ========================================================================== */
#hud-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 50;
}

/* 1. Target Reticle Counter (Top-Left) - Exact Match to Screenshot */
.hud-target-counter {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  padding: 0;
}

.hud-reticle-icon {
  display: block;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.95));
}

.hud-target-text {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Arial Black', sans-serif;
  font-size: 28px;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.95), 0 0 3px #000000;
  line-height: 1;
}

/* 2. Wooden Settings Gear Button (Top-Right) */
.hud-gear-btn {
  pointer-events: auto;
  width: 50px;
  height: 50px;
  background: linear-gradient(180deg, #b87b46 0%, #875125 100%);
  border: 2px solid #522f12;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -2px 0 rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hud-gear-btn:hover {
  background: linear-gradient(180deg, #cb925d 0%, #9e6435 100%);
  transform: scale(1.05);
}

.hud-gear-btn:active {
  transform: scale(0.95);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.8), inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.hud-gear-btn svg {
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

/* ==========================================================================
   TOUCH CONTROLS / VIRTUAL JOYSTICK
   ========================================================================== */
#virtual-stick-container {
  position: absolute;
  bottom: 30px;
  left: 30px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
  border: 2px dashed rgba(245, 176, 65, 0.3);
  pointer-events: none;
  display: none;
  z-index: 40;
}

#virtual-stick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  margin-top: -23px;
  margin-left: -23px;
  border-radius: 50%;
  background: radial-gradient(circle, #f5b041 0%, #b8791c 100%);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   MODAL DIALOGS & OVERLAYS (MENU, VICTORY, DEFEAT, SHOP)
   ========================================================================== */
.screen-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 7, 5, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-in-out;
}

.screen-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.card-panel {
  background: var(--modal-bg);
  border: 2px solid var(--wood-light);
  box-shadow: 0 0 0 1px #110b07, var(--shadow-main);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  text-align: center;
  max-width: 480px;
  width: 90%;
  position: relative;
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.card-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #996515, #f5b041, #996515);
}

.game-title {
  font-family: var(--font-title);
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--gold-accent);
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.8);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.game-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-bottom: 24px;
}

.western-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 14px 0 20px 0;
}

.western-divider::before,
.western-divider::after {
  content: '';
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, rgba(245, 176, 65, 0.4), transparent);
}

.western-star {
  color: var(--gold-accent);
  font-size: 14px;
}

/* Action Buttons */
.btn-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.btn-group.row {
  flex-direction: row;
  justify-content: center;
}

.btn-western {
  background: linear-gradient(180deg, #7c4f2c 0%, #4a2e18 100%);
  color: #fff9f2;
  border: 1px solid #9e693f;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.15s ease;
  font-family: var(--font-body);
}

.btn-western:hover {
  background: linear-gradient(180deg, #946037 0%, #5d3b20 100%);
  border-color: var(--gold-accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6), 0 0 12px rgba(245, 176, 65, 0.3);
}

.btn-western:active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.btn-western.primary {
  background: linear-gradient(180deg, #f5b041 0%, #b8791c 100%);
  color: #1a0f07;
  border-color: #fbe09e;
  font-size: 18px;
  font-family: var(--font-title);
  font-weight: 800;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-western.primary:hover {
  background: linear-gradient(180deg, #ffbe53 0%, #c98522 100%);
  box-shadow: 0 6px 20px rgba(245, 176, 65, 0.45);
}

.btn-western.secondary {
  background: rgba(44, 26, 14, 0.7);
  border-color: rgba(124, 79, 44, 0.5);
}

/* ==========================================================================
   LEVEL SELECT GRID (100 LEVELS)
   ========================================================================== */
#level-select-modal .card-panel {
  max-width: 600px;
  height: 85vh;
}

.level-grid-container {
  overflow-y: auto;
  padding: 10px 4px;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 10px;
}

/* Custom Scrollbar */
.level-grid-container::-webkit-scrollbar {
  width: 6px;
}
.level-grid-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
}
.level-grid-container::-webkit-scrollbar-thumb {
  background: var(--wood-light);
  border-radius: 3px;
}

.level-card {
  aspect-ratio: 1;
  background: #23160e;
  border: 1px solid #4a2e18;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.level-card.unlocked:hover {
  background: #3d2415;
  border-color: var(--gold-accent);
  transform: scale(1.06);
}

.level-card.locked {
  opacity: 0.45;
  cursor: not-allowed;
  background: #140d08;
  border-color: #2b1a10;
}

.level-card .num {
  font-size: 17px;
  font-weight: 800;
  font-family: var(--font-title);
  color: var(--text-primary);
}

.level-card .stars-mini {
  font-size: 9px;
  color: #888;
  margin-top: 3px;
  letter-spacing: 1px;
}

.level-card .stars-mini.earned {
  color: var(--gold-accent);
}

.level-card.current {
  border: 2px solid var(--gold-accent);
  box-shadow: 0 0 10px rgba(245, 176, 65, 0.4);
}

/* ==========================================================================
   SKIN SHOP PANEL
   ========================================================================== */
#shop-modal .card-panel {
  max-width: 580px;
  max-height: 85vh;
}

.shop-grid {
  overflow-y: auto;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding: 10px 4px;
}

.skin-card {
  background: #23160e;
  border: 1px solid #4a2e18;
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.skin-card.selected {
  border-color: var(--gold-accent);
  box-shadow: 0 0 14px rgba(245, 176, 65, 0.35);
  background: #2e1d13;
}

.skin-preview-canvas {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: #180f0a;
  border: 2px solid #5a3920;
}

.skin-name {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 700;
  color: var(--gold-light);
}

.skin-perk {
  font-size: 12px;
  color: var(--text-muted);
  min-height: 28px;
  text-align: center;
}

.skin-btn {
  width: 100%;
  padding: 8px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   VICTORY & DEFEAT OVERLAYS
   ========================================================================== */
.victory-badge {
  font-size: 56px;
  margin-bottom: 8px;
  animation: pop-badge 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop-badge {
  0% { transform: scale(0.2); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.stars-reward {
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 32px;
  color: #443322;
  margin: 12px 0 16px;
}

.star-icon.filled {
  color: var(--gold-accent);
  text-shadow: 0 0 12px rgba(245, 176, 65, 0.7);
  animation: star-glow 0.4s ease-out;
}

@keyframes star-glow {
  0% { transform: scale(1.8); }
  100% { transform: scale(1); }
}

.reward-stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 14px;
}

.reward-stat-row .stat-val {
  font-weight: 700;
  color: var(--gold-accent);
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */
@media (max-width: 600px) {
  #hud-overlay {
    padding: 8px 10px;
  }
  .hud-group {
    padding: 4px 8px;
    gap: 8px;
  }
  .hud-item {
    font-size: 13px;
  }
  .health-bar-bg {
    width: 60px;
  }
  .hud-btn {
    width: 34px;
    height: 34px;
    font-size: 15px;
  }
  .card-panel {
    padding: 20px 18px;
  }
  .game-title {
    font-size: 24px;
  }
  .level-grid-container {
    grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
    gap: 8px;
  }
}
