/* ========================================
   灵偶疗愈系统 v2.0 - 神秘灵性风格样式
   ======================================== */

/* CSS 变量系统 */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-glass: rgba(15, 15, 20, 0.85);

    --gold-primary: #d4a017;
    --gold-light: #f0c040;
    --gold-dark: #a07810;
    --gold-glow: rgba(212, 160, 23, 0.6);
    --gold-glow-strong: rgba(212, 160, 23, 0.9);

    --text-primary: rgba(255, 255, 255, 0.9);
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-muted: rgba(255, 255, 255, 0.4);

    --border-subtle: rgba(255, 255, 255, 0.1);
    --border-gold: rgba(212, 160, 23, 0.4);

    --shadow-gold: 0 0 20px rgba(212, 160, 23, 0.3);
    --shadow-deep: 0 10px 40px rgba(0, 0, 0, 0.8);

    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 20px;

    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* 全局重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    overflow: hidden;
    background-color: var(--bg-primary);
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* ========================================
   门禁系统样式
   ======================================== */
#access-gate {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, #0f0f18 0%, #050508 100%);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s;
}

.gate-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(2px 2px at 20px 30px, rgba(255,255,255,0.8), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255,255,255,0.6), transparent),
        radial-gradient(2px 2px at 130px 80px, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 160px 120px, rgba(255,255,255,0.7), transparent);
    background-repeat: repeat;
    background-size: 200px 150px;
    animation: twinkle 4s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.gate-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 40px;
}

.gate-title {
    font-size: 28px;
    margin-bottom: 10px;
    letter-spacing: 6px;
    font-weight: bold;
    color: var(--gold-primary);
    text-shadow: 0 0 20px var(--gold-glow), 0 0 40px var(--gold-glow);
    animation: glow-pulse 2s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% { text-shadow: 0 0 20px var(--gold-glow), 0 0 40px var(--gold-glow); }
    50% { text-shadow: 0 0 30px var(--gold-glow-strong), 0 0 60px var(--gold-glow-strong); }
}

.gate-subtitle {
    margin-bottom: 30px;
    font-size: 14px;
    opacity: 0.8;
    color: var(--text-secondary);
}

.gate-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: #fff;
    padding: 14px 20px;
    font-size: 16px;
    width: 240px;
    text-align: center;
    border-radius: var(--radius-md);
    outline: none;
    margin-bottom: 20px;
    letter-spacing: 4px;
    transition: all var(--transition-fast);
}

.gate-input:focus {
    border-color: var(--gold-primary);
    box-shadow: 0 0 20px var(--gold-glow);
    background: rgba(212, 160, 23, 0.05);
}

.gate-btn {
    background: linear-gradient(135deg, var(--gold-primary) 0%, var(--gold-dark) 100%);
    color: #000;
    border: none;
    padding: 14px 40px;
    font-size: 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: bold;
    letter-spacing: 2px;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-gold);
}

.gate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px var(--gold-glow);
}

.gate-btn:active {
    transform: scale(0.95);
}

.gate-footer {
    margin-top: 40px;
    font-size: 12px;
    line-height: 1.8;
    color: var(--text-muted);
}

.gate-footer a {
    display: block;
    margin-top: 10px;
    color: var(--text-muted);
    text-decoration: none;
}

.gate-error {
    color: #ff4444;
    margin-top: 15px;
    font-size: 14px;
    display: none;
}

/* ========================================
   主界面头部
   ======================================== */
#header {
    position: absolute;
    top: 10px;
    width: 100%;
    text-align: center;
    color: var(--text-primary);
    pointer-events: none;
    z-index: 10;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    opacity: 0;
    transition: opacity 1s;
}

.header-title {
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 2px;
    background: linear-gradient(90deg, var(--gold-primary), var(--gold-light), var(--gold-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-hint {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 4px;
}

.header-contact {
    color: var(--gold-primary);
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 1px;
    margin-top: 4px;
}

/* ========================================
   加载进度
   ======================================== */
#loader-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 30;
    pointer-events: none;
    transition: opacity 0.5s;
    display: none;
}

.loader-icon {
    font-size: 48px;
    animation: spin-glow 2s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin-glow {
    0% { transform: rotate(0deg); filter: drop-shadow(0 0 10px var(--gold-glow)); }
    50% { filter: drop-shadow(0 0 20px var(--gold-glow-strong)); }
    100% { transform: rotate(360deg); filter: drop-shadow(0 0 10px var(--gold-glow)); }
}

#loader-text {
    color: var(--gold-primary);
    font-size: 14px;
    margin-bottom: 12px;
    font-family: monospace;
    letter-spacing: 1px;
}

#progress-bar-bg {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
}

#progress-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--gold-dark), var(--gold-primary), var(--gold-light));
    border-radius: 2px;
    transition: width 0.2s;
    box-shadow: 0 0 10px var(--gold-glow);
}

