:root {
  /* PRO-COMMENT: Centralized color variables for highlights for easy theme changes. */
  --highlight-move: rgba(74, 255, 234, 0.4);
  --highlight-capture: rgba(255, 77, 210, 0.6);
  --highlight-selected: rgba(255, 255, 0, 0.4);
}

.game-page-container {
  max-width: 1200px;
  margin: 1rem auto;
  padding: 0 1rem;
  text-align: center;
}

.game-meta {
  display: flex;
  justify-content: center;
  gap: 2rem;
  background: #10121a;
  color: #c371f7;
  padding: 0.75rem;
  border-radius: 8px;
  margin: 1rem auto;
  max-width: 600px;
  flex-direction: column;
}

.instructions {
  max-width: 800px;
  margin: 1.5rem auto;
  background: #1a1c2a;
  border: 1px solid rgba(195,113,247,0.4);
  border-radius: 8px;
  padding: 1.5rem;
  color: #ddd;
  text-align: left;
}

.instructions h2 {
    text-align: center;
    color: #c371f7;
    margin-bottom: 1rem;
    font-size: 1.5em;
}

.instructions > p {
    text-align: center;
    margin-bottom: 1.5rem;
}

.tutorial-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.tutorial-step {
    background: rgba(13, 15, 23, 0.7);
    padding: 1rem;
    border-radius: 8px;
    border-left: 3px solid #42c8fa;
}

.tutorial-step h3 {
    font-size: 1.1em;
    color: #4affea;
    margin-bottom: 0.5rem;
}

.tutorial-step .icon {
    display: inline-block;
    margin-right: 0.5em;
    transform: translateY(2px);
}

.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.settings-panel {
    display: flex;
    gap: 1.5rem;
    background: #1a1c2a;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(195,113,247,0.4);
    flex-wrap: wrap;
    justify-content: center;
}

.setting-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.setting-group label {
    font-weight: bold;
    color: #c371f7;
}

.setting-group select {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 0.5rem;
    cursor: pointer;
}

.game-layout {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 2rem;
  flex-wrap: wrap;
  padding: 1rem;
  background: #10121a;
  border-radius: 16px;
  border: 1px solid #42c8fa;
  box-shadow: 0 0 15px #42c8fa33, inset 0 0 10px #10121a;
}

.chess-board-wrapper {
  flex-shrink: 0;
  width: 100%;
  max-width: 650px;
  transition: transform 0.3s ease-in-out;
}

#chess-canvas {
  display: block;
  cursor: pointer;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

.side-panel {
  flex-grow: 1;
  min-width: 280px;
  max-width: 350px;
  color: #fff;
  text-align: left;
  margin-top: 1rem;
}

.hud-panel, .ability-panel, .log-panel, #piece-palette-container {
  background: #1a1c2a;
  border: 1px solid rgba(195, 113, 247, 0.4);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 0 15px rgba(26, 28, 42, 0.5);
}

#piece-palette-container h3, .hud-panel h3, .ability-panel h3, .log-panel h3 {
  color: #c371f7;
  margin-top: 0;
  margin-bottom: 0.75rem;
  text-align: center;
  font-size: 1.3rem;
}

#piece-palette {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 10px;
    height: 200px;
    overflow-y: auto;
    padding: 5px;
    background: #111;
    border-radius: 4px;
}

.palette-piece {
    width: 40px;
    height: 40px;
    cursor: grab;
    transition: transform 0.2s, opacity 0.2s;
}

.palette-piece:active {
    cursor: grabbing;
    transform: scale(1.2);
}

.palette-piece.dragging {
    opacity: 0.5;
}


#status-text {
  font-size: 1.2rem;
  font-weight: bold;
  color: #4affea;
  text-align: center;
  min-height: 2rem;
  margin-bottom: 0.5rem;
}

#zoom-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

#zoom-controls button {
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    border-radius: 50%;
    border: 2px solid #c371f7;
    background: #333;
    color: #fff;
    cursor: pointer;
}

.timer-display {
    display: flex;
    justify-content: space-around;
    background: #111;
    padding: 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.75rem;
    font-family: monospace;
    font-size: 1.2rem;
}

#player-timer.active, #ai-timer.active {
    color: #ffc107;
    font-weight: bold;
}

.energy-display {
  font-size: 1.1rem;
  text-align: center;
}

#ability-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#ability-buttons button {
  background: #333;
  color: #ccc;
  border: 1px solid #555;
  padding: 0.75rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

#ability-buttons button:hover:not(:disabled) {
  background: #444;
  border-color: #c371f7;
  color: #fff;
}

#ability-buttons button:disabled {
  background: #222;
  color: #666;
  cursor: not-allowed;
}

#game-log {
  height: 150px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 0.9rem;
  background: #111;
  padding: 0.5rem;
  border-radius: 4px;
}
#game-log div {
  padding: 0.2rem 0;
  border-bottom: 1px solid #222;
}

.hidden {
    display: none;
}

@media (max-width: 800px) {
    .game-layout {
        flex-direction: column;
        align-items: center;
        border: none;
        background: transparent;
        box-shadow: none;
        padding: 0;
    }
    .game-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    .side-panel {
        width: 100%;
        max-width: 100%;
        margin-top: 1rem;
        order: 2;
    }
    .chess-board-wrapper {
        width: 100%;
        max-width: 650px; /* Added max-width for tablet */
        order: 1;
    }
    .instructions {
        padding: 1rem;
    }
    .settings-panel {
        flex-direction: column;
        gap: 1rem;
        align-items: center; /* Center align for mobile */
    }
    .controls {
      align-items: center; /* Center align for mobile */
    }
}