/* © 2026 FunApp https://funapp.io */
/* Pac-Man AGY - Antigravity Quantum Maze Stylesheet */

:root {
  --bg-primary: #050711;
  --bg-surface: rgba(14, 18, 38, 0.8);
  --bg-card: rgba(22, 28, 56, 0.9);
  --accent-yellow: #ffe600;
  --accent-cyan: #00f0ff;
  --accent-magenta: #ff007f;
  --accent-purple: #9d4edd;
  --accent-amber: #ffb703;
  --wall-glow: rgba(0, 240, 255, 0.45);
  --text-main: #f8f9fa;
  --text-muted: #94a3b8;
  --glass-blur: 16px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  background-color: var(--bg-primary);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans TC', sans-serif;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Top Navigation Chrome */
.funapp-back-link {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-surface);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  pointer-events: auto;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s;
}

.funapp-back-link:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: var(--accent-cyan);
  transform: translateY(-1px);
}

.settings-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  font-size: 20px;
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s;
}

.settings-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: var(--accent-cyan);
}

.settings-btn:active {
  transform: scale(0.92);
}

/* Game Shell & Stage */
#game-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  max-width: 760px;
  padding: 12px;
  position: relative;
}

/* HUD Top Cluster */
#hud {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  background: rgba(14, 18, 38, 0.7);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  margin-bottom: 8px;
  z-index: 5;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.hud-stat-center {
  align-items: center;
}

.hud-stat-right {
  align-items: flex-end;
}

.hud-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  font-weight: 700;
}

.hud-value {
  font-size: 20px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.lives-cluster {
  display: flex;
  gap: 4px;
  font-size: 16px;
}

/* Canvas Canvas Stage */
#stage-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border: 2px solid rgba(0, 240, 255, 0.35);
  border-radius: 16px;
  box-shadow: 0 0 35px rgba(0, 240, 255, 0.2), inset 0 0 30px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

#game-canvas {
  display: block;
  image-rendering: pixelated;
}

/* Toast Anomaly Banner */
.anomaly-banner {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%) scale(0.85);
  opacity: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 18px;
  background: linear-gradient(135deg, rgba(255, 0, 127, 0.85), rgba(0, 240, 255, 0.85));
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.5);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
  pointer-events: none;
  z-index: 20;
  white-space: nowrap;
}

.anomaly-banner.show {
  transform: translateX(-50%) scale(1);
  opacity: 1;
}

/* Virtual Touch D-Pad (for mobile) */
#virtual-dpad {
  display: none;
  margin-top: 10px;
  position: relative;
  width: 140px;
  height: 140px;
  z-index: 10;
}

#virtual-dpad.active {
  display: block;
}

.dpad-btn {
  position: absolute;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 12px;
  color: var(--accent-cyan);
  font-size: 18px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.1s ease;
  backdrop-filter: blur(4px);
}

.dpad-btn:active, .dpad-btn.pressed {
  background: rgba(0, 240, 255, 0.3);
  transform: scale(0.92);
  box-shadow: 0 0 12px var(--accent-cyan);
}

.dpad-up { top: 0; left: 48px; }
.dpad-down { bottom: 0; left: 48px; }
.dpad-left { top: 48px; left: 0; }
.dpad-right { top: 48px; right: 0; }
.dpad-center {
  top: 48px;
  left: 48px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  background: transparent;
  pointer-events: none;
}

/* Modals & Menus */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(3, 5, 12, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
  pointer-events: auto;
}

.modal-overlay.active {
  display: flex;
}

.card-modal {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 24px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 35px rgba(0, 240, 255, 0.18);
  animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes modalPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.game-title {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffe600, #ff007f, #00f0ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.game-subtitle {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--accent-cyan);
  text-transform: uppercase;
  margin-bottom: 22px;
}

/* Mode Selection Cards */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.mode-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 14px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.mode-card:hover, .mode-card.active {
  background: rgba(0, 240, 255, 0.12);
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 240, 255, 0.25);
}

.mode-icon { font-size: 26px; }
.mode-name { font-size: 14px; font-weight: 700; color: #fff; }
.mode-desc { font-size: 11px; color: var(--text-muted); line-height: 1.3; }

.high-score-badge {
  font-size: 12px;
  color: var(--accent-amber);
  font-weight: 700;
  margin: 6px 0 16px;
}

/* Action Buttons */
.btn-primary {
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(135deg, #ffe600, #ff007f);
  color: #111;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 230, 0, 0.35);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(255, 230, 0, 0.5);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-secondary {
  width: 100%;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
}

/* Settings Menu Rows */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.setting-label { font-size: 14px; font-weight: 600; color: #fff; }

.select-control {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 16px; /* Avoid iOS auto-zoom */
  outline: none;
  cursor: pointer;
}

.select-control option { background: #12162b; color: #fff; }

.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.2);
  transition: .3s;
  border-radius: 26px;
}

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

input:checked + .slider { background-color: var(--accent-cyan); }
input:checked + .slider:before { transform: translateX(22px); }

/* Game Over Big Stats */
.gameover-score-big {
  font-size: 50px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 20px rgba(0, 240, 255, 0.6);
  margin: 10px 0 2px;
}

.gameover-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0;
}

.stat-box {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 10px;
}

.stat-box-val { font-size: 18px; font-weight: 800; color: #fff; }
.stat-box-lbl { font-size: 11px; color: var(--text-muted); text-transform: uppercase; margin-top: 2px; }

/* Version Tag */
#version-info {
  position: fixed;
  bottom: 8px;
  right: 8px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  z-index: 9999;
  pointer-events: none;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Responsive Breakpoints */
@media (max-width: 600px) {
  #hud {
    padding: 6px 12px;
    margin-top: 48px;
  }
  .hud-value { font-size: 16px; }
  .card-modal { padding: 22px 16px; }
  .game-title { font-size: 28px; }
  #virtual-dpad {
    display: block;
  }
}