/* ========================================
   右侧菜单面板
   ======================================== */
#ui-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 25;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s;
}

#menu-toggle {
    width: 36px;
    height: 36px;
    background: var(--bg-glass);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-md);
    color: var(--gold-primary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    transition: all var(--transition-fast);
    pointer-events: auto;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-gold);
}

#menu-toggle:active {
    transform: scale(0.9);
    background: rgba(212, 160, 23, 0.2);
}

#menu-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--bg-glass);
    padding: 8px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-gold);
    backdrop-filter: blur(12px);
    transition: all var(--transition-normal);
    transform-origin: top right;
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
    visibility: hidden;
    box-shadow: var(--shadow-deep), var(--shadow-gold);
}

#menu-items.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
    visibility: visible;
}

.hud-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100px;
    transition: all var(--transition-fast);
    user-select: none;
}

.hud-btn:hover {
    background: rgba(212, 160, 23, 0.1);
    border-color: var(--border-gold);
    color: var(--gold-primary);
}

.hud-btn:active {
    background: var(--gold-primary);
    color: #000;
}

.hud-btn span {
    font-size: 14px;
}

.hud-btn.active-state {
    border-color: var(--gold-primary);
    color: var(--gold-primary);
    background: rgba(212, 160, 23, 0.15);
    box-shadow: 0 0 10px var(--gold-glow);
}

.hud-btn.disabled {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(1);
    border-color: #333;
}

.hud-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-subtle), transparent);
    margin: 4px 0;
    width: 100%;
}

/* ========================================
   底部控制栏
   ======================================== */
#controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--bg-glass);
    border-top: 1px solid var(--border-gold);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 10px;
    padding-bottom: calc(12px + var(--safe-area-bottom));
    box-sizing: border-box;
    pointer-events: auto;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.9), 0 -5px 20px var(--gold-glow);
    transition: all var(--transition-normal);
    z-index: 20;
    transform: translateY(200px);
    backdrop-filter: blur(12px);
}

#controls.visible {
    transform: translateY(0);
}

.color-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    overflow-x: auto;
    padding: 4px;
    justify-content: center;
}

.color-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.active {
    border-color: #fff;
    transform: scale(1.2);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.5), 0 0 20px var(--gold-glow);
}

.piece-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    width: 100%;
    padding: 0 10px;
    align-items: center;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.piece-scroll::-webkit-scrollbar {
    display: none;
}

