/* =====================================================================
 * TACTICAL PAC-MAN: BRAILLE EDITION - PREMIUM DESIGN SYSTEM
 * ===================================================================== */

:root {
  --bg-dark: #05070e;
  --bg-matrix: #0b0f19;
  --panel-bg: rgba(14, 20, 35, 0.7);
  --border-color: rgba(0, 242, 254, 0.25);
  
  /* Bioluminescent Game Colors */
  --pacman-yellow: #ffeb3b;
  --pacman-glow: rgba(255, 235, 59, 0.4);
  --blinky-red: #ff003c;
  --blinky-glow: rgba(255, 0, 60, 0.45);
  --pinky-pink: #ff73b9;
  --pinky-glow: rgba(255, 115, 185, 0.45);
  --inky-cyan: #00f2fe;
  --inky-glow: rgba(0, 242, 254, 0.45);
  --clyde-orange: #ff9800;
  --clyde-glow: rgba(255, 152, 0, 0.45);
  --wall-blue: #1d4ed8;
  --wall-glow: rgba(29, 78, 216, 0.3);
  
  /* UI Colors */
  --text-primary: #f8fafc;
  --text-muted: #64748b;
  --danger: #ef4444;
  --success: #22c55e;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

/* Background Cyberpunk Backdrop */
body::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: 
    radial-gradient(circle at 10% 20%, rgba(29, 78, 216, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(255, 0, 60, 0.05) 0%, transparent 40%),
    linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-matrix) 100%);
  z-index: -2;
}

#gameContainer {
  position: relative;
  width: 95vw;
  height: 95vw;
  max-width: 95vh;
  max-height: 95vh;
  aspect-ratio: 1 / 1;
  background: #020308;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 
              0 0 45px rgba(0, 242, 254, 0.15);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  margin: auto;
  container-type: size;
}

#gameCanvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 82cqmin;
  height: 82cqmin;
  z-index: 1;
}

/* Glassmorphism Screens */
.overlay-screen {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: 10;
  background: rgba(4, 6, 12, 0.88);
  backdrop-filter: blur(15px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5cqh 5cqw;
  transition: opacity 0.4s ease, visibility 0.4s;
  text-align: center;
}

.overlay-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

h1.game-title {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(24px, 8cqh, 56px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 1cqh;
  background: linear-gradient(135deg, #ffffff 40%, var(--pacman-yellow) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px rgba(255, 235, 59, 0.3);
}

.subtitle {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(10px, 2.5cqh, 18px);
  color: var(--inky-cyan);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 3cqh;
  font-weight: 600;
  text-shadow: 0 0 10px var(--inky-glow);
}

/* Dashboard HUD */
#hud {
  position: absolute;
  top: 0; left: 0; width: 100%;
  padding: 16px 24px;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(4, 6, 12, 0.8) 0%, transparent 100%);
}

.hud-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 16px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 15px;
  pointer-events: auto;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.hud-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hud-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hud-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.hud-value.highlight-yellow {
  color: var(--pacman-yellow);
  text-shadow: 0 0 8px var(--pacman-glow);
}

.hud-value.highlight-red {
  color: var(--blinky-red);
  text-shadow: 0 0 8px var(--blinky-glow);
}

#pauseHudButton {
  margin-top: 0;
  padding: 8px 16px;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  height: fit-content;
  background: var(--panel-bg);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: var(--text-primary);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: all 0.2s;
  pointer-events: auto;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}

#pauseHudButton:hover {
  background: rgba(0, 242, 254, 0.1);
  border-color: var(--inky-cyan);
  box-shadow: 0 0 15px var(--inky-glow);
  transform: translateY(-1px);
}

#pauseHudButton:active {
  transform: translateY(1px);
}

/* Life Counter Indicators */
.life-indicator-container {
  display: flex;
  gap: 6px;
  align-items: center;
}

.life-dot {
  width: 14px;
  height: 14px;
  background-color: var(--pacman-yellow);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--pacman-glow);
}

/* Ticker Fact Bar */
#tickerContainer {
  position: absolute;
  bottom: 0; left: 0; width: 100%;
  background: rgba(4, 6, 12, 0.9);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 24px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #cbd5e1;
}

.ticker-icon {
  margin-right: 10px;
  color: var(--pacman-yellow);
  animation: pulse-yellow 2s infinite ease-in-out;
}

#tickerText {
  font-weight: 500;
  transition: opacity 0.4s ease;
}

