:root {
    --bg-color: #050505;
    --text-color: #0f0;
    --accent-color: #f0f;
    --syntax-color: #0ff;
    --danger-color: #f00;
    --warn-color: #ff0;
    --ram-color: #ffd700;
    --boss-color: #ff4400;
    --relic-color: #aaddff;
    --event-color: #b088ff;
    /* Original Purple */
    --heal-color: #00ffff;
    /* Cyan for Heal */
    --treasure-color: #ffaa00;
    /* Orange for Treasure/Mimic */
    --slot-bg: #111;
    --slot-border: #333;
    --font-main: 'Courier New', Courier, monospace;
    /* --- 新增這兩行來修復下方選單的顏色 --- */
    --main-color: #0f0;
    /* 或是 var(--text-color) */
    --border-color: #333;
    /* 或是 var(--slot-border) */
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: "Microsoft JhengHei", "Courier New", monospace;
    margin: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    padding-bottom: 50px;
    overscroll-behavior: none;
    user-select: none;

}

/* 1. 全局文字光暈 (Phosphor Glow) */
body {
    /* 讓所有文字帶有一點點綠色螢光暈開的感覺 */
    text-shadow: 0 0 1px rgba(0, 255, 0, 0.3);
    /* 開啟硬體加速，讓動畫更流暢 */
    will-change: text-shadow;
    /* 加入色差動畫 */
    animation: rgb-shift 5s infinite linear;
}

/* 2. RGB 色差分離動畫 (Chromatic Aberration) */
@keyframes rgb-shift {
    0% {
        text-shadow: 1px 0 rgba(255, 0, 0, 0.5), -1px 0 rgba(0, 0, 255, 0.5), 0 0 5px var(--text-color);
    }

    5% {
        text-shadow: 2px 0 rgba(255, 0, 0, 0.5), -2px 0 rgba(0, 0, 255, 0.5), 0 0 5px var(--text-color);
    }

    10% {
        text-shadow: 1px 0 rgba(255, 0, 0, 0.5), -1px 0 rgba(0, 0, 255, 0.5), 0 0 5px var(--text-color);
    }

    100% {
        text-shadow: 1px 0 rgba(255, 0, 0, 0.5), -1px 0 rgba(0, 0, 255, 0.5), 0 0 5px var(--text-color);
    }
}

/* 3. CRT 掃描線與曲面暗角 (這是重點！) */
.scanline {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    pointer-events: none;
    /* 讓滑鼠可以穿透 */

    /* 技巧：用 radial-gradient 做暗角，模擬螢幕曲面 */
    background:
        /* 掃描線紋理 (更細緻) */
        linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
        /* 垂直 RGB 掃描線 (模擬螢幕柵欄) */
        linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06)),
        /* 四周暗角 (Vignette) - 這是造成「曲面錯覺」的關鍵 */
        radial-gradient(circle, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.6) 90%, rgba(0, 0, 0, 1) 100%);

    background-size: 100% 4px, 3px 100%, 100% 100%;
    opacity: 1;
}

/* 4. 畫面微微閃爍 (Flicker) - 降低不透明度以免太刺眼 */
.crt-flicker {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.02);
    z-index: 9998;
    pointer-events: none;
    opacity: 0;
    animation: flicker 0.15s infinite;
}

@keyframes flicker {
    0% {
        opacity: 0.02;
    }

    50% {
        opacity: 0.05;
    }

    100% {
        opacity: 0.02;
    }
}

.item-icon-img {

    filter: drop-shadow(2px 0 0 rgba(255, 0, 0, 0.3)) drop-shadow(-2px 0 0 rgba(0, 0, 255, 0.3));
}

@keyframes flicker {
    0% {
        opacity: 0.01;
    }

    5% {
        opacity: 0.05;
    }

    10% {
        opacity: 0.01;
    }

    100% {
        opacity: 0.01;
    }
}

.scramble-text {
    display: inline-block;
    min-width: 20px;
}

.decoding {
    color: var(--syntax-color);
    text-shadow: 0 0 5px var(--syntax-color);
}

/* Custom Tooltip */
#custom-tooltip {
    position: fixed;
    background: rgba(5, 5, 5, 0.98);
    border: 1px solid var(--text-color);
    padding: 12px;
    z-index: 10000;
    pointer-events: none;
    display: none;
    font-family: var(--font-main);
    max-width: 250px;
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.2);
    font-size: 0.9em;
    line-height: 1.4;
    text-align: left;
    backdrop-filter: blur(4px);
}

.tooltip-title {
    color: #fff;
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 5px;
    border-bottom: 1px dashed #333;
    padding-bottom: 3px;
}

.tooltip-desc {
    color: #ccc;
}

.tooltip-extra {
    margin-top: 8px;
    font-size: 0.8em;
    text-transform: uppercase;
    color: var(--ram-color);
}

.syntax-rule {
    background: #220000;
    color: #ff4444;
    border: 1px dashed #ff0000;
    padding: 5px;
    font-size: 0.8em;
    margin-top: 5px;
    text-align: center;
    display: none;
    animation: flashRed 1s infinite alternate;
}

