/* =========================================================
   style.css
   Global styles, CSS variables, themes, home page,
   settings, glassmorphism, animations
   ========================================================= */

/* ---------- CSS RESET ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  overflow-x: hidden;
}

/* ---------- THEME VARIABLES ---------- */
:root,
[data-theme="dark"] {
  --bg-primary: #0b0e1a;
  --bg-secondary: #121629;
  --bg-gradient-1: #1a1f3a;
  --bg-gradient-2: #0b0e1a;
  --accent-primary: #6c5ce7;
  --accent-secondary: #00d2ff;
  --accent-glow: rgba(108, 92, 231, 0.6);
  --text-primary: #ffffff;
  --text-secondary: #b8bcd0;
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.12);
  --shadow-color: rgba(0, 0, 0, 0.5);
  --success: #00e676;
  --danger: #ff5252;
  --button-text: #ffffff;
}

[data-theme="neon"] {
  --bg-primary: #05010d;
  --bg-secondary: #0e0420;
  --bg-gradient-1: #1a0033;
  --bg-gradient-2: #05010d;
  --accent-primary: #ff00e0;
  --accent-secondary: #00fff7;
  --accent-glow: rgba(255, 0, 224, 0.7);
  --text-primary: #f5f5ff;
  --text-secondary: #c5b8ff;
  --glass-bg: rgba(255, 0, 224, 0.07);
  --glass-border: rgba(0, 255, 247, 0.25);
  --shadow-color: rgba(255, 0, 224, 0.4);
  --success: #39ff14;
  --danger: #ff2e63;
  --button-text: #05010d;
}

[data-theme="cyber"] {
  --bg-primary: #05080a;
  --bg-secondary: #0a1418;
  --bg-gradient-1: #0f2027;
  --bg-gradient-2: #05080a;
  --accent-primary: #00ffab;
  --accent-secondary: #ffb800;
  --accent-glow: rgba(0, 255, 171, 0.6);
  --text-primary: #e8fff6;
  --text-secondary: #9bd9c8;
  --glass-bg: rgba(0, 255, 171, 0.06);
  --glass-border: rgba(255, 184, 0, 0.2);
  --shadow-color: rgba(0, 255, 171, 0.3);
  --success: #00ffab;
  --danger: #ff3860;
  --button-text: #05080a;
}

[data-theme="light"] {
  --bg-primary: #eef1f8;
  --bg-secondary: #ffffff;
  --bg-gradient-1: #dfe7fb;
  --bg-gradient-2: #f7f9fd;
  --accent-primary: #6c5ce7;
  --accent-secondary: #0095ff;
  --accent-glow: rgba(108, 92, 231, 0.35);
  --text-primary: #1a1c2e;
  --text-secondary: #5a5f7a;
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-border: rgba(108, 92, 231, 0.18);
  --shadow-color: rgba(108, 92, 231, 0.18);
  --success: #00b87c;
  --danger: #e63946;
  --button-text: #ffffff;
}

/* ---------- BODY / BACKGROUND ---------- */
body {
  background: linear-gradient(135deg, var(--bg-gradient-1), var(--bg-gradient-2));
  color: var(--text-primary);
  min-height: 100vh;
  transition: background 0.5s ease, color 0.5s ease;
  position: relative;
}

/* Animated particle background canvas */
#bg-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ---------- HOME PAGE LAYOUT ---------- */
.home-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 30px 16px;
  text-align: center;
  gap: 28px;
}

.logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: floatLogo 4s ease-in-out infinite;
}

.logo-icon {
  width: 90px;
  height: 90px;
  filter: drop-shadow(0 0 18px var(--accent-glow));
}

.game-title {
  font-size: clamp(2.2rem, 8vw, 4rem);
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px var(--accent-glow);
}

.game-subtitle {
  font-size: clamp(0.85rem, 2.5vw, 1.1rem);
  color: var(--text-secondary);
  letter-spacing: 4px;
  text-transform: uppercase;
}

@keyframes floatLogo {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-12px); }
}

/* ---------- PLAY BUTTON ---------- */
.play-btn {
  position: relative;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(145deg, var(--accent-primary), var(--accent-secondary));
  color: var(--button-text);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
  box-shadow:
    0 0 30px var(--accent-glow),
    0 10px 40px var(--shadow-color),
    inset 0 0 20px rgba(255, 255, 255, 0.15);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.play-btn::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--accent-secondary);
  opacity: 0.5;
  animation: pulseRing 2.4s ease-out infinite;
}

.play-btn::after {
  content: '';
  position: absolute;
  inset: -18px;
  border-radius: 50%;
  border: 1px solid var(--accent-primary);
  opacity: 0.3;
  animation: pulseRing 2.4s ease-out infinite 0.6s;
}

