/* ============================================
   魔法符文對戰 - 暗色魔法學院風格
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0a0514;
    color: #e8d9ff;
    /* 跨平台字型: Mac 優先 Georgia / PingFang TC, Windows 退到 Microsoft JhengHei */
    font-family: 'Georgia', 'Times New Roman',
                 -apple-system, BlinkMacSystemFont,
                 'Segoe UI', Roboto,
                 'Noto Serif TC', 'Noto Sans TC',
                 'PingFang TC', 'Heiti TC',
                 'Microsoft JhengHei', '微軟正黑體',
                 'Microsoft YaHei', '微软雅黑',
                 sans-serif;
    /* 防止觸控板 / 滑鼠拖曳手勢誤觸發 */
    touch-action: none;
    overscroll-behavior: none;
    /* Windows Chromium/Edge: 更清晰的字體渲染 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

#game-container {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(80, 30, 120, 0.4) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(30, 60, 120, 0.3) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(20, 10, 40, 1) 0%, #05020e 100%);
    overflow: hidden;
}

/* 星光背景 */
#game-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 10% 20%, #fff, transparent),
        radial-gradient(1px 1px at 30% 70%, #aaf, transparent),
        radial-gradient(1px 1px at 60% 10%, #fff, transparent),
        radial-gradient(1px 1px at 80% 40%, #ddf, transparent),
        radial-gradient(1px 1px at 90% 90%, #fff, transparent),
        radial-gradient(2px 2px at 40% 50%, #fff, transparent),
        radial-gradient(1px 1px at 15% 85%, #aaf, transparent);
    background-size: 200% 200%;
    opacity: 0.6;
    animation: twinkle 8s infinite;
    pointer-events: none;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* ============================================
   畫面切換
   ============================================ */
.screen {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* 通用卡片進場動畫 — 多個子項按序淡入 */
@keyframes cardFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-3px); }
}

@keyframes cardShimmer {
    0%   { opacity: 0; transform: translateY(15px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* 進場動畫只用於「一次性建立」的頁面 — 避免互動頁面每次刷新都重播 */
.codex-card:not(.codex-locked),
.level-card:not(.locked) {
    animation: cardShimmer 0.4s cubic-bezier(0.2, 0.8, 0.3, 1.1) both;
}
/* 互動頁面 (skill/shop/loadout/upgrade): 只保留 hover, 不進場動畫 */
.codex-card, .skill-card, .shop-card, .level-card, .upgrade-card, .loadout-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.codex-card:hover, .skill-card:hover, .shop-card:hover:not(.owned):not(.locked),
.level-card:hover:not(.locked), .upgrade-card:hover:not(.maxed), .loadout-card:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 0 22px rgba(180, 120, 255, 0.45);
}
/* 按序延遲 (最多 18 張) */
.codex-card:nth-child(1), .skill-card:nth-child(1), .shop-card:nth-child(1),
.level-card:nth-child(1), .upgrade-card:nth-child(1), .loadout-card:nth-child(1) { animation-delay: 0.02s; }
.codex-card:nth-child(2), .skill-card:nth-child(2), .shop-card:nth-child(2),
.level-card:nth-child(2), .upgrade-card:nth-child(2), .loadout-card:nth-child(2) { animation-delay: 0.06s; }
.codex-card:nth-child(3), .skill-card:nth-child(3), .shop-card:nth-child(3),
.level-card:nth-child(3), .upgrade-card:nth-child(3), .loadout-card:nth-child(3) { animation-delay: 0.10s; }
.codex-card:nth-child(4), .skill-card:nth-child(4), .shop-card:nth-child(4),
.level-card:nth-child(4), .upgrade-card:nth-child(4), .loadout-card:nth-child(4) { animation-delay: 0.14s; }
.codex-card:nth-child(5), .skill-card:nth-child(5), .shop-card:nth-child(5),
.level-card:nth-child(5), .upgrade-card:nth-child(5), .loadout-card:nth-child(5) { animation-delay: 0.18s; }
.codex-card:nth-child(n+6), .skill-card:nth-child(n+6), .shop-card:nth-child(n+6),
.level-card:nth-child(n+6), .upgrade-card:nth-child(n+6), .loadout-card:nth-child(n+6) { animation-delay: 0.22s; }

/* 標題進場動畫 (通用) */
.screen-title {
    animation: titleIntro 0.5s ease-out;
}

/* 返回按鈕 hover */
.back-btn {
    transition: all 0.2s ease;
}
.back-btn:hover {
    transform: translateX(-3px);
    box-shadow: 0 0 12px rgba(180, 120, 255, 0.4);
}

/* 設定面板 row 進場 */
.setting-row {
    animation: cardShimmer 0.4s ease-out both;
    transition: border-color 0.2s ease;
}
.setting-row:hover {
    border-color: #7a5aad;
}
.setting-row:nth-child(1) { animation-delay: 0.05s; }
.setting-row:nth-child(2) { animation-delay: 0.10s; }
.setting-row:nth-child(3) { animation-delay: 0.15s; }
.setting-row:nth-child(4) { animation-delay: 0.20s; }

/* ============================================
   主選單
   ============================================ */
.game-title {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
    z-index: 2;
    animation: titleIntro 0.8s ease-out;
}

@keyframes titleIntro {
    from { opacity: 0; transform: translateY(-30px) scale(0.8); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.title-magic, .title-rune {
    display: inline-block;
    font-size: 4.5rem;
    font-weight: bold;
    letter-spacing: 0.1em;
    text-shadow:
        0 0 10px #b366ff,
        0 0 20px #8844cc,
        0 0 40px #4422aa,
        0 0 80px #221166;
    animation: titleGlow 2.5s ease-in-out infinite alternate, titleFloat 5s ease-in-out infinite;
}

.title-rune {
    animation-delay: -1.2s, -2.5s;
}

@keyframes titleFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

.title-rune {
    color: #66aaff;
    text-shadow:
        0 0 10px #66aaff,
        0 0 20px #4488cc,
        0 0 40px #2244aa,
        0 0 80px #112288;
    animation-delay: 1.5s;
}

.title-magic {
    color: #d9b3ff;
}

.title-sub {
    font-size: 1.2rem;
    letter-spacing: 0.5em;
    color: #8866aa;
    margin-top: 10px;
    font-family: 'SF Mono', 'Cascadia Code', Consolas, 'Courier New', monospace;
}

@keyframes titleGlow {
    from {
        filter: brightness(1);
        text-shadow:
            0 0 10px #b366ff,
            0 0 20px #8844cc,
            0 0 40px #4422aa,
            0 0 80px #221166;
    }
    to {
        filter: brightness(1.5);
        text-shadow:
            0 0 15px #d99fff,
            0 0 30px #b366ff,
            0 0 60px #8844cc,
            0 0 100px #4422aa;
    }
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2;
}

.menu-btn {
    padding: 11px 40px;
    font-size: 1.1rem;
    background: linear-gradient(180deg, rgba(80, 40, 120, 0.6), rgba(40, 20, 80, 0.8));
    color: #e8d9ff;
    border: 2px solid #6644aa;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: 0.15em;
    text-shadow: 0 0 8px #aa66ff;
    box-shadow:
        0 0 20px rgba(120, 60, 200, 0.3),
        inset 0 0 20px rgba(80, 40, 120, 0.4);
    transition: all 0.3s ease;
    min-width: 220px;
    position: relative;
    overflow: hidden;
}

/* 主選單 / 單人子選單 按鈕進場動畫 (按序彈入) */
#main-menu .menu-btn,
#sp-menu .menu-btn {
    opacity: 0;
    transform: translateX(-30px);
    animation: btnSlideIn 0.45s forwards cubic-bezier(0.2, 0.8, 0.3, 1.2);
}
#main-menu .menu-btn:nth-child(1),
#sp-menu .menu-btn:nth-child(1) { animation-delay: 0.10s; }
#main-menu .menu-btn:nth-child(2),
#sp-menu .menu-btn:nth-child(2) { animation-delay: 0.18s; }
#sp-menu .menu-btn:nth-child(3) { animation-delay: 0.26s; }
#sp-menu .menu-btn:nth-child(4) { animation-delay: 0.34s; }
#sp-menu .menu-btn:nth-child(5) { animation-delay: 0.42s; }
#sp-menu .menu-btn:nth-child(6) { animation-delay: 0.50s; }
#sp-menu .menu-btn:nth-child(7) { animation-delay: 0.58s; }

@keyframes btnSlideIn {
    from { opacity: 0; transform: translateX(-30px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* 閃光掃過效果 — hover 時顯示 */
.menu-btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent);
    transition: left 0.5s ease;
    pointer-events: none;
}

.menu-btn:hover::before {
    left: 100%;
}

.menu-btn:hover {
    background: linear-gradient(180deg, rgba(120, 60, 180, 0.7), rgba(60, 30, 120, 0.9));
    border-color: #bb88ff;
    box-shadow:
        0 0 30px rgba(160, 80, 240, 0.6),
        inset 0 0 30px rgba(120, 60, 180, 0.5);
    transform: translateY(-2px);
}

.menu-btn:active {
    transform: translateY(1px);
}

.menu-hint {
    position: absolute;
    bottom: 15px;
    right: 20px;
    font-size: 0.75rem;
    color: #8866aa;
    letter-spacing: 0.08em;
    text-align: right;
    opacity: 0.7;
}

.menu-bg-runes {
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 15% 30%, rgba(180, 100, 255, 0.14) 0%, transparent 40%),
        radial-gradient(circle at 85% 70%, rgba(100, 180, 255, 0.14) 0%, transparent 40%);
    pointer-events: none;
    animation: bgPulse 8s ease-in-out infinite;
}

@keyframes bgPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 背景浮動符文 */
.floating-runes {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

.float-rune {
    position: absolute;
    bottom: -60px;
    font-size: 2.2rem;
    color: rgba(200, 150, 255, 0.3);
    text-shadow: 0 0 12px rgba(180, 100, 255, 0.6);
    animation: drift 18s linear infinite;
}

@keyframes drift {
    0%   { transform: translateY(0) rotate(0);   opacity: 0; }
    10%  { opacity: 0.7; }
    50%  { transform: translateY(-55vh) rotate(180deg); opacity: 0.5; }
    90%  { opacity: 0.4; }
    100% { transform: translateY(-110vh) rotate(360deg); opacity: 0; }
}

/* 標題後光暈 (會旋轉) */
.title-halo {
    position: absolute;
    top: 22%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 620px;
    height: 620px;
    background:
        conic-gradient(from 0deg,
            rgba(180, 100, 255, 0.15),
            rgba(100, 180, 255, 0.08),
            rgba(255, 180, 100, 0.10),
            rgba(180, 100, 255, 0.15));
    border-radius: 50%;
    filter: blur(60px);
    animation: haloSpin 22s linear infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes haloSpin {
    from { transform: translate(-50%, -50%) rotate(0); }
    to   { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ============================================
   通用標題與返回按鈕
   ============================================ */
.screen-title {
    font-size: 2.5rem;
    color: #d9b3ff;
    text-shadow: 0 0 20px #8844cc;
    margin-bottom: 30px;
    letter-spacing: 0.1em;
}

.back-btn {
    position: absolute;
    top: 30px;
    left: 30px;
    padding: 10px 20px;
    background: rgba(60, 30, 90, 0.6);
    color: #e8d9ff;
    border: 1px solid #6644aa;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
}

.back-btn:hover {
    background: rgba(90, 45, 135, 0.8);
}

/* ============================================
   符文圖鑑
   ============================================ */
/* 圖鑑改為可捲動 */
#codex-screen {
    justify-content: flex-start;
    padding-top: 50px;
    padding-bottom: 30px;
    overflow-y: auto;
}

.codex-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    max-width: 1100px;
    width: 92vw;
    padding: 10px;
}

.codex-card {
    background: linear-gradient(180deg, rgba(40, 20, 70, 0.8), rgba(20, 10, 40, 0.9));
    border: 1px solid #6644aa;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    gap: 20px;
    align-items: center;
    box-shadow: 0 0 15px rgba(120, 60, 200, 0.2);
}

.codex-card canvas {
    width: 100px;
    height: 100px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    flex-shrink: 0;
}

.codex-info h3 {
    color: #d9b3ff;
    margin-bottom: 8px;
    font-size: 1.3rem;
}

.codex-info p {
    color: #a088bb;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ============================================
   設定
   ============================================ */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 400px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(40, 20, 70, 0.5);
    border: 1px solid #443366;
    border-radius: 6px;
}

.setting-row span {
    font-size: 1.1rem;
}

.setting-row input[type="range"] {
    width: 180px;
    accent-color: #aa66ff;
}

.setting-row select {
    background: #2a1540;
    color: #e8d9ff;
    border: 1px solid #6644aa;
    padding: 5px 10px;
    border-radius: 4px;
    font-family: inherit;
}

/* ============================================
   關卡選擇
   ============================================ */
.level-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    max-width: 1100px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 10px;
}

.level-card {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, rgba(60, 30, 100, 0.8), rgba(30, 15, 60, 0.9));
    border: 2px solid #6644aa;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(120, 60, 200, 0.2);
}

.level-card:hover:not(.locked) {
    transform: scale(1.05);
    border-color: #bb88ff;
    box-shadow: 0 0 30px rgba(160, 80, 240, 0.5);
}

.level-card.locked {
    opacity: 0.35 !important;
    cursor: not-allowed !important;
    filter: grayscale(0.7) brightness(0.55);
    pointer-events: none;
    position: relative;
}

.level-card.locked .level-num,
.level-card.locked .level-name {
    color: #6a5a7a;
    text-shadow: none;
}

.level-card.locked::after {
    content: '未解鎖';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-18deg);
    font-size: 0.85rem;
    color: #ff9988;
    letter-spacing: 0.15em;
    background: rgba(20, 5, 15, 0.85);
    padding: 3px 12px;
    border: 1px solid #88334a;
    border-radius: 3px;
    font-weight: bold;
}

.level-card.locked:hover {
    transform: none !important;
    box-shadow: none !important;
}

.level-card.boss {
    border-color: #ff4466;
    background: linear-gradient(135deg, rgba(100, 30, 60, 0.8), rgba(60, 15, 30, 0.9));
}

.level-num {
    font-size: 2.5rem;
    color: #d9b3ff;
    text-shadow: 0 0 15px #8844cc;
}

.level-name {
    font-size: 0.9rem;
    color: #a088bb;
    margin-top: 5px;
}

/* ============================================
   遊戲畫面
   ============================================ */
#game-screen, #practice-screen {
    padding: 0;
}

#game-canvas, #practice-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

/* HUD 基底 */
.hud {
    position: absolute;
    color: #e8d9ff;
    pointer-events: none;
    z-index: 10;
    text-shadow: 0 0 8px #000, 0 0 4px #000;
}

#player-hud {
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 280px;
}

.bar-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bar-label {
    font-weight: bold;
    width: 30px;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
}

.bar-container {
    position: relative;
    flex: 1;
    height: 22px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid #443366;
    border-radius: 4px;
    overflow: hidden;
}

.bar {
    height: 100%;
    transition: width 0.3s ease;
    position: relative;
}

.hp-bar {
    background: linear-gradient(90deg, #ff4466, #ff88aa);
    box-shadow: 0 0 10px #ff4466 inset;
    width: 100%;
}

.mp-bar {
    background: linear-gradient(90deg, #4466ff, #88aaff);
    box-shadow: 0 0 10px #4466ff inset;
    width: 100%;
}

.bar-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: bold;
    font-family: 'SF Mono', 'Cascadia Code', Consolas, 'Courier New', monospace;
    text-shadow: 0 0 4px #000, 0 1px 2px #000;
}

#game-info {
    top: 20px;
    right: 20px;
    text-align: right;
    font-size: 1.1rem;
}

#level-display {
    font-size: 1.4rem;
    color: #d9b3ff;
    font-weight: bold;
    text-shadow: 0 0 10px #8844cc;
}

#score-display {
    margin-top: 5px;
    color: #ffcc66;
    text-shadow: 0 0 8px #cc8844;
}

#combo-display {
    margin-top: 8px;
    color: #ff88aa;
    font-weight: bold;
    font-size: 1.3rem;
    text-shadow: 0 0 15px #ff4466;
    animation: comboShake 0.3s ease;
}

#combo-display.hidden {
    display: none;
}

