/* ========================================
   Open Chesssle — 'Midnight Chess Club' Theme
   Premium Dark Mode with Gold Accents
   ======================================== */

/* --- CSS Custom Properties --- */
:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #12122a;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --accent-gold: #d4a843;
  --accent-gold-hover: #e8bc5a;
  --accent-gold-glow: rgba(212, 168, 67, 0.25);
  --green-correct: #538d4e;
  --yellow-present: #b59f3b;
  --grey-absent: #3a3a4c;
  --board-light: #b8a47c;
  --board-dark: #6b5b3e;
  --board-selected: rgba(212, 168, 67, 0.5);
  --board-legal-move: rgba(212, 168, 67, 0.3);
  --glass-blur: blur(20px);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px var(--accent-gold-glow);
}

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  line-height: 1.6;
}

/* --- Animated background dot pattern --- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 30px 30px;
  pointer-events: none;
  z-index: 0;
}

/* Subtle floating orbs for depth */
body::after {
  content: '';
  position: fixed;
  top: -200px;
  right: -200px;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 168, 67, 0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  animation: floatOrb 20s ease-in-out infinite;
}

@keyframes floatOrb {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(-50px, 80px) scale(1.1); }
  50% { transform: translate(30px, 120px) scale(0.95); }
  75% { transform: translate(-20px, 40px) scale(1.05); }
}

/* ========================================
   LAYOUT & SCREENS
   ======================================== */

.app-container {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  opacity: 0;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
}

.screen.active {
  display: flex;
  opacity: 1;
  animation: fadeIn 0.4s ease forwards;
}

/* ========================================
   GLASS CARDS
   ======================================== */

.glass-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 24px;
  transition: var(--transition);
}

.glass-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-md);
}

.glass-card-static {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 24px;
}

/* ========================================
   BUTTONS
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.btn:hover::after {
  opacity: 1;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-hover));
  color: #1a1a2e;
  box-shadow: 0 4px 15px var(--accent-gold-glow);
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 25px var(--accent-gold-glow), var(--shadow-glow);
  filter: brightness(1.1);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  filter: none;
}

.btn-primary:disabled:hover {
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
  transform: scale(1.1);
}

.btn-back {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-back:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.btn-large {
  padding: 16px 32px;
  font-size: 1.1rem;
  border-radius: var(--radius);
}

/* ========================================
   HOME SCREEN
   ======================================== */

#home-screen {
  justify-content: center;
  align-items: center;
  text-align: center;
  padding-top: 60px;
  gap: 16px;
}

.home-header {
  position: relative;
  margin-bottom: 8px;
}

.lang-toggle-wrapper {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
}

#lang-toggle {
  font-size: 0.85rem;
  padding: 8px 16px;
}

.home-icon {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 12px;
  animation: crownFloat 3s ease-in-out infinite;
}

@keyframes crownFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.home-title {
  font-size: 3.2rem;
  font-weight: 900;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--accent-gold) 0%, #f0d78c 50%, var(--accent-gold) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 4s linear infinite;
  line-height: 1.1;
}

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

.home-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-top: 8px;
  margin-bottom: 32px;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 380px;
}

.home-actions .btn {
  width: 100%;
  justify-content: center;
}

.home-actions .btn-primary {
  padding: 18px 32px;
  font-size: 1.15rem;
}

/* Private key inline input group */
.private-key-group {
  display: none;
  flex-direction: row;
  gap: 8px;
  width: 100%;
  animation: fadeIn 0.3s ease;
}

.private-key-group.active {
  display: flex;
}

.private-key-group input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', monospace;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 4px;
  text-align: center;
  outline: none;
  transition: var(--transition);
}

.private-key-group input::placeholder {
  letter-spacing: 0;
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.private-key-group input:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px var(--accent-gold-glow);
}

.home-footer {
  margin-top: 48px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  opacity: 0.7;
}

/* Decorative background chess pieces */
.home-decor {
  position: absolute;
  pointer-events: none;
  z-index: -1;
}

.home-decor-left {
  top: 10%;
  left: 5%;
  font-size: 8rem;
  opacity: 0.03;
  transform: rotate(-15deg);
}

.home-decor-right {
  bottom: 15%;
  right: 5%;
  font-size: 10rem;
  opacity: 0.03;
  transform: rotate(10deg);
}

/* ========================================
   GAME SCREEN
   ======================================== */

#game-screen {
  padding-top: 20px;
  gap: 20px;
}

.game-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 4px;
}

.game-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

#attempt-counter {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-gold);
  background: var(--bg-card);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
}

#turn-indicator {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

#turn-indicator .turn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

#turn-indicator .turn-dot.white {
  background: #f0f0f0;
  border: 1px solid rgba(0,0,0,0.2);
}

#turn-indicator .turn-dot.black {
  background: #333;
  border: 1px solid rgba(255,255,255,0.2);
}

.game-layout {
  display: flex;
  gap: 32px;
  width: 100%;
  align-items: flex-start;
}

.game-left {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.game-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* --- Chess Board --- */
.chess-board-wrapper {
  position: relative;
  width: 100%;
  max-width: 480px;
}

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1;
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 2px solid rgba(255, 255, 255, 0.06);
}

.chess-square {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
  user-select: none;
}

.chess-square.light {
  background: var(--board-light);
}

.chess-square.dark {
  background: var(--board-dark);
}

.chess-square.selected {
  background: var(--board-selected) !important;
}

.chess-square.last-move {
  background: rgba(212, 168, 67, 0.2) !important;
}

.chess-square.legal-move::after {
  content: '';
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: var(--board-legal-move);
  pointer-events: none;
}

.chess-square.legal-capture::after {
  content: '';
  position: absolute;
  width: 85%;
  height: 85%;
  border-radius: 50%;
  border: 3px solid var(--board-legal-move);
  background: transparent;
  pointer-events: none;
}

.chess-square:hover {
  filter: brightness(1.1);
}

/* --- Chess Pieces --- */
.chess-piece {
  width: 85%;
  height: 85%;
  filter: drop-shadow(1px 2px 3px rgba(0, 0, 0, 0.4));
  cursor: grab;
  transition: transform 0.15s ease;
  pointer-events: none;
  user-select: none;
}

.chess-piece:active {
  cursor: grabbing;
}

.chess-square:hover .chess-piece {
  transform: scale(1.05);
}

/* Board coordinate labels */
.board-coords {
  position: absolute;
  font-size: 0.65rem;
  font-weight: 600;
  pointer-events: none;
  opacity: 0.6;
}

.board-coords.file {
  bottom: 2px;
  right: 4px;
}

.board-coords.rank {
  top: 2px;
  left: 4px;
}

.chess-square.light .board-coords { color: var(--board-dark); }
.chess-square.dark .board-coords { color: var(--board-light); }

/* --- Current Moves Row --- */
#current-moves {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
}

.current-move-tile {
  width: 50px;
  height: 40px;
  border-radius: var(--radius-xs);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-primary);
  transition: var(--transition);
}

.current-move-tile.filled {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.current-move-tile.active-tile {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px var(--accent-gold-glow);
  animation: tileActivePulse 2s ease-in-out infinite;
}

@keyframes tileActivePulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--accent-gold-glow); }
  50% { box-shadow: 0 0 0 4px rgba(212, 168, 67, 0.15); }
}

/* --- Action Buttons Row --- */
.game-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.autofill-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* --- Feedback Grid --- */
.feedback-section {
  width: 100%;
}

.feedback-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#feedback-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.feedback-row {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
}

.feedback-tile {
  width: 100%;
  aspect-ratio: 1.15;
  max-height: 44px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  transition: var(--transition);
  perspective: 600px;
  position: relative;
  overflow: hidden;
}

.feedback-tile.correct {
  background: var(--green-correct);
  border-color: var(--green-correct);
  color: #fff;
}

.feedback-tile.present {
  background: var(--yellow-present);
  border-color: var(--yellow-present);
  color: #fff;
}

.feedback-tile.absent {
  background: var(--grey-absent);
  border-color: var(--grey-absent);
  color: rgba(255, 255, 255, 0.7);
}

.feedback-tile.revealing {
  animation: flipIn 0.6s ease forwards;
}

@keyframes flipIn {
  0% { transform: perspective(600px) rotateX(0deg); }
  50% { transform: perspective(600px) rotateX(90deg); }
  100% { transform: perspective(600px) rotateX(0deg); }
}

/* Staggered reveal delays */
.feedback-tile.reveal-delay-1 { animation-delay: 0.1s; }
.feedback-tile.reveal-delay-2 { animation-delay: 0.2s; }
.feedback-tile.reveal-delay-3 { animation-delay: 0.3s; }
.feedback-tile.reveal-delay-4 { animation-delay: 0.4s; }
.feedback-tile.reveal-delay-5 { animation-delay: 0.5s; }
.feedback-tile.reveal-delay-6 { animation-delay: 0.6s; }
.feedback-tile.reveal-delay-7 { animation-delay: 0.7s; }
.feedback-tile.reveal-delay-8 { animation-delay: 0.8s; }
.feedback-tile.reveal-delay-9 { animation-delay: 0.9s; }

