* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: radial-gradient(120% 90% at 50% 0%, #14204e 0%, #0a1233 55%, #060b22 100%);
    font-family: "Microsoft JhengHei", "PingFang TC", "Heiti TC", sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

#app {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* ---------- HUD ---------- */
#hud {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: linear-gradient(180deg, #22336e, #131f48);
    border-bottom: 2px solid rgba(212, 169, 76, 0.5);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    color: #ffe9b0;
    font-size: 14px;
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow: hidden;
}

#hud.show {
    display: flex;
}

#hud .stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 233, 176, 0.16);
    border-radius: 8px;
    padding: 3px 8px;
    min-width: 0;
}

#hud .stat b {
    color: #fff;
    font-variant-numeric: tabular-nums;
}

#hud .spacer {
    flex: 1;
}

.icon-btn {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(212, 169, 76, 0.45);
    color: #ffe9b0;
    border-radius: 8px;
    font-size: 15px;
    padding: 3px 9px;
    cursor: pointer;
    font-family: inherit;
}

.icon-btn:active {
    background: rgba(255, 255, 255, 0.12);
}

.icon-btn.off {
    opacity: 0.45;
}

#stage {
    flex: 1;
    position: relative;
    min-height: 0;
}

#cv {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* ---------- 覆蓋層 ---------- */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(4, 7, 22, 0.72);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 10;
    padding: 16px;
}

.overlay.hidden {
    display: none;
}

.panel {
    background: linear-gradient(165deg, #25356e 0%, #1a2752 45%, #111c40 100%);
    border: 1px solid rgba(222, 178, 90, 0.65);
    border-radius: 18px;
    padding: 24px 28px;
    max-width: 420px;
    width: 100%;
    max-height: 92%;
    overflow-y: auto;
    text-align: center;
    color: #dfe6ff;
    box-shadow:
        0 14px 50px rgba(0, 0, 0, 0.65),
        0 0 0 4px rgba(20, 28, 64, 0.7),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.panel h1 {
    font-size: 34px;
    letter-spacing: 6px;
    margin-bottom: 4px;
    background: linear-gradient(180deg, #fff3c4 10%, #ffd54a 48%, #e8930c 95%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(255, 140, 40, 0.45));
}

.panel h2 {
    color: #ffd54a;
    font-size: 22px;
    margin-bottom: 10px;
    text-shadow: 0 2px 8px rgba(255, 150, 50, 0.35);
}

.panel .sub {
    font-size: 13px;
    color: #9fb0e8;
    letter-spacing: 1px;
    margin-bottom: 14px;
}

.panel .group-label {
    font-size: 13px;
    color: #9fb0e8;
    margin: 12px 0 6px;
    text-align: left;
}

.seg {
    display: flex;
    gap: 8px;
}

.seg button {
    flex: 1;
    background: linear-gradient(180deg, #1c2a5c, #141f46);
    border: 1px solid rgba(120, 145, 220, 0.45);
    color: #cfd9ff;
    border-radius: 10px;
    padding: 9px 4px;
    font-size: 15px;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.25;
    transition: transform 0.08s;
}

.seg button:active {
    transform: scale(0.97);
}

.seg button small {
    display: block;
    font-size: 11px;
    color: #8fa0d8;
}

.seg button.on {
    background: linear-gradient(180deg, #ffe27a, #f5b32d);
    border-color: #fff3c4;
    color: #4a2c00;
    box-shadow: 0 0 12px rgba(255, 200, 70, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.seg button.on small {
    color: #7a5210;
}

.big-btn {
    display: block;
    width: 100%;
    margin-top: 16px;
    background: linear-gradient(180deg, #ffe06a 0%, #ffc83c 40%, #f59d1d 100%);
    border: none;
    border-radius: 12px;
    color: #4a2c00;
    font-size: 19px;
    font-weight: bold;
    letter-spacing: 2px;
    padding: 13px;
    cursor: pointer;
    font-family: inherit;
    box-shadow:
        0 4px 0 #b06a0a,
        0 6px 14px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.65);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.big-btn:active {
    transform: translateY(2px);
    box-shadow:
        0 2px 0 #b06a0a,
        0 3px 8px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.big-btn:disabled {
    filter: grayscale(0.7);
    opacity: 0.6;
    cursor: default;
}

.big-btn.green {
    background: linear-gradient(180deg, #8af08a 0%, #58d268 40%, #2eaf4e 100%);
    color: #073b14;
    box-shadow:
        0 4px 0 #1a6e30,
        0 6px 14px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.big-btn.green:active {
    box-shadow:
        0 2px 0 #1a6e30,
        0 3px 8px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.ghost-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(120, 145, 220, 0.55);
    border-radius: 12px;
    color: #aebbf0;
    font-size: 15px;
    padding: 10px;
    cursor: pointer;
    font-family: inherit;
}

.ghost-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

.result-line {
    font-size: 16px;
    margin: 6px 0;
}

.result-line b {
    color: #ffd54a;
    font-size: 20px;
    text-shadow: 0 1px 6px rgba(255, 170, 50, 0.4);
}

.help-text {
    text-align: left;
    font-size: 14px;
    line-height: 1.7;
    color: #cfd9ff;
}

.help-text em {
    color: #ffd54a;
    font-style: normal;
}

.hidden {
    display: none !important;
}
