/**
 * SCDev Chess - Core Stylesheet
 */

:root {
  --scdc-bg-dark: #071510;
  --scdc-felt: #0c3323;
  --scdc-felt-dark: #072519;
  --scdc-sq-light: #ececd0;
  --scdc-sq-dark: #739552;
  --scdc-sq-highlight: rgba(245, 158, 11, 0.55);
  --scdc-sq-lastmove: rgba(255, 255, 0, 0.45);
  --scdc-sq-check: rgba(239, 68, 68, 0.7);
  --scdc-gold: #fbbf24;
  --scdc-text: #f8fafc;
  --scdc-text-muted: #94a3b8;
}

.scdc-app {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  color: var(--scdc-text);
  background: var(--scdc-bg-dark);
  border-radius: 18px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 16px;
  box-sizing: border-box;
}

/* Toolbar */
.scdc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(12, 51, 35, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.scdc-toolbar-title {
  font-size: 18px;
  font-weight: 900;
  color: var(--scdc-gold);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.5px;
}

.scdc-toolbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.scdc-label-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #cbd5e1;
}

.scdc-label-inline select {
  background: #0f2c1f;
  color: #ffffff;
  border: 1px solid #10b981;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* Buttons */
.scdc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  line-height: 1;
}

.scdc-btn-primary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.scdc-btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.scdc-btn-accent {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.scdc-btn-secondary {
  background: #1e293b;
  color: #cbd5e1 !important;
  border: 1px solid #334155;
}

.scdc-btn-danger {
  background: #dc2626;
  color: #ffffff !important;
}

.scdc-btn-subtle {
  background: transparent;
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.scdc-btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

.scdc-btn-xs {
  padding: 4px 8px;
  font-size: 11px;
}

/* Main Layout */
.scdc-main-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 820px) {
  .scdc-main-layout {
    grid-template-columns: 1fr;
  }
}

/* Board Wrapper */
.scdc-board-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* Player Card */
.scdc-player-card {
  width: 100%;
  max-width: 480px;
  background: rgba(15, 44, 31, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  box-sizing: border-box;
}

.scdc-player-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.scdc-player-meta {
  flex: 1;
  min-width: 0;
}

.scdc-player-name {
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scdc-captured-tray {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 14px;
  min-height: 18px;
  margin-top: 2px;
}

.scdc-turn-indicator {
  background: #10b981;
  color: #000000;
  font-size: 10px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 6px;
  animation: scdcPulse 1s infinite alternate;
}

@keyframes scdcPulse {
  0% { opacity: 0.85; transform: scale(0.96); }
  100% { opacity: 1; transform: scale(1.04); }
}

/* Board Frame & Chessboard Grid */
.scdc-board-frame {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1 / 1;
  background: #2b1f14;
  padding: 8px;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7);
  box-sizing: border-box;
}

.scdc-board {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 6px;
  overflow: hidden;
  user-select: none;
}

/* Squares */
.scdc-square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-sizing: border-box;
}

.scdc-square.light { background-color: var(--scdc-sq-light); }
.scdc-square.dark { background-color: var(--scdc-sq-dark); }

.scdc-square.selected {
  background-color: var(--scdc-sq-highlight) !important;
}

.scdc-square.last-move {
  background-color: var(--scdc-sq-lastmove) !important;
}

.scdc-square.in-check {
  background: radial-gradient(circle, rgba(239, 68, 68, 1) 0%, var(--scdc-sq-check) 70%) !important;
}

/* Legal Move Marker */
.scdc-square.legal-move::after {
  content: '';
  width: 24%;
  height: 24%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.scdc-square.legal-capture::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 4px solid rgba(0, 0, 0, 0.28);
  border-radius: 50%;
  background: transparent;
  pointer-events: none;
}

/* Chess Pieces */
.scdc-piece {
  font-size: clamp(28px, 6vw, 44px);
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
  transition: transform 0.15s ease;
}

.scdc-piece.w {
  color: #ffffff;
  text-shadow: 0 0 2px #000, 0 0 3px #000;
}

.scdc-piece.b {
  color: #1a1a1a;
  text-shadow: 0 0 1px #fff;
}

/* Announcer */
.scdc-announcer {
  font-size: 14px;
  font-weight: 800;
  color: #fef08a;
  text-align: center;
  min-height: 22px;
  margin-top: 4px;
}

/* Side Panel */
.scdc-side-panel {
  background: rgba(12, 51, 35, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  height: 480px;
  box-sizing: border-box;
}

.scdc-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.scdc-panel-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--scdc-gold);
}

.scdc-moves-ledger {
  flex: 1;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scdc-moves-empty {
  font-size: 12px;
  color: var(--scdc-text-muted);
  text-align: center;
  margin-top: 40px;
}

.scdc-move-row {
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 4px;
}

.scdc-move-row:nth-child(odd) {
  background: rgba(255, 255, 255, 0.03);
}

.scdc-move-num {
  width: 32px;
  color: var(--scdc-text-muted);
}

.scdc-move-white, .scdc-move-black {
  flex: 1;
  padding: 2px 4px;
  border-radius: 4px;
}

.scdc-move-white.active, .scdc-move-black.active {
  background: rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}

.scdc-side-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* Modals */
.scdc-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.scdc-modal[hidden] {
  display: none !important;
}

.scdc-modal-card {
  background: linear-gradient(135deg, #0e3020 0%, #071c13 100%);
  border: 2px solid #10b981;
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  text-align: center;
}

.scdc-modal-title {
  font-size: 20px;
  font-weight: 900;
  color: var(--scdc-gold);
  margin-bottom: 12px;
}

.scdc-modal-body {
  font-size: 15px;
  color: #e2e8f0;
  margin-bottom: 20px;
  line-height: 1.5;
}

.scdc-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.scdc-promo-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.scdc-promo-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid #10b981;
  border-radius: 10px;
  color: #ffffff;
  padding: 12px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
}

.scdc-promo-btn:hover {
  background: #10b981;
  color: #000000;
  transform: scale(1.04);
}
