:root {
    --bg-0: #070b1a;
    --bg-1: #0c1330;
    --bg-2: #141c47;
    --ink: #e8efff;
    --ink-dim: #8a97c8;
    --accent: #00e5ff;
    --accent-2: #7c4dff;
    --gold: #ffd54f;
    --orange: #ff9e3d;
    --c1: #4fc3f7;
    --c2: #66bb6a;
    --c3: #ab47bc;
    --c4: #ef5350;
    --c5: #ffd54f;
    --glass: rgba(18, 26, 66, 0.55);
    --glass-line: rgba(124, 77, 255, 0.35);
    --glow: 0 0 24px rgba(0, 229, 255, 0.35);
    --font: -apple-system, BlinkMacSystemFont, "Inter", "PingFang TC", "Noto Sans TC", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: var(--font);
    color: var(--ink);
    background:
        radial-gradient(1200px 800px at 20% -10%, #1a1055 0%, transparent 60%),
        radial-gradient(900px 700px at 100% 110%, #002a4f 0%, transparent 55%),
        linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 100%);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    display: grid;
    grid-template-rows: auto 1fr auto;
    height: 100vh;
    width: 100vw;
}

/* ===== Top bar ===== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 14px 24px;
    background: linear-gradient(180deg, rgba(10, 14, 40, 0.85), rgba(10, 14, 40, 0.35));
    border-bottom: 1px solid var(--glass-line);
    backdrop-filter: blur(12px);
    z-index: 5;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-dot {
    width: 12px; height: 12px; border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #7df9ff, #00e5ff 60%, #004a6b);
    box-shadow: var(--glow);
    animation: pulse 2.4s ease-in-out infinite;
}
.brand h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: linear-gradient(90deg, #7df9ff, #c792ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.brand-sub { font-size: 12px; color: var(--ink-dim); letter-spacing: 0.15em; }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(0, 229, 255, 0.4); }
    50% { box-shadow: 0 0 28px rgba(0, 229, 255, 0.9); }
}

.scene-tabs { display: flex; gap: 6px; }
.scene-tabs button {
    font-family: inherit;
    font-size: 13px;
    color: var(--ink-dim);
    background: rgba(20, 28, 71, 0.45);
    border: 1px solid rgba(124, 77, 255, 0.25);
    padding: 8px 16px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.18s ease;
}
.scene-tabs button:hover { color: var(--ink); border-color: var(--accent); }
.scene-tabs button.active {
    color: #051225;
    background: linear-gradient(135deg, #7df9ff, #c792ff);
    border-color: transparent;
    box-shadow: var(--glow);
    font-weight: 600;
}

.scoreboard { display: flex; gap: 10px; }
.score {
    display: flex; flex-direction: column; align-items: center;
    min-width: 76px;
    padding: 6px 14px;
    background: var(--glass);
    border: 1px solid var(--glass-line);
    border-radius: 12px;
}
.score-label { font-size: 10px; color: var(--ink-dim); letter-spacing: 0.08em; text-transform: uppercase; }
.score-value {
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    background: linear-gradient(180deg, #ffffff, #7df9ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ===== Stage ===== */
.stage-wrap {
    position: relative;
    overflow: hidden;
}
.pixi-root {
    position: absolute;
    inset: 0;
}
.pixi-root canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none; /* 手機拖拉不觸發捲動 */
}

.hint {
    position: absolute;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: var(--glass);
    border: 1px solid var(--glass-line);
    backdrop-filter: blur(10px);
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 13px;
    color: var(--ink-dim);
    pointer-events: none;
    transition: opacity 0.4s;
}
.hint b { color: var(--accent); font-weight: 600; }
.hint.fade { opacity: 0; }

/* ===== Dock ===== */
.dock {
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 12px 24px;
    background: linear-gradient(0deg, rgba(10, 14, 40, 0.85), rgba(10, 14, 40, 0.35));
    border-top: 1px solid var(--glass-line);
    backdrop-filter: blur(12px);
}
.dock-group { display: flex; align-items: center; gap: 10px; }
.dock-group.right { margin-left: auto; }
.dock-label { font-size: 11px; color: var(--ink-dim); letter-spacing: 0.12em; text-transform: uppercase; }

