/* ===== Games Grid ===== */
.games-section {
  padding-top: var(--space-3xl);
  padding-bottom: var(--space-5xl);
}

.games-intro {
  max-width: 700px;
  margin: 0 auto var(--space-4xl);
  text-align: center;
}

.games-intro p {
  font-size: var(--fs-md);
  color: var(--color-text-light);
  line-height: var(--lh-loose);
}

.games-grid {
  display: grid;
  gap: var(--space-2xl);
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .games-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .games-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ===== Game Card ===== */
.game-card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-light);
  border-top: 3px solid var(--color-accent-warm);
  overflow: hidden;
  transition: all var(--transition-normal);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  position: relative;
}

.game-card::before {
  content: '♟';
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 2rem;
  color: var(--color-accent-warm);
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}

.game-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  border-color: var(--color-accent-warm);
  border-top-width: 4px;
}

.game-card:hover::before {
  opacity: 0.25;
}

.game-card__header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--color-border-light);
  position: relative;
  z-index: 1;
}

.game-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.game-card__date {
  font-size: var(--fs-xs);
  color: var(--color-text-light);
  font-weight: var(--fw-medium);
}

.game-card__result {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  background: var(--color-bg-alt);
}

.game-card__result--win {
  background: #d4edda;
  color: #155724;
}

.game-card__result--draw {
  background: #fff3cd;
  color: #856404;
}

.game-card__result--loss {
  background: #f8d7da;
  color: #721c24;
}

.game-card__title {
  font-family: var(--font-heading);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  margin-bottom: var(--space-xs);
  color: var(--color-text);
}

.game-card__opponent {
  font-size: var(--fs-sm);
  color: var(--color-text-light);
}

.game-card__body {
  padding: var(--space-lg);
  flex: 1;
}

.game-card__opening {
  font-size: var(--fs-sm);
  color: var(--color-text-light);
  margin-bottom: var(--space-md);
}

.game-card__opening-name {
  font-weight: var(--fw-semibold);
  color: var(--color-accent-warm);
}

.game-card__description {
  font-size: var(--fs-sm);
  color: var(--color-text-light);
  line-height: var(--lh-normal);
}

.game-card__footer {
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border-light);
  text-align: center;
}

.game-card__cta {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-accent-warm);
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.game-card:hover .game-card__cta {
  color: var(--color-accent-warm-light);
}

/* ===== Game Viewer Overlay ===== */
.game-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 9999;
  display: none;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.game-viewer.is-open {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}

.game-viewer__container {
  width: 100%;
  max-width: 1400px;
  height: 90vh;
  background: white;
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  margin: var(--space-lg);
}

.game-viewer__header {
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-bg-alt);
}

.game-viewer__title-section {
  flex: 1;
}

.game-viewer__title {
  font-family: var(--font-heading);
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  margin-bottom: var(--space-xs);
}

.game-viewer__subtitle {
  font-size: var(--fs-sm);
  color: var(--color-text-light);
}

.game-viewer__close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: white;
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 1.5rem;
  color: var(--color-text-light);
}

.game-viewer__close:hover {
  background: var(--color-accent-warm);
  color: white;
  border-color: var(--color-accent-warm);
  transform: rotate(90deg);
}

.game-viewer__content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ===== Board Panel ===== */
.game-viewer__board-panel {
  flex: 0 0 60%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: var(--space-2xl);
  background: var(--color-bg-alt);
  overflow-y: auto;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: visible;
  box-shadow: var(--shadow-xl);
  border: 3px solid var(--color-border);
  gap: 0;
  margin-bottom: var(--space-xl);
  flex-shrink: 0;
}

.game-board .sq {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  line-height: 1;
  user-select: none;
  aspect-ratio: 1;
  transition: background-color var(--transition-fast);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  font-weight: normal;
}

.game-board .sq--l {
  background: #f0d9b5;
}

.game-board .sq--d {
  background: #b58863;
}

/* White pieces: white fill with dark outline */
.game-board .sq--pw {
  color: #fff;
  -webkit-text-stroke: 1.5px #222;
  paint-order: stroke fill;
  text-shadow: none;
}

/* Black pieces: dark fill */
.game-board .sq--pb {
  color: #1a1a1a;
  -webkit-text-stroke: 0;
  text-shadow: none;
}

