/* 火柴棒数学谜题 */
.main {
    grid-template-columns: minmax(0, 1fr) 400px;
}
@media (max-width: 900px) {
    .main {
        grid-template-columns: 1fr;
    }
}

.main .extra-panel {
    grid-column: 1 / -1;
    margin-top: 0;
}

.hint-box {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.7;
    color: #7c2d12;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    text-align: left;
    animation: hint-pop .25s ease;
}
.hint-box.hidden { display: none; }
@keyframes hint-pop {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.mode-note {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.7;
    background: #f9fafb;
    border: 1px solid #eef0f4;
    border-radius: 8px;
    padding: 10px 12px;
}
.mode-note b {
    color: #374151;
    font-size: 14px;
}

/* ---- 谜题区域 ---- */
.m-zone {
    border-radius: 14px;
    min-height: 360px;
    padding: 24px 20px;
    text-align: center;
    user-select: none;
    -webkit-user-select: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    transition: background .25s ease, box-shadow .25s ease;
}
.m-zone.idle {
    background: #f1f2f4;
    border: 2px dashed #d1d5db;
    color: #6b7280;
}
.m-zone.play {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    color: #334155;
}
.m-zone.win {
    background: linear-gradient(135deg, #10b981 0%, #a7f3d0 160%);
    border: 2px solid #34d399;
    color: #064e3b;
}
.m-zone.over {
    background: linear-gradient(135deg, #0ea5e9 0%, #22c55e 160%);
    border: 2px solid #10b981;
    color: #083344;
}
.m-zone .z-big {
    font-size: 52px;
    font-weight: 800;
    line-height: 1.2;
}
.m-zone .z-sub {
    font-size: 17px;
    opacity: .9;
}
.m-zone .z-chip {
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    background: rgba(255, 255, 255, .9);
    border-radius: 999px;
    padding: 4px 14px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}

.grid-wrap {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-end;
    gap: 10px;
    width: 100%;
    padding: 4px 0;
}
.grid-wrap.hidden { display: none; }

/* 谜题几何尺寸由 CSS 变量驱动，随断点整体缩放 */
.m-zone {
    --mcell-w: 80px;
    --mcell-h: 124px;
    --mst: 16px;
    --mside: 9px;
    --mop-w: 64px;
    --mhside: 7px;
    --mbvtb: 18px;
    --meqoff: 17px;
}

.m-cell {
    position: relative;
    width: var(--mcell-w);
    height: var(--mcell-h);
    flex: 0 0 auto;
}
.digit-cell .mstick {
    position: absolute;
    display: block;
    border-radius: 999px;
    transition: transform .12s ease, box-shadow .12s ease, background .15s ease, border-color .15s ease;
}
.mstick.lit {
    cursor: pointer;
    border: none;
    background: linear-gradient(180deg, #ffe2a3 0%, #f5b32e 22%, #dc8500 60%, #9a5c00 100%);
    box-shadow: inset 0 3px 2px rgba(255, 255, 255, .6), inset 0 -3px 4px rgba(120, 60, 0, .5), 0 3px 4px rgba(120, 60, 0, .35);
}
.mstick.lit:hover {
    transform: scale(1.08);
}
.mstick.ghost {
    background: rgba(148, 163, 184, .08);
    border: 2px dashed #94a3b8;
    cursor: pointer;
}
.mstick.ghost:hover {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, .1);
}
.mstick.selected {
    box-shadow: inset 0 3px 2px rgba(255, 255, 255, .6), inset 0 -3px 4px rgba(120, 60, 0, .5), 0 0 0 3px #facc15, 0 5px 12px rgba(0, 0, 0, .3);
    transform: scale(1.1);
    z-index: 2;
}

/* 7 段火柴坐标（变量驱动，垂直柴长 = (cellH - 柴厚) / 2） */
.mstick.seg-a { top: 0; left: var(--mside); right: var(--mside); height: var(--mst); }
.mstick.seg-b { top: 0; right: var(--mside); width: var(--mst); height: calc((var(--mcell-h) - var(--mst)) / 2); }
.mstick.seg-c { bottom: 0; right: var(--mside); width: var(--mst); height: calc((var(--mcell-h) - var(--mst)) / 2); }
.mstick.seg-d { bottom: 0; left: var(--mside); right: var(--mside); height: var(--mst); }
.mstick.seg-e { bottom: 0; left: var(--mside); width: var(--mst); height: calc((var(--mcell-h) - var(--mst)) / 2); }
.mstick.seg-f { top: 0; left: var(--mside); width: var(--mst); height: calc((var(--mcell-h) - var(--mst)) / 2); }
.mstick.seg-g { top: calc((var(--mcell-h) - var(--mst)) / 2); left: var(--mside); right: var(--mside); height: var(--mst); }

.op-cell {
    position: relative;
    width: var(--mop-w);
    height: var(--mcell-h);
}
.op-cell .opbar {
    position: absolute;
    border-radius: 999px;
    background: linear-gradient(180deg, #ffe2a3 0%, #f5b32e 22%, #dc8500 60%, #9a5c00 100%);
    box-shadow: inset 0 3px 2px rgba(255, 255, 255, .6), inset 0 -3px 4px rgba(120, 60, 0, .5), 0 3px 4px rgba(120, 60, 0, .35);
}
.opbar.b-h { left: var(--mhside); right: var(--mhside); top: 50%; height: var(--mst); transform: translateY(-50%); }
.opbar.b-v { top: var(--mbvtb); bottom: var(--mbvtb); left: 50%; width: var(--mst); transform: translateX(-50%); }
.opbar.eq-1 { transform: translateY(calc(-50% - var(--meqoff))); }
.opbar.eq-2 { transform: translateY(calc(-50% + var(--meqoff))); }

.eq-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 19px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    background: #fff;
    border: 1px solid #eef0f4;
    border-radius: 10px;
    padding: 6px 16px;
}
.eq-info.hidden { display: none; }
.eq-info em {
    font-style: normal;
    font-size: 13px;
    font-weight: 600;
    border-radius: 999px;
    padding: 2px 10px;
}
.eq-info .eq-ok { background: #dcfce7; color: #16a34a; }
.eq-info .eq-bad { background: #fee2e2; color: #dc2626; }

.zone-btn {
    margin-top: 6px;
    padding: 11px 30px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    background: #0ea5e9;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .15);
    transition: background .2s ease, transform .15s ease;
}
.zone-btn:hover {
    background: #0284c7;
    transform: translateY(-1px);
}
.zone-btn.hidden { display: none; }
.zone-btn.ghost-btn {
    background: #fff;
    color: #475569;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}
.zone-btn.ghost-btn:hover {
    background: #f1f5f9;
    transform: translateY(-1px);
}
.zone-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.progress-chip {
    background: #eef2ff;
    color: #4338ca;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ---- 设置面板 ---- */
.grade-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.grade-options .radio-card {
    justify-content: flex-start;
    gap: 6px;
}
.grade-options .radio-card i {
    font-style: normal;
    font-size: 12px;
    color: #9ca3af;
    white-space: nowrap;
}

.grade-box {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding: 12px 14px;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    transition: border-color .25s ease, background .25s ease;
}
.grade-box .grade-icon {
    font-size: 26px;
}
.grade-box .grade-txt {
    font-size: 14px;
    font-weight: 700;
    color: #374151;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 12px;
}
.stat {
    background: #f9fafb;
    border: 1px solid #eef0f4;
    border-radius: 8px;
    padding: 12px 8px;
    text-align: center;
}
.stat b {
    display: block;
    font-size: 20px;
    font-weight: 800;
    color: #4338ca;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}
.stat span {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    color: #6b7280;
}

.record-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin: 16px 0 8px;
}
.record-title .link-btn {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    font-size: 12px;
    color: #6b7280;
    cursor: pointer;
    padding: 4px 12px;
    transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.record-title .link-btn:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #ef4444;
}

.record-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #374151;
    background: #fff;
    border: 1px solid #f1f3f7;
    border-radius: 8px;
    padding: 7px 10px;
    margin-bottom: 6px;
}
.record-item.best {
    background: #f0fdf4;
    border-color: #bbf7d0;
}
.record-item .rec-date {
    color: #9ca3af;
    font-size: 12px;
}
.record-item .rec-time {
    font-weight: 700;
    color: #f59e0b;
    font-variant-numeric: tabular-nums;
}

/* ---- 小屏适配：整体缩小字号与火柴尺寸 ---- */
@media (max-width: 900px) {
    .m-zone .z-big { font-size: 42px; }
    .m-zone .z-sub { font-size: 15px; }
    .m-zone .z-chip { font-size: 12px; }
    .eq-info { font-size: 17px; }
    .mode-note { font-size: 12px; }
    .m-zone {
        --mcell-w: 68px;
        --mcell-h: 104px;
        --mst: 14px;
        --mside: 7px;
        --mop-w: 54px;
        --mhside: 6px;
        --mbvtb: 15px;
        --meqoff: 15px;
    }
}

@media (max-width: 600px) {
    .m-zone .z-big { font-size: 34px; }
    .m-zone .z-sub { font-size: 13px; }
    .m-zone .z-chip { font-size: 11px; }
    .m-zone { padding: 18px 12px; }
    .eq-info { font-size: 15px; }
    .eq-info em { font-size: 12px; }
    .zone-btn { font-size: 14px; padding: 9px 18px; }
    .mode-note { font-size: 11px; }
    .m-zone {
        --mcell-w: 56px;
        --mcell-h: 86px;
        --mst: 12px;
        --mside: 6px;
        --mop-w: 46px;
        --mhside: 5px;
        --mbvtb: 13px;
        --meqoff: 13px;
    }
}