:root {
    color-scheme: dark;
    --page: #101418;
    --surface: #171d23;
    --surface-strong: #1f2730;
    --border: #2c3742;
    --text: #eef3f7;
    --muted: #9aa7b4;
    --primary: #d6a84f;
    --primary-dark: #9d7733;
    --success: #4fb477;
    --danger: #c75f5f;
    --link: #8fb7ff;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--page);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a {
    color: var(--link);
}

h1, h2, h3, p {
    margin-top: 0;
}

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

input, select, textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #0d1115;
    color: var(--text);
    padding: 9px 10px;
}

label {
    display: block;
    color: var(--muted);
    margin: 12px 0 6px;
}

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-strong);
    color: var(--text);
    padding: 8px 14px;
    text-decoration: none;
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.button-primary, button[type="submit"] {
    border-color: var(--primary-dark);
    background: var(--primary);
    color: #17120a;
    font-weight: 700;
}

.flash {
    max-width: 1120px;
    margin: 12px auto 0;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-strong);
}

.public-page {
    min-height: 100vh;
}

.public-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.public-card {
    width: min(100%, 420px);
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.public-card h1 {
    margin-bottom: 20px;
}

.public-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin: 18px 0 0;
}

.app-shell {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 18px;
}

.game-status-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.eyebrow {
    margin: 0 0 2px;
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.game-status-label {
    margin: 0;
    font-weight: 700;
}

.game-status-detail {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.game-status-box.is-running,
.game-status-box.is-matched {
    border-color: rgba(79, 180, 119, 0.65);
}

.game-status-box.is-running .game-status-label,
.game-status-box.is-matched .game-status-label {
    color: var(--success);
}

.game-status-box.is-searching,
.game-status-box.is-draining,
.game-status-box.is-maintenance {
    border-color: rgba(214, 168, 79, 0.7);
}

.game-status-box.is-unverified,
.game-status-box.is-error {
    border-color: rgba(199, 95, 95, 0.7);
}

.game-status-box.is-unverified .game-status-label,
.game-status-box.is-error .game-status-label {
    color: #ffd0d0;
}

.app-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 16px;
}

.app-nav, .app-main {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.app-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    align-self: start;
}

.app-nav a, .nav-logout {
    width: 100%;
    justify-content: flex-start;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    padding: 9px 10px;
    text-align: left;
    text-decoration: none;
    font-weight: 600;
}

.app-nav a:hover, .nav-logout:hover {
    background: var(--surface-strong);
}

.nav-logout {
    color: #ffd0d0;
    cursor: pointer;
}

.app-nav form {
    margin: 6px 0 0;
}

.app-main {
    min-width: 0;
    padding: 20px;
}

.settings-form {
    max-width: 680px;
}

.settings-group {
    margin: 0 0 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 16px 16px;
}

.settings-group legend {
    color: var(--text);
    padding: 0 6px;
    font-weight: 700;
}

.settings-form input[type="checkbox"] {
    width: auto;
    min-height: 0;
    margin-right: 8px;
    padding: 0;
}

.settings-checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.settings-checkbox-row label {
    order: 2;
    display: inline;
    margin: 0;
}

.settings-checkbox-row input[type="checkbox"] {
    order: 1;
    margin: 0;
}

.settings-actions {
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
}

.settings-reload-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

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

.table-scroll {
    overflow-x: auto;
}

th, td {
    border-bottom: 1px solid var(--border);
    padding: 10px;
    text-align: left;
}

.match-row-cancelled td {
    color: var(--muted);
}

.match-row-failed td {
    color: #ffd0d0;
}

dl {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 8px 16px;
}

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

dd {
    margin: 0;
}

#matchmaking {
    max-width: 560px;
}

.search-options {
    margin: 0 0 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
}

.search-options legend {
    color: var(--muted);
    padding: 0 6px;
}

