/**
 * game-ui.css - Dungeon Battles UI Styles
 * Dark theme for dungeon atmosphere
 */

/* ===== CSS Variables ===== */
:root {
  --color-bg-dark: #0a0a1e;
  --color-bg-medium: #1a1a2e;
  --color-bg-light: #2a2a3e;
  --color-primary: #ffaa00;
  --color-secondary: #ff6600;
  --color-accent: #00ffff;
  --color-danger: #ff4444;
  --color-success: #00ff00;
  --color-text: #ffffff;
  --color-text-dim: #aaaaaa;
  --font-main: 'Arial', sans-serif;
}

/* ===== Reset & Base Styles ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* ===== Game Container ===== */
#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #0a0a1e 0%, #1a1a3e 50%, #0a0a1e 100%);
}

/* ===== Canvas ===== */
#game-canvas {
  display: block;
  background-color: var(--color-bg-dark);
  border: 2px solid var(--color-primary);
  box-shadow: 0 0 30px rgba(255, 170, 0, 0.3);
  max-width: 100%;
  max-height: 100%;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

/* Responsive canvas */
@media (max-width: 768px) {
  #game-canvas {
    width: 100vw !important;
    height: 100vh !important;
    border: none;
  }
}

/* ===== Loading Screen ===== */
#loading-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #0a0a1e 0%, #1a1a3e 50%, #0a0a1e 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: opacity 0.5s ease;
}

.loading-content {
  text-align: center;
  max-width: 400px;
  padding: 20px;
}

.loading-content h1 {
  font-size: 48px;
  font-weight: bold;
  color: var(--color-primary);
  margin-bottom: 30px;
  text-shadow: 0 0 20px rgba(255, 170, 0, 0.5);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

.loading-bar {
  width: 100%;
  height: 30px;
  background-color: var(--color-bg-light);
  border: 2px solid var(--color-primary);
  border-radius: 15px;
  overflow: hidden;
  margin-bottom: 20px;
}

.loading-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--color-secondary), var(--color-primary));
  width: 0%;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(255, 170, 0, 0.8);
}

.loading-text {
  font-size: 18px;
  color: var(--color-text-dim);
  animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== Debug Info ===== */
.debug-info {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: rgba(0, 0, 0, 0.7);
  color: var(--color-success);
  padding: 8px 12px;
  border-radius: 5px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  z-index: 100;
}

#fps-counter {
  font-weight: bold;
}

/* ===== Orientation Warning ===== */
#orientation-warning {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.orientation-content {
  text-align: center;
  padding: 20px;
}

.orientation-content p:first-child {
  font-size: 64px;
  margin-bottom: 20px;
}

.orientation-content p {
  font-size: 24px;
  color: var(--color-text);
  margin: 10px 0;
}

/* ===== Error Modal ===== */
#error-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1001;
}

.modal-content {
  background-color: var(--color-bg-medium);
  border: 3px solid var(--color-danger);
  border-radius: 10px;
  padding: 40px;
  max-width: 500px;
  text-align: center;
}

.modal-content h2 {
  color: var(--color-danger);
  font-size: 32px;
  margin-bottom: 20px;
}

.modal-content p {
  color: var(--color-text);
  font-size: 18px;
  margin-bottom: 30px;
}

.modal-content button {
  background-color: var(--color-primary);
  color: var(--color-bg-dark);
  border: none;
  padding: 12px 30px;
  font-size: 18px;
  font-weight: bold;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.modal-content button:hover {
  background-color: var(--color-secondary);
  transform: scale(1.05);
}

.modal-content button:active {
  transform: scale(0.95);
}

/* ===== Utility Classes ===== */
.hidden {
  display: none !important;
}

.no-scroll {
  overflow: hidden;
}

/* ===== Mobile Optimizations ===== */
@media (max-width: 768px) {
  body {
    background-color: var(--color-bg-dark);
  }

  #game-container {
    max-width: 100vw;
    max-height: 100vh;
  }

  .loading-content h1 {
    font-size: 36px;
  }

  .loading-text {
    font-size: 16px;
  }

  .modal-content {
    max-width: 90%;
    padding: 20px;
  }

  .modal-content h2 {
    font-size: 24px;
  }

  .modal-content p {
    font-size: 16px;
  }
}

/* ===== Landscape Mobile ===== */
@media (max-width: 768px) and (orientation: landscape) {
  #game-canvas {
    width: 100vw !important;
    height: 100vh !important;
  }
}

/* ===== High DPI Displays ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  #game-canvas {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-color-scheme: light) {
  /* Could add light theme support here if desired */
}

/* ===== Print Styles ===== */
@media print {
  body {
    background-color: white;
  }

  #game-container {
    display: none;
  }
}

/* ===== Focus Styles for Accessibility ===== */
button:focus,
a:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ===== Selection Styles ===== */
::selection {
  background-color: var(--color-primary);
  color: var(--color-bg-dark);
}

::-moz-selection {
  background-color: var(--color-primary);
  color: var(--color-bg-dark);
}

/* ===== Scrollbar Styles (for debug panels) ===== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--color-primary);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-secondary);
}

/* ===== Performance Optimizations ===== */
#game-canvas {
  will-change: transform;
}

.loading-progress {
  will-change: width;
}

/* ===== iOS Safari Specific ===== */
@supports (-webkit-touch-callout: none) {
  body {
    height: -webkit-fill-available;
  }

  #game-container {
    height: -webkit-fill-available;
  }
}
