:root {
    --brand: #840084;
    --brand-light: #a340a3;
    --brand-dark: #5a005c;
    --brand-secondary: #4e4e4e;
    --brand-muted: #b5b5b5;
    --surface-app: #f8f5fb;
    --surface-card: rgba(255, 255, 255, 0.9);
    --surface-tint: #fff7ff;
    --text-primary: #1f1f1f;
    --text-secondary: #58545c;
    --stroke-subtle: #e7ddeb;
    --shadow-card: 0 18px 48px rgba(54, 0, 54, 0.1);
}

html {
    scroll-behavior: smooth;
}

html, body {
    min-height: 100%;
    color: var(--text-primary);
    background: var(--surface-app);
    font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: var(--brand);
}

a:hover {
    color: var(--brand-light);
}

code {
    color: var(--brand-dark);
}

.hero {
    position: relative;
    overflow: hidden;
    padding: clamp(2rem, 4vw, 4rem);
    border: 1px solid var(--stroke-subtle);
    border-radius: 2rem;
    background:
        radial-gradient(circle at top right, rgba(163, 64, 163, 0.2), transparent 32rem),
        linear-gradient(135deg, #fff, var(--surface-tint));
    box-shadow: var(--shadow-card);
}

.hero h1 {
    max-width: 58rem;
    margin: 0;
    font-size: clamp(2.4rem, 6vw, 5.2rem);
    line-height: 0.95;
    letter-spacing: -0.06em;
}

.hero p {
    max-width: 48rem;
    margin: 1.25rem 0 0;
    color: var(--text-secondary);
    font-size: clamp(1.05rem, 2vw, 1.3rem);
}

.hero-with-visual {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(8rem, 14rem);
    align-items: center;
    gap: 2rem;
}

.hero-visual {
    display: grid;
    place-items: center;
}

.hero-visual img {
    width: clamp(7rem, 18vw, 13rem);
    height: auto;
    filter: drop-shadow(0 22px 34px rgba(90, 0, 92, 0.22));
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-top: 1.75rem;
}

.hero-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.7rem;
}

.button-primary,
.button-secondary {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0.7rem 1rem;
    border-radius: 999px;
    font-weight: 700;
    text-decoration: none;
}

.button-primary {
    color: #fff;
    background: var(--brand);
    box-shadow: 0 10px 24px rgba(132, 0, 132, 0.25);
}

.button-primary:hover {
    color: #fff;
    background: var(--brand-light);
}

.button-secondary {
    color: var(--brand);
    border: 1px solid var(--stroke-subtle);
    background: rgba(255, 255, 255, 0.75);
}

.section {
    margin-top: 2rem;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.section-heading h2 {
    margin: 0;
    font-size: clamp(1.65rem, 3vw, 2.4rem);
    letter-spacing: -0.03em;
}

.section-heading p {
    max-width: 44rem;
    margin: 0.35rem 0 0;
    color: var(--text-secondary);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(17.5rem, 1fr));
    gap: 1rem;
}

.card,
.reference-card {
    border: 1px solid var(--stroke-subtle);
    border-radius: 1.35rem;
    background: var(--surface-card);
    box-shadow: var(--shadow-card);
}

.card {
    padding: 1.35rem;
}

.card h3 {
    margin: 0 0 0.5rem;
}

.component-link {
    color: inherit;
    text-decoration: none;
}

.component-link:hover {
    color: inherit;
    border-color: rgba(132, 0, 132, 0.35);
    transform: translateY(-1px);
}

.component-link h3 {
    font-size: clamp(1.35rem, 3vw, 1.75rem);
    white-space: nowrap;
}

.card p,
.reference-card p {
    color: var(--text-secondary);
}

.pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    color: var(--brand-dark);
    background: rgba(132, 0, 132, 0.1);
    font-size: 0.78rem;
    font-weight: 700;
}

.nuget-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 0.25rem 0.7rem;
    border: 1px solid rgba(132, 0, 132, 0.2);
    border-radius: 999px;
    color: var(--brand);
    background: #fff;
    font-size: 0.78rem;
    font-weight: 800;
    text-decoration: none;
}

.nuget-badge:hover {
    color: #fff;
    background: var(--brand);
}