@keyframes flashRed {
    from {
        opacity: 0.7;
    }

    to {
        opacity: 1;
        text-shadow: 0 0 5px red;
    }
}

#mute-btn {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 10000;
    cursor: pointer;
    color: #0f0;
    font-family: monospace;
    border: 1px solid #0f0;
    padding: 5px 10px;
    background: rgba(0, 0, 0, 0.8);
    font-size: 0.8em;
}

#mute-btn:hover {
    background: #0f0;
    color: #000;
}

.side-decoration {
    display: none;
    flex: 1;
    padding: 20px;
    font-size: 0.85em;
    color: #1a5c2e;
    opacity: 0.8;
    overflow: hidden;
    flex-direction: column;
    justify-content: space-between;
    z-index: 0;
    position: sticky;
    top: 0;
    height: 100vh;
}

.hex-column {
    word-break: break-all;
    line-height: 1.4;
    font-family: monospace;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.2);
}

.container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    padding: 20px;
    box-sizing: border-box;
    z-index: 10;
    background: rgba(5, 5, 5, 0.95);
    border-left: 1px solid #111;
    border-right: 1px solid #111;
    min-height: 100vh;
    transition: transform 0.05s;
}

h1 {
    text-shadow: 0 0 5px var(--text-color);
    margin-bottom: 5px;
    margin-top: 0;
    font-size: 1.5em;
    text-align: center;
}

.high-score {
    color: #666;
    font-size: 0.8em;
    margin-bottom: 10px;
    text-align: center;
}

.status-row {
    display: flex;
    gap: 20px;
}

.status-panel {
    border: 2px solid var(--text-color);
    padding: 10px;
    background: #000;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.1);
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    transition: all 0.3s;
}

.status-panel.boss-mode {
    border-color: var(--boss-color);
    box-shadow: 0 0 20px var(--boss-color);
}

.status-panel.boss-mode .hp-bar-fill {
    background: var(--boss-color);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hp-bar-container {
    width: 100%;
    height: 15px;
    background: #222;
    margin-top: 5px;
    border: 1px solid var(--text-color);
    position: relative;
    overflow: hidden;
}

@keyframes strip-flow {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 40px 0;
    }
}

.hp-bar-fill {
    height: 100%;
    /* 斜紋背景：深紅 + 亮紅 */
    background: repeating-linear-gradient(45deg,
            #8b0000,
            #8b0000 10px,
            var(--danger-color) 10px,
            var(--danger-color) 20px);
    background-size: 200% 100%;
    /* 放大背景以便移動 */
    width: 100%;
    transition: width 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 0 10px var(--danger-color);
    /* 發光 */
    animation: strip-flow 1s linear infinite;
    /* 讓紋路動起來 */
}

.player-hp-fill {
    background: repeating-linear-gradient(45deg,
            #004400,
            #004400 10px,
            #00ff00 10px,
            #00ff00 20px);
    box-shadow: 0 0 10px #00ff00;
}

.ram-display {
    color: var(--ram-color);
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    position: relative;
}

.enemy-ability-icon {
    font-size: 1.5em;
    margin-left: 5px;
    transition: opacity 0.3s;
}

.enemy-ability-icon.silenced {
    opacity: 0.2;
    filter: grayscale(100%);
}

.enemy-intent {
    margin-top: 8px;
    font-size: 0.9em;
    padding: 4px;
    background: #110000;
    border: 1px solid #500;
    color: #ffaaaa;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        border-color: #500;
    }

    50% {
        border-color: #f00;
        box-shadow: 0 0 10px #f00;
    }

    100% {
        border-color: #500;
    }
}

.relic-bar {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #333;
    min-height: 25px;
    flex-wrap: wrap;
}

.relic-icon {
    font-size: 1.2em;
    cursor: help;
    border: 1px solid #444;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #111;
    transition: transform 0.2s;
}

.relic-icon.event-relic {
    border-color: var(--event-color);
    color: var(--event-color);
}

.relic-icon:hover {
    transform: scale(1.2);
    border-color: var(--relic-color);
    box-shadow: 0 0 5px var(--relic-color);
}

.combat-log {
    height: 100px;
    overflow-y: auto;
    border: 1px dashed #333;
    background: #080808;
    padding: 5px;
    font-size: 0.8em;
    color: #888;
    font-family: "Microsoft JhengHei", monospace;
    scroll-behavior: smooth;
}

.log-entry {
    margin: 2px 0;
    border-left: 2px solid transparent;
    padding-left: 5px;
    white-space: nowrap;
    overflow: hidden;
    animation: typing 0.5s steps(30, end);
    max-width: 100%;
}

.log-entry.highlight {
    color: #fff;
    font-weight: bold;
    border-left-color: #fff;
}

.log-entry.syntax {
    color: var(--syntax-color);
    border-left-color: var(--syntax-color);
}

.log-entry.danger {
    color: var(--danger-color);
    border-left-color: var(--danger-color);
}

