:root {
    color-scheme: light;
    font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
    font-synthesis: none;
    --page: #eef2ef;
    --surface: #ffffff;
    --surface-soft: #f8faf8;
    --ink: #17221d;
    --muted: #68756f;
    --line: #d8dfda;
    --line-strong: #c4cec7;
    --header: #14251f;
    --accent: #cb3348;
    --accent-strong: #ad2136;
    --accent-soft: #fff0f2;
    --blue: #2863c5;
    --blue-dark: #1e4e9e;
    --blue-soft: #edf3ff;
    --success: #1a8050;
    --warning: #996417;
    --warning-soft: #fff7e8;
    --shadow: 0 18px 45px rgba(21, 42, 31, 0.07);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--page);
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: var(--page);
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

button svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

button:focus-visible,
input:focus-visible,
.strategy-option input:focus-visible + .strategy-content {
    outline: 3px solid rgba(40, 99, 197, 0.28);
    outline-offset: 2px;
}

.topbar {
    color: #f4f8f5;
    background: var(--header);
}

.topbar-inner {
    width: min(1240px, calc(100% - 40px));
    height: 66px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 8px;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    font-size: 16px;
    font-weight: 700;
}

.brand-name {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0;
}

.sync-cluster {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sync-state {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #c7d4cc;
    font-size: 13px;
    white-space: nowrap;
}

.sync-dot {
    width: 7px;
    height: 7px;
    flex: none;
    border-radius: 50%;
    background: #64cc97;
    box-shadow: 0 0 0 3px rgba(100, 204, 151, 0.12);
}

.sync-state.is-loading .sync-dot {
    background: #f0bb5a;
    box-shadow: 0 0 0 3px rgba(240, 187, 90, 0.14);
    animation: pulse 1.2s ease-in-out infinite;
}

.sync-state.is-warning .sync-dot {
    background: #f09a4a;
    box-shadow: 0 0 0 3px rgba(240, 154, 74, 0.14);
}

.icon-button {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
}

.icon-button-light {
    color: #e7eee9;
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
}

.icon-button-light:hover {
    background: rgba(255, 255, 255, 0.12);
}

.icon-button-light.is-loading svg {
    animation: spin 0.9s linear infinite;
}

.page-shell {
    width: min(1240px, calc(100% - 40px));
    margin: 0 auto;
    padding: 28px 0 34px;
}

.tool-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 18px;
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

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

h1 {
    margin-bottom: 0;
    font-size: 34px;
    line-height: 1.15;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 5px;
    font-size: 19px;
    line-height: 1.3;
    letter-spacing: 0;
}

.game-switch {
    display: inline-grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #e3e9e5;
}

.game-tab {
    min-width: 100px;
    height: 38px;
    padding: 0 18px;
    border: 0;
    border-radius: 6px;
    color: #52615a;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
}

.game-tab:hover {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.48);
}

.game-tab.is-active {
    color: var(--accent-strong);
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(24, 43, 33, 0.08);
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(330px, 0.86fr) minmax(0, 1.42fr);
    gap: 18px;
    align-items: stretch;
}