@media (max-width: 720px) {
    .app-shell {
        padding: 12px;
    }

    .game-status-box {
        align-items: stretch;
        flex-direction: column;
    }

    .game-status-box .button {
        width: 100%;
    }

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

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

    .app-nav form {
        margin: 0;
    }

    .app-main, .public-card {
        padding: 16px;
    }

    dl {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

/* Site presentation layer -------------------------------------------------- */

:root {
    --page-deep: #0a0d10;
    --surface-soft: #141a20;
    --surface-raised: #1b232b;
    --border-soft: rgba(148, 166, 184, 0.16);
    --border-bright: rgba(148, 166, 184, 0.3);
    --primary-light: #edc36d;
    --primary-wash: rgba(214, 168, 79, 0.12);
    --success-wash: rgba(79, 180, 119, 0.12);
    --danger-wash: rgba(199, 95, 95, 0.12);
    --warning-wash: rgba(214, 168, 79, 0.1);
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
    --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.14);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
}

html {
    background: var(--page-deep);
}

body {
    background:
        radial-gradient(circle at 12% -10%, rgba(78, 105, 128, 0.15), transparent 34rem),
        radial-gradient(circle at 100% 0, rgba(214, 168, 79, 0.07), transparent 30rem),
        var(--page);
    font-size: 16px;
}

::selection {
    background: rgba(214, 168, 79, 0.34);
    color: var(--text);
}

a {
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

a:hover {
    color: #bad0ff;
}

h1, h2, h3 {
    line-height: 1.18;
}

h1 {
    margin-bottom: 8px;
    font-size: clamp(1.75rem, 3vw, 2.35rem);
    letter-spacing: -0.035em;
}

h2 {
    margin-bottom: 10px;
    font-size: 1.18rem;
    letter-spacing: -0.015em;
}

p:last-child {
    margin-bottom: 0;
}

:focus-visible {
    outline: 3px solid rgba(143, 183, 255, 0.75);
    outline-offset: 3px;
}

button,
.button,
input,
select,
textarea,
.app-nav a {
    transition:
        border-color 140ms ease,
        background-color 140ms ease,
        color 140ms ease,
        box-shadow 140ms ease,
        transform 140ms ease;
}

input, select, textarea {
    border-color: var(--border-soft);
    background: rgba(8, 12, 15, 0.76);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.24);
}

input:hover, select:hover, textarea:hover {
    border-color: var(--border-bright);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--link);
    box-shadow: 0 0 0 3px rgba(143, 183, 255, 0.12);
    outline: none;
}

input:disabled, select:disabled, textarea:disabled {
    color: #778491;
    cursor: not-allowed;
}

label {
    font-size: 0.9rem;
    font-weight: 650;
}

button, .button {
    min-height: 42px;
    border-color: var(--border-soft);
    border-radius: var(--radius-sm);
    background: var(--surface-raised);
    font-weight: 700;
}

button:hover:not(:disabled), .button:hover {
    border-color: var(--border-bright);
    background: #252f39;
    color: var(--text);
    transform: translateY(-1px);
}

button:active:not(:disabled), .button:active {
    transform: translateY(0);
}

.button-primary,
button.button-primary,
button[type="submit"]:not(.nav-logout) {
    border-color: var(--primary-dark);
    background: linear-gradient(180deg, var(--primary-light), var(--primary));
    box-shadow: 0 5px 15px rgba(214, 168, 79, 0.12);
    color: #21180b;
}

