:root {
    --ink: #111316;
    --ink-soft: #2b2e36;
    --mist: #f7f1e7;
    --sand: #e7dccb;
    --chalk: #fbf7f0;
    --accent: #ff9f59;
    --accent-strong: #f36c4f;
    --teal: #2db7a0;
    --danger: #ec5b5b;
    --board-light: #efe1cd;
    --board-dark: #4a4f5e;
    --panel: rgba(255, 255, 255, 0.7);
    --panel-border: rgba(17, 19, 22, 0.08);
    --shadow-strong: 0 24px 60px rgba(25, 20, 15, 0.25);
    --shadow-soft: 0 10px 25px rgba(25, 20, 15, 0.15);
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: "Space Grotesk", "Sora", "Segoe UI", sans-serif;
    background: radial-gradient(circle at 15% 20%, rgba(255, 210, 150, 0.3), transparent 45%),
        radial-gradient(circle at 85% 5%, rgba(86, 205, 200, 0.2), transparent 40%),
        linear-gradient(120deg, #f5efe5 0%, #f0e6d7 45%, #f5efe5 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
    background-size: 32px 32px;
    pointer-events: none;
    z-index: -1;
}

a {
    color: inherit;
    text-decoration: none;
}

a:hover {
    color: var(--accent-strong);
}

h1, h2, h3 {
    font-family: "Fraunces", "Times New Roman", serif;
    margin: 0 0 1rem 0;
}

p {
    margin: 0 0 1rem 0;
    line-height: 1.6;
}

button {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
}

.site {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 24px 48px;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0 28px;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.brand-mark {
    font-size: 1.1rem;
}

.brand-dot {
    color: var(--accent-strong);
    font-weight: 600;
    letter-spacing: 0.2em;
}

.site-nav {
    display: flex;
    gap: 18px;
    font-weight: 600;
}

.site-nav a {
    position: relative;
    padding-bottom: 6px;
}

.site-nav a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-strong);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.2s ease;
}

.site-nav a:hover::after {
    transform: scaleX(1);
}

.primary,
.ghost {
    padding: 0.6rem 1.2rem;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.primary {
    background: var(--accent-strong);
    color: white;
    box-shadow: var(--shadow-soft);
}

.primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-strong);
}

.ghost {
    background: transparent;
    border-color: rgba(17, 19, 22, 0.2);
    color: var(--ink);
}

.ghost:hover {
    border-color: var(--accent-strong);
    color: var(--accent-strong);
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 40px;
    align-items: start;
}

.hero-copy {
    padding: 24px 0;
    animation: fade-up 0.8s ease both;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.3em;
    font-size: 0.75rem;
    color: var(--ink-soft);
    margin-bottom: 16px;
}

.hero-copy h1 {
    font-size: clamp(2.4rem, 3vw, 3.4rem);
    line-height: 1.1;
}

.lead {
    font-size: 1.05rem;
    color: var(--ink-soft);
}

.hero-actions {
    display: flex;
    gap: 12px;
    margin: 24px 0;
}

.status-card {
    padding: 18px 20px;
    background: var(--panel);
    border-radius: 16px;
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(12px);
}

.status-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--ink-soft);
}

.status-value {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 8px 0 4px;
}

.status-note {
    color: var(--ink-soft);
    font-size: 0.9rem;
}

.hero-board {
    display: flex;
    flex-direction: column;
    gap: 18px;
    animation: fade-up 0.9s ease 0.12s both;
}

.board-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 20px;
    align-items: start;
}

.board-stack {
    display: grid;
    gap: 16px;
}

.board-layer {
    background: rgba(255, 255, 255, 0.75);
    border-radius: 18px;
    border: 1px solid var(--panel-border);
    padding: 14px;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(10px);
}

.board-layer-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
}

.layer-title {
    font-weight: 700;
}

.layer-subtitle {
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.board-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 0;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    border: 1px solid rgba(17, 19, 22, 0.12);
}

.board-square {
    position: relative;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.12s ease;
}

.board-square.light {
    background: var(--board-light);
}

.board-square.dark {
    background: var(--board-dark);
}

.board-square:hover {
    transform: translateY(-1px);
}