.piece-card {
    width: 52px;
    height: 52px;
    background: linear-gradient(145deg, rgba(30, 30, 40, 0.9), rgba(20, 20, 28, 0.9));
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.piece-card:hover {
    border-color: var(--gold-primary);
    box-shadow: 0 0 15px var(--gold-glow), 0 4px 15px rgba(0, 0, 0, 0.5);
    transform: translateY(-2px);
}

.piece-card:active {
    background: rgba(212, 160, 23, 0.2);
    border-color: var(--gold-primary);
    transform: scale(0.95);
}

.piece-emoji {
    font-size: 24px;
    margin-bottom: 0;
    pointer-events: none;
}

.piece-name {
    font-size: 9px;
    color: var(--text-muted);
    pointer-events: none;
    font-weight: bold;
    margin-top: 2px;
}

/* ========================================
   引导模式样式（分步选择）
   ======================================== */

/* 禁用状态 - 灵偶卡片 */
.piece-card.disabled {
    opacity: 0.35;
    pointer-events: none;
    filter: grayscale(0.7);
    cursor: not-allowed;
}

.piece-card.disabled:hover {
    border-color: var(--border-subtle);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transform: none;
}

/* 高亮状态 - 灵偶卡片（引导用户选择） */
.piece-card.highlight {
    animation: pulse-highlight 1.5s ease-in-out infinite;
    border-color: var(--gold-primary);
    box-shadow: 0 0 20px var(--gold-glow), 0 4px 15px rgba(0, 0, 0, 0.5);
}

/* 禁用状态 - 颜色按钮 */
.color-btn.disabled {
    opacity: 0.3;
    pointer-events: none;
    cursor: not-allowed;
    filter: grayscale(0.8);
}

.color-btn.disabled:hover {
    transform: none;
    box-shadow: none;
}

/* 高亮状态 - 颜色按钮（引导用户选择） */
.color-btn.highlight {
    animation: pulse-highlight 1.5s ease-in-out infinite;
    transform: scale(1.15);
    box-shadow: 0 0 15px currentColor;
}

@keyframes pulse-highlight {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* 整个区域的引导高亮 */
.piece-scroll.highlight-region {
    background: rgba(212, 160, 23, 0.1);
    border-radius: var(--radius-md);
    box-shadow: inset 0 0 20px var(--gold-glow);
}

.color-row.highlight-region {
    background: rgba(212, 160, 23, 0.1);
    border-radius: var(--radius-md);
    padding: 8px;
    margin: -8px;
    box-shadow: inset 0 0 20px var(--gold-glow);
}

/* ========================================
   AI 对话面板（底部抽屉）
   ======================================== */
#ai-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    pointer-events: none;
}

#ai-trigger {
    position: absolute;
    bottom: 130px;  /* 在 controls 上方，不遮挡灵偶选择 */
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--bg-glass), rgba(20, 20, 30, 0.95));
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-lg);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    pointer-events: auto;
    backdrop-filter: blur(12px);
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.6), 0 2px 15px var(--gold-glow);
    transition: all var(--transition-fast);
    z-index: 101;
}

#ai-trigger:hover {
    background: rgba(212, 160, 23, 0.15);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.7), 0 -4px 20px var(--gold-glow-strong);
}

.trigger-icon {
    font-size: 18px;
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { filter: drop-shadow(0 0 3px var(--gold-glow)); }
    50% { filter: drop-shadow(0 0 8px var(--gold-glow-strong)); }
}

.trigger-text {
    font-size: 13px;
    font-weight: bold;
    color: var(--gold-primary);
    letter-spacing: 1px;
}

.trigger-arrow {
    font-size: 10px;
    color: var(--gold-primary);
    transition: transform var(--transition-fast);
}

#ai-panel.expanded .trigger-arrow {
    transform: rotate(180deg);
}

#ai-drawer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60vh;
    max-height: 500px;
    background: linear-gradient(180deg, rgba(15, 15, 22, 0.98), rgba(10, 10, 15, 0.99));
    border-top: 1px solid var(--border-gold);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    backdrop-filter: blur(15px);
    box-shadow: 0 -10px 50px rgba(0, 0, 0, 0.8), 0 -5px 30px var(--gold-glow);
    transform: translateY(calc(100% - 50px));
    transition: transform var(--transition-normal);
    visibility: hidden;
}

#ai-panel.expanded #ai-drawer {
    transform: translateY(0);
    visibility: visible;
}

.ai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(212, 160, 23, 0.05);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.ai-title {
    font-size: 15px;
    font-weight: bold;
    color: var(--gold-primary);
    letter-spacing: 1px;
}

.ai-header-btns {
    display: flex;
    gap: 8px;
}

.ai-header-btn {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.ai-header-btn:hover {
    background: rgba(212, 160, 23, 0.2);
    border-color: var(--gold-primary);
    color: var(--gold-primary);
}

#ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.6;
    animation: message-in 0.3s ease;
}

@keyframes message-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold-primary));
    color: #000;
    border-bottom-right-radius: var(--radius-sm);
}

.ai-message.assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-bottom-left-radius: var(--radius-sm);
}

.ai-message.assistant::before {
    content: "🌟 ";
}

.ai-message.loading {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

.ai-message.loading::after {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 8px;
    border: 2px solid var(--gold-primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.ai-actions {
    display: flex;
    gap: 10px;
    padding: 10px 16px;
    border-top: 1px solid var(--border-subtle);
}

.ai-action-btn {
    flex: 1;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--gold-primary), var(--gold-dark));
    border: none;
    border-radius: var(--radius-md);
    color: #000;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 10px var(--gold-glow);
}

.ai-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px var(--gold-glow-strong);
}

.ai-action-btn:active {
    transform: scale(0.98);
}

.ai-action-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    box-shadow: none;
}

.ai-action-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: none;
}

.ai-input-area {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    padding-bottom: calc(12px + var(--safe-area-bottom));
    border-top: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.2);
}

#ai-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all var(--transition-fast);
}

#ai-input:focus {
    border-color: var(--gold-primary);
    box-shadow: 0 0 10px var(--gold-glow);
}

#ai-input::placeholder {
    color: var(--text-muted);
}

.ai-send-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--gold-primary), var(--gold-dark));
    border: none;
    border-radius: var(--radius-lg);
    color: #000;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 10px var(--gold-glow);
}

.ai-send-btn:hover {
    box-shadow: 0 4px 15px var(--gold-glow-strong);
}

.ai-send-btn:active {
    transform: scale(0.95);
}

/* ========================================
   API Key 配置弹窗
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(5px);
}

.modal.visible {
    display: flex;
}

.modal-content {
    background: var(--bg-glass);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-xl);
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-deep), var(--shadow-gold);
    backdrop-filter: blur(15px);
    animation: modal-in 0.3s ease;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-title {
    font-size: 20px;
    font-weight: bold;
    color: var(--gold-primary);
    margin-bottom: 15px;
}

.modal-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.modal-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    margin-bottom: 10px;
    transition: all var(--transition-fast);
}

.modal-input:focus {
    border-color: var(--gold-primary);
    box-shadow: 0 0 10px var(--gold-glow);
}

.modal-hint {
    color: var(--text-muted);
    font-size: 11px;
    margin-bottom: 20px;
}

.modal-btns {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-btn {
    padding: 12px 30px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-btn:not(.secondary) {
    background: linear-gradient(135deg, var(--gold-primary), var(--gold-dark));
    border: none;
    color: #000;
    box-shadow: 0 2px 10px var(--gold-glow);
}

.modal-btn:not(.secondary):hover {
    box-shadow: 0 4px 15px var(--gold-glow-strong);
}

.modal-btn.secondary {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.modal-btn.secondary:hover {
    border-color: var(--text-secondary);
}

/* ========================================
   响应式布局 - 横屏
   ======================================== */
@media (orientation: landscape) {
    #controls {
        width: 130px;
        height: 100%;
        top: 0;
        right: 0;
        left: auto;
        bottom: auto;
        border-top: none;
        border-left: 1px solid var(--border-gold);
        flex-direction: column-reverse;
        padding: 15px 10px;
        padding-bottom: 15px;
        justify-content: flex-start;
        transform: translateX(160px);
        box-shadow: -10px 0 40px rgba(0, 0, 0, 0.9), -5px 0 20px var(--gold-glow);
    }

    #controls.visible {
        transform: translateX(0);
    }

    .piece-scroll {
        flex-direction: column;
        width: 100%;
        height: auto;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 10px 0;
        gap: 8px;
    }

    .color-row {
        flex-wrap: wrap;
        width: 100%;
        justify-content: center;
        gap: 6px;
        margin-bottom: 15px;
    }

    #ui-panel {
        right: 150px;
    }

    /* 横屏时 AI 面板调整 */
    #ai-trigger {
        left: auto;
        right: 150px;
        bottom: 20px;  /* 横屏时放在侧边栏附近 */
        transform: none;
    }

    #ai-drawer {
        left: auto;
        width: 400px;
        max-width: 45vw;
    }
}

/* ========================================
   滚动条美化
   ======================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-gold);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gold-primary);
}

/* ========================================
   移动端优化
   ======================================== */
@media (max-width: 480px) {
    .gate-title {
        font-size: 22px;
        letter-spacing: 4px;
    }

    .header-title {
        font-size: 14px;
    }

    .piece-card {
        width: 48px;
        height: 48px;
    }

    .piece-emoji {
        font-size: 22px;
    }

    #ai-drawer {
        height: 55vh;
    }

    /* 手机端 AI 触发条位置调整 */
    #ai-trigger {
        bottom: 120px;
        padding: 8px 18px;
    }

    .trigger-text {
        font-size: 12px;
    }
}
