* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0a0a12;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'Press Start 2P', cursive;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
}

#canvas {
    image-rendering: pixelated;
    border: 4px solid #d4af37;
    border-radius: 8px;
    box-shadow: 
        0 0 20px rgba(212, 175, 55, 0.3),
        inset 0 0 60px rgba(0, 0, 0, 0.5);
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
}

#ui-overlay > * {
    pointer-events: auto;
}

#footer {
    color: #666;
    font-size: 10px;
    padding: 10px;
    font-family: sans-serif;
}

#footer a {
    color: #d4af37;
    text-decoration: none;
}

#footer a:hover {
    text-decoration: underline;
}

/* Title Screen */
.title-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 20px;
}

.title-glow {
    font-family: 'Cinzel', serif;
    font-size: clamp(24px, 6vw, 48px);
    color: #ff6b00;
    text-shadow: 
        0 0 10px #ff6b00,
        0 0 20px #ff4500,
        0 0 30px #ff0000,
        2px 2px 0 #8B0000;
    animation: flicker 2s infinite alternate;
    text-align: center;
}

@keyframes flicker {
    0%, 100% { opacity: 1; text-shadow: 0 0 10px #ff6b00, 0 0 20px #ff4500, 0 0 30px #ff0000; }
    50% { opacity: 0.9; text-shadow: 0 0 5px #ff6b00, 0 0 10px #ff4500, 0 0 15px #ff0000; }
}

.title-subtitle {
    color: #d4af37;
    font-size: clamp(10px, 2vw, 14px);
    letter-spacing: 2px;
}

.dragon-silhouette {
    width: 150px;
    height: 100px;
    background: linear-gradient(135deg, #3d0000 0%, #1a0000 100%);
    clip-path: polygon(50% 0%, 20% 60%, 0% 100%, 50% 80%, 100% 100%, 80% 60%);
    animation: float 3s ease-in-out infinite;
}

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

/* Buttons */
.game-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(10px, 2vw, 14px);
    padding: 15px 30px;
    background: linear-gradient(180deg, #4a3f6b 0%, #2d2844 100%);
    border: 3px solid #d4af37;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    text-shadow: 1px 1px 0 #000;
    min-width: 200px;
}

.game-btn:hover {
    background: linear-gradient(180deg, #5a4f7b 0%, #3d3854 100%);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
    transform: scale(1.05);
}

.game-btn.primary {
    background: linear-gradient(180deg, #8B0000 0%, #4a0000 100%);
}

.game-btn.primary:hover {
    background: linear-gradient(180deg, #a00000 0%, #5a0000 100%);
}

.sound-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 10px;
}

.sound-btn {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #d4af37;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.sound-btn:hover {
    background: rgba(212, 175, 55, 0.3);
}

/* Naming Screen */
.naming-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 20px;
}

.naming-title {
    color: #d4af37;
    font-size: clamp(14px, 3vw, 20px);
    text-shadow: 2px 2px 0 #000;
}

.name-input {
    font-family: 'Press Start 2P', cursive;
    font-size: 16px;
    padding: 15px 20px;
    background: #1a1a2e;
    border: 3px solid #d4af37;
    color: #fff;
    text-align: center;
    outline: none;
    width: 250px;
}

.name-input:focus {
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

/* Exploration UI */
.exploration-ui {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    padding: 10px;
}

.top-hud {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px;
    background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.6) 100%);
    border: 2px solid #d4af37;
    border-radius: 5px;
    flex-wrap: wrap;
}

.hero-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hero-portrait {
    width: 40px;
    height: 40px;
    background: url('/api/retrodiffusion/image/64/64/portrait?prompt=young+hero+warrior+portrait+pixel+art');
    background-size: cover;
    border: 2px solid #d4af37;
    border-radius: 50%;
}

.hero-stats {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.hero-name {
    color: #d4af37;
    font-size: 10px;
}

.stat-bar {
    position: relative;
    width: 100px;
    height: 12px;
    background: #1a1a2e;
    border: 1px solid #444;
    border-radius: 2px;
    overflow: hidden;
}

.stat-bar.small {
    width: 60px;
    height: 8px;
}

.stat-fill {
    height: 100%;
    transition: width 0.3s;
}

.hp-bar .stat-fill {
    background: linear-gradient(180deg, #ff4444 0%, #aa0000 100%);
}

.mp-bar .stat-fill {
    background: linear-gradient(180deg, #4444ff 0%, #0000aa 100%);
}

.stat-bar span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 6px;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
}

.gold-display, .location-display {
    color: #d4af37;
    font-size: 10px;
    padding: 5px 10px;
    background: rgba(0,0,0,0.5);
    border-radius: 3px;
}

.menu-btn {
    width: 35px;
    height: 35px;
    font-size: 18px;
    background: rgba(0,0,0,0.5);
    border: 2px solid #d4af37;
    color: #d4af37;
    cursor: pointer;
    border-radius: 5px;
    margin-left: auto;
}

.menu-btn:hover {
    background: rgba(212, 175, 55, 0.3);
}

.action-panel {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 15px;
    background: linear-gradient(0deg, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.7) 100%);
    border: 2px solid #d4af37;
    border-radius: 5px;
    justify-content: center;
}

.action-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    padding: 12px 20px;
    background: linear-gradient(180deg, #4a3f6b 0%, #2d2844 100%);
    border: 2px solid #d4af37;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: linear-gradient(180deg, #5a4f7b 0%, #3d3854 100%);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.action-btn.secondary {
    background: linear-gradient(180deg, #333 0%, #222 100%);
    border-color: #666;
}

.action-btn.danger {
    background: linear-gradient(180deg, #8B0000 0%, #4a0000 100%);
    border-color: #ff4444;
    animation: pulse 1s infinite;
}

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

/* Dialogue UI */
.dialogue-ui {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    padding: 10px;
}

.dialogue-box {
    margin-top: auto;
    padding: 20px;
    background: linear-gradient(180deg, rgba(0,0,0,0.95) 0%, rgba(20,20,40,0.95) 100%);
    border: 3px solid #d4af37;
    border-radius: 5px;
    min-height: 150px;
}

.dialogue-speaker {
    color: #d4af37;
    font-size: 12px;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #444;
}

.dialogue-text {
    color: #fff;
    font-size: 11px;
    line-height: 1.8;
}

.cursor {
    animation: blink 0.5s infinite;
}

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

.dialogue-choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.choice-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    padding: 10px 15px;
    background: linear-gradient(180deg, #4a3f6b 0%, #2d2844 100%);
    border: 2px solid #d4af37;
    color: #fff;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.choice-btn:hover {
    background: linear-gradient(180deg, #5a4f7b 0%, #3d3854 100%);
    padding-left: 25px;
}

.continue-hint {
    color: #888;
    font-size: 8px;
    margin-top: 15px;
    text-align: center;
    animation: blink 1s infinite;
}

/* Combat UI */
.combat-ui {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    padding: 10px;
}

.combat-enemy {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.combat-enemy.boss .enemy-sprite-container {
    transform: scale(1.5);
}

.enemy-sprite-container {
    transition: transform 0.1s;
}

.enemy-sprite-container.shake {
    animation: shake 0.2s ease-in-out;
}

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

.enemy-sprite {
    width: 80px;
    height: 80px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: pixelated;
}

.enemy-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
}

.enemy-name {
    color: #ff4444;
    font-size: 12px;
    text-shadow: 2px 2px 0 #000;
}

.enemy-hp {
    width: 150px;
}

.combat-log {
    background: rgba(0, 0, 0, 0.7);
    padding: 10px;
    border: 1px solid #444;
    color: #ccc;
    font-size: 8px;
    line-height: 1.6;
    max-height: 60px;
    overflow: hidden;
    margin: 10px 0;
}

.party-display {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 10px;
    flex-wrap: wrap;
}

.party-member {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #444;
    padding: 10px;
    border-radius: 5px;
    min-width: 80px;
    text-align: center;
}

.party-member.active {
    border-color: #d4af37;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.party-member.dead {
    opacity: 0.5;
    filter: grayscale(1);
}

.member-name {
    color: #fff;
    font-size: 8px;
    margin-bottom: 5px;
}

.combat-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #d4af37;
    flex-wrap: wrap;
}

.combat-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    padding: 12px 20px;
    border: 2px solid;
    cursor: pointer;
    transition: all 0.2s;
}

.combat-btn.attack {
    background: linear-gradient(180deg, #8B0000 0%, #4a0000 100%);
    border-color: #ff4444;
    color: #fff;
}

.combat-btn.magic {
    background: linear-gradient(180deg, #00008B 0%, #00004a 100%);
    border-color: #4444ff;
    color: #fff;
}

.combat-btn.items {
    background: linear-gradient(180deg, #006400 0%, #003200 100%);
    border-color: #44ff44;
    color: #fff;
}

.combat-btn.flee {
    background: linear-gradient(180deg, #333 0%, #222 100%);
    border-color: #888;
    color: #fff;
}

.combat-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.item-menu {
    position: absolute;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid #d4af37;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 200px;
}

.item-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 9px;
    padding: 10px;
    background: linear-gradient(180deg, #4a3f6b 0%, #2d2844 100%);
    border: 2px solid #d4af37;
    color: #fff;
    cursor: pointer;
}

.item-btn.cancel {
    background: linear-gradient(180deg, #333 0%, #222 100%);
    border-color: #666;
}

.item-btn:hover {
    background: linear-gradient(180deg, #5a4f7b 0%, #3d3854 100%);
}

.no-items {
    color: #888;
    font-size: 9px;
    text-align: center;
    padding: 10px;
}

/* Menu UI */
.menu-ui {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
}

.menu-panel {
    background: linear-gradient(180deg, #1a1a2e 0%, #0f0f1a 100%);
    border: 3px solid #d4af37;
    padding: 20px;
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
}

.menu-panel h2 {
    color: #d4af37;
    font-size: 16px;
    text-align: center;
    margin-bottom: 20px;
}

.menu-section {
    margin-bottom: 20px;
}

.menu-section h3 {
    color: #d4af37;
    font-size: 11px;
    margin-bottom: 10px;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
}

.party-stat {
    color: #fff;
    font-size: 8px;
    line-height: 1.8;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
    border: 1px solid #333;
}

.inventory-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.inv-item {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #444;
    padding: 8px;
    color: #fff;
    font-size: 8px;
}

.sound-settings {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sound-settings label {
    color: #fff;
    font-size: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sound-settings input[type="range"] {
    width: 100px;
}

/* Victory Screen */
.victory-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: linear-gradient(180deg, rgba(0,50,0,0.9) 0%, rgba(0,0,0,0.95) 100%);
    padding: 20px;
    text-align: center;
}

.victory-title {
    font-size: clamp(20px, 5vw, 36px);
    color: #d4af37;
    text-shadow: 0 0 20px #d4af37;
    animation: glow 1s infinite alternate;
}

@keyframes glow {
    from { text-shadow: 0 0 10px #d4af37; }
    to { text-shadow: 0 0 30px #d4af37, 0 0 40px #ff6b00; }
}

.victory-message {
    color: #fff;
    font-size: clamp(10px, 2vw, 14px);
    line-height: 2;
}

.survivors {
    color: #88ff88;
    font-size: 10px;
}

.perfect {
    color: #d4af37;
    font-size: 12px;
    padding: 15px;
    border: 2px solid #d4af37;
    background: rgba(212, 175, 55, 0.1);
}

.bittersweet {
    color: #888;
    font-size: 10px;
    font-style: italic;
}

/* Game Over Screen */
.gameover-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: linear-gradient(180deg, rgba(50,0,0,0.9) 0%, rgba(0,0,0,0.95) 100%);
    padding: 20px;
    text-align: center;
}

.gameover-title {
    font-size: clamp(24px, 6vw, 48px);
    color: #8B0000;
    text-shadow: 0 0 20px #ff0000;
}

.gameover-message {
    color: #888;
    font-size: clamp(10px, 2vw, 12px);
    line-height: 2;
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .top-hud {
        padding: 8px;
        gap: 8px;
    }
    
    .stat-bar {
        width: 70px;
    }
    
    .action-btn, .combat-btn {
        font-size: 8px;
        padding: 10px 12px;
    }
    
    .dialogue-text {
        font-size: 9px;
    }
    
    .party-display {
        gap: 8px;
    }
    
    .party-member {
        padding: 6px;
        min-width: 60px;
    }
    
    .combat-enemy.boss .enemy-sprite-container {
        transform: scale(1.2);
    }
}