.log-entry.boss {
    color: var(--boss-color);
    font-weight: bold;
    font-size: 1.1em;
}

.log-entry.relic {
    color: var(--relic-color);
    font-style: italic;
}

.log-entry.event {
    color: var(--event-color);
    font-weight: bold;
}

.section-header {
    font-size: 1em;
    border-bottom: 1px solid var(--text-color);
    margin-bottom: 5px;
    padding-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    justify-content: space-between;
}

.queue-container {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 15px;
    border: 2px solid var(--text-color);
    background: #000;
    position: relative;
}

.queue-container::before {
    content: "PROCESSING...";
    position: absolute;
    top: -10px;
    right: 10px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 0.7em;
    padding: 0 5px;
    display: none;
}

.processing .queue-container::before {
    display: block;
    animation: blink 0.5s infinite;
}

.slot {
    width: 18%;
    aspect-ratio: 1;
    background: var(--slot-bg);
    border: 2px solid var(--slot-border);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5em;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.slot:hover {
    border-color: var(--text-color);
}

/* Drag and Drop Styles */
.slot.drag-over {
    border-color: #fff;
    background: #222;
    box-shadow: inset 0 0 20px #fff;
}

/* 當格子被執行時 (Resolver 加上 active class 時) */
.slot.active {
    /* ...原有設定... */
    background: #002200;
    /* 背景稍微變亮 */
    box-shadow: 0 0 15px var(--text-color), inset 0 0 20px var(--text-color);
    position: relative;
    overflow: hidden;
    /* 限制掃描線在格子內 */
}

/* 新增：掃描光束 */
.slot.active::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(transparent 0%, rgba(0, 255, 0, 0.8) 50%, transparent 100%);
    background-size: 100% 200%;
    animation: scan-slot 0.2s linear infinite;
    /* 超快速掃描 */
    pointer-events: none;
}

@keyframes scan-slot {
    0% {
        background-position: 0% 100%;
    }

    100% {
        background-position: 0% 0%;
    }
}

.slot.synergy-glow {
    border-color: gold;
    box-shadow: 0 0 10px gold, inset 0 0 10px gold;
    animation: pulseGold 2s infinite;
}

@keyframes pulseGold {
    0% {
        box-shadow: 0 0 5px gold;
    }

    50% {
        box-shadow: 0 0 15px gold;
    }

    100% {
        box-shadow: 0 0 5px gold;
    }
}

.slot.skipped {
    opacity: 0.2;
    filter: grayscale(100%);
}

.slot.locked {
    border-color: var(--danger-color);
    background: repeating-linear-gradient(45deg, #220000, #220000 10px, #440000 10px, #440000 20px);
    cursor: not-allowed;
}

.slot.locked::after {
    content: "🔒";
    position: absolute;
    font-size: 0.5em;
    top: 2px;
    right: 2px;
}

.slot-index {
    position: absolute;
    top: 2px;
    left: 5px;
    font-size: 10px;
    color: #444;
}

.inventory-panel {
    border: 2px solid var(--text-color);
    padding: 10px;
    background: #000;
    min-height: 120px;
}

.inventory-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 5px;
    max-height: 220px;
    overflow-y: auto;
    align-content: flex-start;
    padding-right: 5px;

    &::-webkit-scrollbar {
        width: 8px;
    }

    &::-webkit-scrollbar-track {
        background: #111;
    }

    &::-webkit-scrollbar-thumb {
        background: #333;
        border-radius: 4px;
    }

    &::-webkit-scrollbar-thumb:hover {
        background: #555;
    }
}

.item-card {
    border: 1px solid var(--slot-border);
    padding: 5px;
    cursor: grab;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 60px;
    background: #0a0a0a;
    position: relative;
    z-index: 1;
    transition: transform 0.1s;
}

.item-card:hover {
    border-color: #fff;
    background: #222;
    transform: translateY(-2px);
}

.item-card:active {
    transform: scale(0.95);
    cursor: grabbing;
}

.item-card.syntax-type {
    border-color: var(--syntax-color);
    background: #001111;
}

.item-card.bug-type {
    border-color: var(--danger-color);
    background: #110000;
}

.item-emoji {
    font-size: 1.8em;
    pointer-events: none;
}

.item-name {
    font-size: 0.5em;
    text-align: center;
    color: #888;
    margin-top: 2px;
    line-height: 1.1;
    overflow: hidden;
    height: 2.2em;
    pointer-events: none;
}

.item-sell-tag {
    font-size: 0.5em;
    color: var(--ram-color);
    margin-top: 2px;
    font-weight: bold;
    border: 1px solid var(--ram-color);
    padding: 1px 3px;
    border-radius: 3px;
    pointer-events: none;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

button {
    background: #000;
    color: var(--text-color);
    border: 1px solid var(--text-color);
    clip-path: polygon(10px 0, 100% 0,
            100% calc(100% - 10px), calc(100% - 10px) 100%,
            0 100%, 0 10px);

    position: relative;
    overflow: hidden;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
}

button::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 255, 0, 0.4), transparent);
    transition: 0.5s;
}

button:hover::after {
    left: 100%;
}

button:hover {
    background: #002200;
    text-shadow: 0 0 8px var(--text-color);
    box-shadow: 0 0 15px var(--text-color);
    transform: translateY(-2px);
}

button:disabled {
    background: #222;
    color: #555;
    border-color: #444;
    cursor: not-allowed;
    box-shadow: none;
    pointer-events: none;
}

#speed-btn {
    padding: 12px 15px;
    font-size: 0.9em;
    background: #003300;
    color: #0f0;
    border: 1px solid #0f0;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    display: none;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #111;
    border: 2px solid var(--text-color);
    padding: 30px;
    text-align: center;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.1);
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.shop-content {
    border-color: var(--ram-color);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.2);
}

.shop-title {
    color: var(--ram-color);
    font-size: 2em;
    margin-bottom: 10px;
}

body.shopping-mode .container {
    opacity: 0.3;
    pointer-events: none;
}

body.shopping-mode .inventory-panel {
    opacity: 1;
    pointer-events: auto;
    position: relative;
    z-index: 201;
    box-shadow: 0 0 30px var(--ram-color);
}

.shop-section {
    margin-top: 20px;
    border-top: 1px dashed #333;
    padding-top: 10px;
}

.shop-section-title {
    color: #aaa;
    font-size: 0.9em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.loot-options {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

.loot-card {
    border: 1px solid #444;
    padding: 15px;
    cursor: pointer;
    width: 100px;
    background: #000;
    transition: all 0.2s;
}

.loot-card:hover {
    transform: scale(1.1);
    border-color: #fff;
}

.loot-card.relic-card {
    border-color: var(--relic-color);
    box-shadow: 0 0 10px rgba(170, 221, 255, 0.2);
}

.loot-card.event-relic-card {
    border-color: var(--event-color);
    box-shadow: 0 0 10px rgba(176, 136, 255, 0.2);
}

.loot-card.hardware-card {
    border-color: #FFD700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.hardware-card:hover {
    /* 滑鼠移過去更亮 */
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    background: rgba(255, 215, 0, 0.1);
}

.event-content {
    border-color: var(--event-color);
    box-shadow: 0 0 30px var(--event-color);
}

.event-title {
    color: var(--event-color);
    font-size: 2.5em;
    margin-bottom: 20px;
}

.event-desc {
    font-size: 1.2em;
    margin-bottom: 30px;
    line-height: 1.5;
    color: #ddd;
}

.event-choices {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.event-btn {
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--event-color);
    background: #111;
    color: var(--event-color);
    padding: 15px;
    font-size: 1em;
    text-align: left;
    transition: all 0.2s;
    cursor: pointer;
}

.event-btn:hover {
    background: var(--event-color);
    color: #000;
    transform: translateX(10px);
}

.start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: default;
}

.blink {
    animation: blink 1s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* Animation: Floating Damage Text */
.float-text {
    position: fixed;
    font-weight: bold;
    font-size: 1.5em;
    pointer-events: none;
    animation: floatUpFade 1.2s ease-out forwards;
    z-index: 1000;
    text-shadow: 2px 2px 0 #000, -1px -1px 0 #000;
    font-family: var(--font-main);
}

@keyframes floatUpFade {
    0% {
        transform: translate(-50%, 0) scale(0.5);
        opacity: 0;
    }

    20% {
        transform: translate(-50%, -20px) scale(1.5);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -80px) scale(1);
        opacity: 0;
    }
}

.particle {
    position: fixed;
    width: 4px;
    height: 4px;
    background: #fff;
    pointer-events: none;
    animation: particleAnim 0.5s ease-out forwards;
}

@keyframes particleAnim {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty));
    }
}

.victory-title {
    color: var(--ram-color);
    font-size: 4em;
    text-shadow: 0 0 20px var(--ram-color);
    margin-bottom: 20px;
}

.log-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
    width: 100%;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 5px;
}

.log-item {
    border: 1px solid #333;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: help;
    background: #0a0a0a;
    position: relative;
}

.log-item.locked {
    opacity: 0.3;
    filter: grayscale(100%);
}

.log-stat-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    border-bottom: 1px solid #333;
    padding: 5px 0;
}

.tab-btn {
    border: 1px solid #333;
    background: #000;
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    border-color: var(--syntax-color);
    background: #001111;
    color: var(--syntax-color);
    box-shadow: 0 0 10px var(--syntax-color);
    font-weight: bold;
}

.manual-section {
    text-align: left;
    margin-bottom: 20px;
}

.manual-h {
    color: var(--text-color);
    border-bottom: 1px solid #333;
    margin-bottom: 5px;
    font-weight: bold;
}

.manual-p {
    color: #aaa;
    font-size: 0.9em;
    line-height: 1.5;
}