.board-square.selected {
    box-shadow: inset 0 0 0 3px var(--accent);
    z-index: 2;
}

.board-square.last-move::before {
    content: "";
    position: absolute;
    inset: 8px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.7);
}

.board-square.target-quiet::after,
.board-square.target-capture::after {
    content: "";
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    border: 2px dashed var(--teal);
}

.board-square.target-capture::after {
    border-radius: 10px;
    border: 2px solid var(--danger);
}

.board-square:focus-visible {
    outline: 2px solid var(--accent-strong);
    outline-offset: -2px;
}

.piece {
    width: 70%;
    height: 70%;
    filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.25));
}

.board-sidebar {
    display: grid;
    gap: 14px;
}

.panel {
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--panel-border);
    background: var(--panel);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(10px);
}

.panel.subtle {
    background: rgba(255, 255, 255, 0.55);
}

.panel-title {
    font-weight: 700;
    margin-bottom: 12px;
}

.panel-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
    margin-bottom: 8px;
}

.panel-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.promotion-panel {
    display: grid;
    gap: 12px;
}

.promotion-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.promotion-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.85);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.promotion-option:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-soft);
}

.promotion-option:focus-visible {
    outline: 2px solid var(--accent-strong);
    outline-offset: 2px;
}

.promotion-piece {
    width: 26px;
    height: 26px;
}

.learn-section,
.engine-section {
    margin-top: 64px;
}

.section-header {
    max-width: 640px;
    margin-bottom: 24px;
}

.learn-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.learn-card {
    padding: 20px;
    border-radius: 18px;
    border: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.8);
    box-shadow: var(--shadow-soft);
    animation: fade-up 0.7s ease both;
}

.learn-card:nth-child(2) {
    animation-delay: 0.08s;
}

.learn-card:nth-child(3) {
    animation-delay: 0.16s;
}

.learn-card h3 {
    margin-bottom: 8px;
}

.engine-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: 24px;
    align-items: stretch;
}

.engine-preview {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(17, 19, 22, 0.15);
    background: linear-gradient(135deg, #1e222b, #394052);
    min-height: 320px;
    box-shadow: var(--shadow-strong);
}

.orbital-canvas {
    width: 100%;
    height: 100%;
    display: block;
    background-image: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.12), transparent 45%),
        radial-gradient(circle at 70% 60%, rgba(255, 255, 255, 0.1), transparent 50%);
}

.engine-overlay {
    position: absolute;
    inset: auto 24px 24px 24px;
    padding: 16px;
    border-radius: 14px;
    background: rgba(15, 17, 22, 0.75);
    color: white;
    backdrop-filter: blur(6px);
}

.overlay-title {
    font-weight: 700;
    margin-bottom: 6px;
}

.engine-list {
    display: grid;
    gap: 12px;
}

.engine-item {
    padding: 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow-soft);
    animation: fade-up 0.7s ease both;
}

.engine-item:nth-child(2) {
    animation-delay: 0.08s;
}

.engine-item:nth-child(3) {
    animation-delay: 0.16s;
}

.engine-item:nth-child(4) {
    animation-delay: 0.24s;
}

.engine-label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
}

.site-footer {
    margin-top: 64px;
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.not-found {
    margin: 100px auto;
    max-width: 540px;
    text-align: center;
    padding: 32px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow-soft);
}

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

.loading-progress circle {
    fill: none;
    stroke: rgba(255, 255, 255, 0.5);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent-strong);
    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: 600;
    inset: calc(20vh + 2.8rem) 0 auto 0;
}

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

#blazor-error-ui {
    background: #2a2e3a;
    color: white;
    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;
}

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 980px) {
    .site-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .hero {
        grid-template-columns: 1fr;
    }

    .board-panel {
        grid-template-columns: 1fr;
    }

    .learn-grid,
    .engine-grid {
        grid-template-columns: 1fr;
    }

    .site-footer {
        flex-direction: column;
        gap: 6px;
    }
}

@media (max-width: 640px) {
    .site {
        padding: 18px 16px 32px;
    }

    .site-nav {
        flex-wrap: wrap;
    }

    .hero-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
