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

body {
    font-family: 'Inter', sans-serif;
    background: #1c1410;
    color: #e8dcc8;
    min-height: 100vh;
    overflow-x: hidden;
}

#app {
    max-width: 1300px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
}

#app-logo-link {
    display: flex;
    align-items: center;
}

#app-logo {
    height: 64px;
    width: auto;
    display: block;
}

.subtitle {
    font-size: 20px;
    font-weight: 700;
    color: #c4ad90;
    letter-spacing: -0.3px;
}

/* Game container layout */
#game-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: flex-start;
    margin-top: 12px;
}

/* Left panel */
#left-panel {
    width: 260px;
    background: #271e15;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #3a2c1e;
    max-height: 640px;
    display: flex;
    flex-direction: column;
}

#left-panel h3 {
    font-size: 13px;
    font-weight: 600;
    color: #a89880;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

#move-history {
    flex: 1;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.8;
}

#move-history::-webkit-scrollbar {
    width: 4px;
}

#move-history::-webkit-scrollbar-thumb {
    background: #4a3a28;
    border-radius: 4px;
}

.move-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 4px;
    border-radius: 4px;
}

.move-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.move-number {
    color: #6b5d4d;
    font-size: 11px;
    min-width: 24px;
}

.move-san {
    font-weight: 600;
    font-family: 'Inter', monospace;
}

.move-eval-pip {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* Eval bar */
#eval-bar-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid #3a2c1e;
}

#eval-bar {
    flex: 1;
    height: 10px;
    background: #3a2c1e;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

#eval-bar-fill {
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, #fff 0%, #ccc 100%);
    border-radius: 5px;
    transition: width 0.5s ease, background 0.5s ease;
}

#eval-text {
    font-size: 12px;
    font-weight: 700;
    min-width: 36px;
    text-align: right;
    color: #c4ad90;
}

/* Board wrapper */
#board-wrapper {
    flex-shrink: 0;
}

/* Bot speech bubble */
.bot-speech {
    background: #3a2c1e;
    color: #d4c4a8;
    font-size: 13px;
    line-height: 1.45;
    padding: 8px 14px;
    border-radius: 12px 12px 12px 4px;
    margin-bottom: 4px;
    position: relative;
    max-width: 480px;
    min-height: 20px;
    animation: speechPop 0.25s ease-out;
    transition: opacity 0.2s ease;
}

.bot-speech::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 14px;
    width: 0;
    height: 0;
    border-left: 6px solid #3a2c1e;
    border-right: 6px solid transparent;
    border-top: 6px solid #3a2c1e;
    border-bottom: 6px solid transparent;
}

@keyframes speechPop {
    0% { opacity: 0; transform: translateY(4px) scale(0.97); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.player-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    font-size: 14px;
    font-weight: 600;
}

.player-icon {
    font-size: 20px;
}

.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: #3a2c1e;
    color: #c49b6a;
    margin-left: auto;
}

/* Captured pieces */
.captured-pieces {
    min-height: 22px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0px;
}

.captured-piece {
    font-size: 15px;
    opacity: 0.75;
    line-height: 1;
}

.material-adv {
    font-size: 11px;
    font-weight: 700;
    color: #8aaa8a;
    margin-left: 4px;
}

/* chessboard.js overrides */
#board .square-55d63 {
    border: none !important;
}

#board .white-1e1d7 {
    background-color: #e8dcc8 !important;
}

#board .black-3c85d {
    background-color: #a07850 !important;
}

#board .highlight-last-move {
    background-color: rgba(210, 170, 80, 0.5) !important;
}

#board .highlight1-32417 {
    box-shadow: inset 0 0 0 3px rgba(34, 197, 94, 0.6) !important;
    background-color: rgba(34, 197, 94, 0.15) !important;
}

#board .highlight2-9c5d2 {
    box-shadow: inset 0 0 0 3px rgba(34, 197, 94, 0.6) !important;
    background-color: rgba(34, 197, 94, 0.15) !important;
}

#board .highlight-selected {
    box-shadow: inset 0 0 0 3px rgba(196, 155, 106, 0.85) !important;
    background-color: rgba(196, 155, 106, 0.3) !important;
}

#board .highlight-legal {
    background-image: radial-gradient(circle, rgba(0, 0, 0, 0.25) 24%, transparent 25%) !important;
    cursor: pointer !important;
}

#board .square-55d63 {
    cursor: pointer;
}

/* Right panel */
#right-panel {
    width: 260px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Move evaluation display */
#move-eval-display {
    background: #271e15;
    border-radius: 12px;
    padding: 20px 16px;
    text-align: center;
    border: 1px solid #3a2c1e;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: border-color 0.3s ease;
}