/* OS Selection Styles */
.os-selection {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.os-card {
    border: 1px solid #333;
    background: #000;
    padding: 15px;
    width: 120px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    opacity: 0.7;
}

.os-card:hover {
    border-color: #666;
    opacity: 1;
}

.os-card.selected {
    border-color: var(--syntax-color);
    box-shadow: 0 0 15px var(--syntax-color);
    opacity: 1;
    transform: scale(1.05);
}

.os-icon {
    font-size: 2em;
    margin-bottom: 5px;
}

.os-name {
    font-weight: bold;
    color: #fff;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.os-desc {
    font-size: 0.7em;
    color: #888;
    line-height: 1.2;
}

/* BIOS Styles */
#bios-layer {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#bios-credits {
    font-size: 1.2em;
    color: var(--ram-color);
    margin-bottom: 20px;
    font-weight: bold;
    text-shadow: 0 0 5px var(--ram-color);
}

.bios-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    max-width: 800px;
}

.bios-card {
    border: 1px solid #333;
    background: #050505;
    padding: 15px;
    width: 200px;
    text-align: center;
    border-radius: 5px;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.bios-card:hover {
    border-color: #fff;
}

.bios-name {
    font-weight: bold;
    color: #fff;
    margin-bottom: 5px;
}

.bios-lvl {
    font-size: 0.8em;
    color: var(--syntax-color);
    margin-bottom: 10px;
}

.bios-desc {
    font-size: 0.8em;
    color: #888;
    margin-bottom: 15px;
    min-height: 3em;
}

.bios-btn {
    background: #111;
    border: 1px solid var(--text-color);
    color: var(--text-color);
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.9em;
}

.bios-btn:hover {
    background: var(--text-color);
    color: #000;
}

.bios-btn.maxed {
    border-color: #333;
    color: #333;
    cursor: default;
    background: #000;
}

.item-card.exhausted {
    opacity: 0.4;
    filter: grayscale(100%);
    pointer-events: none;
    border-color: #333;
}

.item-icon-img {
    width: 70%;
    height: 70%;
    object-fit: contain;
    /* 保持比例，不要被拉伸 */
    pointer-events: none;
    /* 讓滑鼠點擊能穿透圖片傳到格子 */

    /* --- 下面這行是選用的「駭客濾鏡」 --- */
    /* 如果你的圖是黑白的，這行可以把它強制變成你的駭客綠色！ */
    /* 如果你的圖本身就有顏色，可以把下面這行 filter 刪掉 */
    filter: drop-shadow(0 0 2px var(--text-color));
}

/* --- 新增：讓序列中的圖片置中 --- */
.item-content-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    /* 使用彈性盒子 */
    justify-content: center;
    /* 水平置中 */
    align-items: center;
    /* 垂直置中 */
    pointer-events: none;
    /* 讓滑鼠點擊穿透，才不會擋到拖曳 */
}

/* 確保圖片本身不會有預設的間距 */
.item-icon-img {
    display: block;
    /* 消除圖片底部的微小空隙 */
    margin: 0 auto;
    /* 雙重保險置中 */
}

/* --- v0.6 Visual Juice Updates --- */

/* 1. 畫面震動 (Screen Shake) */
@keyframes shake-anim {
    0% {
        transform: translate(0, 0);
        text-shadow: 2px 0 red, -2px 0 blue;
    }

    20% {
        transform: translate(-5px, 5px);
        text-shadow: -5px 0 red, 5px 0 blue;
    }

    /* 色差拉大 */
    40% {
        transform: translate(5px, -5px);
        text-shadow: 5px 0 red, -5px 0 blue;
    }

    60% {
        transform: translate(-5px, -5px);
        text-shadow: -5px 0 red, 5px 0 blue;
    }

    80% {
        transform: translate(5px, 5px);
        text-shadow: 5px 0 red, -5px 0 blue;
    }

    100% {
        transform: translate(0, 0);
        text-shadow: 2px 0 red, -2px 0 blue;
    }
}

.shaking {
    animation: shake-anim 0.3s cubic-bezier(.36, .07, .19, .97) both;
}

/* 2. 傷害數字跳動 (Damage Popup) */
.float-text {
    position: fixed;
    font-weight: bold;
    pointer-events: none;
    z-index: 2000;
    font-family: 'Courier New', monospace;
    /* 動畫設定 */
    opacity: 0;
    transform: scale(0.5);
    animation: popUp 0.8s ease-out forwards;
}

@keyframes popUp {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(0);
    }

    20% {
        opacity: 1;
        transform: scale(1.5) translateY(-10px);
    }

    /* 彈出變大 */
    40% {
        opacity: 1;
        transform: scale(1.0) translateY(-20px);
    }

    /* 回彈 */
    100% {
        opacity: 0;
        transform: scale(1.0) translateY(-60px);
    }

    /* 飄走 */
}

/* --- 顏色定義 (復刻經典版) --- */
.float-text.crit {
    color: #ff0;
    /* 黃色暴擊 */
    font-size: 2.5em;
    text-shadow: 0 0 10px #f00;
    /* 紅色光暈 */
    z-index: 2001;
}

.float-text.heal {
    color: #f0f;
    /* 紫色/洋紅色 (吸血) */
    font-size: 1.5em;
    text-shadow: 0 0 5px #f0f;
}

