:root {
    --bg: #15181c;
    --panel: #1d2126;
    --panel-edge: #333a42;
    --text: #e3e7ec;
    --text-dim: #96a0ac;
    --board-bg: #22262c;
    --board-line: #6b7684;
    --white-piece: #eef1f4;
    --black-piece: #131519;
    --accent: #4cc06a;
    --accent-dim: #2b6a3e;
    --danger: #e5484d;
    --last-move: #58a6ff;
    --withdrawal: #c792ea;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    font-family: system-ui, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

h1, h2, h3 {
    margin: 0 0 0.5rem 0;
}

button {
    font: inherit;
}

.app-header {
    padding: 0.9rem 1.4rem 0.2rem;
}

    .app-header h1 {
        font-size: 1.25rem;
        color: var(--accent);
    }

    .app-header p {
        margin: 0.15rem 0 0;
        color: var(--text-dim);
        font-size: 0.85rem;
    }

.app-main {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.8rem 1.4rem 1.4rem;
    align-items: flex-start;
}

.board-column {
    flex: 1 1 560px;
    min-width: 340px;
    max-width: 980px;
}

.side-column {
    flex: 0 1 380px;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ---------- toolbar / status ---------- */

.toolbar, .status {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.7rem;
}

.btn {
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    color: var(--text);
    border-radius: 8px;
    padding: 0.4rem 0.85rem;
    cursor: pointer;
    transition: background 0.1s;
}

    .btn:hover:not(:disabled) {
        background: #272d34;
    }

    .btn:disabled {
        opacity: 0.4;
        cursor: default;
    }

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

        .btn.primary:hover:not(:disabled) {
            background: #35804a;
        }

    .btn.danger-outline {
        border-color: var(--danger);
    }

.think-control {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text-dim);
    font-size: 0.85rem;
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 8px;
    padding: 0.3rem 0.7rem;
}

    .think-control input[type=range] {
        width: 110px;
        accent-color: var(--accent);
    }

    /* Fixed width so the slider doesn't shift under the cursor as the number changes. */
    .think-control .think-label {
        min-width: 4.6rem;
    }

.toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-dim);
    font-size: 0.85rem;
    cursor: pointer;
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 8px;
    padding: 0.38rem 0.7rem;
}

    .toggle input {
        accent-color: var(--accent);
    }

.chip {
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 8px;
    padding: 0.3rem 0.7rem;
    font-size: 0.85rem;
    color: var(--text-dim);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

    .chip b {
        color: var(--text);
        font-weight: 600;
    }

.dot {
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    vertical-align: -0.05rem;
}

    .dot.white {
        background: var(--white-piece);
        border: 1px solid #888;
    }

    .dot.black {
        background: var(--black-piece);
        border: 1px solid #8b95a2;
    }

.lenient-note {
    color: #f0c948;
}

/* ---------- board ---------- */

.board {
    width: 100%;
    height: auto;
    display: block;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.board-bg {
    fill: var(--board-bg);
    stroke: var(--panel-edge);
    stroke-width: 2;
}

.grid {
    stroke: var(--board-line);
    stroke-width: 3;
    stroke-linecap: round;
}

.lbl {
    fill: var(--text-dim);
    font-size: 22px;
    text-anchor: middle;
    font-family: inherit;
}

.piece.white {
    fill: var(--white-piece);
    stroke: #8b95a2;
    stroke-width: 3;
}

.piece.black {
    fill: var(--black-piece);
    stroke: #8b95a2;
    stroke-width: 3;
}

.hit {
    fill: transparent;
}

    .hit.on {
        cursor: pointer;
    }

.click-ring {
    fill: none;
    stroke: var(--accent);
    stroke-width: 3;
    stroke-dasharray: 7 7;
    pointer-events: none;
    animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 0.35; }
}

.sel-origin {
    fill: none;
    stroke: var(--accent);
    stroke-width: 4;
}

.sel-path {
    stroke: var(--accent);
    stroke-width: 6;
    stroke-linecap: round;
    opacity: 0.8;
}

.rec-line {
    stroke: var(--accent);
    stroke-width: 6;
    stroke-linecap: round;
}

#arrow path {
    fill: var(--accent);
}

.rec-badge circle {
    fill: #1d4d2b;
    stroke: var(--accent);
    stroke-width: 2;
}

.rec-badge text {
    fill: #fff;
    font-size: 19px;
    font-weight: 700;
    text-anchor: middle;
    font-family: inherit;
}

