:root {
    --bg: #10131c;
    --card: rgba(255, 255, 255, 0.08);
    --card-strong: rgba(255, 255, 255, 0.13);
    --text: #f5f7fb;
    --muted: #a9b0c3;
    --line: rgba(255, 255, 255, 0.12);
    --accent: #ff4655;
    --accent-2: #33d6a6;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255, 70, 85, 0.28), transparent 28rem),
        radial-gradient(circle at top right, rgba(51, 214, 166, 0.16), transparent 24rem),
        var(--bg);
    font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button, input, select, textarea { font: inherit; }

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

.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 28px;
    margin-bottom: 22px;
    border: 1px solid var(--line);
    border-radius: 28px;
    background: linear-gradient(135deg, rgba(255,255,255,0.12), rgba(255,255,255,0.05));
    box-shadow: var(--shadow);
}

.hero.compact { padding: 20px 24px; }
.eyebrow { margin: 0 0 8px; color: var(--accent-2); letter-spacing: 0.14em; text-transform: uppercase; font-size: 12px; }
h1, h2 { margin: 0; }
h1 { font-size: clamp(30px, 4vw, 54px); }
h2 { font-size: 20px; margin-bottom: 14px; }
.subhead { margin: 12px 0 0; color: var(--muted); }

.admin-link, button, .primary {
    border: 0;
    border-radius: 14px;
    padding: 12px 16px;
    color: var(--text);
    background: var(--card-strong);
    text-decoration: none;
    cursor: pointer;
}

.primary { background: linear-gradient(135deg, var(--accent), #ff7a45); font-weight: 700; }
.helper-actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.helper-actions a { border: 1px solid var(--line); border-radius: 14px; padding: 11px 14px; color: var(--text); background: var(--card-strong); text-decoration: none; white-space: nowrap; }
.helper-actions a:hover { border-color: rgba(255, 70, 85, 0.65); background: rgba(255, 70, 85, 0.16); }

.summary-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.progress-wrap { display: flex; align-items: center; gap: 12px; margin: -6px 0 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); }
.progress-bar { flex: 1; height: 10px; overflow: hidden; border-radius: 999px; background: rgba(0, 0, 0, 0.28); }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.25s ease; }
#progressLabel { color: var(--muted); font-size: 13px; white-space: nowrap; }
.summary-card { padding: 16px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); cursor: pointer; transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease; }
.summary-card:hover, .summary-card.active { transform: translateY(-2px); border-color: rgba(255, 70, 85, 0.65); background: var(--card-strong); }
.summary-card strong { display: block; font-size: 26px; margin-top: 4px; }
.summary-card span { color: var(--muted); font-size: 13px; }