.reference-card {
    display: grid;
    gap: 1.25rem;
    min-width: 0;
    padding: clamp(1rem, 2.6vw, 1.5rem);
}

.reference-card + .reference-card {
    margin-top: 1rem;
}

.reference-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
}

.reference-head h2 {
    margin: 0.4rem 0;
}

.preview-panel {
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 16rem;
    overflow: auto;
    padding: 1.25rem;
    border: 1px solid var(--stroke-subtle);
    border-radius: 1.1rem;
    background:
        linear-gradient(90deg, rgba(132, 0, 132, 0.05) 1px, transparent 1px),
        linear-gradient(rgba(132, 0, 132, 0.05) 1px, transparent 1px),
        #fff;
    background-size: 24px 24px;
}

.reference-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 0.85fr);
    gap: 1rem;
}

.reference-body > * {
    min-width: 0;
}

.event-output {
    width: 100%;
    margin-top: 0.8rem;
    padding: 0.75rem;
    border-radius: 0.8rem;
    color: var(--brand-dark);
    background: rgba(132, 0, 132, 0.09);
    font-weight: 700;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.field {
    display: grid;
    gap: 0.35rem;
    color: var(--brand-dark);
    font-size: 0.9rem;
    font-weight: 700;
}

.field input,
.field select {
    width: 100%;
    min-height: 2.3rem;
    padding: 0.4rem 0.55rem;
    border: 1px solid var(--stroke-subtle);
    border-radius: 0.65rem;
    accent-color: var(--brand);
}

.field-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.field-inline input {
    width: auto;
    min-height: auto;
}

.field-hint {
    margin: 0.75rem 0 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.theme-playground {
    background: linear-gradient(135deg, #fff, var(--surface-tint));
}

.theme-preview {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: center;
}

.theme-preview-card {
    padding: 1.25rem;
    border: 1px solid var(--stroke-subtle);
    border-radius: 1.1rem;
    background: #fff;
}

.theme-preview-card h3 {
    margin: 0.75rem 0 0.4rem;
}

.theme-preview-card p {
    margin: 0;
}

.theme-preview-component {
    display: grid;
    place-items: center;
    min-width: 12rem;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--stroke-subtle);
    border-radius: 1rem;
    margin-bottom: 1rem;
}

.parameter-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.parameter-table th,
.parameter-table td {
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid var(--stroke-subtle);
    text-align: left;
    vertical-align: top;
}

.parameter-table th {
    color: var(--brand-dark);
    background: var(--surface-tint);
}

.parameter-table tr:last-child td {
    border-bottom: 0;
}

.swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.swatch {
    min-width: 10rem;
    padding: 1rem;
    border-radius: 1rem;
    color: #fff;
    font-weight: 700;
}

.swatch span {
    display: block;
    margin-top: 0.35rem;
    font-family: Consolas, monospace;
    font-size: 0.85rem;
    font-weight: 400;
}

.code-card {
    min-width: 0;
    overflow: hidden;
    border-radius: 1rem;
    background: #211124;
}

.code-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.55rem 0.75rem;
    color: #f7ecf7;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
    font-weight: 700;
}

.copy-button {
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    font: inherit;
    padding: 0.25rem 0.65rem;
}

.copy-button:hover {
    background: rgba(255, 255, 255, 0.16);
}

pre.code-block {
    margin: 0;
    padding: 1rem;
    overflow-x: auto;
    color: #f7ecf7;
    background: transparent;
}

pre.code-block code {
    color: inherit;
}

.game-layout {
    display: block;
    max-width: 44rem;
    margin-right: auto;
    margin-left: auto;
}

.play-surface {
    gap: 0.75rem;
    padding: clamp(0.75rem, 2vw, 1.1rem);
}

.game-hud {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
    margin-bottom: 0;
}

.game-display {
    min-width: 0;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--stroke-subtle);
    border-radius: 0.85rem;
    background: #fff;
}

.game-display strong {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--brand-dark);
    font-size: 0.85rem;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(7, minmax(1.75rem, 3.25rem));
    justify-content: center;
    gap: 0.25rem;
    padding: 0.75rem;
    border: 1px solid var(--stroke-subtle);
    border-radius: 1.25rem;
    background:
        radial-gradient(circle at center, rgba(132, 0, 132, 0.06), transparent 30rem),
        #fff;
}