/* --- Hint Section --- */
.hint-section {
  width: 100%;
}

.hint-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hint-buttons .btn {
  flex: 1;
  min-width: 180px;
}

/* ========================================
   CREATE SCREEN
   ======================================== */

#create-screen {
  padding-top: 20px;
  gap: 20px;
  max-width: 900px;
}

.create-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
}

.create-title {
  font-size: 1.6rem;
  font-weight: 700;
}

/* --- Tabs --- */
.tab-group {
  display: flex;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 4px;
  width: 100%;
}

.tab {
  flex: 1;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  border: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.tab.active {
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-hover));
  color: #1a1a2e;
  font-weight: 600;
  box-shadow: 0 2px 10px var(--accent-gold-glow);
}

/* --- Create Panels --- */
.create-panel {
  display: none;
  width: 100%;
  animation: fadeIn 0.3s ease;
}

.create-panel.active {
  display: block;
}

.create-panel-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.create-board-section {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.create-board-wrapper {
  flex: 0 0 auto;
  max-width: 360px;
  width: 100%;
}

.create-sidebar {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

#create-move-list {
  min-height: 80px;
  padding: 16px;
  font-size: 0.85rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

#create-move-list .move-number {
  color: var(--text-secondary);
  font-weight: 400;
}

#create-move-list .move-san {
  color: var(--text-primary);
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  transition: var(--transition);
}

#create-move-list .move-san:hover {
  background: var(--bg-card-hover);
}

.create-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.create-note {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
  padding: 8px 12px;
  background: rgba(212, 168, 67, 0.05);
  border-left: 2px solid var(--accent-gold);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

/* --- Form Inputs --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

input[type="text"],
input[type="url"],
textarea {
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
  width: 100%;
}

input[type="text"]:focus,
input[type="url"]:focus,
textarea:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px var(--accent-gold-glow);
}

input[type="text"]::placeholder,
input[type="url"]::placeholder,
textarea::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
}

/* Import preview / PGN preview */
#import-preview,
#pgn-preview {
  min-height: 60px;
  padding: 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-style: dashed;
  border-color: var(--border-subtle);
}

/* --- Toggle Switch --- */
.toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--grey-absent);
  border-radius: 13px;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  outline: none;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toggle-switch:checked {
  background: var(--accent-gold);
}

.toggle-switch:checked::after {
  left: 25px;
}

/* ========================================
   RESULT SCREEN
   ======================================== */

#result-screen {
  justify-content: center;
  align-items: center;
  text-align: center;
  padding-top: 40px;
  gap: 20px;
}

#result-emoji {
  font-size: 5rem;
  animation: resultBounce 0.8s ease;
}

@keyframes resultBounce {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.3); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}

#result-title {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-gold), #f0d78c);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

#result-attempts {
  font-size: 1rem;
  color: var(--text-secondary);
}

.result-answer-section {
  width: 100%;
  max-width: 560px;
}

.result-answer-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

#result-answer {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
}

#result-answer .feedback-tile {
  background: var(--green-correct);
  border-color: var(--green-correct);
  color: #fff;
  width: 50px;
  max-height: 44px;
}

.result-board-wrapper {
  max-width: 320px;
  width: 100%;
}

#source-link {
  color: var(--accent-gold);
  text-decoration: none;
  font-size: 0.85rem;
  transition: var(--transition);
}

#source-link:hover {
  color: var(--accent-gold-hover);
  text-decoration: underline;
}

/* Collapsible PGN */
.pgn-collapsible {
  width: 100%;
  max-width: 560px;
}

.pgn-collapsible summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 8px 0;
  transition: var(--transition);
  list-style: none;
}

.pgn-collapsible summary::before {
  content: '▸ ';
}

.pgn-collapsible[open] summary::before {
  content: '▾ ';
}

.pgn-collapsible summary:hover {
  color: var(--text-primary);
}

#result-pgn {
  padding: 16px;
  margin-top: 8px;
  font-size: 0.8rem;
  font-family: 'Inter', monospace;
  line-height: 1.8;
  color: var(--text-secondary);
  word-break: break-word;
}

.result-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ========================================
   MODALS
   ======================================== */

.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 1;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  position: relative;
  z-index: 2;
  max-width: 500px;
  width: 100%;
  animation: scaleIn 0.3s ease;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  line-height: 1;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  transform: rotate(90deg);
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding-right: 40px;
}

