/* ============================================================
   Extreme Chess Pro — Custom Theme
   ============================================================ */

:root {
  --bg-primary:   #1c1c1e;
  --bg-surface:   #2c2c2e;
  --bg-card:      #3a3a3c;
  --accent:       #c9a84c;
  --accent-dark:  #a8872e;
  --text-primary: #f5f5f5;
  --text-muted:   #8e8e93;
  --border:       #48484a;
  --danger:       #ff453a;
  --success:      #30d158;
}

/* Base */
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  margin: 0;
}

/* Typography */
h1, h2, h3, .chess-title {
  font-family: 'Cinzel', serif;
  letter-spacing: 0.03em;
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
  background: linear-gradient(180deg, #111111 0%, #1c1c1e 100%);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
}

.site-header h1 {
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0;
  line-height: 1.2;
  text-shadow: 0 0 20px rgba(201, 168, 76, 0.3);
}

.site-header h2 {
  font-family: 'Inter', sans-serif;
  font-size: 0.65rem;
  font-weight: 300;
  color: var(--text-muted);
  margin: 0;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.site-logo {
  filter: drop-shadow(0 0 8px rgba(201, 168, 76, 0.4));
}

/* ============================================================
   Auth Card
   ============================================================ */
.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.auth-card h2 {
  font-family: 'Cinzel', serif;
  font-size: 1.8rem;
  color: var(--accent);
  margin-bottom: 1.5rem;
}

/* Form inputs */
.chess-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  margin-bottom: 1rem;
}

.chess-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.15);
}

.chess-input::placeholder {
  color: var(--text-muted);
}

/* Buttons */
.btn-chess-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #111;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  font-weight: 600;
  width: 100%;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  letter-spacing: 0.05em;
}

.btn-chess-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-chess-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  width: 100%;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn-chess-secondary:hover {
  background: #4a4a4c;
  border-color: var(--accent);
}

.btn-chess-ai {
  background: linear-gradient(135deg, #3a3a9c 0%, #1e1e6e 100%);
  color: #fff;
  border: 1px solid #5555cc;
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  font-weight: 600;
  width: 100%;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  letter-spacing: 0.05em;
}

.btn-chess-ai:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.auth-link {
  color: var(--accent);
  text-decoration: none;
}

.auth-link:hover {
  text-decoration: underline;
  color: var(--accent);
}

.error-message {
  color: var(--danger);
  font-size: 0.875rem;
  margin-top: 0.25rem;
  min-height: 1.2em;
}

/* ============================================================
   Game Mode Selection
   ============================================================ */
.mode-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
}

.mode-card h2 {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.mode-card .subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* Time control pills */
.time-pill {
  display: inline-block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
  transition: all 0.2s;
}

.time-pill:hover,
.time-pill.active {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

/* ============================================================
   Modal overrides
   ============================================================ */
.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
}

.modal-header {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
}

.modal-title {
  font-family: 'Cinzel', serif;
  color: var(--accent);
  font-size: 1.1rem;
}

.modal-body {
  padding: 1.5rem;
}

.btn-close {
  filter: invert(1);
}

.modal-time-btn {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  width: 100%;
  margin-bottom: 0.75rem;
  text-align: left;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-time-btn:hover {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

.modal-time-btn .time-icon {
  font-size: 1.5rem;
}

.modal-time-btn .time-label {
  font-weight: 600;
  font-size: 1rem;
}

.modal-time-btn .time-sub {
  font-size: 0.8rem;
  opacity: 0.75;
}

.modal-diff-btn {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  width: 100%;
  margin-bottom: 0.75rem;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  transition: all 0.2s;
}

.modal-diff-btn:hover {
  background: #3a3a9c;
  border-color: #5555cc;
}

/* ============================================================
   Game Page — Player Info
   ============================================================ */
.player-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.5rem;
}

.player-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--border);
  object-fit: cover;
}

.player-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.player-rating {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.timer-block {
  background: #111;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-family: 'Cinzel', serif;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  min-width: 90px;
  letter-spacing: 0.05em;
  margin-left: auto;
}

/* ============================================================
   Game Page — Controls
   ============================================================ */
.game-controls {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin: 0.75rem 0;
}

.btn-game {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  margin-bottom: 0.5rem;
}

.btn-game:hover:not(:disabled):not(.disabled) {
  background: #4a4a4c;
  border-color: var(--accent);
  color: var(--accent);
}

.btn-game.disabled,
.btn-game:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-game.btn-new-game {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #111;
  font-weight: 600;
  border: none;
}

.btn-game.btn-new-game:hover:not(.disabled) {
  opacity: 0.85;
  color: #111;
}

/* Move log */
.move-log {
  background: #111;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  max-height: 120px;
  overflow-y: auto;
  font-family: 'Inter', monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

.move-log .status-label {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ============================================================
   Popups / Overlays
   ============================================================ */
.popup, .rematchPopup {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.popup-content, .rematchPopup-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 20% auto;
  padding: 2rem;
  width: min(90%, 400px);
  text-align: center;
  font-family: 'Cinzel', serif;
  color: var(--text-primary);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.popup-content p, .rematchPopup-content p {
  font-family: 'Inter', sans-serif;
  margin-bottom: 1.25rem;
  font-size: 1rem;
}

/* Captured pieces */
.white-captured-pieces img,
.black-captured-pieces img {
  width: 24px !important;
  height: 24px !important;
  display: inline-block;
  margin-right: 1px;
}

.white-captured-pieces span,
.black-captured-pieces span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  vertical-align: middle;
}

/* AI badge */
.ai-badge {
  display: inline-block;
  background: linear-gradient(135deg, #3a3a9c 0%, #1e1e6e 100%);
  color: #fff;
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  margin-left: 0.5rem;
  vertical-align: middle;
}

/* Footer */
footer {
  background: #111 !important;
  border-top: 1px solid var(--border);
  min-height: 40px;
  padding: 1rem 0 !important;
}

/* Chessboard */
img.piece-417db { width: auto !important; }

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