.picker-panel,
.result-panel,
.history-section {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.picker-panel {
    display: flex;
    flex-direction: column;
    padding: 24px;
}

.result-panel {
    min-height: 470px;
    display: flex;
    flex-direction: column;
    padding: 24px;
}

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.section-heading h2,
.history-heading h2 {
    margin-bottom: 4px;
}

.rules,
.result-meta,
.history-meta {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

.unique-badge {
    flex: none;
    padding: 5px 8px;
    border: 1px solid #d7e4db;
    border-radius: 4px;
    color: #3d6752;
    background: #f0f7f2;
    font-size: 11px;
    font-weight: 700;
}

.field-block {
    display: grid;
    grid-template-columns: 82px auto 1fr;
    align-items: center;
    gap: 12px;
    margin-top: 28px;
}

.field-label {
    margin: 0;
    color: #33423a;
    font-size: 14px;
    font-weight: 700;
}

.stepper {
    height: 42px;
    display: grid;
    grid-template-columns: 40px 58px 40px;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
}

.stepper button {
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    background: var(--surface-soft);
    cursor: pointer;
}

.stepper button:hover {
    color: var(--accent-strong);
    background: var(--accent-soft);
}

.stepper button:first-child {
    border-right: 1px solid var(--line);
}

.stepper button:last-child {
    border-left: 1px solid var(--line);
}

.stepper button svg {
    width: 17px;
    height: 17px;
}

.stepper input {
    width: 100%;
    min-width: 0;
    padding: 0;
    border: 0;
    color: var(--ink);
    background: transparent;
    text-align: center;
    font-size: 17px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
    margin: 0;
    appearance: none;
}

.field-hint {
    color: var(--muted);
    font-size: 12px;
}

.strategy-field {
    min-width: 0;
    margin: 24px 0 0;
    padding: 0;
    border: 0;
}

.strategy-field legend {
    margin-bottom: 10px;
}

.strategy-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.strategy-option {
    min-width: 0;
    cursor: pointer;
}

.strategy-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.strategy-content {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #52615a;
    background: var(--surface-soft);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}

.strategy-content svg {
    width: 18px;
    height: 18px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.strategy-option:hover .strategy-content {
    border-color: var(--line-strong);
    background: #f3f6f4;
}

.strategy-option:has(input:checked) .strategy-content {
    border-color: var(--accent);
    color: var(--accent-strong);
    background: var(--accent-soft);
}

.strategy-note {
    min-height: 20px;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.primary-button {
    min-height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    margin-top: auto;
    padding: 0 20px;
    border: 1px solid var(--accent-strong);
    border-radius: 8px;
    color: #fff;
    background: var(--accent);
    box-shadow: 0 8px 18px rgba(203, 51, 72, 0.18);
    cursor: pointer;
    font-size: 15px;
    font-weight: 800;
}

.primary-button:hover {
    background: var(--accent-strong);
}

.primary-button:disabled {
    cursor: wait;
    opacity: 0.72;
}

.primary-button.is-loading svg {
    animation: spin 0.9s linear infinite;
}

.result-heading {
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.secondary-button {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 11px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    color: #405048;
    background: var(--surface);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

.secondary-button:hover:not(:disabled) {
    border-color: #9eaba3;
    background: var(--surface-soft);
}

.secondary-button:disabled {
    cursor: not-allowed;
    opacity: 0.42;
}

.secondary-button svg {
    width: 16px;
    height: 16px;
}

.result-list {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 9px;
    padding: 18px 0;
}

.result-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 13px 15px;
    border: 1px solid #e3e9e5;
    border-radius: 7px;
    background: #fbfcfb;
}

.group-index {
    color: #8a968f;
    font-size: 12px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.result-numbers {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 16px;
}

.number-line {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 7px;
}

.zone-key {
    flex: none;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.balls {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.ball {
    width: 31px;
    height: 31px;
    display: inline-grid;
    flex: none;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.ball-red {
    background: var(--accent);
}

.ball-blue {
    background: var(--blue);
}

.disclaimer {
    margin: auto 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    color: #7a8780;
    font-size: 11px;
    line-height: 1.6;
}

.loading-state {
    display: grid;
    gap: 10px;
    padding: 8px 0;
}

.loading-line {
    height: 57px;
    border-radius: 7px;
    background: #f2f5f3;
    animation: pulse 1.2s ease-in-out infinite;
}

.loading-line-short {
    width: 74%;
}

.result-error {
    margin: auto 0;
    padding: 22px;
    border: 1px solid #f0d4d7;
    border-radius: 8px;
    color: #8f2938;
    background: #fff5f6;
    font-size: 13px;
    line-height: 1.7;
    text-align: center;
}

.history-section {
    margin-top: 18px;
    overflow: hidden;
}

.history-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 21px 24px 18px;
    border-bottom: 1px solid var(--line);
}

.live-badge {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border: 1px solid #d4e5da;
    border-radius: 4px;
    color: var(--success);
    background: #f0f8f3;
    font-size: 11px;
    font-weight: 700;
}

.live-badge span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #29a266;
}

.live-badge.is-warning {
    border-color: #eadbbc;
    color: var(--warning);
    background: var(--warning-soft);
}

.live-badge.is-warning span {
    background: #d6902f;
}

.history-table-wrap {
    max-height: 690px;
    overflow: auto;
}

.history-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    table-layout: fixed;
}

.history-table th {
    position: sticky;
    z-index: 2;
    top: 0;
    padding: 11px 24px;
    border-bottom: 1px solid var(--line);
    color: #78857e;
    background: #f7f9f7;
    font-size: 11px;
    font-weight: 700;
    text-align: left;
}

.history-table th:nth-child(1) {
    width: 22%;
}

.history-table th:nth-child(2) {
    width: 20%;
}

.history-table th:nth-child(3) {
    width: 58%;
}

.history-table td {
    padding: 12px 24px;
    border-bottom: 1px solid #edf0ee;
    color: #36453d;
    font-size: 13px;
    vertical-align: middle;
}

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

.history-table tbody tr:hover {
    background: #fafcfb;
}

.issue-cell {
    display: flex;
    align-items: center;
    gap: 7px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.issue-latest {
    padding: 2px 5px;
    border-radius: 3px;
    color: var(--accent-strong);
    background: var(--accent-soft);
    font-size: 9px;
    font-weight: 800;
}

.draw-date {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.history-numbers {
    display: flex;
    align-items: center;
    gap: 5px;
}

.history-numbers .ball {
    width: 28px;
    height: 28px;
    font-size: 11px;
}

.number-divider {
    width: 1px;
    height: 20px;
    margin: 0 3px;
    background: var(--line-strong);
}

.table-state {
    height: 126px;
    color: var(--muted) !important;
    text-align: center !important;
}

.table-state.is-error {
    color: #9a3442 !important;
}

.page-footer {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 2px 0;
    color: #78857e;
    font-size: 11px;
}

.toast {
    position: fixed;
    z-index: 20;
    right: 22px;
    bottom: 22px;
    max-width: min(360px, calc(100vw - 44px));
    padding: 11px 14px;
    border: 1px solid #31483c;
    border-radius: 7px;
    color: #f5faf7;
    background: #1d3228;
    box-shadow: 0 12px 30px rgba(13, 31, 22, 0.2);
    font-size: 13px;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.noscript {
    position: fixed;
    right: 16px;
    bottom: 16px;
    left: 16px;
    padding: 12px;
    border: 1px solid #e5c3c8;
    border-radius: 8px;
    color: #812837;
    background: #fff3f5;
    text-align: center;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.52;
    }
}

@media (max-width: 980px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .result-panel {
        min-height: 380px;
    }

    .primary-button {
        margin-top: 24px;
    }
}

@media (max-width: 680px) {
    .topbar-inner,
    .page-shell {
        width: min(100% - 24px, 1240px);
    }

    .topbar-inner {
        height: 60px;
    }

    .sync-state {
        max-width: 160px;
    }

    .sync-state #syncText {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .page-shell {
        padding-top: 20px;
    }

    .tool-head {
        align-items: center;
    }

    h1 {
        font-size: 28px;
    }

    .game-tab {
        min-width: 82px;
        padding: 0 12px;
    }

    .picker-panel,
    .result-panel {
        padding: 18px;
    }

    .field-block {
        grid-template-columns: 72px auto 1fr;
    }

    .strategy-content {
        min-height: 72px;
        flex-direction: column;
        gap: 5px;
    }

    .result-numbers {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .history-heading {
        padding: 18px;
    }

    .history-table th,
    .history-table td {
        padding-right: 18px;
        padding-left: 18px;
    }

    .page-footer {
        align-items: flex-start;
        flex-direction: column;
        gap: 7px;
    }
}

@media (max-width: 430px) {
    .sync-state #syncText {
        max-width: 96px;
    }

    .tool-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 14px;
    }

    .game-switch {
        width: 100%;
    }

    .game-tab {
        width: 100%;
    }

    .picker-panel,
    .result-panel {
        padding: 16px;
    }

    .unique-badge {
        display: none;
    }

    .field-block {
        grid-template-columns: 1fr auto;
    }

    .field-hint {
        display: none;
    }

    .strategy-grid {
        gap: 6px;
    }

    .strategy-content {
        padding-right: 3px;
        padding-left: 3px;
        font-size: 12px;
    }

    .result-row {
        grid-template-columns: 26px minmax(0, 1fr);
        gap: 8px;
        padding: 12px 10px;
    }

    .result-numbers {
        width: 100%;
    }

    .number-line {
        width: 100%;
        align-items: flex-start;
    }

    .zone-key {
        width: 30px;
        padding-top: 9px;
    }

    .balls {
        gap: 4px;
    }

    .ball {
        width: 29px;
        height: 29px;
        font-size: 11px;
    }
}