.modal-body {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* --- Key Modal --- */
#key-display-value {
  font-family: 'Courier New', 'Consolas', monospace;
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--accent-gold);
  text-align: center;
  padding: 24px;
  margin: 16px 0;
  background: rgba(212, 168, 67, 0.08);
  border: 1px dashed var(--accent-gold);
  border-radius: var(--radius);
  user-select: all;
}

#key-copied-feedback {
  font-size: 0.85rem;
  color: var(--green-correct);
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  margin-top: 8px;
}

#key-copied-feedback.visible {
  opacity: 1;
}

.key-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

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

#toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 12px 24px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  animation: slideUp 0.4s ease, fadeOut 0.4s ease 2.6s forwards;
  pointer-events: auto;
  white-space: nowrap;
}

.toast.success {
  border-color: var(--green-correct);
  box-shadow: 0 4px 20px rgba(83, 141, 78, 0.2);
}

.toast.error {
  border-color: #e74c3c;
  box-shadow: 0 4px 20px rgba(231, 76, 60, 0.2);
}

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

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

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

/* Staggered child animations */
.stagger-in > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-in > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-in > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-in > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-in > *:nth-child(5) { animation-delay: 0.25s; }

/* ========================================
   UTILITIES
   ======================================== */

.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-secondary {
  color: var(--text-secondary);
}

.mt-1 {
  margin-top: 8px;
}

.mt-2 {
  margin-top: 16px;
}

.mt-3 {
  margin-top: 24px;
}

.mb-1 {
  margin-bottom: 8px;
}

.mb-2 {
  margin-bottom: 16px;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gap-1 {
  gap: 8px;
}

.gap-2 {
  gap: 16px;
}

.w-full {
  width: 100%;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Selection styling */
::selection {
  background: var(--accent-gold);
  color: #1a1a2e;
}

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

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

/* Tablet breakpoint */
@media (max-width: 900px) {
  .game-layout {
    flex-direction: column;
    align-items: center;
  }

  .game-left {
    width: 100%;
    max-width: 480px;
  }

  .game-right {
    width: 100%;
  }

  .create-board-section {
    flex-direction: column;
    align-items: center;
  }

  .create-board-wrapper {
    max-width: 100%;
  }
}

/* Mobile breakpoint */
@media (max-width: 768px) {
  html {
    font-size: 15px;
  }

  .screen {
    padding: 16px;
  }

  .home-title {
    font-size: 2.4rem;
  }

  .home-subtitle {
    font-size: 0.95rem;
  }

  .home-icon {
    font-size: 2.8rem;
  }

  .chess-board {
    max-width: 100%;
  }

  .feedback-tile {
    font-size: 0.55rem;
    max-height: 36px;
  }

  .current-move-tile {
    width: 42px;
    height: 34px;
    font-size: 0.6rem;
  }

  .glass-card,
  .glass-card-static {
    padding: 16px;
  }

  .btn {
    padding: 10px 18px;
    font-size: 0.85rem;
  }

  .btn-large {
    padding: 14px 24px;
    font-size: 1rem;
  }

  .tab {
    padding: 8px 12px;
    font-size: 0.75rem;
  }

  .modal-content {
    margin: 16px;
  }

  #key-display-value {
    font-size: 1.8rem;
    letter-spacing: 5px;
    padding: 16px;
  }

  .game-actions {
    gap: 6px;
  }

  .hint-buttons {
    flex-direction: column;
  }

  .hint-buttons .btn {
    min-width: unset;
  }
}

/* Small mobile breakpoint */
@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  .home-title {
    font-size: 2rem;
  }

  .home-actions {
    max-width: 100%;
  }

  .feedback-tile {
    font-size: 0.5rem;
    max-height: 30px;
    border-radius: 4px;
  }

  .feedback-row {
    gap: 2px;
  }

  .current-move-tile {
    width: 34px;
    height: 30px;
    font-size: 0.55rem;
    border-radius: 4px;
  }

  #current-moves {
    gap: 2px;
  }

  .tab-group {
    flex-wrap: wrap;
  }

  .tab {
    flex: 0 0 auto;
    padding: 8px 14px;
  }

  .create-actions {
    flex-direction: column;
  }

  .create-actions .btn {
    width: 100%;
  }

  .result-actions {
    flex-direction: column;
    width: 100%;
  }

  .result-actions .btn {
    width: 100%;
  }

  #result-emoji {
    font-size: 3.5rem;
  }

  #result-title {
    font-size: 1.6rem;
  }
}