.game-board .sq--highlight {
  background: #baca44 !important;
}

/* ===== Navigation Controls ===== */
.game-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.game-controls__btn {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: white;
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 1.25rem;
  color: var(--color-text);
  font-weight: var(--fw-bold);
}

.game-controls__btn:hover:not(:disabled) {
  background: var(--color-accent-warm);
  color: white;
  border-color: var(--color-accent-warm);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.game-controls__btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.game-controls__status {
  padding: var(--space-sm) var(--space-lg);
  background: white;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  min-width: 120px;
  text-align: center;
}

/* ===== Info Panel ===== */
.game-viewer__info-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: white;
  border-left: 1px solid var(--color-border-light);
}

.game-viewer__tabs {
  display: flex;
  border-bottom: 2px solid var(--color-border-light);
}

.game-viewer__tab {
  flex: 1;
  padding: var(--space-md) var(--space-lg);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-text-light);
  transition: all var(--transition-fast);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}

.game-viewer__tab:hover {
  color: var(--color-text);
  background: var(--color-bg-alt);
}

.game-viewer__tab.is-active {
  color: var(--color-accent-warm);
  border-bottom-color: var(--color-accent-warm);
}

.game-viewer__tab-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
}

.game-viewer__tab-pane {
  display: none;
}

.game-viewer__tab-pane.is-active {
  display: block;
}

/* ===== Move List ===== */
.move-list {
  font-family: 'Courier New', monospace;
  font-size: var(--fs-sm);
}

.move-pair {
  display: flex;
  align-items: flex-start;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-xs);
  transition: background-color var(--transition-fast);
}

.move-pair:hover {
  background: var(--color-bg-alt);
}

.move-pair.is-current {
  background: var(--color-accent-warm);
  color: white;
}

.move-number {
  font-weight: var(--fw-bold);
  margin-right: var(--space-sm);
  color: var(--color-text-light);
  min-width: 30px;
}

.move-pair.is-current .move-number {
  color: rgba(255, 255, 255, 0.8);
}

.move-notation {
  flex: 1;
  display: flex;
  gap: var(--space-md);
}

.move-notation__move {
  cursor: pointer;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-xs);
  transition: all var(--transition-fast);
  min-width: 60px;
}

.move-notation__move:hover {
  background: rgba(0, 0, 0, 0.05);
}

.move-notation__move.is-active {
  background: var(--color-accent-warm);
  color: white;
  font-weight: var(--fw-bold);
  border-radius: var(--radius-sm);
}

.move-notation__move.has-comment {
  border-bottom: 2px solid var(--color-accent-warm);
}

.move-pair.is-current .move-notation__move.has-comment {
  border-bottom-color: rgba(255, 255, 255, 0.6);
}

.move-pair.is-current .move-notation__move {
  font-weight: var(--fw-bold);
}

/* ===== Comments Section ===== */
.comments-section h3 {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--space-md);
  color: var(--color-text);
}

.comment-item {
  background: var(--color-bg-alt);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--color-accent-warm);
  margin-bottom: var(--space-lg);
}

.comment-item__header {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-accent-warm);
  margin-bottom: var(--space-sm);
  font-family: 'Courier New', monospace;
}

.comment-item__text {
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
  color: var(--color-text);
}

.comment-empty {
  text-align: center;
  color: var(--color-text-light);
  padding: var(--space-2xl);
  font-style: italic;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .game-viewer__content {
    flex-direction: column;
  }

  .game-viewer__board-panel {
    flex: 0 0 auto;
    padding: var(--space-lg);
  }

  .game-board {
    max-width: 400px;
    margin-bottom: var(--space-lg);
  }

  .game-board .sq {
    font-size: 2.5rem;
  }

  .game-viewer__info-panel {
    border-left: none;
    border-top: 1px solid var(--color-border-light);
    min-height: 300px;
  }
}

@media (max-width: 768px) {
  .game-viewer__container {
    height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  .game-viewer__header {
    padding: var(--space-md) var(--space-lg);
  }

  .game-viewer__title {
    font-size: var(--fs-lg);
  }

  .game-board {
    max-width: 100%;
  }

  .game-board .sq {
    font-size: 2rem;
  }

  .game-controls__btn {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
}
