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

:root {
  --bg: #0a0a0f;
  --bg-secondary: #0f0f18;
  --primary: #12121e;
  --accent: #f0c27f;
  --accent-secondary: #f5d6a8;
  --accent-glow: rgba(240, 194, 127, 0.08);
  --text: #f0ece4;
  --text-muted: rgba(240, 236, 228, 0.5);
  --text-dim: rgba(240, 236, 228, 0.25);
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-hover: rgba(255, 255, 255, 0.05);
  --shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 60px rgba(240, 194, 127, 0.06);
  --radius: 24px;
  --radius-sm: 16px;
  --radius-xs: 10px;
  --transition: 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;

  --color-red: #ef4444;
  --color-blue: #3b82f6;
  --color-green: #22c55e;
  --color-yellow: #eab308;
  --color-purple: #a855f7;
  --color-orange: #f97316;
  --color-pink: #ec4899;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; color: inherit; }

/* ============================================
   BACKGROUND
   ============================================ */

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  will-change: transform;
  transition: opacity 1.5s ease;
}

.bg-noise {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* ============================================
   GAME WRAPPER
   ============================================ */

.game-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  padding: 30px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

/* ============================================
   HEADER / SCORES
   ============================================ */

.game-header {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 16px 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  margin-bottom: 32px;
  animation: fadeSlideDown 0.6s ease both;
}

.score-display,
.streak-display,
.high-score-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.score-label,
.streak-label,
.high-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.score-value,
.streak-value,
.high-value {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.2;
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.streak-value {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.high-value {
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================
   GAME CARD
   ============================================ */

.game-card {
  width: 100%;
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 40px 28px;
  text-align: center;
  transition: border-color var(--transition);
  box-shadow: var(--shadow-glow);
}

.game-card:hover {
  border-color: rgba(255, 255, 255, 0.08);
}

.word-display {
  margin-bottom: 8px;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.word-text {
  font-size: 4rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  transition: all 0.3s ease;
  user-select: none;
}

.divider {
  width: 60px;
  height: 2px;
  margin: 0 auto 20px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.3;
  border-radius: 2px;
}

.instruction-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 28px;
  line-height: 1.5;
}

/* ============================================
   COLOR OPTIONS
   ============================================ */

.color-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.color-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 3px solid transparent;
  transition: all var(--transition);
  position: relative;
  cursor: pointer;
}

.color-btn::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: border-color var(--transition);
}

.color-btn:hover {
  transform: scale(1.12);
  box-shadow: 0 0 30px rgba(255, 255, 255, 0.15);
}

.color-btn:active {
  transform: scale(0.95);
}

.color-btn:focus-visible {
  outline: none;
}

.color-btn:focus-visible::after {
  border-color: var(--accent);
}

.color-btn-correct {
  animation: correctPop 0.5s ease;
  box-shadow: 0 0 40px rgba(34, 197, 94, 0.4);
}

.color-btn-wrong {
  animation: wrongShake 0.5s ease;
  box-shadow: 0 0 40px rgba(239, 68, 68, 0.4);
}

/* ============================================
   FEEDBACK
   ============================================ */

.feedback {
  margin-top: 20px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 600;
  transition: opacity 0.3s ease;
}

.feedback-correct {
  color: #22c55e;
}

.feedback-wrong {
  color: #ef4444;
}

/* ============================================
   FOOTER
   ============================================ */

.game-footer {
  margin-top: auto;
  padding-top: 32px;
}

.btn-ghost {
  padding: 10px 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
}

.btn-ghost:hover {
  background: var(--glass-hover);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.12);
}

.btn-ghost:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ============================================
   LOADING
   ============================================ */

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.7s ease, visibility 0.7s ease;
}

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

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 2px solid rgba(240, 194, 127, 0.08);
  border-top-color: var(--accent);
  border-right-color: rgba(240, 194, 127, 0.3);
  border-radius: 50%;
  animation: spin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes correctPop {
  0% { transform: scale(1); }
  30% { transform: scale(1.25); }
  60% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -40px) scale(1.04); }
  50% { transform: translate(-20px, 25px) scale(0.96); }
  75% { transform: translate(35px, 15px) scale(1.02); }
}

/* ============================================
   TOAST
   ============================================ */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  padding: 12px 26px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  pointer-events: none;
}

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

.toast-success {
  background: rgba(34, 197, 94, 0.1);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.15);
}

.toast-error {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.15);
}

.toast-info {
  background: rgba(240, 194, 127, 0.1);
  color: var(--accent);
  border-color: rgba(240, 194, 127, 0.15);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .game-wrapper { padding: 20px 16px 30px; }
  .game-card { padding: 32px 20px; }
  .word-text { font-size: 3.2rem; }
  .color-btn { width: 64px; height: 64px; }
  .game-header { gap: 16px; padding: 14px 16px; }
  .score-value, .streak-value, .high-value { font-size: 1.2rem; }
}

@media (max-width: 480px) {
  .game-wrapper { padding: 14px 12px 24px; }
  .game-card { padding: 24px 16px; border-radius: var(--radius-sm); }
  .word-text { font-size: 2.6rem; }
  .color-btn { width: 56px; height: 56px; }
  .game-header { gap: 12px; padding: 12px 14px; }
  .score-value, .streak-value, .high-value { font-size: 1.1rem; }
  .instruction-text { font-size: 0.8rem; }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.06); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.12); }

::selection {
  background: rgba(240, 194, 127, 0.2);
  color: #fff;
}
