* {
    box-sizing: border-box;
}

:root {
    --red: #d80f1d;
    --deep-red: #9f0712;
    --soft-red: #fff1f2;
    --white: #ffffff;
    --ink: #241013;
    --muted: #75565a;
    --line: #ead0d3;
    --green-bg: #9ee8c4;
    --green-text: #07543d;
    --orange-bg: #ffd38b;
    --orange-text: #704000;
    --red-bg: #ffb4ba;
    --red-text: #7d0710;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        linear-gradient(180deg, rgba(216, 15, 29, 0.10), rgba(255, 255, 255, 0) 280px),
        var(--white);
    color: var(--ink);
}

button,
input {
    font: inherit;
}

.app-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 36px 0 56px;
}

.topbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--red);
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--red);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    color: var(--deep-red);
    font-size: clamp(2.4rem, 6vw, 5.6rem);
    line-height: 0.92;
}

.scoreboard {
    min-width: 132px;
    padding: 14px 18px;
    border: 2px solid var(--red);
    border-radius: 8px;
    text-align: center;
    background: var(--white);
}

.score-label {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.scoreboard strong {
    display: block;
    color: var(--red);
    font-size: 2.2rem;
    line-height: 1;
}

.game-panel {
    padding-top: 28px;
}

.guess-form {
    display: grid;
    gap: 10px;
    max-width: 760px;
}

.guess-form label {
    color: var(--deep-red);
    font-weight: 800;
}

.search-wrap {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.search-wrap input {
    width: 100%;
    min-height: 54px;
    padding: 0 16px;
    border: 2px solid var(--line);
    border-radius: 8px;
    outline: none;
    background: var(--white);
    color: var(--ink);
}

.search-wrap input:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 4px rgba(216, 15, 29, 0.12);
}

.search-wrap > button {
    min-height: 54px;
    padding: 0 22px;
    border: 0;
    border-radius: 8px;
    background: var(--red);
    color: var(--white);
    font-weight: 900;
    cursor: pointer;
}

.search-wrap > button:disabled,
.search-wrap input:disabled {
    cursor: wait;
    opacity: 0.58;
}

.suggestions {
    position: absolute;
    z-index: 10;
    top: calc(100% + 14px);
    left: 0;
    right: 0;
    display: grid;
    gap: 10px;
    padding-top: 8px;
}

.suggestions .suggestion {
    display: grid;
    gap: 14px;
    width: 100%;
    min-height: 86px;
    padding: 16px;
    border: 1px solid rgba(216, 15, 29, 0.22);
    border-radius: 8px;
    background: var(--white);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(159, 7, 18, 0.06);
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, background-color 160ms ease;
}

.suggestions > small {
    justify-self: center;
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 12px;
    border: 1px solid rgba(216, 15, 29, 0.18);
    border-radius: 999px;
    background: var(--soft-red);
    color: var(--deep-red);
    font-size: 0.84rem;
    font-weight: 850;
    text-align: center;
}

.suggestions .suggestion:hover,
.suggestions .suggestion.is-active {
    border-color: rgba(216, 15, 29, 0.55);
    background: #fffafa;
    box-shadow: 0 12px 24px rgba(159, 7, 18, 0.10);
    transform: translateY(-1px);
}

.suggestions .suggestion strong {
    color: var(--ink);
    font-size: 1rem;
    font-weight: 850;
    line-height: 1.2;
}

.suggestions .suggestion small {
    color: var(--deep-red);
    font-weight: 700;
}

.suggestion-lines {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.status {
    justify-self: start;
    min-height: 28px;
    margin: 0;
    padding: 4px 10px;
    border: 1px solid rgba(216, 15, 29, 0.14);
    border-radius: 999px;
    background: var(--white);
    color: var(--deep-red);
    font-size: 0.88rem;
    font-weight: 800;
}

.status.is-error {
    color: var(--red-text);
}

.status.is-success {
    color: var(--green-text);
}

.stats-panel {
    margin-top: 28px;
    padding: 18px;
    border: 1px solid rgba(216, 15, 29, 0.18);
    border-radius: 8px;
    background: var(--white);
    box-shadow: 0 14px 30px rgba(159, 7, 18, 0.07);
}

.stats-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.stats-header .eyebrow {
    margin: 0;
}

.stats-header h2 {
    margin: 0;
    color: var(--deep-red);
    font-size: 1.25rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.stat-card {
    min-height: 98px;
    padding: 14px;
    border: 1px solid rgba(216, 15, 29, 0.16);
    border-radius: 8px;
    background: #fffafa;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 850;
    text-transform: uppercase;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    color: var(--deep-red);
    font-size: 1.65rem;
    line-height: 1.05;
}

.stat-card small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-weight: 750;
}

.table-wrap {
    overflow-x: auto;
    margin-top: 28px;
}

.guess-table {
    width: 100%;
    min-width: 780px;
    border-collapse: separate;
    border-spacing: 8px;
}

.guess-table th {
    padding: 0 12px 8px;
    color: var(--red);
    font-size: 0.78rem;
    font-weight: 900;
    text-align: center;
    text-transform: uppercase;
}

.guess-table td {
    height: 68px;
    padding: 12px 14px;
    border-radius: 8px;
    background: #f8f4f4;
    color: var(--ink);
    font-weight: 850;
    text-align: center;
    vertical-align: middle;
}

.guess-table tr.is-new td {
    animation: flip-in 560ms cubic-bezier(0.2, 0.72, 0.28, 1) both;
    animation-delay: calc(var(--cell-index) * 95ms);
    backface-visibility: hidden;
    transform-origin: center;
}

.guess-table .station-cell {
    width: 24%;
    border: 1px solid var(--line);
    background: var(--white);
}

.cell-good {
    background: var(--green-bg) !important;
    color: var(--green-text) !important;
}

.cell-close {
    background: var(--orange-bg) !important;
    color: var(--orange-text) !important;
}

.cell-bad {
    background: var(--red-bg) !important;
    color: var(--red-text) !important;
}

.line-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.line-logo {
    width: 34px;
    height: 34px;
    object-fit: contain;
    border-radius: 6px;
}

.line-badge {
    display: inline-grid;
    min-width: 34px;
    height: 34px;
    place-items: center;
    padding: 0 7px;
    border-radius: 6px;
    color: var(--white);
    font-weight: 900;
}

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

@keyframes flip-in {
    from {
        opacity: 0;
        transform: perspective(700px) rotateY(-82deg) translateX(-14px);
    }

    60% {
        opacity: 1;
    }

    to {
        opacity: 1;
        transform: perspective(700px) rotateY(0deg) translateX(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .guess-table tr.is-new td {
        animation: none;
    }
}

@media (max-width: 720px) {
    .app-shell {
        width: min(100% - 20px, 1120px);
        padding-top: 22px;
    }

    .topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .scoreboard {
        width: 100%;
    }

    .search-wrap {
        grid-template-columns: 1fr;
    }

    .search-wrap > button {
        width: 100%;
    }

    .stats-header {
        align-items: start;
        flex-direction: column;
        gap: 6px;
    }

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

    .stat-card-wide {
        grid-column: 1 / -1;
    }
}
