/* ============================================
   GLOBAL STYLES — Tic Tac Toe
   ============================================ */

:root {
  /* Colors — Theme 1 (Default) */
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --bg-card-hover: #1a2744;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --accent-glow: rgba(233, 69, 96, 0.3);
  --text-primary: #eaeaea;
  --text-secondary: #a0a0b8;
  --text-muted: #6c6c80;
  --x-color: #00d2ff;
  --x-glow: rgba(0, 210, 255, 0.4);
  --o-color: #ff6b6b;
  --o-glow: rgba(255, 107, 107, 0.4);
  --cell-bg: #1a1a2e;
  --cell-bg-hover: #222240;
  --cell-border: #2a2a4a;
  --cell-border-win: #ffd700;
  --win-glow: rgba(255, 215, 0, 0.5);
  --draw-color: #ffa502;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow-x: 0 0 20px var(--x-glow);
  --shadow-glow-o: 0 0 20px var(--o-glow);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
  --font-main: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-display: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* Theme 2 */
[data-theme="theme2"] {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-card: #21262d;
  --bg-card-hover: #30363d;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --accent-glow: rgba(88, 166, 255, 0.3);
  --text-primary: #c9d1d9;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  --cell-bg: #161b22;
  --cell-bg-hover: #21262d;
  --cell-border: #30363d;
  --cell-border-win: #58a6ff;
  --win-glow: rgba(88, 166, 255, 0.5);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
}

/* Theme 3 */
[data-theme="theme3"] {
  --bg-primary: #1a0a2e;
  --bg-secondary: #2d1b4e;
  --bg-card: #3d2b5a;
  --bg-card-hover: #4d3b6a;
  --accent: #bb86fc;
  --accent-hover: #d4aaff;
  --accent-glow: rgba(187, 134, 252, 0.3);
  --text-primary: #f0e6ff;
  --text-secondary: #b8a0d8;
  --text-muted: #7a6a9a;
  --x-color: #03dac6;
  --x-glow: rgba(3, 218, 198, 0.4);
  --o-color: #cf6679;
  --o-glow: rgba(207, 102, 121, 0.4);
  --cell-bg: #2d1b4e;
  --cell-bg-hover: #3d2b5a;
  --cell-border: #4d3b6a;
  --cell-border-win: #bb86fc;
  --win-glow: rgba(187, 134, 252, 0.5);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Selection */
::selection {
  background: var(--accent);
  color: white;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

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

/* App container */
#app {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Screen management */
.screen {
  display: none;
  width: 100%;
  max-width: 1000px;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}
.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

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

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.5); }
  70% { transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

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

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 5px var(--accent-glow); }
  50% { box-shadow: 0 0 20px var(--accent-glow); }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 32px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-transform: uppercase;
  letter-spacing: 1px;
  min-width: 200px;
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s, height 0.4s;
}

.btn:active::after {
  width: 300px;
  height: 300px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #c0392b);
  color: white;
  box-shadow: var(--shadow-sm), 0 0 15px var(--accent-glow);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), 0 0 25px var(--accent-glow);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--cell-border);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.btn-small {
  padding: 8px 20px;
  font-size: 0.85rem;
  min-width: 120px;
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  min-width: auto;
  border-radius: 50%;
  font-size: 1.2rem;
}

/* Card */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--cell-border);
  width: 100%;
  max-width: 500px;
}

/* Overlay */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.overlay.active {
  display: flex;
}

/* Modal */
.modal {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--cell-border);
  animation: scaleIn 0.3s ease;
}

/* Visually hidden */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* No animations mode */
[data-animations="off"] * {
  animation-duration: 0s !important;
  transition-duration: 0s !important;
}