.seg { display: flex; background: rgba(20, 28, 71, 0.45); border: 1px solid var(--glass-line); border-radius: 999px; padding: 3px; }
.seg-btn {
    font-family: inherit;
    font-size: 12px;
    color: var(--ink-dim);
    background: transparent;
    border: none;
    padding: 6px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active {
    color: #051225;
    background: linear-gradient(135deg, #7df9ff, #c792ff);
    font-weight: 600;
}

.switch { position: relative; display: inline-block; width: 42px; height: 22px; }
.switch input { display: none; }
.slider {
    position: absolute; inset: 0;
    background: rgba(20, 28, 71, 0.6);
    border: 1px solid var(--glass-line);
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s;
}
.slider::before {
    content: "";
    position: absolute;
    left: 3px; top: 2px;
    width: 16px; height: 16px;
    background: var(--ink-dim);
    border-radius: 50%;
    transition: all 0.2s;
}
.switch input:checked + .slider { background: linear-gradient(135deg, #00e5ff, #7c4dff); border-color: transparent; }
.switch input:checked + .slider::before { transform: translateX(20px); background: #fff; box-shadow: 0 0 10px #7df9ff; }

.ghost-btn {
    font-family: inherit;
    font-size: 12px;
    color: var(--ink);
    background: rgba(20, 28, 71, 0.45);
    border: 1px solid var(--glass-line);
    padding: 8px 16px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s;
}
.ghost-btn:hover { border-color: var(--accent); box-shadow: var(--glow); }
.ghost-btn:active { transform: scale(0.96); }

/* Speed slider */
.dock-label b { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.speed-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 140px;
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(124, 77, 255, 0.25), rgba(0, 229, 255, 0.5));
    outline: none;
    cursor: pointer;
}
.speed-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #7df9ff, #00e5ff 55%, #004a6b);
    border: 2px solid #fff;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.8);
    cursor: pointer;
}
.speed-slider::-moz-range-thumb {
    width: 18px; height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #7df9ff, #00e5ff 55%, #004a6b);
    border: 2px solid #fff;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.8);
    cursor: pointer;
}

/* ===== Inspector panel ===== */
.hidden { display: none !important; }

.inspector {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 340px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding: 20px 22px 18px;
    background: linear-gradient(160deg, rgba(20, 28, 71, 0.92), rgba(10, 14, 40, 0.88));
    border: 1px solid var(--glass-line);
    border-radius: 18px;
    backdrop-filter: blur(14px);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5), var(--glow);
    animation: slideInRight 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
    z-index: 10;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

.inspector-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: var(--ink-dim);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.15s;
}
.inspector-close:hover { background: rgba(255, 255, 255, 0.18); color: var(--ink); }

.inspector-head {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 14px;
}
.inspector-tag {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    font-size: 22px;
    font-weight: 900;
    color: #051225;
    background: linear-gradient(135deg, #7df9ff, #c792ff);
    box-shadow: var(--glow);
    letter-spacing: 1px;
}
.inspector-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
}
.inspector-full {
    font-size: 11px;
    color: var(--ink-dim);
    letter-spacing: 0.04em;
    margin-top: 2px;
}

.inspector-stats {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}
.stat {
    flex: 1;
    padding: 10px 12px;
    background: rgba(0, 229, 255, 0.08);
    border: 1px solid rgba(0, 229, 255, 0.22);
    border-radius: 10px;
}
.stat-k {
    display: block;
    font-size: 9px;
    color: var(--ink-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.stat-v {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.inspector-section { margin-bottom: 14px; }
.inspector-section h4 {
    font-size: 10px;
    color: var(--ink-dim);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin-bottom: 6px;
    font-weight: 700;
}
.inspector-section p {
    font-size: 13px;
    line-height: 1.55;
    color: var(--ink);
}
.inspector-lv3 {
    width: 100%;
    margin-top: 4px;
    padding: 10px;
    font-size: 13px;
    font-weight: 600;
}

.card-kicker {
    font-size: 10px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-weight: 700;
}

/* ===== Scene fact card ===== */
.scene-fact {
    position: absolute;
    left: 20px;
    top: 20px;
    width: 360px;
    padding: 18px 22px 20px;
    background: linear-gradient(160deg, rgba(20, 28, 71, 0.92), rgba(10, 14, 40, 0.85));
    border: 1px solid var(--glass-line);
    border-radius: 18px;
    backdrop-filter: blur(14px);
    box-shadow: 0 14px 44px rgba(0, 0, 0, 0.4);
    animation: slideInLeft 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2);
    z-index: 9;
}
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}
.scene-fact-head { margin-bottom: 12px; }
.scene-fact-head h3 {
    margin-top: 4px;
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
}
.scene-fact ul {
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
}
.scene-fact li {
    position: relative;
    padding: 8px 0 8px 20px;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--ink);
    border-bottom: 1px dashed rgba(124, 77, 255, 0.18);
}
.scene-fact li:last-child { border-bottom: none; }
.scene-fact li::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 14px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: radial-gradient(circle, #7df9ff, transparent);
    box-shadow: 0 0 8px #7df9ff;
}
.scene-fact button { width: 100%; }

/* ===== Lv3 modal ===== */
.lv3-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.lv3-backdrop {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(20, 10, 60, 0.88), rgba(5, 8, 20, 0.96));
    backdrop-filter: blur(8px);
}
.lv3-card {
    position: relative;
    width: min(1100px, 96vw);
    max-height: 92vh;
    overflow-y: auto;
    padding: 32px 36px 32px;
    background: linear-gradient(160deg, rgba(20, 28, 71, 0.95), rgba(10, 14, 40, 0.92));
    border: 1px solid var(--glass-line);
    border-radius: 24px;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.6), 0 0 80px rgba(124, 77, 255, 0.35);
    animation: scaleIn 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.92) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.lv3-head { margin-bottom: 24px; }