.button-primary:hover,
button.button-primary:hover:not(:disabled),
button[type="submit"]:not(.nav-logout):hover:not(:disabled) {
    border-color: var(--primary);
    background: linear-gradient(180deg, #f3ce80, #ddaE53);
    color: #17120a;
}

.button-secondary {
    background: transparent;
}

.text-link,
.table-action {
    font-weight: 700;
    text-decoration: none;
}

.flash {
    width: min(1120px, calc(100% - 32px));
    border-color: var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
}

.flash-success {
    border-color: rgba(79, 180, 119, 0.42);
    background: #17271f;
}

.flash-error,
.flash-danger {
    border-color: rgba(199, 95, 95, 0.45);
    background: #2a191b;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.015em;
    text-decoration: none;
}

.site-brand:hover {
    color: var(--text);
}

.site-brand-stage {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0;
}

.site-brand-mark {
    display: inline-grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border: 1px solid rgba(214, 168, 79, 0.55);
    border-radius: 9px;
    background: linear-gradient(145deg, rgba(214, 168, 79, 0.22), rgba(214, 168, 79, 0.05));
    color: var(--primary-light);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.25rem;
}

.public-shell {
    padding: 32px 20px;
}

.public-card {
    width: min(100%, 500px);
    padding: 34px;
    border-color: var(--border-soft);
    border-radius: var(--radius-lg);
    background: rgba(23, 29, 35, 0.92);
    box-shadow: var(--shadow);
}

.public-brand {
    margin-bottom: 34px;
}

.public-intro {
    margin-bottom: 24px;
}

.public-intro h1 {
    margin-bottom: 10px;
}

.public-intro > p:last-child {
    color: var(--muted);
}

.public-form > div {
    margin-bottom: 15px;
}

.public-form label {
    margin-top: 0;
}

.registration-info {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.4;
}

.registration-terms {
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid var(--border-soft);
    color: var(--muted);
    font-size: 0.84rem;
}

.registration-terms strong {
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.registration-terms span {
    display: block;
    margin-top: 5px;
}

.public-form > button,
.public-form > div + button,
.public-card form > button {
    width: 100%;
    margin-top: 8px;
}

.public-links {
    align-items: center;
    justify-content: space-between;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border-soft);
    font-size: 0.92rem;
}

.app-shell {
    width: min(1240px, 100%);
    padding: 22px;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 42px;
    margin-bottom: 14px;
    padding: 0 4px;
}

.app-user {
    max-width: min(45vw, 360px);
    overflow: hidden;
    color: var(--muted);
    font-size: 0.9rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-layout {
    grid-template-columns: 224px minmax(0, 1fr);
    gap: 18px;
}

.app-nav,
.app-main,
.game-status-box {
    border-color: var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
}

.app-nav {
    gap: 3px;
    padding: 10px;
    background: rgba(20, 26, 32, 0.88);
}

.app-nav a,
button.nav-logout {
    position: relative;
    min-height: 42px;
    color: #cbd4dc;
    font-size: 0.92rem;
}

.app-nav a:hover,
button.nav-logout:hover {
    background: var(--surface-raised);
    color: var(--text);
    transform: none;
}

.app-nav a.is-current {
    background: var(--primary-wash);
    color: var(--primary-light);
}

.app-nav a.is-current::before {
    position: absolute;
    top: 10px;
    bottom: 10px;
    left: 0;
    width: 3px;
    border-radius: 4px;
    background: var(--primary);
    content: "";
}

.app-nav a.nav-primary:not(.is-current) {
    color: var(--primary-light);
}

.nav-divider {
    height: 1px;
    margin: 6px 8px;
    background: var(--border-soft);
}

.app-nav form {
    margin: 0;
}

button.nav-logout,
button.nav-logout[type="submit"] {
    border: 0;
    background: transparent;
    box-shadow: none;
    color: #e7a0a0;
    font-weight: 650;
}

button.nav-logout:hover:not(:disabled),
button.nav-logout[type="submit"]:hover:not(:disabled) {
    background: var(--danger-wash);
    color: #ffc0c0;
}

.game-status-box {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto;
    margin-bottom: 18px;
    padding: 14px 16px;
    background: rgba(20, 26, 32, 0.88);
}

.game-status-indicator,
.matchmaking-state-indicator {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: #667481;
    box-shadow: 0 0 0 4px rgba(102, 116, 129, 0.12);
}

.game-status-copy {
    min-width: 0;
}

.game-status-box.is-running .game-status-indicator,
.game-status-box.is-matched .game-status-indicator,
#matchmaking.is-matched .matchmaking-state-indicator {
    background: var(--success);
    box-shadow: 0 0 0 4px var(--success-wash);
}

.game-status-box.is-searching .game-status-indicator,
.game-status-box.is-draining .game-status-indicator,
.game-status-box.is-maintenance .game-status-indicator,
#matchmaking.is-searching .matchmaking-state-indicator,
#matchmaking.is-draining .matchmaking-state-indicator,
#matchmaking.is-maintenance .matchmaking-state-indicator {
    background: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-wash);
    animation: status-pulse 1.8s ease-in-out infinite;
}

.game-status-box.is-error .game-status-indicator,
.game-status-box.is-unverified .game-status-indicator {
    background: var(--danger);
    box-shadow: 0 0 0 4px var(--danger-wash);
}

.eyebrow {
    color: #82909c;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.11em;
}

.game-status-label {
    line-height: 1.3;
}

.game-status-detail {
    font-size: 0.88rem;
}

.app-main {
    padding: clamp(22px, 4vw, 38px);
    background: rgba(23, 29, 35, 0.93);
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border-soft);
}

.page-header .eyebrow {
    margin-bottom: 7px;
}

.page-intro {
    max-width: 650px;
    margin: 0;
    color: var(--muted);
}

.content-card,
.empty-state,
.matchmaking-state,
.notice {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    background: rgba(12, 17, 21, 0.38);
}

.content-card {
    padding: 22px;
}

.content-card + .notice {
    margin-top: 16px;
}

.news-item {
    position: relative;
    overflow: hidden;
}

.news-item::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--primary);
    content: "";
}

