:root {
    --game-primary: #c90c0f;
    --game-secondary: #1a1a1a;
    --ko-ink: #161616;
    --ko-paper: #f7f4ee;
    --ko-wall: #e7e1d6;
    --ko-serif: "Cormorant Garamond", "Palatino Linotype", Palatino, "Times New Roman", serif;
    --ko-mono: "IBM Plex Mono", "Courier New", ui-monospace, monospace;
}

body.ko-page {
    margin: 0;
    min-height: 100vh;
    color: var(--ko-ink);
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.45), transparent 220px),
        var(--ko-wall);
}

body.ko-page.game-menu-active {
    overflow-x: hidden;
    color: #f8fafc;
    background:
        radial-gradient(circle at 12% 8%, rgba(201, 162, 39, 0.2), transparent 42%),
        linear-gradient(180deg, #2a2118 0%, #140e0b 100%);
}

body.ko-page.game-menu-active #game-header {
    display: none !important;
}

.ko-page .game-screen {
    display: none;
    min-height: 100vh;
}

.ko-page .game-screen.active {
    display: block;
}

body.ko-page.with-game-header .ko-shell {
    padding-top: 5.4rem;
}

.ko-shell {
    max-width: 1040px;
    margin: 0 auto;
    padding: 0.85rem 0.8rem 6.5rem;
}

.ko-hud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    align-items: stretch;
    justify-content: space-between;
    margin-bottom: 0.7rem;
    padding: 0.35rem 0;
    border-top: 1px solid #161616;
    border-bottom: 1px solid #161616;
}

.ko-lcd {
    min-width: 5.2rem;
    padding: 0.15rem 0.7rem 0.2rem;
    background: transparent;
    color: #161616;
    font-family: var(--ko-mono);
    font-weight: 500;
    text-align: center;
}

.ko-lcd span {
    display: block;
    color: #6d675f;
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.ko-lcd strong {
    font-family: var(--ko-serif);
    font-size: 1.55rem;
    font-weight: 600;
    line-height: 1;
}

.ko-patience {
    position: relative;
    height: 3px;
    margin: 0 0 1rem;
    background: #d5cec3;
    overflow: hidden;
}

.ko-patience__bar {
    height: 100%;
    width: 100%;
    background: #161616;
}

.ko-patience.is-low .ko-patience__bar {
    background: #c90c0f;
}

.ko-patience__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.ko-shop {
    display: grid;
    gap: 0.85rem;
}

.ko-receipt {
    position: relative;
    padding: 1.25rem 0.95rem 1.15rem;
    color: #1a1a1a;
    background: var(--ko-paper);
    font-family: var(--ko-mono);
    box-shadow: 0 18px 34px rgba(22, 22, 22, 0.12);
}

.ko-receipt::before,
.ko-receipt::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 10px;
    background: radial-gradient(circle, var(--ko-wall) 5px, transparent 5.5px);
    background-size: 16px 10px;
    background-repeat: repeat-x;
    pointer-events: none;
}

.ko-receipt::before {
    top: -5px;
}

.ko-receipt::after {
    bottom: -5px;
}

body.ko-page .ko-receipt,
body.ko-page .ko-receipt *:not(i) {
    font-family: var(--ko-mono) !important;
}

body.ko-page .ko-receipt__brand,
body.ko-page .ko-who strong,
body.ko-page .ko-looks,
body.ko-page .ko-bench h2,
body.ko-page .ko-lcd strong {
    font-family: var(--ko-serif) !important;
}

body.ko-page .ko-choice__text,
body.ko-page .ko-tile span,
body.ko-page .ko-counter__empty,
body.ko-page .ko-btn,
body.ko-page .ko-queue span,
body.ko-page .ko-lcd,
body.ko-page .ko-lcd span,
body.ko-page .ko-toast {
    font-family: var(--ko-mono) !important;
}