.float-text.block {
    color: #0ff;
    /* 青色/藍色 (格檔) */
    font-size: 1.5em;
    text-shadow: 0 0 5px #0ff;
}

.float-text.dmg {
    color: #f00;
    /* 紅色 (一般傷害) */
    font-size: 1.8em;
    text-shadow: 2px 2px 0 #000;
}

.float-text.poison {
    color: #0f0;
    /* 綠色 (毒) */
    font-size: 1.2em;
}

/* 新增打字機動畫 */
@keyframes typing {
    from {
        width: 0;
    }

    to {
        width: 100%;
    }
}

.click-ripple {
    position: fixed;
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-color);
    background: transparent;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    pointer-events: none;
    z-index: 9999;
    animation: ripple-anim 0.4s ease-out forwards;
}

@keyframes ripple-anim {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
        border-width: 5px;
    }

    100% {
        transform: translate(-50%, -50%) scale(3.0);
        opacity: 0;
        border-width: 0px;
    }
}

.sw-item {
    padding: 10px;
    border-bottom: 1px dashed #333;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    color: #888;
    transition: all 0.2s;
}

.sw-item:hover {
    background: #111;
    color: #fff;
}

.sw-item.selected {
    background: #222;
    color: #0ff;
    border-left: 3px solid #0ff;
}

.sw-item.installed {
    color: #0f0;
    font-weight: bold;
}

#install-progress-bar {
    background: #0f0;
    height: 100%;
    width: 0%;
    transition: width 0.5s;
}

/* --- 加大執行按鈕 --- */
#run-btn {
    font-size: 1.5em;
    /* 字體變大 */
    padding: 10px 30px;
    /* 內距加大 (上下, 左右) */
    min-width: 200px;
    /* 設定最小寬度，更有份量感 */
    font-weight: 900;
    /* 字體加粗 */
    border-width: 2px;
    /*邊框加粗 */
    clip-path: polygon(15px 0, 100% 0,
            100% calc(100% - 15px), calc(100% - 15px) 100%,
            0 100%, 0 15px);
    margin-right: 10px;
}

#speed-btn {
    font-size: 1.1em;
    padding: 15px 20px;
    border-width: 2px;
}

/* =========================================
   UI 優化：選單與按鈕 (上下垂直佈局，卡片橫向展開)
   ========================================= */

/* 1. 核心容器：改為垂直排列 */
.config-container {
    display: flex;
    flex-direction: column;
    /* 關鍵：垂直排列 */
    gap: 40px;
    /* 上下區塊間距 */
    width: 90%;
    max-width: 1200px;
    margin: 20px auto 40px auto;
    flex-grow: 1;
}

/* 2. 區塊樣式 */
.selection-section {
    width: 100%;
    /* 佔滿整行 */
    display: flex;
    flex-direction: column;
    background: rgba(0, 20, 0, 0.3);
    border: 1px solid #333;
    padding: 20px;
    border-radius: 4px;
}

.selection-section h3 {
    color: var(--main-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 20px;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: linear-gradient(90deg, rgba(0, 255, 0, 0.1) 0%, rgba(0, 0, 0, 0) 100%);
}

/* 3. 網格佈局 (Grid)：讓卡片橫向排列 */
.selection-grid {
    display: grid;
    /* 關鍵：每張卡片最少 240px，空間夠就並排，不夠自動換行 */
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    overflow: visible;
}

/* 4. 卡片樣式 */
.map-card,
.os-card {
    position: relative;
    border: 1px solid #444;
    border-left: 4px solid #444;
    padding: 20px;
    background: rgba(0, 0, 0, 0.8);
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 100px;
    /* 給予足夠高度 */

    /* 切角效果 */
    clip-path: polygon(0 0,
            100% 0,
            100% calc(100% - 15px),
            calc(100% - 15px) 100%,
            0 100%);
}

.map-card:hover,
.os-card:hover {
    transform: translateY(-3px);
    background: rgba(0, 50, 0, 0.9);
    border-color: var(--main-color);
    box-shadow: 0 5px 15px rgba(0, 255, 0, 0.15);
    z-index: 10;
}

.map-card.selected,
.os-card.selected {
    border-color: var(--main-color);
    background: rgba(0, 255, 0, 0.15);
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3) inset;
    border-left-width: 8px;
}

.map-card.locked,
.os-card.locked {
    opacity: 0.4;
    filter: grayscale(100%);
    border-style: dashed;
    cursor: not-allowed;
}

.map-card div:first-child,
.os-card div:first-child {
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 8px;
    color: #fff;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
}

/* 5. 底部按鈕區 */
.action-footer {
    display: flex;
    gap: 30px;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px dashed #333;
}

/* 6. Map 2 主題適配 */
body.theme-firewall .selection-section h3 {
    background: linear-gradient(90deg, rgba(0, 240, 255, 0.2) 0%, rgba(0, 0, 0, 0) 100%);
}

