/**
 * Cheeky Wee Rats - Theme & UI Stylesheet
 * Filthy Casual Games Arcade Style with Modern Cyber & Tartan Accents
 */

:root {
  --bg-dark: #070a12;
  --bg-panel: #0f172a;
  --surface-card: rgba(15, 23, 42, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.12);
  --border-glow: rgba(0, 240, 255, 0.4);
  --neon-cyan: #00f0ff;
  --cheese-gold: #ffd700;
  --neon-pink: #ff0055;
  --highland-green: #22c55e;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-mono: 'JetBrains Mono', monospace;
  --font-heading: 'Space Grotesk', sans-serif;
  --font-sans: 'Plus Jakarta Sans', sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
}

/* Header Navigation */
.game-header {
  height: 54px;
  background: rgba(10, 15, 26, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 50;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.15rem;
}

.brand-badge {
  background: linear-gradient(135deg, var(--cheese-gold), #ea580c);
  color: #000;
  font-size: 0.75rem;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Base Buttons */
.btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  text-decoration: none;
  font-family: var(--font-sans);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--neon-cyan);
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border-color: #38bdf8;
  color: #fff;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

.btn-danger {
  background: linear-gradient(135deg, #e11d48, #9f1239);
  border-color: #fb7185;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #f43f5e, #be123c);
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.4);
}

.btn-cheese {
  background: linear-gradient(135deg, #d97706, #b45309);
  border-color: var(--cheese-gold);
  color: #fff;
}

.btn-cheese:hover {
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
}

/* Viewport & Game Canvas */
.game-viewport-wrap {
  position: relative;
  width: 100%;
  height: calc(100% - 54px - 84px);
  background: #020617;
  overflow: hidden;
  cursor: crosshair;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* HUD Overlay Layer */
.hud-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 16px;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  z-index: 10;
}

.hud-top-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto;
  flex: 0 0 auto;
}

/* Center HUD 2-Row Music Player (Title on top, controls under) */
.hud-top-center {
  pointer-events: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 0 1 auto;
  margin: 0 auto;
}

#headerMusicPlayer .fcg-music-player-bar,
#hudMusicPlayerWrap .fcg-music-player-bar {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 3px !important;
  padding: 5px 14px !important;
  background: rgba(15, 23, 42, 0.9) !important;
  backdrop-filter: blur(14px) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5) !important;
  min-width: 250px !important;
  max-width: 320px !important;
}

/* Row 1: Top Title & Category */
#headerMusicPlayer .fcg-music-info,
#hudMusicPlayerWrap .fcg-music-info {
  display: flex !important;
  flex-direction: row !important;
  align-items: baseline !important;
  justify-content: center !important;
  text-align: center !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  gap: 6px !important;
}

#headerMusicPlayer .fcg-music-title,
#hudMusicPlayerWrap .fcg-music-title {
  font-size: 0.8rem !important;
  font-weight: 700 !important;
  color: #f8fafc !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 200px !important;
  text-align: center !important;
}

#headerMusicPlayer .fcg-music-category,
#hudMusicPlayerWrap .fcg-music-category {
  font-size: 0.6rem !important;
  color: var(--cheese-gold, #ffd700) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  font-weight: 700 !important;
  white-space: nowrap !important;
}

#headerMusicPlayer .fcg-music-visualizer,
#hudMusicPlayerWrap .fcg-music-visualizer {
  display: none !important;
}

/* Row 2: Bottom Control Buttons & Volume Slider */
#headerMusicPlayer .fcg-music-controls,
#hudMusicPlayerWrap .fcg-music-controls {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  width: 100% !important;
}

#headerMusicPlayer .fcg-music-btn,
#hudMusicPlayerWrap .fcg-music-btn {
  padding: 3px 7px !important;
  font-size: 0.78rem !important;
  border-radius: 5px !important;
  min-width: 26px !important;
  height: 24px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#headerMusicPlayer .fcg-btn-primary,