.lv3-head h2 {
    margin-top: 6px;
    font-size: 26px;
    font-weight: 800;
    background: linear-gradient(90deg, #ffd54f, #ffea7f);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.lv3-head p {
    margin-top: 4px;
    font-size: 13px;
    color: var(--ink-dim);
}
.lv3-body {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 24px;
    align-items: start;
}
.lv3-diagram {
    background: rgba(5, 8, 20, 0.6);
    border: 1px solid rgba(255, 213, 79, 0.25);
    border-radius: 16px;
    padding: 20px;
    aspect-ratio: 1 / 1.1;
}
.lv3-diagram svg { width: 100%; height: 100%; }
.lv3-gamma-rotor {
    transform-box: fill-box;
    transform-origin: center;
    animation: gammaRotate 4s linear infinite;
}
@keyframes gammaRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.lv3-parts { display: flex; flex-direction: column; gap: 14px; }
.lv3-part {
    padding: 14px 16px;
    background: rgba(255, 213, 79, 0.06);
    border: 1px solid rgba(255, 213, 79, 0.2);
    border-radius: 12px;
    transition: all 0.2s;
}
.lv3-part:hover {
    background: rgba(255, 213, 79, 0.12);
    border-color: rgba(255, 213, 79, 0.5);
    transform: translateX(4px);
}
.lv3-part-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.lv3-part-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
}
.lv3-part-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
}
.lv3-part-desc {
    font-size: 12px;
    line-height: 1.55;
    color: var(--ink-dim);
}

@media (max-width: 820px) {
    .lv3-body { grid-template-columns: 1fr; }
    .lv3-diagram { aspect-ratio: 1 / 0.9; }
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
    .topbar {
        flex-wrap: wrap;
        gap: 10px;
        padding: 10px 12px;
    }
    .brand h1 { font-size: 15px; }
    .brand-sub { display: none; }
    .scene-tabs { order: 3; width: 100%; justify-content: center; }
    .scene-tabs button { padding: 6px 12px; font-size: 12px; }
    .scoreboard { gap: 6px; }
    .score { min-width: 56px; padding: 4px 8px; }
    .score-value { font-size: 16px; }
    .score-label { font-size: 9px; }

    .hint {
        font-size: 11px;
        padding: 8px 14px;
        bottom: 12px;
        max-width: calc(100vw - 24px);
        text-align: center;
    }

    .dock {
        flex-wrap: wrap;
        gap: 10px 14px;
        padding: 10px 12px;
        justify-content: center;
    }
    .dock-group { gap: 6px; }
    .dock-group.right { margin-left: 0; }
    .dock-label { font-size: 10px; letter-spacing: 0.08em; }
    .seg-btn { padding: 5px 10px; font-size: 11px; }
    .ghost-btn { padding: 6px 12px; font-size: 11px; }
    .speed-slider { width: 100px; }
}

@media (max-width: 480px) {
    .topbar .brand { flex: 1 1 auto; }
    .scoreboard { flex: 1 1 100%; order: 4; justify-content: center; }
    .dock-group { flex-basis: auto; }
}