.capx line {
    stroke: var(--danger);
    stroke-width: 6;
    stroke-linecap: round;
}

.capx.old line {
    stroke-width: 4;
    opacity: 0.45;
    stroke: var(--last-move);
}

.last-path {
    stroke: var(--last-move);
    stroke-width: 5;
    stroke-linecap: round;
    opacity: 0.55;
}

.last-ring {
    fill: none;
    stroke: var(--last-move);
    stroke-width: 4;
}

.pend-a {
    fill: none;
    stroke: var(--danger);
    stroke-width: 4;
    stroke-dasharray: 6 6;
}

.pend-w {
    fill: none;
    stroke: var(--withdrawal);
    stroke-width: 4;
    stroke-dasharray: 6 6;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.1rem;
    margin-top: 0.55rem;
    color: var(--text-dim);
    font-size: 0.8rem;
}

    .legend .g {
        color: var(--accent);
        font-weight: 700;
    }

    .legend .r {
        color: var(--danger);
        font-weight: 700;
    }

    .legend .b {
        color: var(--last-move);
        font-weight: 700;
    }

/* ---------- side panel ---------- */

.panel {
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 12px;
    padding: 1rem 1.1rem;
}

    .panel h2 {
        font-size: 1rem;
    }

    .panel .hint {
        color: var(--text-dim);
        font-size: 0.85rem;
        margin: 0.2rem 0 0.6rem;
    }

.rec-move {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--accent);
    margin: 0.2rem 0;
}

.rec-meta {
    color: var(--text-dim);
    font-size: 0.82rem;
    margin-bottom: 0.5rem;
}

.steps {
    margin: 0.3rem 0 0.8rem;
    padding-left: 1.4rem;
}

    .steps li {
        margin: 0.25rem 0;
    }

    .steps li::marker {
        color: var(--accent);
        font-weight: 700;
    }

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.4rem;
}

.path-preview {
    font-family: Consolas, monospace;
    font-size: 1.25rem;
    background: var(--bg);
    border: 1px solid var(--panel-edge);
    border-radius: 8px;
    padding: 0.45rem 0.7rem;
    margin: 0.4rem 0 0.6rem;
    min-height: 2.4rem;
}

.moves-list {
    margin: 0.5rem 0 0;
    padding-left: 1.2rem;
    font-family: Consolas, monospace;
    font-size: 0.85rem;
    color: var(--text-dim);
    max-height: 16rem;
    overflow-y: auto;
}

    .moves-list li {
        margin: 0.15rem 0;
    }

.outcome {
    font-size: 1.2rem;
    font-weight: 700;
}

    .outcome.win {
        color: var(--accent);
    }

    .outcome.loss {
        color: var(--danger);
    }

    .outcome.draw {
        color: #f0c948;
    }

.thinking {
    color: var(--text-dim);
}

.spinner {
    display: inline-block;
    width: 0.9rem;
    height: 0.9rem;
    border: 2px solid var(--accent);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: -0.15rem;
    margin-right: 0.35rem;
}

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

/* ---------- dialogs ---------- */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.dialog {
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 12px;
    padding: 1.3rem 1.5rem;
    max-width: 34rem;
    width: calc(100% - 2rem);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

    .dialog p {
        color: var(--text-dim);
    }

    .dialog .btn-row {
        margin-top: 0.9rem;
    }

.choice-btn {
    display: block;
    width: 100%;
    text-align: left;
    margin: 0.45rem 0;
    padding: 0.6rem 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--panel-edge);
}

    .choice-btn:hover {
        background: #272d34;
    }

    .choice-btn.approach {
        border-color: var(--danger);
    }

    .choice-btn.withdrawal {
        border-color: var(--withdrawal);
    }

    .choice-btn b {
        display: block;
    }

    .choice-btn span {
        color: var(--text-dim);
        font-size: 0.85rem;
    }

.save-text {
    width: 100%;
    min-height: 11rem;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--panel-edge);
    border-radius: 8px;
    font-family: Consolas, monospace;
    font-size: 0.85rem;
    padding: 0.5rem;
    resize: vertical;
}

.error-text {
    color: var(--danger);
    font-size: 0.85rem;
}

/* ---------- blazor boilerplate ---------- */

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    color: #222;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: var(--panel-edge);
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: var(--accent);
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
    color: var(--text-dim);
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }
