
:root {
    --sk-primary: #345d57;
    --sk-primary-dark: #244741;
    --sk-background: #f5f7f6;
    --sk-text: #24332f;
    --sk-muted: #74817d;
    --sk-border: #dfe7e3;
}

html {
    font-size: 16px;
    min-height: 100%;
}

body {
    background: var(--sk-background);
    color: var(--sk-text);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    min-height: 100vh;
}

.site-header {
    background: white;
    border-bottom: 1px solid var(--sk-border);
}

.navbar {
    min-height: 72px;
}

.navbar-brand {
    color: var(--sk-primary-dark);
    font-size: 1.45rem;
    font-weight: 750;
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    font-size: 2rem;
    line-height: 1;
}

.header-label {
    color: var(--sk-muted);
    font-size: .88rem;
}

.hero-section {
    padding: 48px 0 30px;
    text-align: center;
}

.hero-content {
    max-width: 720px;
    margin: auto;
}

.eyebrow {
    color: var(--sk-primary);
    font-size: .75rem;
    font-weight: 750;
    letter-spacing: .16em;
}

.hero-content h1 {
    font-size: clamp(2rem, 5vw, 3.4rem);
    font-weight: 800;
    letter-spacing: -.045em;
    margin: 12px 0;
}

.hero-content p {
    color: var(--sk-muted);
    font-size: 1.04rem;
    line-height: 1.6;
}

.workspace {
    max-width: 1180px;
    padding-bottom: 65px;
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(250px, .9fr) minmax(0, 1.7fr);
    gap: 18px;
    align-items: start;
}

.workspace-card {
    min-width: 0;
    background: white;
    border: 1px solid var(--sk-border);
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 5px 22px rgba(25, 50, 40, .035);
}

.step-heading {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 22px;
}

.step-number {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    background: #e4efeb;
    color: var(--sk-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 750;
}

.step-heading h2 {
    font-size: 1.2rem;
    font-weight: 750;
    margin: 0 0 4px;
}

.step-heading p {
    color: var(--sk-muted);
    font-size: .85rem;
    margin: 0;
}

.upload-zone {
    border: 2px dashed #aac2b8;
    border-radius: 14px;
    min-height: 215px;
    background: #f8fbf9;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 22px;
    text-align: center;
    gap: 8px;
    transition: background .2s, border-color .2s;
}

    .upload-zone:hover {
        border-color: var(--sk-primary);
        background: #edf5f1;
    }

.upload-icon {
    font-size: 2.8rem;
    color: var(--sk-primary);
    line-height: 1;
}

.upload-zone strong {
    font-size: 1rem;
}

.upload-zone span:not(.upload-icon) {
    color: var(--sk-muted);
    font-size: .83rem;
}

.upload-formats {
    font-size: .72rem !important;
}

.preview-container {
    margin-top: 18px;
    text-align: center;
}

    .preview-container img {
        max-height: 350px;
        border-radius: 10px;
        border: 1px solid var(--sk-border);
    }

.btn-primary {
    background: var(--sk-primary);
    border-color: var(--sk-primary);
}

    .btn-primary:hover {
        background: var(--sk-primary-dark);
        border-color: var(--sk-primary-dark);
    }

.btn-outline-primary {
    color: var(--sk-primary);
    border-color: var(--sk-primary);
}

    .btn-outline-primary:hover {
        color: white;
        background: var(--sk-primary);
        border-color: var(--sk-primary);
    }

.board-wrapper {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
}

#chessboard {
    width: 100%;
    aspect-ratio: 1;
    user-select: none;
    -webkit-user-select: none;
}

.cm-chessboard .markers .marker.marker-frame-primary {
    stroke: #18a875 !important;
    stroke-width: 3px !important;
    opacity: 1 !important;
}

.cm-chessboard .markers .marker.marker-frame-uncertain {
    stroke: #e58a12 !important;
    stroke-width: 3px !important;
    opacity: 1 !important;
}

.board-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
}

    .board-actions .btn {
        min-height: 36px;
        padding: 6px 12px;
        font-weight: 600;
    }

        .board-actions .btn:disabled {
            opacity: .4;
            cursor: not-allowed;
        }

.analysis-panel {
    margin-top: 18px;
    padding: 16px;
    background: #f4f8f6;
    border: 1px solid #d5e5dc;
    border-radius: 14px;
}

.analysis-settings {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 12px;
}

    .analysis-settings > div {
        min-width: 0;
    }

    .analysis-settings .form-select {
        min-height: 44px;
    }

.turn-hint, .verification-hint {
    margin: 10px 0 0;
    font-size: .83rem;
    color: #596f66;
    line-height: 1.5;
}

.uncertain-key {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 3px solid #e58a12;
    vertical-align: -1px;
    margin-right: 4px;
}

.analysis-action {
    margin-top: 14px;
}

.quick-status {
    display: none;
}

.analyze-button {
    width: 100%;
    padding: 13px;
    font-weight: 750;
}

    .analyze-button:disabled {
        opacity: .55;
        cursor: not-allowed;
    }

.analysis-status {
    color: #805319;
    margin: 10px 0 0;
    font-size: .85rem;
}

    .analysis-status:empty {
        display: none;
    }

#sideToMove {
    scroll-margin-top: 24px;
}

.editor-section {
    border-top: 1px solid var(--sk-border);
    margin-top: 25px;
    padding-top: 24px;
}

    .editor-section h3 {
        font-size: 1rem;
        font-weight: 750;
        margin-bottom: 12px;
    }

.piece-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.piece-tool {
    min-width: 43px;
    height: 45px;
    border: 1px solid var(--sk-border);
    border-radius: 8px;
    background: #f8faf9;
    color: var(--sk-text);
    font-size: 1.55rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
}

    .piece-tool[data-tool="move"], .piece-tool[data-tool="remove"] {
        padding: 0 12px;
        font-size: .78rem;
        font-weight: 700;
    }

    .piece-tool.selected {
        background: var(--sk-primary);
        color: white;
        border-color: var(--sk-primary);
    }

    .piece-tool:hover:not(.selected) {
        background: #e8f0ec;
    }

    .piece-tool:focus-visible {
        outline: 3px solid #85b9a9;
        outline-offset: 2px;
    }

.editor-status {
    margin-top: 12px;
    color: var(--sk-muted);
    font-size: .85rem;
    min-height: 20px;
}

.castling-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    font-size: .85rem;
}

    .castling-options label {
        display: flex;
        align-items: center;
        gap: 7px;
    }

    .castling-options input {
        accent-color: var(--sk-primary);
    }

.fen-input {
    font-family: Consolas, monospace;
    font-size: .83rem;
    overflow-wrap: anywhere;
}

.site-footer {
    padding: 25px 0;
    border-top: 1px solid var(--sk-border);
    color: var(--sk-muted);
    font-size: .8rem;
}

@media (max-width: 991px) {
    .workspace-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 767px) {
    body {
        padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px));
    }

    .hero-section {
        padding: 28px 0 18px;
    }

    .hero-content p {
        font-size: .94rem;
    }

    .workspace {
        padding-bottom: 35px;
    }

    .workspace-card {
        padding: 16px;
        border-radius: 14px;
    }

    .board-actions {
        gap: 6px;
    }

        .board-actions .btn {
            font-size: .8rem;
            padding: 6px 10px;
        }

    .analysis-panel {
        padding: 12px;
    }

    .analysis-settings {
        grid-template-columns: 1.35fr 1fr;
        gap: 8px;
    }

        .analysis-settings .form-select {
            font-size: .9rem;
        }

    .analysis-action {
        position: fixed;
        z-index: 1000;
        left: 0;
        right: 0;
        bottom: 0;
        margin: 0;
        padding: 7px 14px calc(10px + env(safe-area-inset-bottom, 0px));
        background: rgba(255, 255, 255, .98);
        border-top: 1px solid var(--sk-border);
        box-shadow: 0 -6px 22px rgba(20, 40, 30, .10);
    }

    .quick-status {
        display: block;
        text-align: center;
        font-size: .77rem;
        color: var(--sk-muted);
        margin-bottom: 4px;
    }

    .analyze-button {
        min-height: 45px;
        padding: 9px;
    }

    .piece-toolbar {
        gap: 4px;
    }

    .piece-tool {
        min-width: 39px;
        height: 42px;
    }

    .header-label {
        display: none;
    }

    .castling-options {
        grid-template-columns: 1fr;
    }
}

/* Single-row piece toolbar */
.piece-toolbar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    overflow: visible;
    padding-bottom: 0;
}

.piece-toolbar .piece-tool {
    flex: 0 1 38px;
    min-width: 0;
    height: 40px;
    padding: 0;
    font-size: 1.35rem;
}

.piece-toolbar .piece-tool[data-tool="move"],
.piece-toolbar .piece-tool[data-tool="remove"] {
    flex: 0 0 auto;
    padding: 0 8px;
    font-size: .75rem;
}

