/* pvpTD — Main Styles */
:root {
  --color-primary: #2a1a4e;
  --color-primary-light: #3d2a6e;
  --color-secondary: #f0c040;
  --color-accent: #40f070;
  --color-danger: #e94560;
  --color-defender: #4ecca3;
  --color-attacker: #e94560;
  --color-bg-dark: #0e0a1a;
  --color-bg-medium: #16102e;
  --color-bg-panel: #1e1440;
  --color-bg-panel-hover: #2a1c55;
  --color-text: #e8e4f0;
  --color-text-dim: #9990b0;
  --color-text-muted: #6b6088;
  --color-border: #3a2e60;
  --color-border-light: #5040a0;
  --color-gold: #f0c040;
  --color-lives: #ff6b6b;
  --color-timer: #ffd93d;

  --font-main: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Georgia', 'Times New Roman', serif;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow-defender: 0 0 12px rgba(78, 204, 163, 0.3);
  --shadow-glow-attacker: 0 0 12px rgba(233, 69, 96, 0.3);
  --shadow-glow-gold: 0 0 12px rgba(240, 192, 64, 0.3);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;

  /* Card system */
  --card-width-tower: 80px;
  --card-height-tower: 110px;
  --card-width-mob: 72px;
  --card-height-mob: 100px;
  --card-border-width: 3px;
  --card-radius: 10px;
  --card-shadow-idle: 0 4px 8px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);
  --card-shadow-hover: 0 8px 20px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.4);
  --card-shadow-selected: 0 12px 28px rgba(0, 0, 0, 0.6);
  --spring-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  --z-game: 1;
  --z-hud: 10;
  --z-panel: 20;
  --z-modal: 50;
  --z-overlay: 100;
  --z-toast: 200;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--color-bg-dark);
  color: var(--color-text);
  font-family: var(--font-main);
  font-size: 14px;
  line-height: 1.4;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* UI overlay root — sits on top of game viewport, passes through clicks */
#ui-root {
  position: absolute;
  inset: 0;
  z-index: var(--z-overlay);
  pointer-events: none;
  overflow: hidden;
}

/* Game canvas container */
#game-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #000;
  z-index: var(--z-game);
}

#game-viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--color-bg-dark);
}
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-border-light);
}

/* Common button base */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-panel);
  color: var(--color-text);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  background: var(--color-bg-panel-hover);
  border-color: var(--color-border-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn:active:not(:disabled) {
  transform: translateY(0) scale(0.96);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  border-color: var(--color-secondary);
  color: var(--color-secondary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-light);
  box-shadow: var(--shadow-glow-gold);
}

.btn-defender {
  border-color: var(--color-defender);
  color: var(--color-defender);
}
.btn-defender:hover:not(:disabled) {
  background: rgba(78, 204, 163, 0.15);
  box-shadow: var(--shadow-glow-defender);
}
.btn-defender.active {
  background: rgba(78, 204, 163, 0.2);
  border-color: var(--color-defender);
  box-shadow: var(--shadow-glow-defender);
}

.btn-attacker {
  border-color: var(--color-attacker);
  color: var(--color-attacker);
}
.btn-attacker:hover:not(:disabled) {
  background: rgba(233, 69, 96, 0.15);
  box-shadow: var(--shadow-glow-attacker);
}
.btn-attacker.active {
  background: rgba(233, 69, 96, 0.2);
  border-color: var(--color-attacker);
  box-shadow: var(--shadow-glow-attacker);
}

.btn-danger {
  border-color: var(--color-danger);
  color: var(--color-danger);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(233, 69, 96, 0.15);
}

.btn-icon {
  padding: 6px;
  width: 36px;
  height: 36px;
}

/* Panel base */
.panel {
  background: var(--color-bg-panel);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* Screen overlays */
.screen-overlay {
  position: absolute;
  inset: 0;
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 6, 20, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.screen-overlay.hidden {
  display: none;
}

/* Global utility: .hidden means NOT VISIBLE, no exceptions. Half the UI
   toggled this class with no matching rule (the dare-a-friend button was
   unhideable) — every specific `.x.hidden` rule below remains harmless. */
.hidden {
  display: none !important;
}

/* Loading screen */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: var(--color-bg-dark);
  transition: opacity 0.5s ease;
}
#loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}
.loading-title {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: bold;
  color: var(--color-secondary);
  text-shadow: 0 0 20px rgba(240, 192, 64, 0.3);
}
.loading-bar-container {
  width: 260px;
  height: 8px;
  background: var(--color-bg-medium);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}
.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-defender), var(--color-secondary));
  border-radius: 4px;
  transition: width 0.3s ease;
}
.loading-status {
  font-size: 13px;
  color: var(--color-text-dim);
}

/* Hotkey badge */
.hotkey {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  padding: 0 4px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  font-size: 10px;
  font-weight: bold;
  text-align: center;
  color: var(--color-text-dim);
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 60px;
  right: 16px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: var(--color-text);
  pointer-events: auto;
  animation: toast-in 0.3s ease;
}
.toast.fade-out {
  animation: toast-out 0.3s ease forwards;
}

/* Build version badge */
.version-badge {
  position: fixed;
  bottom: 8px;
  right: 12px;
  z-index: var(--z-toast);
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--color-text-muted);
  opacity: 0.5;
  pointer-events: none;
}