.workspace { display: grid; grid-template-columns: 340px 1fr; gap: 18px; align-items: start; }
.filter-layout { display: grid; gap: 18px; }
.filter-form { display: block; }
.filter-top { display: grid; grid-template-columns: 1fr; gap: 18px; align-items: stretch; }
.source-card, .criteria-card { display: flex; flex-direction: column; min-width: 0; }
.source-card .token-input { flex: 1 1 auto; min-height: 210px; }
.source-actions { display: grid; grid-template-columns: 1fr; gap: 10px; align-items: end; margin-top: auto; }
.source-actions label { grid-column: 1 / -1; }
.source-actions .primary { min-width: 150px; }
.criteria-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.field { display: grid; gap: 8px; align-content: start; min-width: 0; }
.wide-field { grid-column: auto; }
.results-wide { min-height: 560px; display: flex; flex-direction: column; min-width: 0; }
.results-wide .table-wrap { flex: 1 1 auto; min-height: 330px; max-height: 52vh; min-width: 0; }
.results-wide #lineOutput { min-height: 170px; max-height: 240px; }
.helper-workspace { grid-template-columns: 360px 1fr; }
.helper-page .filters { position: static; gap: 8px; }
.helper-page .token-input { min-height: 110px; max-height: 170px; }
.helper-page #lineOutput { min-height: 120px; max-height: 190px; }
.helper-page .panel { padding: 16px; }
.helper-page .summary-grid { margin-bottom: 12px; }
.helper-page .results { max-height: calc(100vh - 140px); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.helper-page .table-wrap { max-height: 360px; overflow: auto; flex: 1 1 auto; min-width: 0; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 20px; box-shadow: var(--shadow); }
.filters { position: sticky; top: 18px; display: grid; gap: 10px; }
label { color: var(--text); font-weight: 700; }
label span { display: block; color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 2px; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--text);
    background: rgba(0, 0, 0, 0.22);
    padding: 12px 13px;
    outline: none;
}
select option { color: #141824; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.result-head p { margin: 6px 0 0; color: var(--muted); }
.actions { display: flex; gap: 10px; }
.table-wrap { overflow: auto; border-radius: 18px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 13px; background: rgba(0, 0, 0, 0.16); }
td { color: #eef1f8; }
.rank-group-row td { color: var(--accent-2); font-weight: 800; background: rgba(51, 214, 166, 0.08); }
.rank-group-clickable { cursor: pointer; }
.rank-group-clickable:hover td, .rank-group-clickable.active td { color: var(--text); background: rgba(255, 70, 85, 0.18); }
.game-list-row td { background: rgba(0, 0, 0, 0.12); }
.game-row { display: grid; grid-template-columns: minmax(160px, 1fr) auto auto auto auto auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.game-row:last-child { border-bottom: 0; }
.game-row strong { display: block; }
.game-row small { display: block; color: var(--muted); margin-top: 3px; }
.game-status-banned, .game-status-normal { border-radius: 999px; padding: 5px 10px; font-size: 13px; font-weight: 800; white-space: nowrap; }
.game-status-banned { color: #ffb3ba; background: rgba(255, 70, 85, 0.18); }
.game-status-normal { color: var(--accent-2); background: rgba(51, 214, 166, 0.14); }
.game-feedback { grid-column: 1 / -1; color: var(--accent-2); font-size: 13px; min-height: 18px; }
.game-feedback.error { color: #ffb3ba; }
textarea { min-height: 260px; margin-top: 16px; resize: vertical; line-height: 1.7; }
.token-input { min-height: 150px; margin-top: 0; }
.hint,
.hint-inline { margin: 0 0 8px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.hint-inline { margin: 0; grid-column: 1 / -1; }
.center-page { display: grid; place-items: center; }
.login-card { width: min(420px, calc(100% - 32px)); padding: 28px; border-radius: 24px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; gap: 14px; }
.error { color: #ffb3ba; margin: 0; }
pre { white-space: pre-wrap; color: var(--muted); background: rgba(0,0,0,0.2); padding: 14px; border-radius: 14px; }

@media (min-width: 981px) {
    .filter-top { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .criteria-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .wide-field { grid-column: span 2; }
    .source-actions { grid-template-columns: minmax(120px, 160px) 1fr; }
}

@media (hover: none), (pointer: coarse) {
    .filter-top { grid-template-columns: 1fr; }
    .criteria-grid { grid-template-columns: 1fr; }
    .wide-field { grid-column: auto; }
    .source-actions { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
    .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .workspace { grid-template-columns: 1fr; }
    .filter-top { grid-template-columns: 1fr; }
    .source-card .token-input { min-height: 170px; }
    .criteria-grid { grid-template-columns: 1fr; }
    .wide-field { grid-column: auto; }
    .results-wide { min-height: auto; }
    .results-wide .table-wrap { min-height: 300px; max-height: 58vh; }
    .helper-workspace { grid-template-columns: 1fr; }
    .filters { position: static; }
    .result-head, .hero { align-items: flex-start; flex-direction: column; }
    .helper-actions { width: 100%; justify-content: flex-start; }
}

@media (max-width: 560px) {
    .shell { width: min(100% - 20px, 1420px); padding: 14px 0; }
    .hero, .panel { border-radius: 18px; padding: 16px; }
    h1 { font-size: 28px; }
    h2 { font-size: 18px; }
    .summary-grid { grid-template-columns: 1fr; gap: 6px; }
    .summary-card { padding: 10px 14px; border-radius: 12px; display: flex; align-items: center; justify-content: space-between; }
    .summary-card strong { font-size: 20px; margin-top: 0; }
    .workspace { gap: 12px; }
    .filter-layout, .filter-top, .criteria-grid { gap: 12px; }
    .criteria-grid { grid-template-columns: 1fr; }
    .wide-field { grid-column: auto; }
    .source-actions { grid-template-columns: 1fr; }
    .two-cols { grid-template-columns: 1fr; }
    .result-head { gap: 12px; }
    .actions { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .actions button:first-child { grid-column: auto; }
    .helper-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .helper-actions a { text-align: center; }
    input, select, textarea, button, .primary { min-height: 44px; }
    textarea { min-height: 180px; }
    .source-card .token-input { min-height: 150px; }
    .results-wide .table-wrap { min-height: 260px; max-height: 52vh; }
    .results-wide #lineOutput { min-height: 150px; }
    table { min-width: 680px; }
    .game-row { grid-template-columns: 1fr 1fr; }
}

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