:root {
    --bg: #0a1224;
    --panel: #121d35;
    --panel-soft: #172645;
    --surface: #eff4fb;
    --text: #f1efe4;
    --text-dark: #0f1728;
    --muted: #9eb0d0;
    --border: rgba(255, 255, 255, 0.08);
    --money: #28c76f;
    --users: #42a5f5;
    --reputation: #ff6b6b;
    --energy: #ffb020;
    --quality: #8e63ff;
    --shadow: 0 20px 45px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    background:
        radial-gradient(circle at top left, rgba(66, 165, 245, 0.16), transparent 28%),
        radial-gradient(circle at top right, rgba(142, 99, 255, 0.18), transparent 34%),
        linear-gradient(180deg, #08101f 0%, #0a1224 42%, #111b30 100%);
    color: var(--text);
}

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

button,
input,
select,
textarea {
    font: inherit;
}

:focus-visible {
    outline: 3px solid #6fc5ff;
    outline-offset: 3px;
}

.skip-link {
    position: absolute;
    left: 16px;
    top: -60px;
    z-index: 1000;
    padding: 10px 14px;
    border-radius: 12px;
    background: #6fc5ff;
    color: #08101f;
    font-weight: 700;
}

.skip-link:focus {
    top: 16px;
}

img {
    max-width: 100%;
    display: block;
}

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

.site-header,
.site-footer,
.page-wrap {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

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

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.1rem;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, #42a5f5, #8e63ff);
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    color: var(--muted);
}

.main-nav a:hover {
    color: #fff;
}

.main-nav a.is-current {
    color: #fff;
    background: rgba(111, 197, 255, 0.12);
    padding: 10px 12px;
    border-radius: 14px;
}

.menu-toggle {
    display: none;
    width: 52px;
    height: 52px;
    padding: 0;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 6px;
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.menu-toggle.is-open span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.menu-toggle.is-open span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.is-open span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

.page-wrap {
    padding: 12px 0 40px;
}

.site-footer {
    padding: 24px 0 40px;
    color: var(--muted);
    text-align: center;
}

.hero-panel,
.scenario-layout,
.game-topbar,
.section-block,
.table-card,
.result-box,
.panel-form,
.info-card,
.stat-card,
.choice-editor,
.choice-group {
    background: rgba(18, 29, 53, 0.9);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.hero-panel {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 26px;
    padding: 32px;
    align-items: center;
}

.hero-card {
    padding: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
    border-radius: 20px;
}

.hero-card-img {
    border-radius: 20px;
}

.hero-copy h1,
.section-heading h1,
.section-heading h2,
.scenario-copy h2 {
    margin: 0 0 12px;
    line-height: 1.05;
}

.hero-copy h1 {
    font-size: clamp(2.4rem, 5vw, 4.3rem);
}

.lead,
.section-heading p,
.scenario-copy p,
.info-card p {
    color: var(--muted);
    line-height: 1.6;
}

.eyebrow {
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.8rem;
    color: #6fc5ff;
}

.hero-actions,
.action-row,
.section-heading.split {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.centered-actions {
    justify-content: center;
    margin-top: 10px;
}

.centered-actions .button {
    width: auto;
    min-width: 220px;
}

.top-spaced-action {
    margin-top: 10px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    padding: 12px 18px;
    font-weight: 700;
    border: 1px solid transparent;
    cursor: pointer;
}

.button:hover {
    filter: brightness(1.08);
}

.button.small {
    padding: 8px 12px;
    font-size: 0.88rem;
}

.button-primary {
    background: linear-gradient(135deg, #42a5f5, #8e63ff);
    color: #fff;
}

.button-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.button-ghost {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.button-danger {
    background: #c43c50;
    color: #fff;
}

.admin-actions-cell form {
    margin: 0;
}

.section-block {
    margin-top: 28px;
    padding: 28px;
}

.section-block.narrow {
    width: min(850px, 100%);
    margin-left: auto;
    margin-right: auto;
}

.section-heading {
    margin-bottom: 18px;
}

.card-grid,
.stats-grid,
.effect-grid {
    display: grid;
    gap: 18px;
}

.card-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    margin: 22px 0;
}

.round-stats {
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
    gap: 12px;
    margin: 14px 0 18px;
}

.effect-grid {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.info-card,
.stat-card,
.choice-editor,
.choice-group,
.table-card,
.panel-form {
    padding: 20px;
}

.info-stack {
    display: grid;
    gap: 18px;
}

.card-image,
.scenario-image {
    width: 100%;
    object-fit: cover;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
}

.card-image {
    height: 160px;
    margin-bottom: 16px;
}

.scenario-image {
    height: 280px;
}

.mini-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.stat-pill,
.round-badge {
    border-radius: 999px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.9rem;
}

.effect-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.effect-pill {
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    background: rgba(255, 255, 255, 0.08);
    color: #dbe7ff;
}

.effect-pill.positive {
    background: rgba(40, 199, 111, 0.14);
    color: #8df0b7;
}

.effect-pill.negative {
    background: rgba(255, 107, 107, 0.14);
    color: #ffb1b1;
}

.game-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 22px 24px;
}

.progress-track {
    height: 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
    margin: 18px 0 24px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #42a5f5, #8e63ff);
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card.warning {
    border-color: rgba(255, 176, 32, 0.45);
}

.stat-card.critical {
    border-color: rgba(255, 107, 107, 0.6);
    box-shadow: 0 18px 40px rgba(196, 60, 80, 0.18);
}

.stat-card::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 4px;
    background: currentColor;
    opacity: 0.9;
}

.money { color: var(--money); }
.users { color: var(--users); }
.reputation { color: var(--reputation); }
.energy { color: var(--energy); }
.quality { color: var(--quality); }

.stat-card h3,
.stat-card strong {
    color: #fff;
}

.stat-card strong {
    font-size: 2rem;
}

.round-stats .stat-card {
    padding: 12px 13px;
    border-radius: 16px;
}

.round-stats .stat-card h3 {
    margin: 0 0 4px;
    font-size: 0.74rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    line-height: 1.2;
}

.round-stats .stat-card strong {
    font-size: 1.15rem;
    line-height: 1;
}

.scenario-layout {
    display: grid;
    gap: 22px;
    padding: 26px;
}

.scenario-top {
    display: grid;
    grid-template-columns: minmax(320px, 0.95fr) minmax(480px, 1.25fr);
    gap: 22px;
    align-items: stretch;
    width: min(100%, 1080px);
    margin: 0 auto;
}

.scenario-card {
    display: grid;
    grid-template-columns: minmax(320px, 0.95fr) minmax(480px, 1.25fr);
    gap: 22px;
    align-items: stretch;
    width: 100%;
}

.scenario-copy {
    min-width: 0;
}

.task-label {
    margin: 0 0 12px;
    color: #bfe7ff;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.92rem;
    font-weight: 700;
    text-shadow: 0 0 18px rgba(111, 197, 255, 0.18);
}

.task-highlight {
    width: 100%;
    padding: 22px 24px;
    border-radius: 22px;
    background:
        linear-gradient(135deg, rgba(66, 165, 245, 0.2), rgba(142, 99, 255, 0.16)),
        rgba(10, 20, 38, 0.88);
    border: 1px solid rgba(111, 197, 255, 0.28);
    box-shadow: 0 18px 40px rgba(8, 16, 31, 0.22);
    position: relative;
    overflow: hidden;
}

.task-highlight::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 6px;
    background: linear-gradient(180deg, #6fc5ff, #8e63ff);
}

.task-meta {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.difficulty-badge {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e5efff;
    font-size: 0.78rem;
    font-weight: 700;
}

.task-highlight h2 {
    margin: 0 0 12px;
    font-size: clamp(1.5rem, 3.2vw, 2rem);
    line-height: 1.08;
}

.task-highlight p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.7;
}

.choices-panel {
    display: grid;
    gap: 14px;
    align-content: start;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 6px;
}

.choice-selection-form,
.choice-list {
    display: grid;
    gap: 14px;
}

.choice-option {
    display: block;
}

.choice-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.choice-button {
    display: block;
    width: 100%;
    text-align: left;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff;
    padding: 18px;
    border-radius: 18px;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.choice-button:hover {
    transform: translateY(-2px);
    border-color: #6fc5ff;
    background: rgba(111, 197, 255, 0.08);
}

.choice-input:checked + .choice-button {
    border-color: #6fc5ff;
    background: rgba(111, 197, 255, 0.12);
    box-shadow: 0 0 0 3px rgba(111, 197, 255, 0.18);
}

.choice-option:focus-within .choice-button {
    border-color: #6fc5ff;
    box-shadow: 0 0 0 3px rgba(111, 197, 255, 0.22);
}

.choice-button .choice-title {
    display: inline;
    font-weight: 700;
}

.choice-marker {
    display: inline-block;
    min-width: 28px;
    margin-right: 6px;
    color: #8fd4ff;
    font-weight: 800;
}

.choice-button .choice-helper {
    display: block;
    color: var(--muted);
    font-size: 0.92rem;
}

.choice-submit-button {
    justify-self: center;
    width: min(100%, 240px);
    margin-top: 8px;
}

.choice-submit-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    filter: none;
}

.panel-form,
.choice-editor,
.choice-group {
    display: grid;
    gap: 16px;
}

.form-row {
    display: grid;
    gap: 8px;
}

label,
.field-label {
    display: grid;
    gap: 8px;
    color: var(--muted);
}

.form-row label,
.choice-editor > legend,
.choice-group > legend {
    color: var(--text);
    font-weight: 700;
}

input,
textarea,
select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(8, 16, 31, 0.6);
    color: #fff;
}

input[type="file"] {
    padding: 10px 12px;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    border-color: #6fc5ff;
}

textarea {
    resize: vertical;
}

.choice-group,
.choice-editor {
    min-width: 0;
}

.choice-group {
    margin: 8px 0 0;
}

.choice-editor {
    background: rgba(255, 255, 255, 0.03);
}

.choice-group legend,
.choice-editor legend {
    padding: 0 8px;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-row input {
    width: auto;
    margin: 0;
}

.checkbox-row label {
    display: inline;
    color: var(--text);
    font-weight: 700;
}

.startup-picker input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.select-card {
    display: block;
}

.select-card-body {
    display: block;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    min-height: 100%;
}

.select-card input:checked + .select-card-body {
    border-color: #6fc5ff;
    box-shadow: 0 0 0 2px rgba(111, 197, 255, 0.18);
}

.select-card:focus-within .select-card-body {
    border-color: #6fc5ff;
    box-shadow: 0 0 0 3px rgba(111, 197, 255, 0.28);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table th,
.leaderboard-table td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.leaderboard-table th {
    color: #fff;
}

.flash {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 16px;
}

.async-feedback {
    margin-top: 10px;
}

.flash-success {
    background: rgba(40, 199, 111, 0.14);
    border: 1px solid rgba(40, 199, 111, 0.35);
}

.flash-error {
    background: rgba(255, 107, 107, 0.14);
    border: 1px solid rgba(255, 107, 107, 0.35);
}

.flash.flash-error h2 {
    margin: 0 0 10px;
    font-size: 1rem;
    color: #fff;
}

.flash.flash-error ul {
    margin: 0;
    padding-left: 20px;
}

.flash.flash-error li {
    margin: 4px 0;
    color: #ffd3d3;
}

.field-error {
    color: #ffb1b1;
    font-size: 0.92rem;
}

.field-help {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.45;
}

.start-field-help {
    color: #f4df9b;
    font-size: 0.82rem;
}

.empty-table-message {
    text-align: center;
    color: var(--muted);
    padding: 24px 12px;
}

.warning-box {
    margin: 18px 0 22px;
    padding: 16px 18px;
    border-radius: 18px;
    background: rgba(255, 176, 32, 0.12);
    border: 1px solid rgba(255, 176, 32, 0.35);
}

.warning-box h3 {
    margin: 0 0 10px;
}

.warning-list {
    margin: 0;
    padding-left: 18px;
    color: #ffe2ad;
}

.result-box {
    margin: 22px 0;
    padding: 22px;
    text-align: center;
}

.muted {
    color: var(--muted);
}

.admin-link-card {
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.admin-link-card:hover {
    transform: translateY(-3px);
    border-color: #6fc5ff;
}

@media (max-width: 1024px) {
    .hero-panel,
    .scenario-top,
    .scenario-card {
        grid-template-columns: 1fr;
    }

    .hero-card,
    .choices-panel {
        order: 2;
    }
}

@media (max-width: 760px) {
    .game-topbar,
    .site-header {
        flex-direction: column;
        align-items: stretch;
    }

    .site-header {
        padding: 18px 0;
    }

    .brand {
        justify-content: space-between;
    }

    .brand img {
        width: 92px;
        height: 92px;
    }

    .menu-toggle {
        display: inline-flex;
        align-self: flex-end;
        position: absolute;
        top: 38px;
        right: 0;
    }

    .main-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 16px;
        border-radius: 14px;
        background: rgba(18, 29, 53, 0.96);
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: var(--shadow);
    }

    .main-nav.is-open {
        display: flex;
    }

    .main-nav a {
        padding: 12px 14px;
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.04);
    }

    .hero-panel,
    .section-block,
    .scenario-layout,
    .panel-form,
    .table-card,
    .info-card,
    .choice-editor,
    .choice-group,
    .result-box {
        padding: 20px;
    }

    .hero-actions,
    .section-heading.split,
    .action-row {
        align-items: stretch;
    }

    .hero-actions .button,
    .section-heading.split .button {
        width: 100%;
    }

    .centered-actions {
        justify-content: center;
    }

    .centered-actions .button {
        width: min(100%, 280px);
        margin-inline: auto;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .round-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin: 12px 0 16px;
    }

    .round-stats .stat-card {
        padding: 10px 11px;
    }

    .round-stats .stat-card h3 {
        font-size: 0.68rem;
        margin-bottom: 3px;
    }

    .round-stats .stat-card strong {
        font-size: 1.02rem;
    }

    .leaderboard-table {
        border: 0;
    }

    .leaderboard-table thead {
        display: none;
    }

    .leaderboard-table tbody,
    .leaderboard-table tr,
    .leaderboard-table td {
        display: block;
        width: 100%;
    }

    .leaderboard-table tr {
        margin-bottom: 14px;
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 18px;
        padding: 12px;
        background: rgba(255, 255, 255, 0.03);
    }

    .leaderboard-table td {
        white-space: normal;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        padding: 10px 0 10px 44%;
        position: relative;
        min-height: 36px;
    }

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

    .leaderboard-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        top: 10px;
        width: 38%;
        color: var(--muted);
        font-weight: 700;
    }

    .startup-type-actions,
    .scenario-actions {
        display: grid;
        gap: 10px;
        padding-left: 0;
        padding-top: 28px;
    }

    .startup-type-actions::before,
    .scenario-actions::before {
        position: static;
        display: block;
        width: auto;
        margin-bottom: 6px;
    }

    .startup-type-actions .button,
    .startup-type-actions form,
    .startup-type-actions form .button,
    .scenario-actions .button,
    .scenario-actions form,
    .scenario-actions form .button {
        width: 100%;
    }

    .startup-type-actions form,
    .scenario-actions form {
        margin-top: 10px;
    }

    .hero-copy h1 {
        font-size: 2.4rem;
    }
}

@media (max-width: 560px) {
    .site-header,
    .site-footer,
    .page-wrap {
        width: min(100% - 20px, 1180px);
    }

    .hero-copy h1,
    .section-heading h1 {
        font-size: 2.1rem;
    }

    .card-grid,
    .stats-grid,
    .effect-grid {
        grid-template-columns: 1fr;
    }

    .round-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .leaderboard-table td {
        padding-left: 0;
        padding-top: 28px;
    }

    .leaderboard-table td::before {
        position: static;
        display: block;
        width: auto;
        margin-bottom: 6px;
    }

    .scenario-image {
        height: 220px;
    }

    .task-highlight {
        padding: 18px 18px 18px 20px;
    }

    .task-meta {
        justify-content: flex-start;
        margin-bottom: 10px;
    }

    .task-highlight h2 {
        font-size: 1.32rem;
    }

    .task-highlight p {
        font-size: 0.96rem;
        line-height: 1.6;
    }

    .choice-submit-button {
        width: min(100%, 280px);
    }

    .round-badge {
        align-self: flex-start;
    }
}

@media (max-width: 460px) {
    .card-grid,
    .stats-grid,
    .effect-grid {
        grid-template-columns: 1fr;
    }

    .round-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .round-stats .stat-card {
        padding: 9px 10px;
        border-radius: 14px;
    }

    .round-stats .stat-card h3 {
        font-size: 0.64rem;
    }

    .round-stats .stat-card strong {
        font-size: 0.94rem;
    }

    .task-label {
        font-size: 0.8rem;
        letter-spacing: 0.16em;
    }

    .difficulty-badge {
        font-size: 0.72rem;
        padding: 6px 10px;
    }

    .task-highlight {
        padding: 16px 16px 16px 18px;
        border-radius: 18px;
    }

    .task-highlight h2 {
        font-size: 1.18rem;
    }

    .task-highlight p {
        font-size: 0.92rem;
    }

    .choice-submit-button {
        width: 100%;
    }

    .hero-actions .button,
    .section-heading.split .button,
    .centered-actions .button {
        width: 100%;
    }

    .hero-panel,
    .section-block,
    .scenario-layout,
    .panel-form,
    .table-card,
    .info-card,
    .choice-editor,
    .choice-group,
    .result-box {
        padding: 16px;
    }
}