/* Erase button: light red */
.piece-toolbar .piece-tool[data-tool="remove"] {
    margin-left: 4px;
    background: #fce8e8;
    border-color: #efb8b8;
    color: #a52a2a;
}

.piece-toolbar .piece-tool[data-tool="remove"]:hover {
    background: #f8d0d0;
    border-color: #e89a9a;
}

.piece-toolbar .piece-tool[data-tool="remove"].selected {
    background: #dc7777;
    border-color: #c85b5b;
    color: white;
}


/* ---------------------------------------------------------------
   Stockfish analysis results and variation playback
   --------------------------------------------------------------- */

.analysis-results[hidden],
.variation-panel[hidden] {
    display: none !important;
}

.analysis-results {
    margin-top: 18px;
    padding: 18px;
    border: 1px solid var(--sk-border);
    border-radius: 14px;
    background: #fff;
}

.analysis-results-header h3 {
    font-size: 1.1rem;
    font-weight: 750;
    margin-bottom: 4px;
}

.analysis-meta {
    color: var(--sk-muted);
    font-size: .82rem;
    margin: 0 0 15px;
}

.analysis-lines {
    display: grid;
    gap: 9px;
}

.analysis-line {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 5px;
    padding: 12px;
    text-align: left;
    background: #f8faf9;
    border: 1px solid var(--sk-border);
    border-radius: 10px;
    color: var(--sk-text);
    cursor: pointer;
}

    .analysis-line:hover,
    .analysis-line.selected {
        border-color: var(--sk-primary);
        background: #edf6f1;
    }

    .analysis-line:focus-visible,
    .variation-move:focus-visible {
        outline: 3px solid #85b9a9;
        outline-offset: 2px;
    }

.analysis-line-heading {
    display: flex;
    align-items: center;
    gap: 11px;
}

.analysis-rank {
    min-width: 30px;
    color: var(--sk-muted);
    font-size: .85rem;
}

.analysis-san {
    font-size: 1.05rem;
}

.analysis-score {
    font-weight: 750;
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

.analysis-line-detail {
    font-size: .78rem;
    color: var(--sk-muted);
}

.analysis-line-preview {
    font-size: .82rem;
    color: #526860;
    overflow-wrap: anywhere;
    line-height: 1.5;
}

.analysis-empty {
    margin: 0;
    color: var(--sk-muted);
}

.variation-panel {
    margin-top: 20px;
    border-top: 1px solid var(--sk-border);
    padding-top: 18px;
}

    .variation-panel h4 {
        font-size: 1rem;
        font-weight: 750;
    }

.variation-board {
    width: 100%;
    max-width: 330px;
    aspect-ratio: 1;
    margin: 10px auto 14px;
}

.variation-moves {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.variation-move {
    border: 1px solid var(--sk-border);
    border-radius: 6px;
    padding: 6px 8px;
    background: #f8faf9;
    color: var(--sk-text);
    font-size: .8rem;
}

    .variation-move.current {
        background: var(--sk-primary);
        border-color: var(--sk-primary);
        color: white;
    }

.variation-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

/* cm-chessboard v8 arrow overlay. */
.cm-chessboard .arrow-default .arrow-head {
    fill: #238c65;
    fill-opacity: 1;
}

.cm-chessboard .arrow-default .arrow-line {
    stroke: #238c65;
    stroke-linecap: round;
    opacity: .7;
}

@media (max-width: 767px) {
    .analysis-results {
        padding: 13px;
    }

    .variation-board {
        max-width: 290px;
    }

    .analysis-line {
        padding: 11px;
    }
}


/* Play-move controls inside Stockfish results */

.analysis-entry {
    border: 1px solid var(--sk-border);
    border-radius: 10px;
    padding: 10px;
    background: #f8faf9;
}

.analysis-entry.selected {
    border-color: var(--sk-primary);
    background: #edf6f1;
}

.analysis-entry .analysis-line,
.analysis-entry .analysis-line:hover,
.analysis-entry .analysis-line.selected {
    border: none;
    background: transparent;
    padding: 0;
    border-radius: 0;
}

.analysis-play {
    display: block;
    margin: 9px 0 0 auto;
    font-weight: 600;
}

.analysis-return {
    display: block;
    margin: 12px auto 0;
    font-weight: 650;
}

.analysis-preview-note {
    text-align: center;
    font-size: .83rem;
    color: var(--sk-muted);
    margin: 8px 0 0;
}

.analysis-return[hidden],
.analysis-preview-note[hidden] {
    display: none !important;
}