.news-meta {
    margin-bottom: 10px;
    color: var(--primary-light);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.prose {
    max-width: 780px;
}

.prose p,
.prose li {
    color: #c6d0d9;
}

.prose ul {
    display: grid;
    gap: 10px;
    padding-left: 22px;
}

.game-guide {
    display: grid;
    gap: 34px;
}

.guide-section-heading {
    margin-bottom: 15px;
}

.guide-section-heading .eyebrow {
    margin-bottom: 5px;
}

.guide-section-heading h2 {
    margin: 0;
    font-size: 1.35rem;
}

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

.guide-card {
    min-width: 0;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    background: rgba(12, 17, 21, 0.38);
    padding: 18px;
}

.guide-card h3 {
    margin-bottom: 7px;
    color: var(--primary-light);
    font-size: 1rem;
}

.guide-card p {
    margin: 0;
    color: #c6d0d9;
    font-size: 0.94rem;
}

.calculation-card {
    padding-top: 6px;
    padding-bottom: 6px;
}

.calculation-list {
    display: block;
    margin: 0;
}

.calculation-list > div {
    display: grid;
    grid-template-columns: minmax(190px, 0.3fr) minmax(0, 1fr);
    gap: 22px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-soft);
}

.calculation-list > div:last-child {
    border-bottom: 0;
}

.calculation-list dt {
    color: var(--text);
    font-weight: 750;
}

.calculation-list dd {
    color: #c6d0d9;
}

.calculation-list code {
    color: var(--primary-light);
    font-size: 0.88em;
}

.important-info {
    max-width: 800px;
}

.important-info h2:not(:first-child) {
    margin-top: 30px;
}

.info-list {
    margin: 0;
    border-top: 1px solid var(--border-soft);
    padding: 0;
    list-style: none;
}

.info-list li {
    display: grid;
    grid-template-columns: minmax(150px, 0.35fr) 1fr;
    gap: 20px;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-soft);
}

.info-list strong {
    color: var(--text);
}

.info-list span {
    color: #c6d0d9;
}

kbd {
    display: inline-block;
    min-width: 25px;
    border: 1px solid var(--border-bright);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--surface-raised);
    padding: 1px 6px;
    color: var(--text);
    font: 0.82em/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    text-align: center;
    white-space: nowrap;
}

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

.hotkey-section {
    min-width: 0;
}

.hotkey-section h2 {
    margin-bottom: 16px;
}

.hotkey-section-wide {
    grid-column: 1 / -1;
}

.hotkey-list {
    display: block;
    margin: 0;
}

.hotkey-list > div {
    display: grid;
    grid-template-columns: minmax(150px, 0.42fr) minmax(0, 1fr);
    gap: 18px;
    padding: 13px 0;
    border-top: 1px solid var(--border-soft);
}

.hotkey-list > div:last-child {
    padding-bottom: 0;
}

.hotkey-list dt,
.hotkey-list dd {
    min-width: 0;
}

.hotkey-list dd {
    color: #c6d0d9;
}

.hotkey-detail {
    display: block;
    margin-top: 5px;
    color: var(--muted);
}

.hotkey-list dd kbd {
    font-size: 0.76em;
}

.notice {
    margin-bottom: 20px;
    padding: 14px 16px;
}

.notice p {
    margin: 4px 0 0;
}

.notice-danger {
    border-color: rgba(199, 95, 95, 0.38);
    background: var(--danger-wash);
    color: #ffd0d0;
}

.notice-warning {
    border-color: rgba(214, 168, 79, 0.38);
    background: var(--warning-wash);
}

.account-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-top: 18px;
}

.account-notice h2 {
    margin-bottom: 4px;
}

.detail-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    margin: 0;
}

.detail-list > div {
    display: grid;
    grid-template-columns: minmax(120px, 0.35fr) 1fr;
    gap: 18px;
    padding: 13px 0;
    border-bottom: 1px solid var(--border-soft);
}

.detail-list > div:first-child {
    padding-top: 0;
}

.detail-list > div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.detail-list dd {
    overflow-wrap: anywhere;
}

.empty-state {
    padding: clamp(32px, 7vw, 64px) 24px;
    text-align: center;
}

.empty-state-mark {
    display: grid;
    width: 50px;
    height: 50px;
    margin: 0 auto 18px;
    place-items: center;
    border: 1px solid rgba(214, 168, 79, 0.34);
    border-radius: 15px;
    background: var(--primary-wash);
    color: var(--primary-light);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.45rem;
}