#hudMusicPlayerWrap .fcg-btn-primary {
  background: var(--neon-cyan, #00f0ff) !important;
  color: #0f172a !important;
  border-color: var(--neon-cyan, #00f0ff) !important;
  font-weight: bold !important;
}

#headerMusicPlayer .fcg-music-vol-slider,
#hudMusicPlayerWrap .fcg-music-vol-slider {
  width: 60px !important;
  height: 4px !important;
  accent-color: var(--neon-cyan, #00f0ff) !important;
  cursor: pointer !important;
}

.level-badge-title {
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.tribe-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
}

.hud-stats-bar {
  display: flex;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.stat-pill {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px 8px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Live Quota Progress Meter */
.hud-quota-meter-wrap {
  position: relative;
  width: 100%;
  max-width: 320px;
  height: 14px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  margin-top: 4px;
}

.hud-quota-meter-fill {
  height: 100%;
  background: linear-gradient(90deg, #00f0ff, #38bdf8);
  border-radius: 8px;
  transition: width 0.3s ease, background 0.3s ease;
}

.hud-quota-meter-fill.quota-met {
  background: linear-gradient(90deg, #f59e0b, #ffd700) !important;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}

.hud-quota-target-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #ef4444;
  box-shadow: 0 0 6px #ef4444;
  z-index: 2;
}

.hud-quota-label {
  position: absolute;
  width: 100%;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  z-index: 3;
}

/* Trophy Badges */
.trophy-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 800;
  margin-top: 4px;
}

.trophy-gold {
  background: rgba(255, 215, 0, 0.15);
  color: #ffd700;
  border: 1px solid rgba(255, 215, 0, 0.5);
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}

.trophy-silver {
  background: rgba(226, 232, 240, 0.15);
  color: #e2e8f0;
  border: 1px solid rgba(226, 232, 240, 0.5);
}

.trophy-bronze {
  background: rgba(205, 127, 50, 0.15);
  color: #fb923c;
  border: 1px solid rgba(205, 127, 50, 0.5);
}

.hud-top-right {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

.minimap-wrap {
  width: 140px;
  height: 70px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--neon-cyan);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
  cursor: pointer;
}

#minimapCanvas {
  width: 100%;
  height: 100%;
}

.hud-zoom-controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-rate-controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.btn-micro {
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-micro:hover {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--neon-cyan);
}

@media (max-width: 768px) {
  .minimap-wrap {
    width: 100px;
    height: 50px;
  }
  .hud-stats-bar {
    flex-wrap: wrap;
    font-size: 0.72rem;
  }
  .level-badge-title {
    font-size: 0.85rem;
    padding: 4px 8px;
  }
}

/* Bottom Skill Hotbar */
.bottom-control-bar {
  height: 84px;
  background: rgba(10, 15, 26, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 50;
  gap: 12px;
}

.skill-hotbar-container {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0;
  flex: 1;
}

.skill-hotbar-container::-webkit-scrollbar {
  height: 4px;
}
.skill-hotbar-container::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 2px;
}

.skill-card {
  position: relative;
  flex: 0 0 64px;
  height: 68px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-main);
  padding: 4px;
}

.skill-card:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--neon-cyan);
}

.skill-card.active {
  background: rgba(0, 240, 255, 0.15);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
  transform: translateY(-2px);
}

.skill-card.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: transparent;
}

.skill-hotkey {
  position: absolute;
  top: 2px;
  left: 4px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
}

.skill-icon {
  font-size: 1.2rem;
  margin-bottom: 2px;
}

.skill-name {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 58px;
}

.skill-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--cheese-gold);
}

.global-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Rat Inspector Hover Tooltip */
#ratInspectorTooltip {
  position: absolute;
  display: none;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--neon-cyan);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 0.75rem;
  color: #fff;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  font-family: var(--font-sans);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.hidden {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.modal-overlay.hidden {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.modal-dialog {
  background: var(--bg-panel);
  border: 1px solid var(--border-glow);
  border-radius: 12px;
  padding: 24px;
  max-width: 540px;
  width: 90%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  text-align: center;
}

.modal-dialog h3 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  margin-bottom: 12px;
  color: var(--cheese-gold);
}

.modal-dialog p {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* Level Select Hub Modal */
.level-select-dialog {
  max-width: 800px;
  max-height: 80vh;
  overflow-y: auto;
  text-align: left;
}

.level-select-dialog h3 {
  text-align: center;
}

.tribe-section {
  margin-bottom: 20px;
}

.tribe-section h4 {
  font-family: var(--font-heading);
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.level-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}

.level-select-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px;
  color: #fff;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.15s ease;
}

