* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; display: flex; justify-content: center; align-items: center; padding: 20px; }
.container { background: white; border-radius: 20px; padding: 30px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); max-width: 400px; width: 100%; }
h1 { text-align: center; font-family: 'Orbitron', sans-serif; font-size: 2.5em; margin-bottom: 20px; }
h1 .x { color: #e74c3c; }
h1 .o { color: #3498db; }
h1 .dash { color: #666; }
.mode-select, .difficulty { margin-bottom: 15px; display: flex; gap: 10px; align-items: center; }
.difficulty { display: none; }
.difficulty.show { display: flex; }
label { font-weight: 600; color: #555; }
select { padding: 8px 12px; border: 2px solid #ddd; border-radius: 8px; font-size: 1em; cursor: pointer; }
.status { text-align: center; font-size: 1.2em; font-weight: 600; color: #667eea; margin: 20px 0; padding: 12px; background: #f8f9fa; border-radius: 10px; min-height: 44px; }
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 20px; background: #667eea; padding: 8px; border-radius: 12px; }
.cell { aspect-ratio: 1; background: white; border-radius: 8px; display: flex; justify-content: center; align-items: center; font-size: 2.5em; font-weight: bold; cursor: pointer; transition: all 0.2s ease; user-select: none; }
.cell:hover:not(.taken) { background: #f0f0f0; transform: scale(0.95); }
.cell.taken { cursor: not-allowed; }
.cell.x { color: #e74c3c; }
.cell.o { color: #3498db; }
.cell.win { background: #ffeaa7; animation: pulse 0.8s infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.scores { display: flex; justify-content: space-around; gap: 10px; margin-bottom: 20px; }
.score { background: #f8f9fa; padding: 12px 20px; border-radius: 10px; text-align: center; flex: 1; }
.score span { display: block; font-size: 0.85em; color: #666; margin-bottom: 4px; }
.score b { font-size: 1.5em; color: #333; }
.x-score b { color: #e74c3c; }
.o-score b { color: #3498db; }
.reset-btn { width: 100%; padding: 14px; font-size: 1.1em; font-weight: 600; color: white; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border: none; border-radius: 10px; cursor: pointer; transition: all 0.2s ease; }
.reset-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(102,126,234,0.4); }
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); display: flex; justify-content: center; align-items: center; opacity: 0; visibility: hidden; transition: all 0.3s ease; z-index: 1000; }
.modal.show { opacity: 1; visibility: visible; }
.modal-content { background: white; padding: 40px; border-radius: 20px; text-align: center; transform: scale(0.8); transition: all 0.3s ease; max-width: 350px; width: 90%; }
.modal.show .modal-content { transform: scale(1); }
.trophy { font-size: 4em; margin-bottom: 10px; }
.modal h2 { font-size: 1.8em; margin-bottom: 10px; color: #333; }
.modal p { color: #666; margin-bottom: 25px; }
.modal-btns { display: flex; gap: 12px; justify-content: center; }
.modal-btns button { padding: 12px 24px; border: none; border-radius: 10px; font-size: 1em; cursor: pointer; transition: all 0.2s; }
.btn-primary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; }
.btn-secondary { background: #f0f0f0; color: #333; }
.modal-btns button:hover { transform: translateY(-2px); }

/* Theme Toggle Switch */
.theme-switch { position: fixed; top: 20px; right: 20px; cursor: pointer; z-index: 100; }
.switch-track { width: 60px; height: 30px; background: #e0e0e0; border-radius: 15px; padding: 2px; transition: background 0.3s cubic-bezier(0.4, 0.0, 0.2, 1); box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
.switch-thumb { width: 26px; height: 26px; background: #fff; border-radius: 50%; transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1); display: flex; align-items: center; justify-content: center; position: relative; }
.switch-thumb .icon { position: absolute; font-size: 14px; transition: opacity 0.3s cubic-bezier(0.4, 0.0, 0.2, 1); }
.switch-thumb .sun { opacity: 1; }
.switch-thumb .moon { opacity: 0; }
body.dark .switch-track { background: #4a4a6a; }
body.dark .switch-thumb { background: #2d2d5a; transform: translateX(30px); }
body.dark .switch-thumb .sun { opacity: 0; }
body.dark .switch-thumb .moon { opacity: 1; }

/* Dark Mode */
body.dark { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); }
body.dark .container { background: #1e1e3f; color: white; }
body.dark h1 .dash { color: #888; }
body.dark label { color: #aaa; }
body.dark select { background: #2d2d5a; color: white; border-color: #444; }
body.dark .status { background: #2d2d5a; color: #a78bfa; }
body.dark .score { background: #2d2d5a; }
body.dark .score span { color: #aaa; }
body.dark .score b { color: white; }
body.dark .modal-content { background: #1e1e3f; color: white; }
body.dark .modal h2 { color: white; }
body.dark .modal p { color: #aaa; }
body.dark .btn-secondary { background: #2d2d5a; color: white; } body.dark .cell { background: #2d2d5a; border: 1px solid #444; } body.dark .cell:hover:not(.taken) { background: #3d3d7a; } body.dark .cell.x { color: #ff6b6b; text-shadow: 0 0 10px #ff6b6b, 0 0 20px #ff6b6b, 0 0 30px #ff4757; } body.dark .cell.o { color: #4ecdc4; text-shadow: 0 0 10px #4ecdc4, 0 0 20px #4ecdc4, 0 0 30px #00d2d3; }

@media (max-width: 400px) {
  .container { padding: 20px; }
  h1 { font-size: 2em; }
  .cell { font-size: 2em; }
  .theme-switch { top: 10px; right: 10px; }
  .switch-track { width: 50px; height: 26px; }
  .switch-thumb { width: 22px; height: 22px; }
  body.dark .switch-thumb { transform: translateX(24px); }
}