.buffs-display {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.buff-tag {
    background: rgba(40, 20, 70, 0.7);
    border: 1px solid #8844cc;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.8rem;
    color: #ffcc66;
    text-shadow: 0 0 6px #cc8844;
    letter-spacing: 0.05em;
}

.buff-time {
    font-size: 0.7rem;
    color: #a088bb;
    margin-left: 6px;
}

@keyframes comboShake {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* 冷卻指示器 — 10 個符文 */
#cooldowns {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 7px;
    pointer-events: none;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 95vw;
}

.cooldown-icon {
    width: 52px;
    height: 52px;
    background: linear-gradient(180deg, rgba(40, 20, 70, 0.9), rgba(20, 10, 40, 0.95));
    border: 2px solid #6644aa;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 12px rgba(120, 60, 200, 0.3);
}

.cooldown-icon .rune-canvas {
    width: 38px;
    height: 38px;
    z-index: 2;
    margin-top: 2px;
}

.cooldown-icon .rune-name {
    font-size: 0.6rem;
    color: #a088bb;
    z-index: 2;
    margin-top: -2px;
}

.cooldown-icon .cd-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.75);
    transition: height 0.1s linear;
    z-index: 1;
}

.cooldown-icon.ready {
    border-color: #88ffcc;
    box-shadow: 0 0 20px rgba(100, 255, 180, 0.5);
}

/* 繪製提示 */
.draw-hint {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.2rem;
    color: #a088bb;
    letter-spacing: 0.1em;
    animation: pulseHint 2s infinite;
}

.draw-hint.hidden {
    display: none;
}

@keyframes pulseHint {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* 角落按鈕 */
.corner-btn {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: rgba(40, 20, 70, 0.8);
    color: #e8d9ff;
    border: 1px solid #6644aa;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.corner-btn:hover {
    background: rgba(90, 45, 135, 0.9);
}

/* 識別結果彈跳顯示 */
#recognition-display {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: bold;
    color: #ffcc66;
    text-shadow: 0 0 20px #ff8844, 0 0 40px #ff4422;
    pointer-events: none;
    z-index: 15;
    animation: recognizePop 0.8s ease-out forwards;
}

#recognition-display.hidden {
    display: none;
}

#recognition-display.critical {
    color: #ff4466;
    text-shadow: 0 0 20px #ff88aa, 0 0 40px #ff4466;
}

#recognition-display.fail {
    color: #888888;
    text-shadow: 0 0 10px #444;
}

@keyframes recognizePop {
    0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
    30% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    70% { transform: translate(-50%, -70%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -100%) scale(0.9); opacity: 0; }
}

/* ============================================
   練習模式
   ============================================ */
#practice-hud {
    top: 20px;
    right: 20px;
    text-align: right;
    font-size: 1.1rem;
}

#practice-target {
    color: #d9b3ff;
    font-size: 1.4rem;
    text-shadow: 0 0 10px #8844cc;
}

#practice-score {
    margin-top: 5px;
    color: #ffcc66;
}

#practice-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
}

.practice-btn {
    padding: 10px 16px;
    background: rgba(40, 20, 70, 0.8);
    color: #e8d9ff;
    border: 1px solid #6644aa;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    pointer-events: auto;
}

.practice-btn:hover {
    background: rgba(90, 45, 135, 0.9);
    border-color: #bb88ff;
}

.practice-btn.active {
    background: rgba(120, 60, 180, 0.9);
    border-color: #ddaaff;
    box-shadow: 0 0 15px rgba(180, 120, 255, 0.5);
}

/* ============================================
   Modal 彈窗
   ============================================ */
.modal {
    position: absolute;
    inset: 0;
    background: rgba(5, 2, 14, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    backdrop-filter: blur(8px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(180deg, rgba(40, 20, 70, 0.95), rgba(20, 10, 40, 1));
    border: 2px solid #6644aa;
    border-radius: 10px;
    padding: 40px 60px;
    text-align: center;
    box-shadow: 0 0 40px rgba(120, 60, 200, 0.5);
    min-width: 400px;
}

.modal-content h2 {
    font-size: 2.5rem;
    color: #d9b3ff;
    margin-bottom: 30px;
    text-shadow: 0 0 20px #8844cc;
    letter-spacing: 0.1em;
}

.modal-content .menu-btn {
    margin: 8px 0;
    width: 100%;
    min-width: unset;
}

#result-stats {
    margin-bottom: 25px;
    color: #a088bb;
    line-height: 2;
    font-size: 1.1rem;
}

#result-stats .stat-value {
    color: #ffcc66;
    font-weight: bold;
    margin-left: 10px;
}

/* ============================================
   名稱輸入
   ============================================ */
.mp-name-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-width: 400px;
    width: 90vw;
}

.mp-name-hint {
    color: #a088bb;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
}

#mp-name-input {
    width: 100%;
    padding: 14px 18px;
    background: #1a0a28;
    border: 2px solid #6644aa;
    color: #e8d9ff;
    font-family: inherit;
    font-size: 1.4rem;
    text-align: center;
    border-radius: 6px;
    letter-spacing: 0.05em;
    box-sizing: border-box;
}

#mp-name-input:focus {
    outline: none;
    border-color: #bb88ff;
    box-shadow: 0 0 20px rgba(180, 120, 255, 0.4);
}

/* ============================================
   多人房間公共大廳 (左下角)
   ============================================ */
.mp-chat {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 320px;
    max-width: 36vw;
    background: linear-gradient(180deg, rgba(30, 15, 50, 0.9), rgba(15, 8, 30, 0.95));
    border: 1px solid #5a3a8a;
    border-radius: 8px;
    padding: 8px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 0 18px rgba(120, 60, 200, 0.25);
    z-index: 10;
}

.mp-chat-title {
    font-size: 0.8rem;
    color: #a088bb;
    letter-spacing: 0.15em;
    border-bottom: 1px solid rgba(120, 80, 180, 0.3);
    padding-bottom: 4px;
}

.mp-chat-log {
    height: 160px;
    overflow-y: auto;
    font-size: 0.82rem;
    line-height: 1.45;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: #6644aa transparent;
}

.mp-chat-log::-webkit-scrollbar { width: 6px; }
.mp-chat-log::-webkit-scrollbar-thumb { background: #6644aa; border-radius: 3px; }

.mp-chat-msg {
    color: #e8d9ff;
    padding: 1px 0;
    word-break: break-word;
}
.mp-chat-msg.self .mp-chat-name { color: #aaffcc; }
.mp-chat-msg.system {
    color: #ffcc66;
    font-style: italic;
    font-size: 0.78rem;
    opacity: 0.85;
    text-align: center;
}
.mp-chat-name {
    color: #bb88ff;
    font-weight: bold;
}
.mp-chat-text {
    color: #e8d9ff;
}

.mp-chat-form {
    display: flex;
    gap: 6px;
}

#mp-chat-input {
    flex: 1;
    padding: 6px 10px;
    background: rgba(10, 5, 20, 0.7);
    border: 1px solid #5a3a8a;
    color: #e8d9ff;
    font-family: inherit;
    font-size: 0.85rem;
    border-radius: 4px;
    box-sizing: border-box;
    min-width: 0;
}
#mp-chat-input:focus {
    outline: none;
    border-color: #bb88ff;
    box-shadow: 0 0 8px rgba(180, 120, 255, 0.4);
}

.mp-chat-send {
    padding: 6px 14px;
    background: linear-gradient(180deg, rgba(90, 45, 135, 0.9), rgba(60, 30, 90, 0.95));
    color: #e8d9ff;
    border: 1px solid #6644aa;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}
.mp-chat-send:hover {
    background: linear-gradient(180deg, rgba(120, 60, 180, 0.95), rgba(80, 40, 120, 1));
    border-color: #bb88ff;
}

/* ============================================
   Ping 顯示 (對戰右上角)
   ============================================ */
#mp-ping-display {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(10, 20, 30, 0.7);
    border: 1px solid rgba(100, 180, 130, 0.4);
    padding: 4px 10px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Cascadia Code', Consolas, 'Courier New', monospace;
    font-size: 0.82rem;
    letter-spacing: 0.05em;
    z-index: 15;
    pointer-events: none;
    color: #88ffaa;
    transition: color 0.3s ease, border-color 0.3s ease;
}

#mp-ping-display.ping-good    { color: #88ffaa; border-color: rgba(100, 200, 130, 0.5); }
#mp-ping-display.ping-mid     { color: #ffcc66; border-color: rgba(200, 180, 100, 0.5); }
#mp-ping-display.ping-bad     { color: #ff7777; border-color: rgba(220, 120, 130, 0.6); }

/* ============================================
   大亂鬥 HUD
   ============================================ */
#brawl-score {
    position: absolute;
    top: 90px;
    right: 12px;
    background: rgba(30, 10, 40, 0.82);
    border: 1px solid rgba(200, 140, 80, 0.5);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.88rem;
    color: #ffcc88;
    z-index: 15;
    pointer-events: none;
    min-width: 160px;
    max-width: 220px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
#brawl-score .brawl-header {
    font-size: 0.75rem;
    color: #ffaa66;
    border-bottom: 1px solid rgba(200, 140, 80, 0.3);
    padding-bottom: 4px;
    margin-bottom: 5px;
    text-align: center;
    letter-spacing: 0.05em;
}
#brawl-score .brawl-row {
    padding: 3px 4px;
    display: flex;
    justify-content: space-between;
    gap: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#brawl-score .brawl-row.self {
    background: rgba(255, 200, 100, 0.18);
    border-radius: 4px;
    color: #ffdd55;
    font-weight: 700;
}

#brawl-respawn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(60, 10, 20, 0.85);
    border: 2px solid rgba(255, 100, 120, 0.7);
    padding: 20px 40px;
    border-radius: 12px;
    font-size: 1.8rem;
    font-weight: bold;
    color: #ff8899;
    z-index: 20;
    pointer-events: none;
    text-align: center;
    animation: brawlRespawnPulse 0.5s ease-in-out infinite alternate;
}
@keyframes brawlRespawnPulse {
    from { transform: translate(-50%, -50%) scale(1); }
    to { transform: translate(-50%, -50%) scale(1.05); }
}

/* ============================================
   多人暫停選單
   ============================================ */
.mp-pause-note {
    color: #ffcc66;
    font-size: 0.85rem;
    margin-bottom: 18px;
    padding: 8px 12px;
    background: rgba(100, 60, 30, 0.3);
    border: 1px solid #88552a;
    border-radius: 4px;
    letter-spacing: 0.05em;
}

.menu-btn.mp-surrender-btn {
    color: #ff9999;
    border-color: #aa4466;
    text-shadow: 0 0 8px #ff4466;
    background: linear-gradient(180deg, rgba(120, 40, 60, 0.6), rgba(60, 20, 30, 0.8));
}

.menu-btn.mp-surrender-btn:hover {
    background: linear-gradient(180deg, rgba(180, 60, 90, 0.7), rgba(100, 30, 45, 0.9));
    border-color: #ff6688;
    box-shadow: 0 0 30px rgba(240, 80, 120, 0.6);
}

/* ============================================
   多人模式選擇
   ============================================ */
.mp-mode-grid {
    display: flex;
    gap: 24px;
    max-width: 720px;
    width: 92vw;
    margin-bottom: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

/* 單人子選單的按鈕欄 */
#sp-menu .menu-buttons {
    margin-top: 10px;
}

.mp-mode-card {
    flex: 1 1 280px;
    max-width: 340px;
    background: linear-gradient(180deg, rgba(40, 20, 70, 0.8), rgba(20, 10, 40, 0.95));
    border: 2px solid #5a3a8a;
    border-radius: 12px;
    padding: 30px 24px;
    cursor: pointer;
    transition: all 0.25s ease;
    color: #e8d9ff;
    font-family: inherit;
    font-size: 1rem;
    text-align: center;
    min-width: 240px;
    box-sizing: border-box;
    line-height: 1.3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.mp-mode-card:hover {
    transform: translateY(-3px);
    border-color: #bb88ff;
    box-shadow: 0 0 30px rgba(180, 120, 255, 0.5);
    background: linear-gradient(180deg, rgba(70, 35, 110, 0.9), rgba(30, 15, 50, 0.95));
}

.mp-mode-icon {
    font-size: 3rem;
    color: #ffcc66;
    text-shadow: 0 0 20px #cc8844;
    margin-bottom: 10px;
}

.mp-mode-name {
    font-size: 1.4rem;
    color: #d9b3ff;
    font-weight: bold;
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}

.mp-mode-desc {
    font-size: 0.88rem;
    color: #a088bb;
    line-height: 1.5;
}

/* 多人子選單下方的次要按鈕區塊 (練習 / 圖鑑 / 設定) */
.mp-sub-actions {
    flex-direction: row;
    gap: 14px;
    margin-top: 14px;
    justify-content: center;
    flex-wrap: wrap;
}
.mp-sub-actions .menu-btn {
    padding: 8px 22px;
    font-size: 0.95rem;
    min-width: 120px;
}

/* ============================================
   多人連線 Lobby & 房間
   ============================================ */
.mp-lobby-content {
    display: flex;
    align-items: stretch;
    gap: 40px;
    max-width: 900px;
    width: 90vw;
}

.mp-col {
    flex: 1;
    background: linear-gradient(180deg, rgba(40, 20, 70, 0.7), rgba(20, 10, 40, 0.85));
    border: 2px solid #5a3a8a;
    border-radius: 8px;
    padding: 30px 24px;
    text-align: center;
}

.mp-col h3 {
    color: #d9b3ff;
    margin-bottom: 12px;
    font-size: 1.3rem;
}

.mp-help {
    color: #a088bb;
    font-size: 0.9rem;
    margin-bottom: 18px;
    line-height: 1.5;
}

.mp-divider {
    display: flex;
    align-items: center;
    color: #5a3a8a;
    font-size: 1.2rem;
    font-weight: bold;
}

#mp-code-input {
    width: 100%;
    padding: 12px;
    background: #1a0a28;
    border: 2px solid #6644aa;
    color: #e8d9ff;
    font-family: 'SF Mono', 'Cascadia Code', Consolas, 'Courier New', monospace;
    font-size: 1.8rem;
    text-align: center;
    letter-spacing: 0.3em;
    border-radius: 4px;
    margin-bottom: 14px;
    text-transform: uppercase;
}

.mp-status {
    margin-top: 18px;
    padding: 10px 18px;
    background: rgba(40, 20, 70, 0.6);
    border-radius: 4px;
    color: #a088bb;
    font-size: 0.95rem;
}

.mp-status.mp-error {
    background: rgba(100, 20, 40, 0.6);
    color: #ff99aa;
}

/* 房間畫面 */
.mp-room-code {
    text-align: center;
    margin-bottom: 30px;
}

.mp-code-label {
    color: #a088bb;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.mp-code-big {
    font-family: 'SF Mono', 'Cascadia Code', Consolas, 'Courier New', monospace;
    font-size: 3.5rem;
    color: #ffe066;
    letter-spacing: 0.25em;
    font-weight: bold;
    text-shadow: 0 0 20px #cc8844, 0 0 40px #cc8844;
    background: rgba(20, 10, 40, 0.6);
    padding: 10px 40px;
    border: 2px dashed #8844cc;
    border-radius: 8px;
    display: inline-block;
    user-select: all;
    cursor: text;
}

.mp-code-hint {
    color: #a088bb;
    font-size: 0.85rem;
    margin-top: 8px;
}

.mp-room-players {
    display: flex;
    gap: 30px;
    align-items: center;
    margin-bottom: 25px;
}

#mp-room {
    justify-content: flex-start;
    padding-top: 30px;
    padding-bottom: 20px;
    overflow-y: auto;
}

/* 動態隊伍容器 (含藍/紅分欄) */
.mp-teams-container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    margin-bottom: 22px;
    max-width: 900px;
    width: 92vw;
    justify-content: center;
}

.mp-teams-container .mp-vs {
    align-self: center;
    margin-top: 30px;
}

.mp-team-col {
    flex: 1;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

.mp-team-label {
    font-size: 1.15rem;
    font-weight: bold;
    text-align: center;
    padding: 10px 0;
    border-radius: 6px;
    letter-spacing: 0.2em;
    position: relative;
    overflow: hidden;
}

.mp-team-label::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    animation: teamShimmer 3s linear infinite;
}

@keyframes teamShimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.mp-team-label.blue {
    background: linear-gradient(180deg, rgba(60, 100, 200, 0.45), rgba(30, 50, 140, 0.4));
    color: #cce7ff;
    border: 1.5px solid #5a9adf;
    text-shadow: 0 0 12px rgba(100, 170, 255, 0.8);
    box-shadow: 0 0 20px rgba(80, 140, 220, 0.35), inset 0 0 15px rgba(100, 170, 255, 0.2);
}

.mp-team-label.red {
    background: linear-gradient(180deg, rgba(200, 60, 80, 0.45), rgba(140, 30, 50, 0.4));
    color: #ffcccc;
    border: 1.5px solid #df5a7a;
    text-shadow: 0 0 12px rgba(255, 100, 120, 0.8);
    box-shadow: 0 0 20px rgba(220, 80, 100, 0.35), inset 0 0 15px rgba(255, 120, 140, 0.2);
}

/* VS 動畫 */
.mp-vs {
    position: relative;
    animation: vsPulse 2s ease-in-out infinite;
}

@keyframes vsPulse {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50%      { transform: scale(1.12); filter: brightness(1.4); }
}

.mp-team-slots {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mp-player-card {
    background: linear-gradient(180deg, rgba(40, 20, 70, 0.8), rgba(20, 10, 40, 0.9));
    border: 2px solid #5a3a8a;
    border-radius: 6px;
    padding: 10px 14px;
    position: relative;
    min-height: 56px;
}

.mp-player-card.self {
    border-color: #bb88ff;
    box-shadow: 0 0 15px rgba(180, 120, 255, 0.4);
}

.mp-player-card.empty {
    opacity: 0.55;
    border-style: dashed;
    animation: emptyPulse 2s ease-in-out infinite;
}

@keyframes emptyPulse {
    0%, 100% { opacity: 0.35; border-color: #443366; }
    50%      { opacity: 0.75; border-color: #8866cc; }
}

.mp-player-card.self {
    border-color: #bb88ff;
    box-shadow: 0 0 15px rgba(180, 120, 255, 0.4);
    animation: selfGlow 2.5s ease-in-out infinite alternate;
}

@keyframes selfGlow {
    from { box-shadow: 0 0 15px rgba(180, 120, 255, 0.4); }
    to   { box-shadow: 0 0 28px rgba(200, 140, 255, 0.7); }
}

.mp-card-slot {
    font-size: 0.7rem;
    color: #886699;
    font-weight: bold;
    letter-spacing: 0.1em;
}

.mp-card-name {
    font-size: 1.05rem;
    color: #e8d9ff;
    font-weight: bold;
    margin: 2px 0;
}

.mp-card-status {
    font-size: 0.78rem;
    color: #88ffaa;
}

.mp-player-card.empty .mp-card-status {
    color: #886699;
}

.mp-team-swap-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(80, 40, 120, 0.8);
    color: #e8d9ff;
    border: 1px solid #6644aa;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.7rem;
    cursor: pointer;
}

.mp-team-swap-btn:hover {
    background: rgba(120, 60, 180, 0.9);
    border-color: #bb88ff;
}

.mp-player-slot {
    padding: 16px 30px;
    background: linear-gradient(180deg, rgba(40, 20, 70, 0.7), rgba(20, 10, 40, 0.9));
    border: 2px solid #5a3a8a;
    border-radius: 8px;
    min-width: 200px;
    text-align: center;
}

.mp-slot-label {
    color: #d9b3ff;
    font-size: 1.1rem;
    font-weight: bold;
}

.mp-slot-status {
    color: #a088bb;
    font-size: 0.9rem;
    margin-top: 6px;
}

.mp-vs {
    color: #ffcc66;
    font-size: 2rem;
    font-weight: bold;
    text-shadow: 0 0 10px #cc8844;
}

.mp-config {
    background: rgba(40, 20, 70, 0.5);
    border: 1px solid #443366;
    border-radius: 8px;
    padding: 18px 24px;
    margin: 0 auto 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 440px;
    max-width: 92vw;
    box-sizing: border-box;
}

.mp-loadout-area {
    margin: 0 auto 16px;
    text-align: center;
}

.mp-config .setting-row {
    padding: 8px 12px;
}

#mp-host-config.hidden { display: none; }

.mp-banner {
    position: absolute;
    top: 42%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: bold;
    color: #ffe066;
    text-shadow: 0 0 25px #cc8844, 0 0 50px #cc8844, 0 4px 0 #000;
    letter-spacing: 0.12em;
    line-height: 1.3;
    z-index: 15;
    pointer-events: none;
    text-align: center;
    white-space: pre-line;
    animation: mpBannerPop 0.5s ease-out;
}

.mp-banner.hidden { display: none; }

@keyframes mpBannerPop {
    0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ============================================
   技能管理
   ============================================ */
#skills-screen {
    justify-content: flex-start;
    padding-top: 50px;
    padding-bottom: 30px;
    overflow-y: auto;
}

.skills-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.skills-pts {
    color: #ffcc66;
    font-size: 1.05rem;
    letter-spacing: 0.06em;
    text-shadow: 0 0 8px rgba(255, 200, 100, 0.4);
}

.menu-btn.small {
    padding: 8px 18px;
    font-size: 0.88rem;
    min-width: auto;
    margin: 0;
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 1100px;
    width: 94vw;
    padding: 6px;
}

.skill-card {
    background: linear-gradient(180deg, rgba(40, 20, 70, 0.8), rgba(20, 10, 40, 0.9));
    border: 2px solid #443366;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.skill-card.locked {
    opacity: 0.5;
}

.skill-card canvas {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    flex-shrink: 0;
}

.skill-info {
    flex: 1;
    min-width: 0;
}

.skill-name {
    font-size: 0.95rem;
    color: #e8d9ff;
    font-weight: bold;
}

.skill-locked {
    color: #886699;
    font-size: 0.75rem;
    font-weight: normal;
    margin-left: 6px;
}

.skill-stars {
    color: #ffcc66;
    font-size: 0.85rem;
    text-shadow: 0 0 6px rgba(255, 200, 100, 0.5);
}

.skill-desc {
    font-size: 0.72rem;
    color: #a088bb;
    margin-top: 2px;
    line-height: 1.3;
}

.skill-ctrl {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.skill-btn {
    width: 32px;
    height: 32px;
    background: linear-gradient(180deg, rgba(80, 40, 120, 0.7), rgba(40, 20, 80, 0.9));
    border: 1px solid #6644aa;
    color: #e8d9ff;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
}

.skill-btn:not(:disabled):hover {
    background: linear-gradient(180deg, rgba(120, 60, 180, 0.8), rgba(60, 30, 120, 0.95));
    border-color: #bb88ff;
}

.skill-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.skill-btn.plus {
    color: #66ffaa;
    border-color: #5aaa77;
}

.skill-btn.minus {
    color: #ff8888;
    border-color: #aa5a5a;
}

.skill-lvl {
    font-size: 0.8rem;
    color: #ccaaff;
    font-weight: bold;
}

/* ============================================
   圖鑑額外樣式
   ============================================ */
.codex-card.codex-locked {
    opacity: 0.55;
    filter: grayscale(0.4);
}

.codex-lock-tag {
    font-size: 0.7rem;
    color: #ff9988;
    font-weight: normal;
    margin-left: 6px;
}

.codex-stars {
    color: #ffcc66;
    font-size: 0.85rem;
    margin: 4px 0 2px;
    text-shadow: 0 0 6px rgba(255, 200, 100, 0.5);
}

/* ============================================
   出戰選擇 Loadout
   ============================================ */
#loadout-screen {
    justify-content: flex-start;
    padding-top: 40px;
    padding-bottom: 20px;
    overflow-y: auto;
}

.loadout-hint {
    color: #a088bb;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.loadout-slots {
    display: flex;
    gap: 12px;
    margin-bottom: 25px;
    padding: 12px;
    background: rgba(20, 10, 40, 0.5);
    border-radius: 8px;
    border: 1px solid #443366;
}

.loadout-slot {
    width: 96px;
    height: 96px;
    border: 2px dashed #5a3a8a;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: rgba(30, 15, 50, 0.4);
}

.loadout-slot.filled {
    border-style: solid;
    border-color: #bb88ff;
    background: linear-gradient(180deg, rgba(70, 35, 110, 0.5), rgba(30, 15, 50, 0.8));
    box-shadow: 0 0 20px rgba(180, 120, 255, 0.4);
}

.loadout-slot-idx {
    position: absolute;
    top: 3px;
    left: 6px;
    font-size: 0.7rem;
    color: #886699;
    font-weight: bold;
}

.loadout-slot-name {
    font-size: 0.75rem;
    color: #e8d9ff;
    margin-top: 2px;
}

.loadout-slot-empty {
    color: #5a3a8a;
    font-size: 1.2rem;
    letter-spacing: 0.2em;
}

.loadout-pool {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    max-width: 1100px;
    width: 92vw;
    margin-bottom: 20px;
}

.loadout-card {
    background: linear-gradient(180deg, rgba(40, 20, 70, 0.8), rgba(20, 10, 40, 0.9));
    border: 2px solid #443366;
    border-radius: 6px;
    padding: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.loadout-card:hover {
    transform: translateY(-2px);
    border-color: #bb88ff;
}

.loadout-card.equipped {
    border-color: #66ffaa;
    box-shadow: 0 0 20px rgba(100, 255, 180, 0.4);
    background: linear-gradient(180deg, rgba(40, 80, 50, 0.7), rgba(20, 40, 30, 0.9));
}

.loadout-card canvas {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    flex-shrink: 0;
}

.loadout-card-info {
    flex: 1;
    min-width: 0;
}

.loadout-card-name {
    font-size: 0.95rem;
    color: #e8d9ff;
    font-weight: bold;
}

.loadout-card-stars {
    color: #ffcc66;
    font-size: 0.8rem;
    text-shadow: 0 0 6px rgba(255, 200, 100, 0.5);
}

.loadout-card-stars.pvp-lvl {
    color: #88ccff;
    text-shadow: 0 0 6px rgba(100, 170, 255, 0.5);
    font-weight: bold;
}

.loadout-card-desc {
    font-size: 0.72rem;
    color: #a088bb;
    margin-top: 3px;
    line-height: 1.3;
}

.loadout-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.loadout-actions .back-btn {
    position: static;
}

/* ============================================
   商城
   ============================================ */
#shop-screen {
    justify-content: flex-start;
    padding-top: 60px;
    overflow-y: auto;
}

.shop-gold {
    font-size: 1.4rem;
    color: #ffcc66;
    text-shadow: 0 0 12px #cc8844;
    margin-bottom: 30px;
    letter-spacing: 0.1em;
}

#shop-sections {
    display: flex;
    flex-direction: column;
    gap: 30px;
    max-width: 1100px;
    width: 90vw;
}

.shop-section h3 {
    color: #d9b3ff;
    margin-bottom: 15px;
    font-size: 1.2rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #443366;
    padding-bottom: 6px;
}

.shop-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

/* 12 張符文時改 4 欄 */
#shop-spells.shop-grid {
    grid-template-columns: repeat(4, 1fr);
}

.shop-card {
    background: linear-gradient(180deg, rgba(40, 20, 70, 0.85), rgba(20, 10, 40, 0.95));
    border: 2px solid #5a3a8a;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.shop-card:hover:not(.owned):not(.locked) {
    transform: translateY(-2px);
    border-color: #bb88ff;
    box-shadow: 0 0 25px rgba(180, 120, 255, 0.5);
    background: linear-gradient(180deg, rgba(70, 35, 110, 0.9), rgba(30, 15, 50, 0.95));
}

.shop-card.owned {
    border-color: #66ffaa;
    opacity: 0.75;
    cursor: default;
}

.shop-card.locked {
    opacity: 0.45;
    cursor: not-allowed;
}

.shop-card canvas {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    flex-shrink: 0;
}

.shop-icon {
    font-size: 2.4rem;
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    flex-shrink: 0;
}

.shop-info {
    flex: 1;
    min-width: 0;
}

.shop-name {
    font-size: 1.05rem;
    color: #e8d9ff;
    font-weight: bold;
}

.shop-desc {
    font-size: 0.8rem;
    color: #a088bb;
    margin-top: 3px;
    line-height: 1.4;
}

.shop-level {
    font-size: 0.8rem;
    color: #ccaaff;
    margin-top: 3px;
}

.shop-price {
    font-size: 0.95rem;
    color: #ffcc66;
    font-weight: bold;
    margin-top: 5px;
    text-shadow: 0 0 6px rgba(255, 200, 100, 0.5);
}

.shop-card.owned .shop-price {
    color: #66ffaa;
}

/* ============================================
   HUD 金幣
   ============================================ */
#gold-display {
    margin-top: 5px;
    color: #ffcc66;
    text-shadow: 0 0 8px #cc8844;
    font-family: 'SF Mono', 'Cascadia Code', Consolas, 'Courier New', monospace;
}

/* ============================================
   升級 Modal
   ============================================ */
.upgrade-content {
    min-width: 720px;
    max-width: 90vw;
}

.upgrade-hint {
    color: #a088bb;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.upgrade-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.upgrade-card {
    background: linear-gradient(180deg, rgba(40, 20, 70, 0.8), rgba(20, 10, 40, 0.9));
    border: 2px solid #5a3a8a;
    border-radius: 8px;
    padding: 10px 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.upgrade-card:hover {
    transform: translateY(-3px) scale(1.03);
    border-color: #bb88ff;
    box-shadow: 0 0 25px rgba(180, 120, 255, 0.5);
    background: linear-gradient(180deg, rgba(70, 35, 110, 0.9), rgba(30, 15, 50, 0.95));
}

.upgrade-card.maxed {
    opacity: 0.45;
    cursor: default;
    border-color: #d9a845;
}

.upgrade-card.maxed:hover {
    transform: none;
    box-shadow: none;
}

.upgrade-card canvas {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
}

.upgrade-info {
    text-align: center;
    width: 100%;
}

.upgrade-name {
    font-size: 0.95rem;
    color: #e8d9ff;
    font-weight: bold;
    margin-top: 2px;
}

.upgrade-stars {
    font-size: 0.85rem;
    color: #ffcc66;
    letter-spacing: 0.05em;
    text-shadow: 0 0 8px rgba(255, 200, 100, 0.6);
}

.upgrade-next {
    font-size: 0.75rem;
    color: #a088bb;
}

/* ============================================
   操作提示 (左下角)
   ============================================ */
#controls-hint {
    bottom: 100px;
    left: 20px;
    font-size: 0.82rem;
    color: #a088bb;
    background: rgba(20, 10, 40, 0.6);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(100, 70, 160, 0.4);
    line-height: 1.6;
}

#controls-hint kbd {
    display: inline-block;
    padding: 1px 7px;
    background: #2a1540;
    border: 1px solid #6644aa;
    border-bottom-width: 2px;
    border-radius: 3px;
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', 'Courier New', monospace;
    color: #ddccff;
    font-size: 0.7rem;
    font-weight: bold;
    min-width: 14px;
    text-align: center;
    margin-right: 2px;
    line-height: 1.2;
}

/* ============================================
   練習模式增強
   ============================================ */
.practice-tip {
    margin-top: 8px;
    font-size: 0.75rem;
    color: #8866aa;
    font-style: italic;
    max-width: 260px;
    text-align: right;
}

#practice-controls {
    flex-wrap: wrap;
    max-width: 90vw;
    justify-content: center;
}

/* 5 關以上的 grid */
.level-grid {
    grid-template-columns: repeat(6, 1fr);
}

/* ============================================
   工具類
   ============================================ */
.hidden {
    display: none !important;
}

/* 小螢幕適配 */
@media (max-width: 1200px) {
    .title-magic, .title-rune { font-size: 4rem; }
    .codex-grid { grid-template-columns: repeat(2, 1fr); }
    .level-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 900px) {
    .codex-grid { grid-template-columns: 1fr; }
    .level-grid { grid-template-columns: repeat(3, 1fr); }
    .modal-content { min-width: 300px; padding: 30px; }
}