@keyframes pulseRing {
  0% { transform: scale(0.95); opacity: 0.6; }
  70% { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}

.play-btn:hover {
  transform: scale(1.06);
  box-shadow:
    0 0 50px var(--accent-glow),
    0 14px 50px var(--shadow-color),
    inset 0 0 25px rgba(255, 255, 255, 0.25);
}

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

.play-btn span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.play-btn .play-icon {
  font-size: 2.4rem;
  line-height: 1;
}

/* ---------- HOME ACTION ROW (Settings / High Score) ---------- */
.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  width: 100%;
  max-width: 420px;
}

.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 32px var(--shadow-color);
}

.high-score-card {
  flex: 1 1 100%;
  padding: 14px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.high-score-card .value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent-secondary);
  text-shadow: 0 0 12px var(--accent-glow);
}

/* ---------- BUTTON STYLES (general) ---------- */
.btn {
  font-family: inherit;
  border: none;
  cursor: pointer;
  border-radius: 14px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-primary);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px var(--shadow-color);
  border-color: var(--accent-secondary);
}

.btn:active {
  transform: translateY(0px) scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: var(--button-text);
  border: none;
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  font-size: 1.2rem;
}

/* ---------- SETTINGS PAGE ---------- */
.settings-container {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 16px 100px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 4px 6px;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 1px;
}

.back-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 1.3rem;
  padding: 0;
}

.settings-section {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-section h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent-secondary);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- SKIN GRID ---------- */
.skin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}

.skin-option {
  background: var(--glass-bg);
  border: 2px solid var(--glass-border);
  border-radius: 14px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.skin-option:hover {
  border-color: var(--accent-secondary);
  transform: translateY(-2px);
}

.skin-option.active {
  border-color: var(--accent-primary);
  box-shadow: 0 0 18px var(--accent-glow);
  background: var(--glass-bg);
}

.skin-preview {
  width: 56px;
  height: 16px;
  border-radius: 8px;
  position: relative;
}

.skin-preview::after {
  content: '';
  position: absolute;
  right: -4px;
  top: -4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: inherit;
}

.skin-classic .skin-preview { background: linear-gradient(90deg, #4caf50, #81c784); }
.skin-neon .skin-preview { background: linear-gradient(90deg, #ff00e0, #00fff7); box-shadow: 0 0 12px #ff00e0; }
.skin-cyber .skin-preview { background: linear-gradient(90deg, #00ffab, #ffb800); box-shadow: 0 0 12px #00ffab; }
.skin-fire .skin-preview { background: linear-gradient(90deg, #ff5722, #ffc107); box-shadow: 0 0 12px #ff5722; }
.skin-ice .skin-preview { background: linear-gradient(90deg, #00bcd4, #e0f7fa); box-shadow: 0 0 12px #00bcd4; }

.skin-option span.skin-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.skin-option.active span.skin-name {
  color: var(--text-primary);
}

/* ---------- THEME GRID ---------- */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}

.theme-option {
  border: 2px solid var(--glass-border);
  border-radius: 14px;
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.theme-option:hover {
  transform: translateY(-2px);
  border-color: var(--accent-secondary);
}

.theme-option.active {
  border-color: var(--accent-primary);
  box-shadow: 0 0 18px var(--accent-glow);
  color: var(--text-primary);
}

.theme-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.theme-dark .theme-swatch { background: linear-gradient(135deg, #1a1f3a, #6c5ce7); }
.theme-neon .theme-swatch { background: linear-gradient(135deg, #1a0033, #ff00e0); }
.theme-cyber .theme-swatch { background: linear-gradient(135deg, #0f2027, #00ffab); }
.theme-light .theme-swatch { background: linear-gradient(135deg, #dfe7fb, #6c5ce7); }

/* ---------- TOGGLE SWITCH ---------- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle-label {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.switch {
  position: relative;
  width: 58px;
  height: 32px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  border: 1px solid var(--glass-border);
  border-radius: 34px;
  transition: 0.3s;
}

.slider::before {
  content: '';
  position: absolute;
  height: 24px;
  width: 24px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.switch input:checked + .slider {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
}

.switch input:checked + .slider::before {
  transform: translateX(26px);
}

/* ---------- RESET BUTTON SECTION ---------- */
.danger-btn {
  background: rgba(255, 82, 82, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
}

.danger-btn:hover {
  background: rgba(255, 82, 82, 0.2);
  box-shadow: 0 8px 24px rgba(255, 82, 82, 0.25);
}

/* ---------- TOAST NOTIFICATION ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 14px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 999;
  opacity: 0;
  transition: all 0.35s ease;
  box-shadow: 0 8px 24px var(--shadow-color);
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- FOOTER ---------- */
.footer-note {
  position: relative;
  z-index: 1;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 10px;
  letter-spacing: 1px;
}

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: 4px;
}
