/* ===== Базовые настройки ===== */
:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --text-primary: #eaeaea;
  --text-secondary: #b8b8d1;
  --accent: #e94560;
  --accent-hover: #ff6b6b;
  --success: #4ade80;
  --warning: #fbbf24;
  --dice-bg: #2d2d44;
  --dice-border: #4a4a6a;
  --board-light: #eeeed2;
  --board-dark: #769656;
  --highlight: rgba(255, 255, 0, 0.4);
  --valid-move: rgba(100, 255, 100, 0.5);
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== Шапка ===== */
.game-header {
  background: var(--bg-secondary);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.game-header h1 {
  font-size: 1.8rem;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(233, 69, 96, 0.5);
}

.game-info {
  display: flex;
  gap: 1.5rem;
  font-size: 1.1rem;
}

#turn-indicator {
  font-weight: 600;
}

#status-message {
  color: var(--warning);
}

/* ===== Основная область ===== */
.game-area {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  gap: 1.5rem;
  padding: 1.5rem;
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ===== Панели ===== */
.control-panel,
.info-panel {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

.control-panel h3,
.info-panel h3,
.info-panel h4 {
  color: var(--accent);
  margin-bottom: 0.8rem;
  font-size: 1.2rem;
  border-bottom: 1px solid var(--bg-tertiary);
  padding-bottom: 0.5rem;
}

/* ===== Кубики ===== */
.dice-section {
  text-align: center;
}

.dice-container {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 1rem 0;
  min-height: 80px;
}

.die {
  width: 60px;
  height: 60px;
  background: var(--dice-bg);
  border: 3px solid var(--dice-border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
  color: var(--text-primary);
  transition: all 0.3s ease;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.die.rolling {
  animation: roll 0.6s ease-in-out;
}

@keyframes roll {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-15deg) scale(1.1); }
  50% { transform: rotate(10deg) scale(0.95); }
  75% { transform: rotate(-5deg) scale(1.05); }
}

.die.white-piece { color: #fff; text-shadow: 0 0 5px rgba(255,255,255,0.8); }
.die.black-piece { color: #333; background: #ccc; }

/* ===== Кнопки ===== */
.btn-primary,
.btn-secondary {
  width: 100%;
  padding: 0.8rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 0.5rem;
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(233, 69, 96, 0.4);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: #1a4a7a;
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Доступные ходы ===== */
.moves-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 60px;
}

.move-chip {
  background: var(--bg-tertiary);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: all 0.2s;
}

.move-chip:hover {
  background: var(--accent);
  transform: scale(1.05);
}

.move-chip.mandatory {
  border: 2px solid var(--warning);
}

.move-chip.optional {
  border: 2px dashed var(--text-secondary);
}

.hint {
  color: var(--text-secondary);
  font-style: italic;
  font-size: 0.9rem;
}

/* ===== Настройки ===== */
.settings-section label {
  display: block;
  margin: 0.5rem 0;
  cursor: pointer;
}

.settings-section select {
  width: 100%;
  padding: 0.4rem;
  margin-top: 0.3rem;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--dice-border);
  border-radius: 4px;
}

/* ===== Доска ===== */
.board-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

#chessboard {
  border: 4px solid var(--bg-tertiary);
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.board-controls {
  display: flex;
  gap: 1rem;
}

/* ===== История ходов ===== */
.move-history {
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 0.8rem;
  font-family: monospace;
  font-size: 0.95rem;
}

.move-history::-webkit-scrollbar {
  width: 6px;
}

.move-history::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}

.move-entry {
  padding: 0.2rem 0;
  border-bottom: 1px dashed var(--bg-secondary);
}

.move-entry:last-child {
  border-bottom: none;
}

.move-entry.white-move::before { content: "⚪ "; }
.move-entry.black-move::before { content: "⚫ "; }

/* ===== Взятые фигуры ===== */
.captures {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.captured-piece {
  min-height: 40px;
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.captured-piece .piece-icon {
  font-size: 1.5rem;
}

/* ===== Правила ===== */
.rules-reminder {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.9rem;
}

.rules-reminder ul {
  list-style: none;
  padding-left: 0;
}

.rules-reminder li {
  margin: 0.4rem 0;
  padding-left: 1.2rem;
  position: relative;
}

.rules-reminder li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--accent);
}

/* ===== Модальное окно ===== */
.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-secondary);
  padding: 2rem;
  border-radius: 16px;
  text-align: center;
  max-width: 400px;
  border: 3px solid var(--accent);
  box-shadow: 0 12px 40px rgba(233, 69, 96, 0.3);
}

.modal-content h2 {
  color: var(--accent);
  margin-bottom: 1rem;
  font-size: 2rem;
}

.modal-content p {
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}

/* ===== Адаптивность ===== */
@media (max-width: 1200px) {
  .game-area {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  
  .board-section {
    order: 1;
  }
  .control-panel {
    order: 2;
  }
  .info-panel {
    order: 3;
  }
  
  #chessboard {
    width: 90vw;
    max-width: 480px;
  }
}

@media (max-width: 600px) {
  .game-header {
    flex-direction: column;
    gap: 0.8rem;
    text-align: center;
  }
  
  .dice-container {
    gap: 0.5rem;
  }
  
  .die {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }
}

/* ===== Chessboard.js overrides ===== */
.board-b7269 {
  border: none !important;
}

.square-55d63 {
  transition: background-color 0.2s;
}

.highlight-32417 {
  box-shadow: inset 0 0 3px 3px var(--highlight) !important;
}

.highlight2-5bc79 {
  box-shadow: inset 0 0 3px 3px var(--valid-move) !important;
}



/* ===== UI Animations & States ===== */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.status-info { color: var(--text-secondary); transition: opacity 0.15s; }
.status-warning { color: var(--warning); font-weight: 500; }
.status-success { color: var(--success); font-weight: 500; }
.status-error { color: var(--accent); font-weight: 500; }

.move-chip {
  position: relative;
  transition: all 0.2s ease;
}

.move-chip.selected {
  background: var(--accent) !important;
  color: white;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(233, 69, 96, 0.4);
}

.move-chip .move-count {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  margin-left: 0.3rem;
}

/* Preview highlights */
.preview-source {
  box-shadow: inset 0 0 0 3px var(--warning) !important;
}

.preview-target {
  box-shadow: inset 0 0 0 3px var(--success) !important;
}

.capture-preview {
  box-shadow: inset 0 0 0 3px var(--accent) !important;
}

/* History styling */
.move-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  border-bottom: 1px dashed var(--bg-tertiary);
}

.move-number {
  color: var(--text-secondary);
  min-width: 1.5rem;
  font-weight: 600;
}

.move {
  font-family: 'Courier New', monospace;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.move.white { 
  background: rgba(255,255,255,0.1); 
  color: #fff; 
}
.move.black { 
  background: rgba(0,0,0,0.2); 
  color: #ccc; 
}

/* Turn indicators */
#turn-indicator.white-turn { color: #fff; }
#turn-indicator.black-turn { color: #aaa; }

/* Light theme overrides */
body.light-theme {
  --bg-primary: #f5f5f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e0e0e0;
  --text-primary: #1a1a2e;
  --text-secondary: #4a4a6a;
  --dice-bg: #f0f0f5;
  --dice-border: #c0c0d0;
}

body.light-theme .die {
  background: var(--dice-bg);
  border-color: var(--dice-border);
  color: #333;
}

body.light-theme .move-chip {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .move-chip {
    font-size: 0.85rem;
    padding: 0.3rem 0.6rem;
  }
  
  .move-row {
    font-size: 0.9rem;
  }
}