:root {
    --blue: #1687d9;
    --deep-blue: #0872bd;
    --red: #e34040;
    --ink: #273444;
    --line: #dce5ed;
    --soft: #f4f8fb;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--ink);
    background: #eef3f7;
    font-family: "Microsoft YaHei", Arial, sans-serif;
}
.site-header {
    padding: 20px 15px 12px;
    text-align: center;
    background: #fff;
}
.brand {
    color: #1e90ff;
    font-size: 40px;
    font-weight: 700;
    text-decoration: none;
}
.site-header p { margin: 4px 0 0; color: #8593a0; }
.site-shell {
    width: min(100% - 24px, 900px);
    margin: 18px auto;
    padding: 16px;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 30px rgba(39, 52, 68, .08);
}
.nav { display: flex; margin-bottom: 10px; padding: 0; }
.nav li { flex: 1; padding: 2px; list-style: none; text-align: center; }
.nav-primary > li > a {
    display: block;
    padding: 9px 6px;
    border-radius: 5px;
    color: var(--deep-blue);
    background: #edf7ff;
}
.nav-primary > li.active > a,
.nav-primary > li > a:hover { color: #fff; background: var(--blue); }
.category-nav { flex-wrap: wrap; overflow: hidden; transition: max-height .35s ease; }
.category-nav li { flex: 0 0 25%; }
.category-nav.collapsed { max-height: 0; }
.toggle-button {
    margin-bottom: 10px;
    padding: 6px 11px;
    border: 0;
    border-radius: 5px;
    color: #fff;
    background: var(--blue);
}
.status-card {
    display: grid;
    grid-template-columns: repeat(4, 1fr) auto;
    gap: 10px;
    align-items: center;
    margin: 12px 0;
    padding: 14px;
    border-radius: 10px;
    background: #eaf6ff;
}
.status-card div, .scratch-card div { display: grid; gap: 4px; }
.status-actions {
    display: flex !important;
    grid-auto-flow: column;
    align-items: center;
}
.icon-button {
    width: 38px;
    height: 38px;
    padding: 3px;
    border: 0;
    background: transparent;
    cursor: pointer;
}
.icon-button img { width: 100%; height: 100%; object-fit: contain; }
small { color: #71808d; }
.scratch-card {
    display: flex;
    gap: 24px;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--soft);
}
.scratch-card.is-hidden { display: none; }
.scratch-card img { object-fit: contain; }
.scratch-card #resetInlineScratch {
    justify-self: center;
    margin-top: 7px;
}
.inline-scratch-button {
    width: 48px;
    height: 48px;
}
.scratch-result {
    position: relative;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid #d5dde5;
    border-radius: 8px;
    background: #fff;
}
.scratch-result-inline { width: 190px; height: 58px; }
.scratch-result-popup {
    position: relative;
    display: grid;
    width: 240px;
    height: 80px;
    margin: 0 auto;
    place-items: center;
    overflow: hidden;
    border-radius: 10px;
    background: #fff;
}
.scratch-result strong { color: var(--red); font-size: 22px; letter-spacing: 2px; }
.scratch-result-popup strong { color: var(--red); font-size: 24px; letter-spacing: 4px; }
.scratch-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
    overscroll-behavior: contain;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
html.is-scratching,
body.is-scratching {
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
}
.scratch-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    place-items: center;
    padding: 20px;
    background: rgba(16, 28, 39, .55);
    backdrop-filter: blur(5px);
}
.scratch-modal.is-open { display: grid; }
.scratch-modal.is-open,
.scratch-modal-card {
    overscroll-behavior: contain;
}
.scratch-modal-card { position: relative; width: min(100%, 420px); }
.scratch-modal-card > img { display: block; width: 100%; border-radius: 18px; }
.scratch-modal-content {
    position: absolute;
    left: 50%;
    bottom: 30px;
    width: 260px;
    padding: 10px;
    transform: translateX(-50%);
    border-radius: 12px;
    color: #fff;
    background: transparent;
}
.scratch-popup-title {
    margin-bottom: 10px;
    font-weight: 700;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}
.scratch-popup-meta {
    margin-top: 12px;
    padding: 0 4px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}
.scratch-popup-meta > div { display: flex; align-items: center; }
.scratch-popup-meta > div + div { margin-top: 5px; }
.scratch-popup-meta b { min-width: 52px; }
.scratch-popup-meta .label + .label { margin-left: 4px; }
#resetPopupScratch {
    display: block;
    margin: 9px auto 0;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; font-size: 15px; text-align: center; }
th { color: var(--red); text-align: center; white-space: nowrap; }
td { vertical-align: middle !important; white-space: nowrap; }
.label-danger { background-color: var(--red); }
.label-primary { background-color: #0094e0; }
.prediction-label { font-weight: 700; }
.trend-ball {
    display: inline-grid;
    width: 24px;
    min-height: 36px;
    place-items: center;
    border-radius: 5px;
    color: #fff;
    background: #586fb5;
}
.trend-ball.combo { background: #382240; font-size: 11px; }
.source-meta { color: #82909d; font-size: 12px; text-align: right; }
footer {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    color: #87939d;
    font-size: 12px;
    text-align: center;
}

@media (max-width: 720px) {
    .site-shell { width: 100%; margin: 0; border-radius: 0; padding: 10px; }
    .brand { font-size: 34px; }
    .category-nav li { flex-basis: 33.333%; }
    .status-card { grid-template-columns: repeat(2, 1fr); }
    .status-actions { grid-column: 1 / -1; justify-content: center; }
    .scratch-card { justify-content: space-between; gap: 8px; }
    .scratch-modal-content {
        bottom: 4%;
        width: 65%;
        padding: 2%;
    }
    .scratch-result-popup {
        width: 100%;
        height: auto;
        aspect-ratio: 3 / 1;
    }
    .scratch-popup-title { font-size: 12px; }
    .scratch-popup-meta { margin-top: 3%; font-size: 12px; }
    table { font-size: 13px; }
}