/* ========================================
   PRINT STYLES (just in case)
   ======================================== */
@media print {
  body {
    background: #fff;
    color: #000;
  }

  .glass-card,
  .glass-card-static {
    background: #f5f5f5;
    border: 1px solid #ddd;
    backdrop-filter: none;
  }

  .btn {
    border: 1px solid #999;
  }

  .modal,
  #toast-container {
    display: none !important;
  }
}

/* ========================================
   ADDITIONAL JS-GENERATED BOARD STYLES
   ======================================== */

/* The BoardUI JS creates a .chess-board-inner grid inside the container */
.chess-board-inner {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
}

/* Square coordinate labels generated by JS */
.sq-label {
  position: absolute;
  font-size: 0.6rem;
  font-weight: 700;
  pointer-events: none;
  opacity: 0.55;
  line-height: 1;
  user-select: none;
}
.sq-label.file-label {
  bottom: 2px;
  right: 4px;
}
.sq-label.rank-label {
  top: 2px;
  left: 4px;
}
.chess-square.light .sq-label { color: var(--board-dark); }
.chess-square.dark .sq-label  { color: var(--board-light); }

/* Non-interactive board override */
.non-interactive .chess-square { cursor: default; }
.non-interactive .chess-square:hover { filter: none; }
.non-interactive .chess-square:hover .chess-piece { transform: none; }

/* Hint board inside modal */
.hint-board-container {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}
.hint-board-container .chess-board-inner {
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

/* Move 7 hint display */
.hint-move7 {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 0;
}
.hint-move7-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.1rem;
}
.hint-move7-label {
  color: var(--text-secondary);
  font-weight: 500;
}
.hint-move7-value {
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--accent-gold);
}

/* Current move tiles: white/black indicators */
.current-move-tile.w-move {
  border-bottom: 2px solid rgba(255,255,255,0.3);
}
.current-move-tile.b-move {
  border-bottom: 2px solid rgba(80,80,100,0.5);
}

/* Turn indicator styling */
.turn-indicator { display: flex; align-items: center; gap: 6px; }
.turn-dot {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block;
}
.turn-dot.white { background: #fff; border: 1px solid #999; }
.turn-dot.black { background: #333; border: 1px solid #666; }
.turn-dot.ready { background: var(--accent-gold); border: 1px solid var(--accent-gold-hover); animation: pulse 1.5s infinite; }

/* Submit button glow when ready */
#submit-guess-btn.ready {
  box-shadow: var(--shadow-glow);
  animation: pulse 2s ease-in-out infinite;
}

/* Create screen: move list */
.move-list-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: baseline;
}
.move-number {
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-left: 4px;
}
.move-san {
  font-weight: 600;
  font-size: 0.9rem;
  padding: 2px 6px;
  border-radius: 4px;
}
.move-san.w-move { background: rgba(255,255,255,0.08); }
.move-san.b-move { background: rgba(0,0,0,0.2); }

/* Import preview */
.import-success h4 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.import-success p { margin-bottom: 4px; }
.move-preview {
  font-family: 'Inter', monospace;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent-gold);
  line-height: 1.8;
}
.loading-spinner {
  text-align: center;
  color: var(--text-secondary);
  padding: 20px;
}
.error-msg {
  text-align: center;
  color: #e57373;
  padding: 12px;
  background: rgba(229,115,115,0.1);
  border-radius: var(--radius-sm);
}

/* Result screen board */
.result-board-wrapper {
  max-width: 320px;
  margin: 0 auto;
}
.result-board-wrapper .chess-board-inner {
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

/* Result answer row */
#result-answer {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}
#result-answer .feedback-tile {
  width: 50px;
  height: 38px;
  aspect-ratio: auto;
}

/* Bounce animation for result emoji */
.result-bounce {
  animation: resultBounce 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
@keyframes resultBounce {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.15); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}

/* Key display */
#key-display-value {
  font-family: 'Inter', monospace;
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: 8px;
  color: var(--accent-gold);
  padding: 20px;
  margin: 16px 0;
  background: rgba(212,168,67,0.08);
  border-radius: var(--radius);
  border: 2px dashed rgba(212,168,67,0.3);
}

#key-copied-feedback {
  opacity: 0;
  transition: opacity 0.3s ease;
  color: var(--green-correct);
  font-size: 0.85rem;
  margin-top: 8px;
}

.key-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

/* Pulse keyframe (if not already defined) */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

