:root {
    color-scheme: light;

    --paper: #e7e3d6;
    --panel: #f1eee4;
    --ink: #16130d;
    --ink-soft: #6c6557;
    --accent: #ff3b00;
    --line: 2.5px;

    --sans: "Arial Black", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

button {
    font: inherit;
    color: inherit;
    cursor: pointer;
}

/* ------------------------------------------------------------------ machine */

.machine {
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    height: 100%;
    max-width: 1180px;
    margin: 0 auto;
    background: var(--paper);
    border-left: var(--line) solid var(--ink);
    border-right: var(--line) solid var(--ink);
    overflow: hidden;
}

/* ------------------------------------------------------------------- header */

.bar {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 20px;
    background: var(--ink);
    color: var(--paper);
}

.brand {
    min-width: 0;
}

.logo {
    margin: 0;
    font-family: var(--sans);
    font-weight: 900;
    font-size: clamp(22px, 4.4vw, 34px);
    letter-spacing: -0.02em;
    line-height: 0.92;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 0.32em;
}

.logo-accent {
    color: var(--accent);
}

.lab {
    margin: 6px 0 0;
    font-size: 11px;
    letter-spacing: 0.22em;
    color: var(--paper);
    opacity: 0.55;
}

.clock {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    text-align: right;
}

.clock-label {
    font-size: 10px;
    letter-spacing: 0.2em;
    opacity: 0.55;
}

.clock-time {
    font-family: var(--sans);
    font-size: clamp(22px, 4.6vw, 34px);
    line-height: 1;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}

.clock.is-low .clock-time {
    color: var(--accent);
    animation: blink 1s steps(2, start) infinite;
}

/* --------------------------------------------------------------- doom strip */

.doom {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 20px;
    background: var(--panel);
    border-bottom: var(--line) solid var(--ink);
}

.doom-tag {
    font-family: var(--sans);
    font-size: 13px;
    letter-spacing: 0.12em;
}

.doom-track {
    flex: 1;
    display: flex;
    gap: 3px;
    height: 18px;
}

.doom-cell {
    flex: 1;
    background: transparent;
    border: 1.5px solid var(--ink);
}

.doom-cell.on {
    background: var(--ink);
}

.doom-cell.hot {
    background: var(--accent);
    border-color: var(--accent);
}

.doom-read {
    flex-shrink: 0;
    font-size: 12px;
    letter-spacing: 0.08em;
    font-variant-numeric: tabular-nums;
    min-width: 132px;
    text-align: right;
}

.doom.is-critical {
    background: var(--accent);
    color: #fff;
}

.doom.is-critical .doom-cell {
    border-color: #fff;
}

.doom.is-critical .doom-cell.on,
.doom.is-critical .doom-cell.hot {
    background: #fff;
    border-color: #fff;
}

.doom.is-meltdown {
    animation: blink 0.6s steps(2, start) infinite;
}

/* ---------------------------------------------------------------- the floor */

.floor {
    display: grid;
    grid-template-columns: minmax(260px, 36%) 1fr;
    min-height: 0;
}

/* ------------------------------------------------------------------ console */

.console {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    padding: 26px 20px;
    border-right: var(--line) solid var(--ink);
    text-align: center;
}

.readout {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.readout-label {
    font-size: 10px;
    letter-spacing: 0.24em;
    color: var(--ink-soft);
}

.readout-value {
    font-family: var(--sans);
    font-size: clamp(30px, 6.4vw, 58px);
    line-height: 1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    word-break: break-all;
}

.readout-rate {
    font-size: 12px;
    letter-spacing: 0.12em;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}

.mint {
    position: relative;
    width: min(220px, 70%);
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: var(--ink);
    color: var(--paper);
    border: var(--line) solid var(--ink);
    box-shadow: 8px 8px 0 var(--ink);
    user-select: none;
    transition: transform 0.04s steps(1), box-shadow 0.04s steps(1);
}

.mint:hover {
    background: var(--accent);
    border-color: var(--ink);
}

.mint:active,
.mint.is-hit {
    transform: translate(6px, 6px);
    box-shadow: 2px 2px 0 var(--ink);
}

.mint:focus-visible {
    outline: var(--line) solid var(--accent);
    outline-offset: 5px;
}

.mint-top {
    font-family: var(--sans);
    font-size: clamp(30px, 5.4vw, 46px);
    letter-spacing: 0.02em;
    line-height: 0.9;
}

.mint-sub {
    font-size: 10px;
    letter-spacing: 0.28em;
    opacity: 0.7;
}

.perclick {
    font-family: var(--sans);
    font-size: 16px;
    letter-spacing: 0.04em;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.perclick span {
    color: var(--accent);
}

.best {
    margin: 0;
    font-size: 11px;
    letter-spacing: 0.1em;
    color: var(--ink-soft);
}

.best b {
    color: var(--ink);
}

/* --------------------------------------------------------------------- shop */

.shop {
    min-height: 0;
    overflow-y: auto;
    padding: 16px 18px 20px;
}

.shop-group + .shop-group {
    margin-top: 18px;
}

.shop-head {
    margin: 0 0 10px;
    font-family: var(--sans);
    font-size: 14px;
    letter-spacing: 0.06em;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    border-bottom: var(--line) solid var(--ink);
    padding-bottom: 6px;
}

.shop-sub {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.18em;
    color: var(--ink-soft);
}

.shop-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.row {
    width: 100%;
    display: grid;
    grid-template-columns: 46px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 9px 11px;
    text-align: left;
    background: var(--panel);
    border: var(--line) solid var(--ink);
    box-shadow: 3px 3px 0 var(--ink);
    transition: transform 0.05s steps(1), box-shadow 0.05s steps(1), background 0.05s steps(1);
}

.row:hover {
    background: var(--ink);
    color: var(--paper);
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 var(--ink);
}

.row:focus-visible {
    outline: var(--line) solid var(--accent);
    outline-offset: 2px;
}

.row-count {
    font-family: var(--sans);
    font-size: 18px;
    text-align: center;
    padding: 2px 0;
    border: 1.5px solid currentColor;
    font-variant-numeric: tabular-nums;
}

.row-main {
    min-width: 0;
}

.row-name {
    display: block;
    font-family: var(--sans);
    font-size: 14px;
    letter-spacing: 0.01em;
}

.row-desc {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.35;
    color: var(--ink-soft);
}

.row:hover .row-desc {
    color: var(--paper);
}

.row-cost {
    font-family: var(--sans);
    font-size: 15px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.row-cost::before {
    content: "◆ ";
    font-size: 10px;
    vertical-align: 1px;
}

/* decisions — the spicy column */

.row--decision {
    border-left-width: 9px;
    border-left-color: var(--accent);
}

.row--decision:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--ink);
    border-left-color: var(--ink);
}

.row--decision:hover .row-desc {
    color: #fff;
}

/* states */

.row.is-locked {
    opacity: 0.42;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.row.is-locked:hover {
    background: var(--panel);
    color: var(--ink);
    transform: none;
    box-shadow: none;
}

.row.is-locked.row--decision:hover {
    background: var(--panel);
    color: var(--ink);
}

.row.is-locked:hover .row-desc {
    color: var(--ink-soft);
}

.row.is-done {
    cursor: default;
    background: var(--ink);
    color: var(--paper);
    box-shadow: none;
    transform: none;
}

.row.is-done .row-desc {
    color: var(--paper);
    opacity: 0.6;
}

.row.is-done .row-name {
    text-decoration: line-through;
    text-decoration-thickness: 2px;
}

.row.is-done .row-cost {
    color: var(--accent);
}

.row.is-flash {
    animation: flash 0.18s steps(1) 2;
}

/* ------------------------------------------------------------------- ticker */

.ticker {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 20px;
    min-height: 42px;
    background: var(--ink);
    color: var(--paper);
    border-top: var(--line) solid var(--ink);
    overflow: hidden;
}

.ticker-cap {
    flex-shrink: 0;
    font-family: var(--sans);
    font-size: 12px;
    letter-spacing: 0.12em;
    color: var(--accent);
}

.ticker-feed {
    list-style: none;
    margin: 0;
    padding: 0;
    min-width: 0;
    flex: 1;
}

.ticker-feed li {
    font-size: 12px;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ticker-feed li:nth-child(1) {
    opacity: 1;
}

.ticker-feed li:nth-child(2) {
    opacity: 0.5;
    font-size: 11px;
}

.ticker-feed li:nth-child(1)::before {
    content: "> ";
    color: var(--accent);
}

.ticker-feed li:nth-child(2)::before {
    content: "> ";
}

/* ------------------------------------------------------------- float number */

.float {
    position: fixed;
    z-index: 5;
    font-family: var(--sans);
    font-size: 20px;
    color: var(--accent);
    pointer-events: none;
    text-shadow: 1px 1px 0 var(--ink);
    animation: rise 0.7s steps(7) forwards;
}

/* ------------------------------------------------------------------- report */

.report {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(22, 19, 13, 0.82);
}

.report[hidden] {
    display: none;
}

.report-card {
    width: min(560px, 100%);
    max-height: 100%;
    overflow-y: auto;
    padding: 28px;
    background: var(--paper);
    border: var(--line) solid var(--ink);
    box-shadow: 12px 12px 0 var(--accent);
}

.report-kicker {
    margin: 0;
    font-size: 11px;
    letter-spacing: 0.32em;
    color: var(--ink-soft);
}

.report-ending {
    margin: 8px 0 0;
    font-family: var(--sans);
    font-size: clamp(28px, 6vw, 44px);
    line-height: 0.96;
    letter-spacing: -0.01em;
    color: var(--accent);
    -webkit-text-stroke: 1px var(--ink);
}

.report-flavor {
    margin: 14px 0 0;
    font-size: 13px;
    line-height: 1.5;
}

.report-stats {
    margin: 20px 0 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border: var(--line) solid var(--ink);
}

.report-stats div {
    padding: 10px 12px;
    border: 1px solid var(--ink);
}

.report-stats dt {
    font-size: 9px;
    letter-spacing: 0.2em;
    color: var(--ink-soft);
}

.report-stats dd {
    margin: 3px 0 0;
    font-family: var(--sans);
    font-size: 19px;
    font-variant-numeric: tabular-nums;
}

.again {
    margin-top: 22px;
    width: 100%;
    padding: 14px;
    font-family: var(--sans);
    font-size: 18px;
    letter-spacing: 0.04em;
    background: var(--ink);
    color: var(--paper);
    border: var(--line) solid var(--ink);
    box-shadow: 5px 5px 0 var(--accent);
    transition: transform 0.05s steps(1), box-shadow 0.05s steps(1);
}

.again:hover {
    background: var(--accent);
}

.again:active {
    transform: translate(5px, 5px);
    box-shadow: 0 0 0 var(--accent);
}

/* ---------------------------------------------------------------- keyframes */

@keyframes blink {
    50% {
        opacity: 0.25;
    }
}

@keyframes flash {
    50% {
        background: var(--accent);
        color: #fff;
    }
}

@keyframes rise {
    to {
        transform: translateY(-46px);
        opacity: 0;
    }
}

/* --------------------------------------------------------------- responsive */

@media (max-width: 720px) {
    .machine {
        height: auto;
        min-height: 100%;
        grid-template-rows: auto auto auto auto;
    }

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

    .console {
        border-right: none;
        border-bottom: var(--line) solid var(--ink);
    }

    .shop {
        overflow: visible;
    }
}

@media (prefers-reduced-motion: reduce) {
    .float {
        display: none;
    }

    .clock.is-low .clock-time,
    .doom.is-meltdown {
        animation: none;
    }
}
