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

:root {
  --bg-dark: #1a1a2e;
  --bg-card: #16213e;
  --bg-panel: #0f3460;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --text: #eee;
  --text-muted: #a0a0b0;
  --success: #2ecc71;
  --error: #e74c3c;
  --border: #2a2a4a;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
}

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 2rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}

.nav-icon {
  font-size: 1.6rem;
}

.nav-links {
  display: flex;
  gap: 0.5rem;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: all 0.2s;
  font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: var(--bg-panel);
}

/* Pages */
.page {
  display: none;
}

.page.active {
  display: block;
}

/* Hero */
.hero {
  text-align: center;
  padding: 4rem 2rem 2rem;
}

.hero h1 {
  font-size: 3rem;
  margin-bottom: 0.8rem;
  background: linear-gradient(135deg, var(--accent), #ff9a56);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1.2rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 2rem;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Features */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  padding: 2rem;
  max-width: 900px;
  margin: 0 auto;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  transition: transform 0.2s, border-color 0.2s;
}

.feature-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
}

.feature-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.feature-card h3 {
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.feature-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-panel);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  margin-top: 0.4rem;
}

/* Page Content Layout */
.page-content {
  display: flex;
  gap: 2rem;
  padding: 2rem;
  max-width: 1100px;
  margin: 0 auto;
  align-items: flex-start;
}

/* Board */
.board-container {
  flex-shrink: 0;
}

.chess-board {
  width: 480px;
  height: 480px;
}

.board-controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* Side Panel */
.side-panel {
  flex: 1;
  min-width: 250px;
}

.side-panel h2 {
  margin-bottom: 1.2rem;
  color: var(--accent);
  font-size: 1.5rem;
}

/* Settings */
.settings-group {
  margin-bottom: 1rem;
}

.settings-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  font-weight: 500;
}

.settings-group select,
.fen-input {
  width: 100%;
  padding: 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
}

.fen-input {
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
}

/* Status Box */
.status-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
}

.status-box.success {
  border-color: var(--success);
  background: rgba(46, 204, 113, 0.1);
}

.status-box.error {
  border-color: var(--error);
  background: rgba(231, 76, 60, 0.1);
}

/* Info Box */
.info-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.puzzle-title {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 0.3rem;
}

.puzzle-rating,
.puzzle-theme {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Stats */
.stats-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
}

.stats-box h3 {
  margin-bottom: 0.8rem;
  font-size: 1rem;
  color: var(--text-muted);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
  border-bottom: none;
}

/* Move List */
.move-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
  max-height: 300px;
  overflow-y: auto;
}

.move-list h3 {
  margin-bottom: 0.5rem;
  font-size: 1rem;
  color: var(--text-muted);
}

.move-entry {
  display: inline-block;
  padding: 0.2rem 0.4rem;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
}

.move-number {
  color: var(--text-muted);
  margin-right: 0.2rem;
}

/* Responsive */
@media (max-width: 800px) {
  .page-content {
    flex-direction: column;
    align-items: center;
  }

  .chess-board {
    width: 340px;
    height: 340px;
  }

  .side-panel {
    width: 100%;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .navbar {
    flex-direction: column;
    gap: 0.5rem;
  }
}

@media (max-width: 400px) {
  .chess-board {
    width: 280px;
    height: 280px;
  }
}

/* My Games Page */
.mygames-layout {
  flex-direction: row;
}

.mygames-left {
  width: 320px;
  flex-shrink: 0;
}

.mygames-right {
  flex: 1;
  min-width: 0;
}

.input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.input-row .fen-input {
  flex: 1;
}

.games-list {
  margin-top: 1rem;
  max-height: 500px;
  overflow-y: auto;
}

.game-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.game-card:hover,
.game-card.active {
  border-color: var(--accent);
  background: var(--bg-panel);
}

.game-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}

.game-card-type {
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 600;
}

.game-card-result {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.game-card-result.win {
  background: rgba(46, 204, 113, 0.2);
  color: var(--success);
}

.game-card-result.loss {
  background: rgba(231, 76, 60, 0.2);
  color: var(--error);
}

.game-card-result.draw {
  background: rgba(160, 160, 176, 0.2);
  color: var(--text-muted);
}

.game-card-players {
  font-size: 0.9rem;
  font-weight: 500;
}

.game-card-players .you {
  color: var(--accent);
}

.game-card-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.game-card-tactics {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.tactic-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 0.3rem;
}

.tactic-detail,
.tactic-move-context {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.loading-spinner {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

@media (max-width: 800px) {
  .mygames-layout {
    flex-direction: column;
  }

  .mygames-left {
    width: 100%;
  }
}

/* Highlight squares */
.highlight-hint {
  box-shadow: inset 0 0 3px 3px rgba(255, 255, 0, 0.6);
}

.highlight-correct {
  box-shadow: inset 0 0 3px 3px rgba(46, 204, 113, 0.6);
}

.highlight-wrong {
  box-shadow: inset 0 0 3px 3px rgba(231, 76, 60, 0.6);
}