#eval-icon {
    font-size: 32px;
    line-height: 1;
}

#eval-label {
    font-size: 18px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#eval-detail {
    font-size: 12px;
    color: #8a7a66;
}

/* Evaluation colors */
.eval-brilliant  { color: #1bccee; }
.eval-great      { color: #5caaef; }
.eval-best       { color: #96c44c; }
.eval-good       { color: #96bc4b; }
.eval-book       { color: #a88764; }
.eval-inaccuracy { color: #f1c848; }
.eval-mistake    { color: #e69a28; }
.eval-miss       { color: #e07020; }
.eval-blunder    { color: #ca3431; }

.eval-border-brilliant  { border-color: #1bccee; }
.eval-border-great      { border-color: #5caaef; }
.eval-border-best       { border-color: #96c44c; }
.eval-border-good       { border-color: #96bc4b; }
.eval-border-book       { border-color: #a88764; }
.eval-border-inaccuracy { border-color: #f1c848; }
.eval-border-mistake    { border-color: #e69a28; }
.eval-border-miss       { border-color: #e07020; }
.eval-border-blunder    { border-color: #ca3431; }

.pip-brilliant  { background-color: #1bccee; }
.pip-great      { background-color: #5caaef; }
.pip-best       { background-color: #96c44c; }
.pip-good       { background-color: #96bc4b; }
.pip-book       { background-color: #a88764; }
.pip-inaccuracy { background-color: #f1c848; }
.pip-mistake    { background-color: #e69a28; }
.pip-miss       { background-color: #e07020; }
.pip-blunder    { background-color: #ca3431; }

/* Controls */
.control-group {
    background: #271e15;
    border-radius: 12px;
    padding: 14px 16px;
    border: 1px solid #3a2c1e;
}

.control-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #a89880;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

/* Color picker */
#color-picker {
    display: flex;
    gap: 6px;
}

.color-btn {
    flex: 1;
    padding: 7px 4px;
    border: 2px solid #4a3a28;
    border-radius: 8px;
    background: transparent;
    color: #9a8a74;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.color-btn:hover {
    border-color: #6b5840;
    color: #d4c4a8;
}

.color-btn.active {
    border-color: #c49b6a;
    background: rgba(196, 155, 106, 0.12);
    color: #c49b6a;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #3a2c1e;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #c49b6a;
    cursor: pointer;
    border: 2px solid #1c1410;
    box-shadow: 0 0 6px rgba(196, 155, 106, 0.4);
}

#rating-display {
    text-align: center;
    font-size: 20px;
    font-weight: 800;
    color: #c49b6a;
    margin: 6px 0 2px;
    letter-spacing: -0.5px;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #6b5d4d;
    margin-top: 6px;
}

/* Buttons */
#game-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
}

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

.btn-primary {
    background: #22c55e;
    color: #000;
}

.btn-primary:hover:not(:disabled) {
    background: #16a34a;
}

.btn-secondary {
    background: #3a2c1e;
    color: #e8dcc8;
}

.btn-secondary:hover:not(:disabled) {
    background: #4a3a28;
}

.btn-danger {
    background: #5c1a1a;
    color: #f0a8a8;
}

.btn-danger:hover:not(:disabled) {
    background: #7a2020;
}

/* Export buttons */
#export-buttons {
    display: flex;
    gap: 8px;
}

#export-buttons .btn {
    flex: 1;
    font-size: 12px;
    padding: 8px 10px;
}

/* Game status */
#game-status {
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    padding: 10px;
    border-radius: 8px;
    display: none;
}

#game-status.show {
    display: block;
}

#game-status.win {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

#game-status.lose {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

#game-status.draw {
    background: rgba(250, 204, 21, 0.15);
    color: #facc15;
}

/* Game summary (ratings after game ends) */
#game-summary {
    display: none;
    background: #271e15;
    border-radius: 10px;
    padding: 14px;
    border: 1px solid #3a2c1e;
}

#game-summary.show {
    display: block;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
}

.summary-row + .summary-row {
    border-top: 1px solid #3a2c1e;
}

.summary-label {
    color: #8a7a66;
}

.summary-value {
    font-weight: 700;
    font-size: 15px;
}

.summary-value.player-rating {
    color: #22c55e;
}

.summary-value.bot-rating {
    color: #c49b6a;
}

/* Stockfish status */
#stockfish-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6b5d4d;
    justify-content: center;
}

.loader {
    width: 14px;
    height: 14px;
    border: 2px solid #3a2c1e;
    border-top-color: #c49b6a;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loader.hidden {
    display: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Thinking indicator */
.thinking-indicator {
    display: inline-flex;
    gap: 3px;
    align-items: center;
    margin-left: 6px;
}

.thinking-indicator span {
    width: 4px;
    height: 4px;
    background: #c49b6a;
    border-radius: 50%;
    animation: pulse 1.2s ease-in-out infinite;
}

.thinking-indicator span:nth-child(2) { animation-delay: 0.15s; }
.thinking-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes pulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* Eval graph */
#eval-graph-container {
    margin-top: 10px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #3a2c1e;
    background: #271e15;
}

#eval-graph-container h4 {
    font-size: 11px;
    font-weight: 600;
    color: #9a8a74;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 12px 4px;
    margin: 0;
}

#move-strip {
    display: flex;
    gap: 2px;
    padding: 4px 12px 10px;
    min-height: 34px;
    align-items: flex-end;
}

.strip-block {
    height: 22px;
    flex: 1;
    min-width: 5px;
    max-width: 22px;
    border-radius: 3px;
    transition: transform 0.15s ease, opacity 0.15s ease;
    cursor: default;
    opacity: 0.8;
}

.strip-block:hover {
    transform: scaleY(1.4);
    opacity: 1;
}

.strip-block:last-child {
    opacity: 1;
}

.strip-placeholder {
    color: #5a4a38;
    font-size: 12px;
    padding: 2px 0;
}

#strip-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    padding: 2px 12px 8px;
    font-size: 10px;
    color: #7a6a56;
}

#strip-legend span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

/* Focus (pop-out) mode */
#focus-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 999;
}

#focus-backdrop.show {
    display: block;
}

body.focus-mode #board-wrapper {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: #1c1410;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

#focus-controls {
    display: none;
    gap: 8px;
    justify-content: center;
    margin-top: 10px;
}

body.focus-mode #focus-controls {
    display: flex;
}

#focus-controls .btn {
    font-size: 12px;
    padding: 8px 16px;
}

/* ============================================================
   Chess Pitch specific styles
   ============================================================ */

/* Mode badge above board */
.pitch-mode-badge {
    background: #3a2c1e;
    color: #f59e0b;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 10px;
    margin-bottom: 8px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.pitch-mode-badge.mode-playing {
    color: #22c55e;
}

/* FEN input group */
.fen-input-group {
    display: flex;
    gap: 6px;
}

.fen-input-group input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    background: #1c1410;
    border: 1px solid #4a3a28;
    border-radius: 8px;
    color: #e8dcc8;
    font-family: 'Inter', monospace;
    font-size: 12px;
    outline: none;
    transition: border-color 0.2s;
}

.fen-input-group input[type="text"]:focus {
    border-color: #c49b6a;
}

.fen-input-group .btn {
    padding: 8px 14px;
    font-size: 12px;
    white-space: nowrap;
}

/* Setup buttons stack */
#setup-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#setup-buttons .btn {
    font-size: 12px;
    padding: 8px 12px;
    justify-content: flex-start;
}

/* Mode picker (manual vs bot) */
#mode-picker {
    display: flex;
    gap: 6px;
}

.mode-btn {
    flex: 1;
    padding: 7px 4px;
    border: 2px solid #4a3a28;
    border-radius: 8px;
    background: transparent;
    color: #9a8a74;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mode-btn:hover {
    border-color: #6b5840;
    color: #d4c4a8;
}

.mode-btn.active {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}

/* Large start button */
.btn-large {
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 700;
    margin-top: 8px;
    width: 100%;
}

/* Turn picker reuses .color-btn styles */
#turn-picker {
    display: flex;
    gap: 6px;
}

/* Spare pieces tray (chessboard.js setup mode) */
.spare-pieces-7492f {
    padding: 4px 0;
}

/* Responsive */
@media (max-width: 900px) {
    #game-container {
        flex-direction: column;
        align-items: center;
    }

    #left-panel, #right-panel {
        width: 100%;
        max-width: 480px;
    }

    #left-panel {
        max-height: 200px;
    }

    #board {
        width: min(520px, calc(100vw - 40px)) !important;
    }

    #app-logo {
        height: 44px;
    }

    .subtitle {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    #app {
        padding: 10px 6px;
    }

    #board {
        width: calc(100vw - 4px) !important;
        margin-left: -4px;
    }

    #board-wrapper {
        width: 100%;
    }

    #app-logo {
        height: 36px;
    }

    .subtitle {
        font-size: 14px;
    }

    header {
        gap: 8px;
        padding: 8px 0;
    }

    #left-panel, #right-panel {
        max-width: 100%;
    }
}
