/* ===== 基础样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-move: #4CAF50;
    --color-move-light: #81C784;
    --color-calc: #FF5722;
    --color-calc-light: #FF8A65;
    --color-jump: #FFC107;
    --color-jump-light: #FFD54F;
    --color-bg: #FFF8E1;
    --color-card-bg: #FFFFFF;
    --color-text: #3E2723;
    --color-border: #8D6E63;
    --shadow-soft: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-card: 0 6px 12px rgba(0,0,0,0.15);
    --shadow-pressed: 0 2px 4px rgba(0,0,0,0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

body {
    font-family: 'Nunito', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #FFF8E1 0%, #FFECB3 100%);
    min-height: 100vh;
    color: var(--color-text);
    overflow-x: hidden;
}

#app {
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100vh;
}

/* ===== 屏幕管理 ===== */
.screen {
    display: none;
    min-height: 100vh;
    padding: 16px;
}

.screen.active {
    display: block;
}

/* 关卡选择屏幕 - 与首页连续显示 */
#level-select-screen.active {
    display: block;
    min-height: auto;
    padding-top: 0;
}

/* 自由探索模式屏幕 - 与首页连续显示 */
#free-mode-screen.active {
    display: block;
    min-height: auto;
    padding-top: 0;
}

/* ===== 开始界面 ===== */
#start-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
}

.title-container {
    margin-bottom: 30px;
}

.game-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--color-text);
    text-shadow: 3px 3px 0 #FFCC80;
    margin-bottom: 10px;
    animation: bounce 2s ease infinite;
}

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

.subtitle {
    font-size: 1.2rem;
    color: #8D6E63;
    font-weight: 600;
}

.character-showcase {
    display: flex;
    gap: 30px;
    margin: 40px 0;
}

.character {
    font-size: 4rem;
    animation: float 3s ease-in-out infinite;
}

.character:nth-child(2) { animation-delay: 0.5s; }
.character:nth-child(3) { animation-delay: 1s; }

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-15px) rotate(5deg); }
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 280px;
}

/* ===== 按钮样式 ===== */
.btn {
    padding: 16px 32px;
    border: none;
    border-radius: var(--radius-xl);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-soft);
    font-family: inherit;
}

.btn:active {
    transform: translateY(2px);
    box-shadow: var(--shadow-pressed);
}