.empty-state p {
    max-width: 430px;
    margin: 0 auto 20px;
    color: var(--muted);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    background: rgba(154, 167, 180, 0.08);
    padding: 3px 9px;
    color: #cbd4dc;
    font-size: 0.78rem;
    font-weight: 750;
    white-space: nowrap;
}

.status-success,
.status-running,
.status-ready,
.status-ended {
    border-color: rgba(79, 180, 119, 0.34);
    background: var(--success-wash);
    color: #94deb0;
}

.status-warning,
.status-pending {
    border-color: rgba(214, 168, 79, 0.34);
    background: var(--primary-wash);
    color: var(--primary-light);
}

.status-failed,
.status-cancelled {
    border-color: rgba(199, 95, 95, 0.3);
    background: var(--danger-wash);
    color: #efaaaa;
}

.table-scroll {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
}

th {
    background: rgba(12, 17, 21, 0.5);
    color: var(--muted);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

th, td {
    padding: 13px 14px;
}

tbody tr {
    transition: background-color 140ms ease;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.025);
}

tbody tr:last-child td {
    border-bottom: 0;
}

.settings-form {
    max-width: 720px;
}

.settings-group {
    margin-bottom: 20px;
    padding: 12px 18px 18px;
    border-color: var(--border-soft);
    border-radius: var(--radius);
    background: rgba(12, 17, 21, 0.28);
}

.settings-group legend {
    padding: 0 8px;
    font-size: 1.05rem;
}

.settings-group-intro {
    margin: 2px 0 14px;
    color: var(--muted);
    font-size: 0.88rem;
}

.settings-group > div:not(.settings-checkbox-row) {
    margin-bottom: 14px;
}

.settings-group > div:not(.settings-checkbox-row):last-child {
    margin-bottom: 0;
}

.settings-group > div:not(.settings-checkbox-row) label {
    margin-top: 0;
}

.settings-checkbox-row {
    min-height: 46px;
    margin: 7px 0 0;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 9px 10px;
}

.settings-checkbox-row:hover {
    border-color: var(--border-soft);
    background: rgba(255, 255, 255, 0.025);
}

.settings-checkbox-row label {
    color: #cbd4dc;
    cursor: pointer;
    font-weight: 550;
}

.settings-form input[type="checkbox"] {
    width: 19px;
    height: 19px;
    accent-color: var(--primary);
    cursor: pointer;
}

.settings-form input[type="range"] {
    padding: 0;
    accent-color: var(--primary);
}

.settings-form .help-text,
.settings-form .form-help {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.84rem;
}

.settings-form ul {
    margin: 6px 0;
    padding-left: 20px;
    color: #efaaaa;
}

.settings-actions {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    margin-top: 6px;
    padding: 16px 0 0;
    border-top: 1px solid var(--border-soft);
}

.settings-reload-note {
    max-width: 420px;
    text-align: right;
}

#matchmaking {
    max-width: 640px;
}

.matchmaking-state {
    display: grid;
    grid-template-columns: 10px 1fr;
    gap: 14px;
    padding: 18px;
}

.matchmaking-state-indicator {
    margin-top: 19px;
}

#matchmaking-status {
    margin: 3px 0 0;
    font-size: 1.04rem;
    font-weight: 750;
}

#matchmaking-capacity {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.matchmaking-actions {
    display: flex;
    gap: 10px;
    margin: 14px 0 24px;
}

.search-options {
    margin-bottom: 0;
    border-color: var(--border-soft);
    border-radius: var(--radius);
    background: rgba(12, 17, 21, 0.2);
}

.search-options[disabled] {
    opacity: 0.64;
}

.form-help {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.result-banner {
    margin-bottom: 18px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    background: rgba(12, 17, 21, 0.38);
    padding: 24px;
}

.result-banner strong {
    display: block;
    margin-top: 5px;
    font-size: clamp(1.4rem, 3vw, 2rem);
    line-height: 1.2;
}

.result-won {
    border-color: rgba(79, 180, 119, 0.38);
    background: var(--success-wash);
}

.result-lost {
    border-color: rgba(199, 95, 95, 0.38);
    background: var(--danger-wash);
}

body.match-start-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at 50% 0%, rgba(214, 168, 79, 0.12), transparent 38%),
        var(--page);
}

.match-start-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: clamp(18px, 5vw, 56px);
}

.match-start-card {
    width: min(100%, 900px);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    background: rgba(23, 29, 35, 0.94);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
    padding: clamp(26px, 6vw, 60px);
    text-align: center;
}