body.theme-firewall .selection-section,
body.theme-firewall .map-card,
body.theme-firewall .os-card {
    border-color: #00aaff !important;
    background-color: #001122 !important;
    color: #00f0ff !important;
    box-shadow: 0 0 5px rgba(0, 170, 255, 0.2);
}

/* =========================================
   UI 強制修正補丁 (Fix Layout Issues)
   把這段貼在 CSS 檔案的最下面
   ========================================= */

/* 1. 強制容器垂直排列，並佔滿寬度 */
.config-container {
    display: flex !important;
    flex-direction: column !important;
    /* 關鍵：強制由上而下 */
    width: 100% !important;
    max-width: 900px !important;
    /* 限制最大寬度，避免在大螢幕太寬 */
    margin: 0 auto !important;
    /* 水平置中 */
    padding: 20px;
    box-sizing: border-box;
}

/* 2. 確保選擇區塊佔滿整行，不再被按鈕擠壓 */
.selection-section {
    width: 100% !important;
    margin-bottom: 30px !important;
    box-sizing: border-box;
}

/* 3. 優化網格：讓卡片能橫向排列 */
/* auto-fit 會在空間足夠時自動把卡片拉開，minmax 改小一點(180px)適應你的螢幕 */
.selection-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
    gap: 20px !important;
    width: 100% !important;
}

/* 4. 修正卡片高度與內容 */
.map-card,
.os-card {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    /* 內容垂直置中 */
    align-items: center;
    /* 內容水平置中 */
    min-height: 140px !important;
    /* 給予足夠高度 */
    text-align: center;
    /* 文字置中 */
}

/* 5. 把那些飛到右邊的按鈕強制拉回底部 */
.action-footer,
.controls {
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    /* 按鈕置中 */
    gap: 20px !important;
    margin-top: 20px !important;
    padding-top: 20px;
    border-top: 1px dashed #333;
}

/* 6. 標題樣式微調 (對齊綠色框線) */
h3 {
    text-align: left;
    width: 100%;
    margin-bottom: 15px;
}

/* --- 變數補救 (如果在 :root 沒加到的話，這裡強制定義) --- */
.map-card,
.os-card {
    border-color: #333;
    /* 預設邊框 */
}

.map-card.selected,
.os-card.selected {
    border-color: #0f0 !important;
    /* 選中變綠 */
    background: rgba(0, 255, 0, 0.1);
}

/* =========================================
   UI 排版最終強制修正 (Final Layout Fix)
   ========================================= */

/* 1. 強制最外層容器垂直排列 (由上而下) */
#map-selection-layer {
    flex-direction: column !important;
    /* 關鍵：變成垂直 */
    justify-content: center !important;
    /* 垂直置中 */
    align-items: center !important;
    /* 水平置中 */
    width: 100% !important;
    height: 100% !important;
    padding-top: 50px;
    /* 避免標題太貼頂 */
}

/* 2. 標題置中 */
#map-selection-layer h2 {
    width: 100%;
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.8em;
    text-shadow: 0 0 10px var(--text-color);
}

/* 3. 中間選單容器：確保佔滿寬度但不過寬 */
.config-container {
    width: 90% !important;
    max-width: 800px !important;
    margin: 0 auto 20px auto !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 30px !important;
    /* 上下區塊間距 */
}

/* 4. 按鈕區：強制移到最下方並置中 */
.action-footer {
    width: 100% !important;
    max-width: 800px !important;
    display: flex !important;
    justify-content: center !important;
    gap: 40px !important;
    /* 按鈕之間的距離 */
    margin-top: 10px !important;
    padding-top: 20px !important;
    border-top: 1px dashed #333;
}

/* 5. 修復按鈕樣式 (避免跑版) */
.action-footer button {
    min-width: 150px;
    font-size: 1.2em;
    padding: 10px 20px;
}

/* 6. 針對 OS 卡片被切掉的問題 */
.selection-section {
    overflow: visible !important;
    /* 確保陰影或邊框不會被切掉 */
    padding: 10px;
}

/* --- src/style.css (貼在最下方) --- */

/* 🔵 [Map 2] 企業防火牆 - 強制覆蓋樣式 */
body.theme-firewall {
    background-color: #020a15 !important;
    color: #00f0ff !important;
}

/* 強制改變所有面板、容器的背景與邊框 */
body.theme-firewall .game-container,
body.theme-firewall .panel,
body.theme-firewall .slot,
body.theme-firewall .log-entry,
body.theme-firewall .item-card,
body.theme-firewall .map-card,
body.theme-firewall .os-card,
body.theme-firewall .bios-card,
body.theme-firewall button {
    border-color: #00aaff !important;
    background-color: #001122 !important;
    color: #00f0ff !important;
    box-shadow: 0 0 5px rgba(0, 170, 255, 0.2);
}

/* 強制改變進度條顏色 (血條/RAM) */
body.theme-firewall .bar-fill {
    background-color: #00f0ff !important;
    box-shadow: 0 0 10px #00f0ff;
}