.btn-primary {
    background: linear-gradient(135deg, #FF8A65 0%, #FF5722 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #FF7043 0%, #F4511E 100%);
    transform: translateY(-2px);
}

.btn-secondary {
    background: linear-gradient(135deg, #81C784 0%, #4CAF50 100%);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #66BB6A 0%, #43A047 100%);
    transform: translateY(-2px);
}

/* 确认按钮 - 绿色 */
.btn-confirm {
    background: linear-gradient(135deg, #81C784 0%, #4CAF50 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-confirm:hover {
    background: linear-gradient(135deg, #66BB6A 0%, #43A047 100%);
    transform: translateY(-2px);
}

/* 取消按钮 - 红色 */
.btn-cancel {
    background: linear-gradient(135deg, #EF5350 0%, #C62828 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel:hover {
    background: linear-gradient(135deg, #E53935 0%, #B71C1C 100%);
    transform: translateY(-2px);
}

/* 下一关按钮 - 绿色 */
.btn-next-level {
    background: linear-gradient(135deg, #81C784 0%, #4CAF50 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-next-level:hover {
    background: linear-gradient(135deg, #66BB6A 0%, #43A047 100%);
    transform: translateY(-2px);
}

/* 重试按钮 - 蓝色 */
.btn-retry {
    background: linear-gradient(135deg, #42A5F5 0%, #1976D2 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-retry:hover {
    background: linear-gradient(135deg, #2196F3 0%, #1565C0 100%);
    transform: translateY(-2px);
}

.btn-back {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid var(--color-border);
    background: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-back:hover {
    background: #FFECB3;
    transform: scale(1.1);
}

.btn-help {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid var(--color-border);
    background: #FFECB3;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-help:hover {
    background: #FFE082;
    transform: scale(1.1);
}

.btn-execute {
    background: linear-gradient(135deg, #4CAF50 0%, #2E7D32 100%);
    color: white;
    padding: 12px 16px;
}

.btn-run-all {
    background: linear-gradient(135deg, #2196F3 0%, #0D47A1 100%);
    color: white;
    padding: 12px 16px;
}

.btn-clear {
    background: linear-gradient(135deg, #EF5350 0%, #C62828 100%);
    color: white;
    padding: 12px 20px;
}

.btn-reset {
    background: linear-gradient(135deg, #42A5F5 0%, #1565C0 100%);
    color: white;
    padding: 12px 20px;
}

.assembly-actions .btn-help {
    background: linear-gradient(135deg, #FFCA28 0%, #FF8F00 100%);
    color: white;
    padding: 12px 20px;
    width: auto;
    height: auto;
    border-radius: var(--radius-md);
    border: none;
    font-size: 0.9rem;
}

/* ===== 关卡选择界面 ===== */
.screen-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 10px 0;
}

.screen-header h2 {
    flex: 1;
    text-align: center;
    font-size: 1.5rem;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    padding: 10px;
}

.level-card {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #FFFFFF 0%, #FFF8E1 100%);
    border: 3px solid var(--color-border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    box-shadow: var(--shadow-soft);
}

.level-card:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: var(--shadow-card);
}

.level-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.level-card.completed {
    border-color: #4CAF50;
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
}

.level-number {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-text);
}

.level-name {
    font-size: 0.8rem;
    color: #666;
    text-align: center;
    padding: 0 4px;
    margin-top: 4px;
    line-height: 1.2;
    max-height: 1.2em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.level-stars {
    font-size: 0.9rem;
    margin-top: 5px;
}

/* ===== 游戏界面 ===== */
.game-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 2px dashed #D7CCC8;
    margin-bottom: 15px;
}

.level-info {
    flex: 1;
    text-align: center;
}

.level-info span {
    display: block;
}

#level-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-text);
}

#level-desc {
    font-size: 0.9rem;
    color: #8D6E63;
}

/* ===== 任务区域 ===== */
.mission-area {
    margin-bottom: 15px;
}

.mission-card {
    background: linear-gradient(135deg, #FFE0B2 0%, #FFCC80 100%);
    border: 3px solid #FF9800;
    border-radius: var(--radius-lg);
    padding: 15px;
    box-shadow: var(--shadow-soft);
    transition: all 0.3s ease;
}

.mission-card h3 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: #E65100;
}

.mission-card p {
    font-size: 0.95rem;
    color: var(--color-text);
}

/* 新关卡提示动画 */
@keyframes missionPulse {
    0% {
        border-color: #FF9800;
        box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.7);
        transform: scale(1);
    }
    25% {
        border-color: #FF5722;
        box-shadow: 0 0 20px 10px rgba(255, 87, 34, 0.5);
        transform: scale(1.02);
    }
    50% {
        border-color: #FF9800;
        box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.7);
        transform: scale(1);
    }
    75% {
        border-color: #FF5722;
        box-shadow: 0 0 20px 10px rgba(255, 87, 34, 0.5);
        transform: scale(1.02);
    }
    100% {
        border-color: #FF9800;
        box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.7);
        transform: scale(1);
    }
}

.mission-card.new-level {
    animation: missionPulse 1.5s ease-in-out;
}

/* ===== 可视化区域 ===== */
.visualization-area {
    background: linear-gradient(180deg, #E3F2FD 0%, #BBDEFB 100%);
    border: 3px solid #64B5F6;
    border-radius: var(--radius-lg);
    padding: 15px;
    margin-bottom: 15px;
    min-height: 180px;
}

.scene {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.zone-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #1565C0;
    margin-bottom: 8px;
    text-align: center;
}

/* 仓库（内存）- 绿色背景 */
.warehouse-zone {
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
    border: 2px solid #4CAF50;
    border-radius: var(--radius-md);
    padding: 10px;
}

.memory-slots, .register-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.memory-slot, .register-slot {
    width: 50px;
    height: 50px;
    background: white;
    border: 2px solid #8D6E63;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    position: relative;
    box-shadow: var(--shadow-soft);
}

.memory-slot .slot-label, .register-slot .slot-label {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 0.6rem;
    color: #8D6E63;
    font-weight: 700;
}

.memory-slot .slot-value, .register-slot .slot-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
}

.memory-slot.has-value {
    background: #E8F5E9;
    border-color: #4CAF50;
}

.register-slot.has-value {
    background: linear-gradient(135deg, #90CAF9 0%, #42A5F5 100%);
    border-color: #1565C0;
    color: white;
}

.register-slot.has-value .slot-label,
.register-slot.has-value .slot-value {
    color: white;
}

/* 零号寄存器 (x0/zero) 特殊样式 */
.register-slot.zero-reg {
    background: #E0E0E0;
    border-color: #9E9E9E;
    opacity: 0.8;
}

.register-slot.zero-reg .slot-label,
.register-slot.zero-reg .slot-value {
    color: #757575;
}

/* 路径区域 */
.path-zone {
    min-height: 60px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 动画元素 */
.anim-truck, .anim-wizard, .anim-arrow, .anim-data {
    font-size: 2rem;
    position: absolute;
    transition: all 0.5s ease;
    z-index: 100;
}

/* 数据移动动画 */
@keyframes moveFromTo {
    0% {
        transform: translate(var(--start-x), var(--start-y)) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(calc((var(--start-x) + var(--end-x)) / 2), calc(var(--start-y) - 30px)) scale(1.2);
        opacity: 1;
    }
    100% {
        transform: translate(var(--end-x), var(--end-y)) scale(1);
        opacity: 1;
    }
}

/* 魔法效果 */
@keyframes magicEffect {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    30% {
        transform: scale(1.5) rotate(180deg);
        opacity: 1;
    }
    60% {
        transform: scale(1.2) rotate(360deg);
        opacity: 1;
    }
    100% {
        transform: scale(0) rotate(540deg);
        opacity: 0;
    }
}

/* 闪光效果 */
@keyframes sparkle {
    0%, 100% {
        opacity: 0;
        transform: scale(0);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

.sparkle {
    position: absolute;
    font-size: 1.5rem;
    animation: sparkle 0.5s ease-in-out;
}

/* 数据包样式 */
.data-packet {
    position: absolute;
    background: linear-gradient(135deg, #FFD54F 0%, #FFC107 100%);
    border: 2px solid #FF8F00;
    border-radius: 8px;
    padding: 4px 8px;
    font-weight: bold;
    font-size: 0.9rem;
    color: #3E2723;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 100;
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 魔法阵样式 */
.magic-circle {
    position: absolute;
    width: 60px;
    height: 60px;
    border: 3px dashed #9C27B0;
    border-radius: 50%;
    animation: magicEffect 1s ease-in-out;
    pointer-events: none;
}

.magic-circle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 2px solid #E1BEE7;
    border-radius: 50%;
}

/* 跳跃箭头 */
.jump-arrow {
    position: absolute;
    font-size: 2.5rem;
    animation: bounce 0.5s ease infinite;
}

@keyframes pathGlow {
    0% {
        box-shadow: 0 0 5px #4CAF50;
    }
    50% {
        box-shadow: 0 0 20px #4CAF50, 0 0 40px #81C784;
    }
    100% {
        box-shadow: 0 0 5px #4CAF50;
    }
}

.path-active {
    animation: pathGlow 1s ease-in-out;
}

/* 货架（寄存器）- 蓝色背景，与卡牌一致 */
.shelf-zone {
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
    border: 2px solid #2196F3;
    border-radius: var(--radius-md);
    padding: 10px;
}

/* ===== 指令列表区 ===== */
.instruction-list-area {
    background: linear-gradient(135deg, #FFF8E1 0%, #FFECB3 100%);
    border: 3px solid #FFC107;
    border-radius: var(--radius-lg);
    padding: 12px;
    margin-bottom: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.list-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #F57C00;
    margin-bottom: 8px;
    text-align: center;
}

.instruction-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 2px solid #FFB74D;
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 0.85rem;
}

.instruction-item .instr-index {
    background: #FF9800;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.instruction-item .instr-text {
    flex: 1;
    color: var(--color-text);
    font-family: monospace;
}

.instruction-item .btn-remove {
    background: #EF5350;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.instruction-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border: 2px dashed #FFB74D;
    border-radius: var(--radius-sm);
    color: #FF9800;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.instruction-placeholder:hover {
    background: #FFF3E0;
    border-color: #FF9800;
}

/* 空列表提示 */
.instruction-empty-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    color: #999;
    font-size: 0.8rem;
    font-style: italic;
}

/* 列表头部 */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.optimal-hint {
    font-size: 0.75rem;
    color: #FF9800;
    font-weight: 600;
}

/* 编辑中的指令高亮 */
.instruction-item.editing {
    background: #E3F2FD;
    border-color: #2196F3;
    box-shadow: 0 0 8px rgba(33, 150, 243, 0.3);
}

.instruction-item.editing .instr-index {
    background: #2196F3;
    animation: pulse 1s ease-in-out infinite;
}

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

.btn-add-instr:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* 编辑按钮 */
.btn-edit {
    background: #42A5F5;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 4px;
}

.btn-edit:hover {
    background: #1976D2;
}

/* ===== 指令组装区 ===== */
.instruction-assembly {
    background: linear-gradient(135deg, #F3E5F5 0%, #E1BEE7 100%);
    border: 3px solid #9C27B0;
    border-radius: var(--radius-lg);
    padding: 15px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.assembly-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.assembly-title {
    font-size: 1rem;
    font-weight: 700;
    color: #7B1FA2;
}

/* 添加到列表按钮（放在模式切换下方） */
.btn-add-to-list-below {
    background: linear-gradient(135deg, #9C27B0 0%, #7B1FA2 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 12px;
    align-self: flex-end;
}

.btn-add-to-list-below:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(156, 39, 176, 0.4);
}

.btn-mode-toggle {
    background: white;
    border: 2px solid #9C27B0;
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-mode-toggle:hover {
    background: #F3E5F5;
}

/* 文本输入模式 */
.text-input-area {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.text-instruction-input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #BA68C8;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: monospace;
}

.text-instruction-input:focus {
    outline: none;
    border-color: #7B1FA2;
}

.btn-add-text {
    background: linear-gradient(135deg, #4CAF50 0%, #2E7D32 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    font-size: 0.9rem;
    cursor: pointer;
}

.text-hint {
    font-size: 0.75rem;
    color: #7B1FA2;
    text-align: center;
}

.assembly-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 15px;
}

.slot {
    width: 80px;
    height: 100px;
    background: rgba(255,255,255,0.8);
    border: 3px dashed #BA68C8;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.slot::before {
    content: attr(data-hint);
    font-size: 0.65rem;
    color: #9C27B0;
    position: absolute;
    top: 4px;
    pointer-events: none;
}

.slot.filled {
    background: white;
    border-style: solid;
    border-color: #7B1FA2;
}

.slot.filled .slot-content {
    font-size: 1.5rem;
}

.slot.filled .slot-name {
    font-size: 0.7rem;
    color: var(--color-text);
    margin-top: 2px;
}

.assembly-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ===== 卡片卡组 ===== */
.card-deck {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

.deck-tabs {
    display: flex;
    background: #F5F5F5;
}

.tab {
    flex: 1;
    padding: 12px 8px;
    border: none;
    background: transparent;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.tab.active {
    background: white;
    color: var(--color-text);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
}

.tab[data-tab="move"].active {
    color: var(--color-move);
    border-bottom: 3px solid var(--color-move);
}

.tab[data-tab="calc"].active {
    color: var(--color-calc);
    border-bottom: 3px solid var(--color-calc);
}

.tab[data-tab="calc_imm"].active {
    color: #FF9800;
    border-bottom: 3px solid #FF9800;
}

.tab[data-tab="jump"].active {
    color: var(--color-jump);
    border-bottom: 3px solid var(--color-jump);
}

.card-container {
    padding: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    min-height: 220px;
    max-height: 320px;
    overflow-y: auto;
}

/* ===== 卡片样式 ===== */
.card {
    width: 80px;
    height: 100px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-soft);
    position: relative;
    user-select: none;
}

.card:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: var(--shadow-card);
}

.card:active {
    transform: translateY(0) scale(0.95);
}

.card-move {
    background: linear-gradient(135deg, var(--color-move-light) 0%, var(--color-move) 100%);
    border: 3px solid #2E7D32;
}

.card-calc {
    background: linear-gradient(135deg, var(--color-calc-light) 0%, var(--color-calc) 100%);
    border: 3px solid #BF360C;
}

.card-calc_imm {
    background: linear-gradient(135deg, #FFB74D 0%, #FF9800 100%);
    border: 3px solid #E65100;
}

.card-jump {
    background: linear-gradient(135deg, var(--color-jump-light) 0%, var(--color-jump) 100%);
    border: 3px solid #F57F17;
}

.card-other {
    background: linear-gradient(135deg, #BDBDBD 0%, #9E9E9E 100%);
    border: 3px solid #616161;
}

.card-icon {
    font-size: 2rem;
    margin-bottom: 5px;
}

.card-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    text-align: center;
}

.card-type-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.6rem;
    background: rgba(255,255,255,0.9);
    padding: 2px 5px;
    border-radius: 10px;
    font-weight: 700;
}

.card-move .card-type-badge { color: var(--color-move); }
.card-calc .card-type-badge { color: var(--color-calc); }
.card-jump .card-type-badge { color: var(--color-jump); }

/* ===== 教程界面 ===== */
.tutorial-content {
    padding: 10px;
}

.tutorial-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: var(--shadow-soft);
}

.tutorial-section h3 {
    color: var(--color-text);
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.tutorial-section p, .tutorial-section li {
    color: #5D4037;
    line-height: 1.6;
    font-size: 0.95rem;
}

.tutorial-section ul {
    padding-left: 20px;
}

.tutorial-section li {
    margin-bottom: 8px;
}

.card-types {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card-type {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #F5F5F5;
    border-radius: var(--radius-md);
}

.type-icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.type-icon.move { background: var(--color-move-light); }
.type-icon.calc { background: var(--color-calc-light); }
.type-icon.jump { background: var(--color-jump-light); }

/* ===== 弹窗样式 ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    padding: 25px;
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.modal-content.victory {
    text-align: center;
    background: linear-gradient(135deg, #FFF8E1 0%, #FFECB3 100%);
    border: 4px solid #FFC107;
}

.close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #8D6E63;
}

.close:hover {
    color: var(--color-text);
}

.victory-emoji {
    font-size: 4rem;
    animation: bounce 1s ease infinite;
}

.victory h2 {
    color: var(--color-text);
    margin: 15px 0;
}

.score-info {
    background: rgba(255,255,255,0.8);
    border-radius: var(--radius-md);
    padding: 15px;
    margin: 15px 0;
}

.score-info p {
    margin: 8px 0;
    font-size: 1rem;
}

.victory-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

/* ===== 响应式设计 ===== */
@media (min-width: 768px) {
    .game-title {
        font-size: 3.5rem;
    }
    
    .character {
        font-size: 5rem;
    }
    
    .menu-buttons {
        flex-direction: row;
        justify-content: center;
        max-width: none;
    }
    
    .scene {
        flex-direction: row;
        align-items: center;
    }
    
    .warehouse-zone, .shelf-zone {
        flex: 1;
    }
    
    .path-zone {
        width: 100px;
        min-height: auto;
    }
    
    .assembly-slots {
        flex-wrap: nowrap;
    }
    
    .slot {
        width: 80px;
        height: 100px;
    }
    
    .card {
        width: 90px;
        height: 110px;
    }
}

@media (max-width: 380px) {
    .game-title {
        font-size: 2rem;
    }
    
    .character {
        font-size: 3rem;
    }
    
    .card {
        width: 70px;
        height: 90px;
    }
    
    .slot {
        width: 70px;
        height: 90px;
    }
}

/* ===== 动画效果 ===== */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.pulse {
    animation: pulse 1s ease infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.3s ease;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px rgba(255,193,7,0.5); }
    50% { box-shadow: 0 0 20px rgba(255,193,7,0.8); }
}

.glow {
    animation: glow 1s ease infinite;
}

/* 选中状态 */
.selected {
    box-shadow: 0 0 0 4px #FFC107, var(--shadow-card) !important;
}

/* ===== 分页显示样式 ===== */
/* 组装页面 - 压缩样式 */
.instruction-assembly.compact {
    padding: 10px;
    margin-bottom: 10px;
}

.instruction-assembly.compact .assembly-slots {
    margin-bottom: 10px;
}

.instruction-assembly.compact .slot {
    width: 80px;
    height: 100px;
}

.instruction-assembly.compact .slot::before {
    font-size: 0.55rem;
}

.instruction-assembly.compact .slot.filled .slot-content {
    font-size: 1.2rem;
}

.instruction-assembly.compact .assembly-actions {
    gap: 8px;
}

.instruction-assembly.compact .assembly-actions .btn {
    padding: 8px 12px;
    font-size: 0.8rem;
}

/* 运行页面样式 */
.visualization-area.large {
    min-height: 250px;
    padding: 20px;
}

.visualization-area.large .memory-slot,
.visualization-area.large .register-slot {
    width: 60px;
    height: 60px;
}

.current-instruction-area {
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
    border: 2px solid #4CAF50;
    border-radius: var(--radius-md);
    padding: 12px 15px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.current-instruction-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: #2E7D32;
    white-space: nowrap;
}

.current-instruction-text {
    flex: 1;
    font-family: monospace;
    font-size: 1rem;
    color: var(--color-text);
    background: white;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid #81C784;
}

.run-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.run-actions .btn {
    padding: 12px 20px;
    font-size: 0.9rem;
}

.btn-back-to-assembly {
    background: linear-gradient(135deg, #9C27B0 0%, #7B1FA2 100%);
    color: white;
}

/* 指令编码显示区 */
.instruction-encoding-area {
    background: linear-gradient(135deg, #ECEFF1 0%, #CFD8DC 100%);
    border: 2px solid #607D8B;
    border-radius: var(--radius-md);
    padding: 8px;
    margin-top: 8px;
}

.instruction-encoding-area.collapsed {
    padding: 6px 10px;
}

.encoding-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.encoding-header:hover {
    opacity: 0.8;
}

.encoding-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #455A64;
}

.encoding-toggle {
    font-size: 1rem;
    font-weight: 700;
    color: #607D8B;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 50%;
    border: 1px solid #607D8B;
    transition: all 0.2s;
}

.encoding-toggle:hover {
    background: #607D8B;
    color: white;
}

.encoding-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #B0BEC5;
    max-height: 150px;
    overflow-y: auto;
}

.encoding-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.encoding-item {
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-sm);
    padding: 6px;
    border: 1px solid #B0BEC5;
}

.encoding-item-header {
    font-size: 0.7rem;
    font-weight: 700;
    color: #455A64;
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px dashed #CFD8DC;
}

.encoding-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: monospace;
    font-size: 0.7rem;
    margin-bottom: 3px;
}

.encoding-row:last-child {
    margin-bottom: 0;
}

.encoding-label {
    color: #607D8B;
    font-weight: 600;
    min-width: 50px;
    font-size: 0.65rem;
}

.encoding-value {
    flex: 1;
    background: white;
    padding: 2px 5px;
    border-radius: var(--radius-sm);
    border: 1px solid #B0BEC5;
    color: var(--color-text);
    word-break: break-all;
    font-size: 0.65rem;
}

.encoding-empty {
    font-size: 0.7rem;
    color: #90A4AE;
    text-align: center;
    padding: 10px;
}

/* 指令卡片悬停提示 */
.card-tooltip {
    position: fixed;
    background: rgba(33, 33, 33, 0.95);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    z-index: 3000;
    max-width: 280px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    line-height: 1.5;
}

.card-tooltip.show {
    opacity: 1;
}

.card-tooltip .tooltip-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 6px;
    color: #FFD54F;
}

.card-tooltip .tooltip-syntax {
    background: rgba(255,255,255,0.1);
    padding: 6px 10px;
    border-radius: 4px;
    font-family: monospace;
    margin: 8px 0;
    color: #81D4FA;
}

.card-tooltip .tooltip-example {
    color: #A5D6A7;
    margin-top: 6px;
}

.card-tooltip .tooltip-desc {
    color: #E0E0E0;
    margin-bottom: 6px;
}

/* 导出功能区 */
.export-area {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #B0BEC5;
    align-items: center;
    justify-content: flex-end;
}

.export-select {
    padding: 6px 10px;
    border: 1px solid #B0BEC5;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    background: white;
    color: var(--color-text);
    cursor: pointer;
    outline: none;
}

.export-select:focus {
    border-color: #607D8B;
}

.btn-export {
    padding: 6px 12px;
    font-size: 0.8rem;
    background: linear-gradient(135deg, #4CAF50 0%, #388E3C 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-export:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* 底部链接 */
.game-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px;
    text-align: center;
    border-top: 1px solid #ddd;
    z-index: 100;
}

.footer-link {
    color: #1976D2;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    transition: all 0.2s;
}

.footer-link:hover {
    background: rgba(25, 118, 210, 0.1);
    color: #1565C0;
}

/* 为底部链接腾出空间 */
.screen {
    padding-bottom: 50px;
}

/* 自由探索模式样式 */
.import-area {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 15px;
    padding: 10px;
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
    border-radius: 12px;
    border: 2px solid #90CAF9;
}

.btn-import {
    background: linear-gradient(135deg, #4CAF50 0%, #388E3C 100%);
    color: white;
}

.btn-clear-all {
    background: linear-gradient(135deg, #F44336 0%, #D32F2F 100%);
    color: white;
}

/* ===== CPU 流水线可视化样式 ===== */

/* 流水线弹窗 */
.pipeline-modal .modal-content {
    max-width: 95%;
    width: 1200px;
    max-height: 90vh;
    overflow-y: auto;
}

.pipeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #E0E0E0;
}

.pipeline-header h3 {
    font-size: 1.3rem;
    color: #333;
    margin: 0;
}

.pipeline-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 流水线阶段 */
.pipeline-stages {
    display: flex;
    align-items: stretch;
    gap: 8px;
    padding: 15px;
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
    border-radius: 12px;
    overflow-x: auto;
}

.stage {
    flex: 1;
    min-width: 120px;
    background: white;
    border: 3px solid #ddd;
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
}

.stage.active {
    border-color: #4CAF50;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.3);
    transform: scale(1.02);
}

.stage.stalled {
    border-color: #FF5722;
    background: #FFEBEE;
    animation: stallPulse 1s ease-in-out infinite;
}

@keyframes stallPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

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

.stage-icon {
    font-size: 1.2rem;
}

.stage-name {
    font-size: 1rem;
    font-weight: 700;
    color: #333;
}

.stage-desc {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 10px;
}

.stage-content {
    width: 100%;
    min-height: 60px;
    background: #f9f9f9;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.stage-arrow {
    font-size: 1.5rem;
    color: #999;
    display: flex;
    align-items: center;
    font-weight: 700;
}

/* 流水线中的指令卡片 */
.pipeline-instr {
    background: linear-gradient(135deg, #42A5F5 0%, #1976D2 100%);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    animation: instrEnter 0.3s ease;
}

@keyframes instrEnter {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pipeline-instr.move {
    background: linear-gradient(135deg, #66BB6A 0%, #43A047 100%);
}

.pipeline-instr.calc {
    background: linear-gradient(135deg, #FF7043 0%, #E64A19 100%);
}

.pipeline-instr.jump {
    background: linear-gradient(135deg, #FFCA28 0%, #FFB300 100%);
    color: #333;
}

.pipeline-instr.output {
    background: linear-gradient(135deg, #AB47BC 0%, #8E24AA 100%);
}

/* 控制按钮 */
.pipeline-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-pipeline {
    padding: 10px 20px;
    font-size: 0.9rem;
    border-radius: 8px;
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-pipeline:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* 指令队列 */
.pipeline-instruction-queue {
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
    border: 2px solid #4CAF50;
    border-radius: 10px;
    padding: 15px;
}

.pipeline-instruction-queue h4 {
    margin: 0 0 10px 0;
    color: #2E7D32;
    font-size: 1rem;
}

.queue-content {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 40px;
}

.queue-item {
    background: white;
    border: 2px solid #4CAF50;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.8rem;
    font-family: monospace;
}

.queue-item.executed {
    opacity: 0.5;
    border-color: #999;
    background: #f5f5f5;
}

/* 数据冲突显示 */
.pipeline-hazards {
    background: linear-gradient(135deg, #FFEBEE 0%, #FFCDD2 100%);
    border: 2px solid #EF5350;
    border-radius: 10px;
    padding: 15px;
}

.pipeline-hazards h4 {
    margin: 0 0 10px 0;
    color: #C62828;
    font-size: 1rem;
}

.hazard-content {
    font-size: 0.9rem;
}

.no-hazard {
    color: #4CAF50;
    font-weight: 600;
}

.hazard-item {
    background: white;
    border-left: 4px solid #F44336;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 0 6px 6px 0;
}

.hazard-type {
    font-weight: 700;
    color: #D32F2F;
}

.hazard-detail {
    color: #666;
    font-size: 0.85rem;
    margin-top: 4px;
}

/* 时钟周期显示 */
.pipeline-clock {
    text-align: center;
    padding: 15px;
    background: linear-gradient(135deg, #FFF3E0 0%, #FFE0B2 100%);
    border: 2px solid #FF9800;
    border-radius: 10px;
}

.clock-label {
    font-size: 1rem;
    color: #E65100;
    font-weight: 600;
}

.clock-value {
    font-size: 2rem;
    font-weight: 700;
    color: #E65100;
    margin-left: 10px;
}

/* 前递路径显示 */
.forwarding-path {
    position: absolute;
    height: 3px;
    background: linear-gradient(90deg, #FF9800, #FFC107);
    border-radius: 2px;
    animation: forwardingFlow 0.5s ease;
}

@keyframes forwardingFlow {
    from {
        width: 0;
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.forwarding-label {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: #FF9800;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    white-space: nowrap;
}

/* 气泡（停顿）指示 */
.bubble-indicator {
    background: #FF5722;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    animation: bubblePop 0.3s ease;
}

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

/* 数据依赖箭头 */
.dependency-arrow {
    stroke: #FF5722;
    stroke-width: 2;
    fill: none;
    marker-end: url(#arrowhead);
    animation: dash 1s linear infinite;
}

@keyframes dash {
    to {
        stroke-dashoffset: -10;
    }
}

/* ===== 输出终端样式 ===== */

/* 输出终端 */
.output-terminal {
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    border: 2px solid #0f3460;
    border-radius: var(--radius-md);
    margin-top: 15px;
    overflow: hidden;
}

.terminal-header {
    background: linear-gradient(90deg, #0f3460 0%, #16213e 100%);
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #0f3460;
}

.terminal-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #00ff88;
}

.btn-clear-terminal {
    background: transparent;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-clear-terminal:hover {
    background: rgba(255, 255, 255, 0.1);
}

.terminal-content {
    padding: 12px;
    min-height: 60px;
    max-height: 120px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: #00ff88;
    line-height: 1.5;
}

.terminal-placeholder {
    color: #4a5568;
    font-style: italic;
}

.terminal-output-char {
    color: #00ff88;
}

.terminal-output-number {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
    padding: 0 4px;
    border-radius: 3px;
    margin: 0 2px;
}

.terminal-output-string {
    color: #ffd93d;
}

/* 输出指令卡片样式 */
.card-output {
    background: linear-gradient(135deg, #BA68C8 0%, #9C27B0 100%);
    border: 3px solid #7B1FA2;
}

.card-output .card-type-badge { 
    color: #9C27B0; 
}