.ko-receipt__brand {
    margin: 0;
    font-family: var(--ko-serif);
    font-size: 2.15rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    line-height: 0.9;
    text-align: center;
    text-indent: 0.22em;
    text-transform: uppercase;
}

.ko-receipt__tag,
.ko-receipt__thanks,
.ko-receipt__till {
    margin: 0.35rem 0 0;
    color: #3f3a34;
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-align: center;
    text-transform: uppercase;
}

.ko-receipt__till {
    display: flex;
    justify-content: space-between;
    margin-top: 0.7rem;
    letter-spacing: 0.08em;
}

.ko-receipt__rule {
    height: 0;
    margin: 0.65rem 0;
    border: 0;
    border-top: 1px dashed #2b2b2b;
}

.ko-who {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0;
}

.ko-who small {
    display: block;
    color: #6a645c;
    font-size: 0.66rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.ko-who strong {
    display: block;
    font-family: var(--ko-serif);
    font-size: 1.65rem;
    font-weight: 600;
    line-height: 1;
}

.ko-ask {
    margin: 0 0 0.65rem;
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.45;
}

.ko-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ko-line {
    position: relative;
    list-style: none;
    margin: 0.35rem 0;
    padding-left: 1.55rem;
    line-height: 1.35;
}

.ko-line::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.28rem;
    width: 0.85rem;
    height: 0.85rem;
    border: 2px solid #c4b8a8;
    border-radius: 3px;
    background: #fff;
}

.ko-line.is-met::before {
    background: #1f7a4d;
    border-color: #1f7a4d;
    box-shadow: inset 0 0 0 2px #fff;
}

.ko-line.is-miss {
    color: #9f1239;
}

.ko-line.is-miss::before {
    border-color: #c90c0f;
    background: #fde8ea;
}

.ko-line--note {
    padding-left: 0.85rem;
    color: #1a1a1a;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.4;
}

.ko-line--note::before {
    content: "–";
    position: absolute;
    top: 0;
    left: 0;
    width: auto;
    height: auto;
    border: 0;
    background: none;
}

.ko-caret {
    display: inline-block;
    width: 0.55em;
    height: 0.9em;
    margin-left: 1px;
    background: #1a1a1a;
    vertical-align: -0.08em;
    animation: ko-caret 0.75s steps(1) infinite;
}

@keyframes ko-caret {
    50% { opacity: 0; }
}

.ko-count {
    margin-top: 0.85rem;
}

.ko-count label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 700;
}

.ko-count input {
    width: 6.5rem;
    padding: 0.55rem 0.7rem;
    border: 2px solid #c4b8a8;
    border-radius: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ko-ink);
    background: #fff;
}

.ko-count input:focus {
    outline: 3px solid rgba(201, 12, 15, 0.35);
    border-color: #c90c0f;
}

.ko-working {
    margin: 0.75rem 0 0;
    color: #3f3a34;
    font-size: 0.75rem;
    line-height: 1.45;
}

.ko-looks,
.ko-bench h2 {
    margin: 0.95rem 0 0.45rem;
    font-family: var(--ko-serif);
    font-size: 1.7rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    line-height: 1;
}

.ko-looks {
    margin-top: 1.15rem;
}

.ko-counter,
.ko-rail {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-content: flex-start;
}

.ko-counter {
    min-height: 7.4rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f7f4ee;
    border: 1px solid #161616;
}

.ko-counter__empty {
    margin: auto;
    color: #3f3a34;
    font-family: var(--ko-mono);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.ko-rail {
    padding: 0.85rem 0.1rem 0.2rem;
    background-image: linear-gradient(#161616, #161616);
    background-size: 100% 2px;
    background-repeat: no-repeat;
    background-position: center 0.2rem;
}

.ko-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 108px;
    min-height: 118px;
    padding: 0.3rem 0.3rem 0.4rem;
    border: 1px solid #161616;
    border-radius: 0;
    background: #fff;
    color: var(--ko-ink);
    cursor: default;
    text-align: center;
}

.ko-tile:focus-visible {
    outline: 3px solid #c90c0f;
    outline-offset: 2px;
}

.ko-tile svg,
.ko-tile img,
.ko-choice img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    background: #f3f0ea;
    border-radius: 0;
}