/* 按鈕 Hover 效果 */
body.theme-firewall button:hover,
body.theme-firewall .map-card:hover,
body.theme-firewall .os-card:hover {
    background-color: #003355 !important;
    color: #fff !important;
    box-shadow: 0 0 15px #00aaff;
}

/* 選中狀態 */
body.theme-firewall .selected {
    border-color: #fff !important;
    background-color: #004466 !important;
}

/* 讓原本綠色的文字變藍色 (例如 Log) */
body.theme-firewall .log-entry {
    color: #88ccff !important;
}

body.theme-firewall .log-entry.highlight {
    color: #fff !important;
    text-shadow: 0 0 5px #00aaff;
}

@media (min-width: 1200px) {

    /* 1. 放寬核心容器限制 */
    .container,
    .config-container,
    .action-footer,
    #map-selection-layer h2 {
        max-width: 1400px !important;
        /* 從 800px 放寬到 1400px */
        width: 85% !important;
        /* 佔據 85% 的螢幕寬度 */
    }

    /* 2. 整體字體放大 (像變焦一樣) */
    body {
        font-size: 18px;
        /* 基礎字體加大 (原本預設通常是 16px) */
    }

    /* 3. 卡片尺寸與文字加大 */
    .map-card,
    .os-card {
        min-height: 220px !important;
        /* 卡片長高 */
        padding: 40px !important;
        /* 內距加寬 */
    }

    .map-card div:first-child,
    .os-card div:first-child {
        font-size: 1.8em !important;
        /* 卡片標題變大 */
        margin-bottom: 15px !important;
    }

    .map-card div:last-child,
    .os-card div:last-child {
        font-size: 1.1em !important;
        /* 描述文字變大 */
    }

    /* 4. 網格佈局調整 (讓卡片更寬) */
    .selection-grid {
        /* 卡片最小寬度從 200px 增加到 350px，看起來更大氣 */
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)) !important;
        gap: 30px !important;
    }

    /* 5. 按鈕加大 */
    button,
    .menu-btn {
        font-size: 1.4em !important;
        /* 按鈕文字加大 */
        padding: 15px 40px !important;
        /* 按鈕變胖 */
        letter-spacing: 2px !important;
    }

    /* 6. 標題加大 */
    h1,
    h2,
    h3 {
        font-size: 2.5em !important;
        margin-bottom: 30px !important;
    }
}

@media (min-width: 1800px) {
    body {
        font-size: 22px;
    }

    /* 字體再加大 */
    .container,
    .config-container {
        max-width: 1600px !important;
    }

    .selection-grid {
        grid-template-columns: repeat(auto-fit, minmax(450px, 1fr)) !important;
    }
}

/* =========================================
   🔧 修正：針對選單頁面的微調 (防止變得過大)
   請放在 style.css 最下面，確保蓋過原本的大螢幕設定
   ========================================= */

@media (min-width: 1200px) {

    /* 單獨把選單層的基礎字體縮小一點 (18px -> 16px) */
    #map-selection-layer {
        font-size: 16px !important;
        max-width: 1200px !important;
        /* 限制選單最大寬度，不要太寬 */
    }

    /* 縮小選單內的卡片尺寸 */
    #map-selection-layer .map-card,
    #map-selection-layer .os-card {
        min-height: 180px !important;
        /*原本 220px -> 改 180px */
        padding: 20px !important;
        /*原本 40px -> 改 20px */
    }

    /* 縮小卡片內的標題文字 */
    #map-selection-layer .map-card div:first-child,
    #map-selection-layer .os-card div:first-child {
        font-size: 1.2em !important;
        /*原本 1.8em -> 改 1.4em */
        margin-bottom: 10px !important;
    }

    /* 縮小選單的大標題 (PHASE_1...) */
    #map-selection-layer h2 {
        font-size: 2em !important;
        /*原本 2.5em -> 改 2em */
        margin-bottom: 20px !important;
    }

    /* 讓 Grid 排列稍微緊湊一點 */
    #map-selection-layer .selection-grid {
        gap: 20px !important;
        /*原本 30px -> 改 20px */
    }
}

/* =========================================
   🔧 修正：強制 OS 卡片 3 張並排 (不換行)
   ========================================= */

/* 針對 OS 選擇容器進行特殊設定 */
#os-selection-container {
    /* 關鍵：強制分成 3 等份 (1fr 1fr 1fr)，不管寬度多少都擠在同一排 */
    grid-template-columns: repeat(3, 1fr) !important;

    /* 稍微縮小卡片間距，避免太擠 */
    gap: 13px !important;
}

/* 為了確保 3 張並排時不會太高，稍微調整 OS 卡片的高度 */
#os-selection-layer .os-card {
    min-height: 160px !important;
    /* 原本可能是 180px 或 220px，改矮一點 */
    padding: 15px !important;
}

/* 讓下方的按鈕區不要被擠出去，增加一點頂部空間的彈性 */
.action-footer {
    margin-top: 15px !important;
    padding-top: 15px !important;
    flex-shrink: 0;
    /* 防止按鈕被壓縮 */
}