.match-start-heading h1 {
    margin: 7px 0 8px;
    font-size: clamp(1.65rem, 4vw, 2.75rem);
    line-height: 1.15;
}

.match-start-live {
    min-height: 145px;
}

.match-start-countdown {
    margin: 10px 0 0;
    color: var(--primary);
    font-size: clamp(4rem, 13vw, 7.5rem);
    font-variant-numeric: tabular-nums;
    font-weight: 850;
    line-height: 1;
    text-shadow: 0 0 28px rgba(214, 168, 79, 0.18);
}

.match-start-status {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.match-start-players {
    display: grid;
    align-items: stretch;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: clamp(12px, 3vw, 26px);
    margin: 28px 0 22px;
}

.match-start-player {
    min-width: 0;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    background: rgba(12, 17, 21, 0.46);
    padding: 22px 18px;
}

.match-start-player.is-current {
    border-color: rgba(214, 168, 79, 0.38);
    background: var(--primary-wash);
}

.match-start-player h2 {
    overflow-wrap: anywhere;
    margin: 8px 0 4px;
    font-size: clamp(1.15rem, 3vw, 1.55rem);
}

.match-start-player > p:last-child {
    margin: 0;
    color: var(--muted);
}

.match-start-versus {
    align-self: center;
    margin: 0;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.match-start-map {
    margin: 0;
    color: var(--muted);
}

.match-start-map strong {
    color: var(--text);
    font-weight: 750;
}

.match-start-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 22px;
}

@keyframes status-pulse {
    0%, 100% {
        opacity: 0.65;
        transform: scale(0.9);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

@media (max-width: 720px) {
    .app-shell {
        padding: 12px;
    }

    .app-header {
        margin-bottom: 10px;
    }

    .app-user {
        max-width: 42vw;
    }

    .game-status-box {
        grid-template-columns: 9px minmax(0, 1fr);
        gap: 11px;
        padding: 12px 14px;
    }

    .game-status-box .button {
        grid-column: 2;
        width: fit-content;
        min-height: 38px;
        margin-top: 3px;
    }

    .app-layout {
        min-width: 0;
        width: 100%;
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
    }

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

    .hotkey-section-wide {
        grid-column: auto;
    }

    .hotkey-list > div {
        grid-template-columns: minmax(0, 1fr);
        gap: 6px;
    }

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

    .calculation-list > div {
        grid-template-columns: minmax(0, 1fr);
        gap: 5px;
    }

    .app-nav {
        display: flex;
        width: 100%;
        min-width: 0;
        max-width: calc(100vw - 24px);
        flex-flow: row nowrap;
        gap: 4px;
        overflow-x: auto;
        padding: 7px;
        scroll-snap-type: x proximity;
        scrollbar-width: thin;
    }

    .app-nav a,
    button.nav-logout {
        width: auto;
        min-width: max-content;
        justify-content: center;
        padding: 8px 11px;
        scroll-snap-align: start;
    }

    .app-nav a.is-current::before {
        inset: auto 10px 2px;
        width: auto;
        height: 2px;
    }

    .nav-divider {
        flex: 0 0 1px;
        width: 1px;
        height: 26px;
        margin: 8px 4px;
    }

    .app-nav form {
        margin: 0;
        padding: 0;
        border: 0;
    }

    .app-main {
        padding: 22px 17px;
    }

    .page-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 16px;
        margin-bottom: 22px;
        padding-bottom: 18px;
    }

    .page-header .button {
        width: 100%;
    }

    .public-card {
        padding: 25px 20px;
    }

    .public-brand {
        margin-bottom: 28px;
    }

    .account-notice,
    .settings-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .account-notice form,
    .account-notice button {
        width: 100%;
    }

    .detail-list > div {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .info-list li {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .settings-reload-note {
        max-width: none;
        text-align: left;
    }

    .settings-actions button {
        width: 100%;
    }

    .settings-form input[type="checkbox"] {
        flex: 0 0 19px;
    }

    .matchmaking-actions {
        flex-direction: column;
    }

    .matchmaking-actions button {
        width: 100%;
    }

    .match-start-card {
        padding: 28px 18px;
    }

    .match-start-live {
        min-height: 120px;
    }

    .match-start-players {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
        margin-top: 20px;
    }

    .match-start-versus {
        padding: 1px 0;
    }

    .match-start-player {
        padding: 17px 14px;
    }

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

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