.ko-tile span {
    display: block;
    margin-top: 0.2rem;
    font-family: var(--ko-mono);
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    line-height: 1.2;
    text-transform: lowercase;
}

.ko-counter .ko-tile {
    background: #fff;
}

.ko-choices {
    display: grid;
    gap: 0.45rem;
    margin-top: 0.85rem;
}

.ko-choice {
    display: flex;
    gap: 0.55rem;
    align-items: center;
    width: 100%;
    padding: 0.4rem;
    border: 1px solid #161616;
    border-radius: 0;
    background: #fff;
    color: var(--ko-ink);
    text-align: left;
    cursor: pointer;
}

.ko-choice.is-selected {
    border-color: #161616;
    background: #161616;
    color: #fff;
    box-shadow: none;
}

.ko-choice.is-selected .ko-choice__text {
    color: #fff;
}

.ko-choice.is-correct {
    border-color: #1f7a4d;
    background: #eef8f1;
}

.ko-choice.is-wrong {
    border-color: #c90c0f;
    background: #fde8ea;
}

.ko-choice.is-correct,
.ko-choice.is-wrong,
.ko-choice.is-correct .ko-choice__text,
.ko-choice.is-wrong .ko-choice__text {
    color: #161616;
}

.ko-choice:disabled {
    cursor: default;
}

.ko-choice__photos {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.ko-choice__photos img {
    width: 52px;
    height: 52px;
}

.ko-choice__text {
    font-family: var(--ko-mono);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.35;
}

.ko-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    gap: 0.55rem;
    justify-content: center;
    padding: 0.7rem 0.8rem calc(0.7rem + env(safe-area-inset-bottom));
    background: rgba(231, 225, 214, 0.96);
    border-top: 1px solid #161616;
    z-index: 20;
}

.ko-btn {
    min-height: 48px;
    padding: 0.65rem 1.05rem;
    border-radius: 0;
    border: 1px solid #161616;
    background: #fff;
    color: #161616;
    font-family: var(--ko-mono);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
}

.ko-btn:hover,
.ko-btn:focus-visible {
    background: #161616;
    color: #fff;
}

.ko-btn--primary {
    background: #c90c0f;
    border-color: #8d090c;
    color: #fff;
}

.ko-btn--primary:hover,
.ko-btn--primary:focus-visible {
    background: #8d090c;
    border-color: #8d090c;
    color: #fff;
}

.ko-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.ko-toast {
    margin: 0.8rem 0 0;
    min-height: 1.4rem;
    font-weight: 700;
}

.ko-toast.is-good {
    color: #146c43;
}

.ko-toast.is-bad {
    color: #9f1239;
}

.ko-queue {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0 0 0.7rem;
}

