* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #333;
    font-family: Arial, sans-serif;
}

#game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#game-container {
    position: relative;
    width: min(800px, 95vw);
    height: min(600px, calc(95vw * 0.75), calc(100vh - 60px));
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#game-canvas {
    width: 100%;
    height: 100%;
}

#game-canvas {
    display: block;
    background-color: #87CEEB;
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
    text-align: center;
    padding: 20px 0;
    overflow-y: auto;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
}

/* 遊戲logo */
.game-logo {
    margin-bottom: 10px;
}

.game-logo h1 {
    font-size: 40px;
    margin-bottom: 5px;
    color: #FFD700;
    text-shadow: 
        3px 3px 0 #000,
        -1px -1px 0 #FF4500,
        1px -1px 0 #FF4500,
        -1px 1px 0 #FF4500,
        1px 1px 0 #FF4500;
    letter-spacing: 2px;
}

.logo-underline {
    height: 5px;
    width: 300px;
    background: linear-gradient(90deg, transparent, #FFD700, transparent);
    margin: 0 auto;
}

/* 菜單内容 */
.menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 10px;
    width: 80%;
    max-height: none;
    overflow-y: visible;
}

/* 控制卡片 */
.control-card {
    background-color: rgba(0, 0, 0, 0.6);
    border: 2px solid #4169E1;
    border-radius: 10px;
    padding: 10px;
    width: 100%;
    margin-bottom: 10px;
}

.control-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.control-item {
    display: flex;
    align-items: center;
}

.key-icon {
    background-color: #333;
    border: 2px solid #FFD700;
    border-radius: 5px;
    padding: 5px 10px;
    margin-right: 10px;
    font-weight: bold;
    font-size: 14px;
    min-width: 60px;
    text-align: center;
}

/* 遊戲特性 */
.game-features {
    background-color: rgba(0, 0, 0, 0.6);
    border: 2px solid #FF1493;
    border-radius: 10px;
    padding: 10px;
    width: 100%;
    margin-bottom: 10px;
}

.game-features ul {
    list-style-type: none;
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.game-features li {
    position: relative;
    padding-left: 20px;
    text-align: left;
    font-size: 15px;
}

.game-features li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #00FF00;
    font-weight: bold;
}

/* 開始指示 */
.start-instruction {
    background-color: rgba(0, 0, 0, 0.6);
    border: 2px solid #00FF00;
    border-radius: 50px;
    padding: 10px 30px;
    margin-top: 20px;
    animation: pulse 1.5s infinite;
}

.start-instruction span {
    font-size: 20px;
    font-weight: bold;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* 成就菜單 */
.menu-achievements {
    background-color: rgba(0, 0, 0, 0.6);
    border: 2px solid #FFD700;
    border-radius: 10px;
    padding: 10px;
    width: 100%;
    margin-top: 10px;
}

h1 {
    font-size: 36px;
    margin-bottom: 15px;
    color: #FFD700;
    text-shadow: 3px 3px 0 #000;
}

h2 {
    font-size: 22px;
    margin-bottom: 5px;
    color: #FFD700;
    text-shadow: 2px 2px 0 #000;
}

p {
    font-size: 24px;
    margin-bottom: 20px;
    color: white;
    text-shadow: 2px 2px 0 #000;
}

/* 成就系統樣式 */
#achievements-list {
    list-style: none;
    text-align: left;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
}

#achievements-list li {
    padding: 5px;
    font-size: 14px;
    display: flex;
    align-items: center;
}

#achievements-list li::before {
    content: '🔒';
    margin-right: 5px;
    font-size: 12px;
}

#achievements-list li.unlocked::before {
    content: '🏆';
    font-size: 12px;
}

#achievements-list li.locked {
    color: #999;
    opacity: 0.8;
}

#achievements-list li.unlocked {
    color: #FFD700;
}

/* 關卡完成屏幕 */
#level-complete {
    justify-content: flex-start;
    padding-top: 50px;
}

#stats-container {
    margin: 20px 0;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.5);
    border: 2px solid #4169E1;
    border-radius: 10px;
    width: 80%;
}