/* Subtitles */
#subtitlesContainer {
  position: absolute;
  bottom: clamp(55px, 11cqh, 70px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  border: 1px dashed var(--pacman-yellow);
  border-radius: 8px;
  padding: 6px 16px;
  color: #ffffff;
  font-size: clamp(10px, 2.2cqh, 14px);
  font-weight: 600;
  text-align: center;
  max-width: 85%;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  transition: opacity 0.25s ease;
}

#subtitlesContainer.active {
  opacity: 1;
}

/* Accessibility Toggles */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
  vertical-align: middle;
}

.toggle-switch input {
  opacity: 0; width: 0; height: 0;
}

.toggle-slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .3s;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.toggle-slider:before {
  position: absolute; content: "";
  height: 14px; width: 14px;
  left: 3px; bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: rgba(255, 235, 59, 0.25);
  border-color: var(--pacman-yellow);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(22px);
  background-color: var(--pacman-yellow);
}

/* Premium Buttons & Cards */
.btn {
  background: linear-gradient(135deg, var(--pacman-yellow), #e65100);
  color: #000000;
  border: none;
  border-radius: 1.5cqh;
  padding: 1.5cqh 4cqh;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: clamp(11px, 2.2cqh, 17px);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(255, 235, 59, 0.3);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 1.5cqh;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(255, 235, 59, 0.5);
  filter: brightness(1.1);
}

.btn:active {
  transform: translateY(1px);
}

.card-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2cqw;
  width: 100%;
  max-width: 85cqw;
  margin-bottom: 3cqh;
}

.guide-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 1.5cqh;
  padding: 2cqh 2cqw;
  text-align: left;
  transition: all 0.3s;
}

.guide-card:hover {
  border-color: rgba(255, 235, 59, 0.2);
  background: rgba(255, 255, 255, 0.05);
}

.card-icon {
  font-size: clamp(14px, 4.5cqh, 28px);
  margin-bottom: 1cqh;
}

.card-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: clamp(9px, 2.2cqh, 15px);
  margin-bottom: 0.8cqh;
  text-transform: uppercase;
}

.card-desc {
  font-size: clamp(8px, 1.7cqh, 12px);
  color: var(--text-muted);
  line-height: 1.4;
}

/* Tactical Braille Mode overlay terminal screen */
#brailleConsole {
  background: rgba(4, 6, 12, 0.97);
  justify-content: flex-start;
  text-align: left;
  padding: 24px;
}

#brailleHud {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--pacman-yellow);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

#brailleLog {
  width: 100%;
  flex-grow: 1;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 16px;
  font-family: monospace;
  font-size: clamp(12px, 2cqh, 15px);
  line-height: 1.6;
  color: #e2e8f0;
  margin-bottom: 16px;
  scroll-behavior: smooth;
}

/* Animations */
@keyframes pulse-yellow {
  0%, 100% { opacity: 0.6; transform: scale(1); filter: drop-shadow(0 0 2px var(--pacman-glow)); }
  50% { opacity: 1; transform: scale(1.1); filter: drop-shadow(0 0 8px var(--pacman-yellow)); }
}

/* Mobile landscape overrides */
@media (max-width: 980px) or (max-height: 620px) {
  #gameContainer {
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
  
  .overlay-screen {
    overflow-y: auto !important;
    padding: 16px 20px !important;
    justify-content: flex-start;
  }
  
  .card-container {
    display: none !important;
  }
  
  h1.game-title {
    font-size: 2.2rem;
    margin-top: 10px;
  }
  
  .subtitle {
    font-size: 0.85rem;
    margin-bottom: 10px;
  }
  
  .btn {
    padding: 8px 20px;
    font-size: 0.8rem;
    margin-top: 5px;
    margin-bottom: 15px;
  }
  
  #tickerContainer {
    padding: 6px 16px;
    font-size: 0.7rem;
  }
  
  #pauseHudButton {
    padding: 6px 12px;
    font-size: 0.7rem;
    border-radius: 8px;
  }
}

/* Keyboard Outline Focus */
*:focus-visible {
  outline: 3px solid var(--pacman-yellow) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 15px var(--pacman-yellow) !important;
}

/* Portrait Warning Container */
#portraitWarning {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100dvh;
  z-index: 9999;
  background: radial-gradient(circle at 50% 50%, #0d0915 0%, var(--bg-dark) 100%);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
}

@media (orientation: portrait) and (max-width: 980px) {
  #portraitWarning {
    display: flex;
  }
  #gameContainer {
    display: none;
  }
}