.game-cell {
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border: 1px solid #eaddea;
    border-radius: 0.45rem;
    color: var(--brand-muted);
    background: #fff;
    font-size: clamp(0.7rem, 1.5vw, 0.95rem);
    font-weight: 800;
}

.game-cell.player {
    color: #fff;
    background: var(--brand);
    box-shadow: 0 8px 20px rgba(132, 0, 132, 0.28);
}

.game-cell.target {
    color: var(--brand-dark);
    background: #f4d9f4;
}

.game-cell.beam {
    color: var(--brand);
    background: rgba(163, 64, 163, 0.12);
}

.game-cell svg,
.game-cell img {
    display: block;
    max-width: 80%;
    max-height: 80%;
}

.game-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 0.55rem;
    margin-top: 0;
}

.control-card {
    display: grid;
    grid-template-rows: auto 1fr;
    min-height: 11.25rem;
    padding: 0.55rem;
    border: 1px solid var(--stroke-subtle);
    border-radius: 0.85rem;
    background: #fff;
}

.control-card h2 {
    margin: 0;
    color: var(--brand-dark);
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-align: center;
    text-transform: uppercase;
}

.control-preview {
    display: grid;
    place-items: center;
    min-height: 9.25rem;
    padding: 0;
    touch-action: none;
    user-select: none;
}

.control-preview * {
    touch-action: none;
    user-select: none;
}

.status-message {
    margin: 0;
    padding: 0.5rem 0.65rem;
    overflow-wrap: anywhere;
    font-size: 0.9rem;
    line-height: 1.25;
}

.scenario-dashboard {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.scenario-panel {
    display: grid;
    place-items: center;
    gap: 0.75rem;
    min-width: 0;
    min-height: 14rem;
    padding: 1rem;
    border: 1px solid var(--stroke-subtle);
    border-radius: 1rem;
    background: #fff;
}

.scenario-panel strong {
    color: var(--brand-dark);
}

.scenario-panel.wide {
    min-height: 9rem;
}

.scenario-card {
    display: grid;
    gap: 0.75rem;
}

.smart-home-panel .scenario-panel {
    text-align: center;
}

.scenario-value {
    color: var(--brand-dark);
    font-weight: 800;
}

.scenario-copy {
    max-width: 20rem;
    margin: 0;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    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;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

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

.loading-progress circle:last-child {
    stroke: var(--brand);
    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;
}

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

@media (max-width: 980px) {
    .hero-with-visual {
        grid-template-columns: 1fr;
    }

    .hero-visual {
        justify-content: start;
    }

    .reference-body {
        grid-template-columns: minmax(0, 1fr);
    }

    .game-layout {
        grid-template-columns: 1fr;
    }

    .control-card {
        min-height: 0;
        padding: 0.45rem;
    }

    .game-controls {
        gap: 0.45rem;
    }

    .control-card h2 {
        font-size: 0.8rem;
    }

    .control-preview {
        min-height: 7.25rem;
    }
}

@media (max-width: 720px) {
    .hero {
        padding: 1.25rem;
        border-radius: 1.25rem;
    }

    .hero h1,
    .section-heading h2,
    .reference-head h2 {
        overflow-wrap: anywhere;
    }

    .section-heading,
    .reference-head,
    .code-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .reference-card {
        gap: 1rem;
        padding: 0.85rem;
        border-radius: 1rem;
    }

    .preview-panel {
        min-height: 11rem;
        padding: 0.75rem;
        border-radius: 0.85rem;
    }

    .control-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.65rem;
    }

    .table-wrap {
        margin-right: -0.25rem;
        margin-left: -0.25rem;
        border-radius: 0.8rem;
    }

    .parameter-table {
        min-width: 36rem;
    }

    pre.code-block {
        padding: 0.8rem;
    }

    .scenario-dashboard {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.75rem;
    }

    .scenario-panel,
    .scenario-panel.wide {
        grid-column: auto;
        min-height: 0;
        padding: 0.85rem;
    }

    .smart-home-panel .scenario-panel {
        gap: 0.6rem;
    }
}