#stats-container p {
    font-size: 20px;
    margin: 10px 0;
    text-align: left;
}

#new-achievements {
    margin: 20px 0;
    width: 80%;
}

#new-achievements-list {
    list-style: none;
    text-align: left;
    color: #FFD700;
}

#new-achievements-list li {
    padding: 8px 10px;
    font-size: 18px;
    margin-bottom: 5px;
    background-color: rgba(255, 215, 0, 0.2);
    border-radius: 5px;
    display: flex;
    align-items: center;
}

#new-achievements-list li::before {
    content: '🏆';
    margin-right: 10px;
}

/* 遊戲結束和暫停屏幕 */
#game-over, #pause-screen {
    justify-content: center;
}

/* 成就通知 */
#achievement-notification {
    position: absolute;
    top: 20px;
    right: -300px;
    width: 280px;
    background-color: rgba(0, 0, 0, 0.8);
    border-left: 4px solid #FFD700;
    border-radius: 5px;
    padding: 10px;
    display: flex;
    align-items: center;
    transition: right 0.5s;
    pointer-events: none;
}

#achievement-notification.show {
    right: 20px;
}

.achievement-icon {
    font-size: 32px;
    margin-right: 10px;
}

.achievement-text h3 {
    font-size: 18px;
    margin: 0;
    color: #FFD700;
}

.achievement-text p {
    font-size: 16px;
    margin: 5px 0 0;
}

/* 音效控制 */
#sound-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
}

#toggle-sound {
    background: none;
    border: none;
    font-size: 24px;
    color: white;
    cursor: pointer;
    background-color: rgba(0, 0, 0, 0.5);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    outline: none;
}

#toggle-sound:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

/* 螢幕尺寸適配 */
@media (min-height: 700px) {
    .screen {
        padding: 30px 0;
    }
    
    .game-logo h1 {
        font-size: 48px;
    }
    
    .game-logo {
        margin-bottom: 15px;
    }
    
    .menu-content {
        margin-bottom: 20px;
    }
    
    h1 {
        font-size: 42px;
        margin-bottom: 20px;
    }
    
    h2 {
        font-size: 24px;
        margin-bottom: 8px;
    }
    
    .control-card, .game-features, .menu-achievements {
        padding: 12px;
        margin-bottom: 15px;
    }
    
    .menu-achievements {
        margin-top: 15px;
    }
    
    .control-info {
        gap: 15px;
        margin-top: 12px;
    }
    
    .game-features ul {
        gap: 10px;
        margin-top: 12px;
    }
    
    .game-features li {
        font-size: 16px;
    }
    
    #achievements-list li {
        font-size: 15px;
        padding: 8px 5px;
    }
}

/* Footer */
.mario-footer {
    text-align: center;
    padding: 8px;
}

.mario-footer a {
    color: #87CEEB;
    text-decoration: none;
    font-size: 14px;
    padding: 6px 16px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    transition: all 0.3s;
}

.mario-footer a:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-2px);
}

/* 觸控控制 */
#touch-controls {
    display: none;
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    padding: 0 15px;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 20;
    pointer-events: none;
}

#touch-controls > * {
    pointer-events: auto;
}

.touch-dpad, .touch-actions {
    display: flex;
    gap: 10px;
}

.touch-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.6);
    background: rgba(0,0,0,0.4);
    color: white;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
}

.touch-btn:active {
    background: rgba(255,255,255,0.3);
    transform: scale(0.9);
}

.touch-jump {
    width: 70px;
    height: 70px;
    font-size: 28px;
    background: rgba(76, 175, 80, 0.4);
    border-color: rgba(76, 175, 80, 0.8);
}

.touch-start {
    width: auto;
    border-radius: 30px;
    padding: 0 20px;
    font-size: 16px;
    background: rgba(33, 150, 243, 0.4);
    border-color: rgba(33, 150, 243, 0.8);
}

@media (hover: none) and (pointer: coarse) {
    #touch-controls {
        display: flex;
    }
}

@media (max-width: 820px) {
    #game-container {
        width: 100vw;
        height: calc(100vw * 0.75);
        max-width: 800px;
        max-height: 600px;
    }
}