.level-select-card:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--neon-cyan);
  transform: translateY(-2px);
}

.level-select-card.completed {
  border-color: var(--cheese-gold);
  background: rgba(255, 215, 0, 0.08);
}

.level-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.level-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--cheese-gold);
  margin-top: 4px;
}

/* Level Editor Floating Studio Panel */
#editorModal {
  pointer-events: none;
  background: transparent;
  backdrop-filter: none;
  align-items: flex-start;
  padding-top: 10px;
}

#editorModal .editor-dialog {
  pointer-events: auto;
  max-width: 960px;
  width: 95%;
  max-height: 42vh;
  overflow-y: auto;
  background: rgba(10, 15, 26, 0.94);
  backdrop-filter: blur(16px);
  border: 1px solid var(--neon-cyan);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8), 0 0 15px rgba(0, 240, 255, 0.2);
  padding: 14px 18px;
  border-radius: 10px;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

.editor-tool-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}

.editor-tool-btn.active {
  background: var(--neon-cyan);
  color: #000;
  font-weight: 700;
}

.editor-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.editor-input-group label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.editor-input-group input, .editor-input-group select {
  width: 100%;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-subtle);
  padding: 6px 10px;
  border-radius: 6px;
  color: #fff;
  font-family: var(--font-sans);
}

/* Player Guide Dialog Styling */
.guide-dialog {
  max-width: 820px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 20px 24px;
}

.guide-content-scroll {
  overflow-y: auto;
  padding-right: 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.guide-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px 16px;
}

.guide-card h4 {
  margin: 0 0 8px 0;
  color: var(--cheese-gold);
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.guide-card p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #cbd5e1;
}

.guide-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 0.82rem;
  color: #cbd5e1;
}

.guide-skills-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.guide-skill-item {
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

@media (max-width: 768px) {
  .guide-grid-2, .guide-skills-list {
    grid-template-columns: 1fr;
  }
}

/* Main Menu Modal Styling */
.main-menu-dialog {
  max-width: 680px;
  text-align: center;
  padding: 32px 28px;
  background: radial-gradient(circle at top, rgba(30, 41, 59, 0.98), rgba(10, 15, 26, 0.98));
  border: 2px solid rgba(255, 215, 0, 0.4);
  box-shadow: 0 0 35px rgba(255, 215, 0, 0.25), 0 20px 50px rgba(0, 0, 0, 0.8);
}

.main-menu-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--cheese-gold);
  background: rgba(255, 215, 0, 0.12);
  border: 1px solid rgba(255, 215, 0, 0.3);
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 12px;
}

.main-menu-title {
  font-family: var(--font-heading);
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 1px;
  margin: 0 0 8px 0;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
  color: #fff;
}

.main-menu-subtitle {
  font-size: 0.95rem;
  color: #94a3b8;
  line-height: 1.5;
  margin: 0 0 20px 0;
}

.main-menu-section-title {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  text-align: left;
  margin: 12px 0 8px 0;
  text-transform: uppercase;
}

.main-menu-tribes-preview {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.tribe-mini-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1.5px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tribe-mini-card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.08);
}

.tribe-mini-card.selected {
  border-color: var(--tribe-color, var(--cheese-gold)) !important;
  background: rgba(255, 255, 255, 0.14) !important;
  box-shadow: 0 0 14px var(--tribe-color, var(--cheese-gold));
  transform: translateY(-3px) scale(1.04);
}

.tribe-mini-card .tribe-icon {
  font-size: 1.35rem;
}

.tribe-mini-card strong {
  font-size: 0.68rem;
  color: #cbd5e1;
}

.tribe-mini-card.selected strong {
  color: #ffffff;
  font-weight: 800;
}

/* Selected Clan Highlight Banner */
.selected-clan-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  text-align: left;
}

.selected-clan-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.selected-clan-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.selected-clan-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
}

.selected-clan-desc {
  font-size: 0.78rem;
  color: #94a3b8;
  line-height: 1.35;
}

.main-menu-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.btn-large {
  padding: 12px 20px;
  font-size: 1.02rem;
  font-weight: 700;
}

@media (max-width: 600px) {
  .main-menu-tribes-preview {
    grid-template-columns: repeat(4, 1fr);
  }
  .main-menu-title {
    font-size: 1.8rem;
  }
}