.ko-queue span {
    padding: 0.18rem 0.5rem;
    border: 1px solid #161616;
    background: transparent;
    color: #161616;
    font-family: var(--ko-mono);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.ko-queue .is-now {
    background: #161616;
    color: #fff;
}

@media (min-width: 900px) {
    .ko-shop {
        grid-template-columns: minmax(280px, 360px) 1fr;
        align-items: start;
    }

    .ko-shell {
        padding-bottom: 6.2rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ko-patience__bar,
    .ko-caret {
        transition: none;
        animation: none;
    }
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 14, 11, 0.72);
    z-index: 12000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    color: #1a1a1a;
    border-radius: 1rem;
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 760px;
}

.modal-header,
.modal-footer {
    padding: 1.1rem 1.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.modal-header {
    border-bottom: 2px solid #eee;
}

.modal-header h2 {
    margin: 0;
    color: #c90c0f;
    font-size: 1.35rem;
}

.modal-close {
    background: #fff;
    border: 2px solid #c90c0f;
    color: #c90c0f;
    border-radius: 8px;
    cursor: pointer;
    padding: 0.35rem 0.55rem;
}

.modal-body {
    padding: 1.2rem 1.4rem;
}

.modal-footer {
    border-top: 2px solid #eee;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.help-section {
    margin-bottom: 1.1rem;
}

.help-section h3 {
    color: #c90c0f;
    margin: 0 0 0.4rem;
}

.help-section ul {
    margin: 0.3rem 0 0;
    padding-left: 1.2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: #f8fafc;
    border-radius: 12px;
    padding: 0.85rem;
    text-align: center;
}

.stat-value {
    font-size: 1.6rem;
    color: #c90c0f;
    font-weight: 700;
}

.stat-label {
    color: #64748b;
    font-size: 0.85rem;
}

.difficulty-stats {
    display: grid;
    gap: 0.45rem;
}

.win-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    margin-top: 0.8rem;
}

.win-stat {
    text-align: center;
    background: #f8fafc;
    border-radius: 12px;
    padding: 0.7rem;
}

.win-stat strong {
    display: block;
    color: #c90c0f;
    font-size: 1.3rem;
}

.difficulty-pill {
    border: 2px solid #c90c0f;
    background: #fff;
    color: #c90c0f;
    border-radius: 999px;
    padding: 0.45rem 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

.difficulty-pill.is-selected {
    background: #c90c0f;
    color: #fff;
}

.ko-settings-note {
    color: #475569;
}

.btn {
    min-height: 44px;
    border-radius: 10px;
    border: 2px solid transparent;
    padding: 0.55rem 0.9rem;
    font-weight: 700;
    cursor: pointer;
}

.btn-primary {
    background: #c90c0f;
    color: #fff;
}

.btn-secondary {
    background: #fff;
    color: #c90c0f;
    border-color: #c90c0f;
}

/* Shared game CSS forces Rockwell with a long :not() list. Match that specificity. */
body.ko-page .ko-receipt *:not(i[class*="fa-"]):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands):not(.mt-card[data-deck="disasters"] *),
body.ko-page .ko-choice__text:not(i[class*="fa-"]):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands):not(.mt-card[data-deck="disasters"] *),
body.ko-page .ko-tile span:not(i[class*="fa-"]):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands):not(.mt-card[data-deck="disasters"] *),
body.ko-page .ko-counter__empty:not(i[class*="fa-"]):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands):not(.mt-card[data-deck="disasters"] *),
body.ko-page .ko-btn:not(i[class*="fa-"]):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands):not(.mt-card[data-deck="disasters"] *),
body.ko-page .ko-queue span:not(i[class*="fa-"]):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands):not(.mt-card[data-deck="disasters"] *),
body.ko-page .ko-lcd:not(i[class*="fa-"]):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands):not(.mt-card[data-deck="disasters"] *),
body.ko-page .ko-lcd span:not(i[class*="fa-"]):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands):not(.mt-card[data-deck="disasters"] *),
body.ko-page .ko-toast:not(i[class*="fa-"]):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands):not(.mt-card[data-deck="disasters"] *) {
    font-family: "IBM Plex Mono", "Courier New", ui-monospace, monospace !important;
}

body.ko-page .ko-receipt__brand:not(i[class*="fa-"]):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands):not(.mt-card[data-deck="disasters"] *),
body.ko-page .ko-who strong:not(i[class*="fa-"]):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands):not(.mt-card[data-deck="disasters"] *),
body.ko-page .ko-looks:not(i[class*="fa-"]):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands):not(.mt-card[data-deck="disasters"] *),
body.ko-page .ko-bench h2:not(i[class*="fa-"]):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands):not(.mt-card[data-deck="disasters"] *),
body.ko-page .ko-lcd strong:not(i[class*="fa-"]):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands):not(.mt-card[data-deck="disasters"] *) {
    font-family: "Cormorant Garamond", "Palatino Linotype", Palatino, "Times New Roman", serif !important;
}
