@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* Alagard - Retro Fantasy Font */
@font-face {
    font-family: 'Alagard';
    src: url('assets/fonts/alagard.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ========================================
   Ultima IV-V Theme Variables
   ======================================== */
:root {
    --ultima-blue: #0000AA;       /* Primary blue */
    --ultima-dark: #000055;       /* Dark blue */
    --ultima-bright: #5555FF;     /* Bright blue (highlights) */
    --ultima-gold: #AA5500;       /* Gold accents */
    --ultima-gold-bright: #FFAA00;/* Bright gold */
    --text-white: #FFFFFF;
    --text-gray: #AAAAAA;
    --text-dark: #555555;
    --bg-black: #000000;
    --danger-red: #AA0000;
    --danger-bright: #FF0000;
    --heal-green: #00AA00;
    --heal-bright: #00FF00;
    --warning-yellow: #AAAA00;
    --warning-bright: #FFFF00;
}

/* ========================================
   Custom Cursor with Glow Effect
   ======================================== */
#cursor-glow {
    position: fixed;
    width: 300px;
    height: 300px;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    background: radial-gradient(
        circle at center,
        rgba(218, 165, 32, 0.15) 0%,
        rgba(218, 165, 32, 0.08) 30%,
        rgba(218, 165, 32, 0.03) 60%,
        rgba(218, 165, 32, 0) 100%
    );
    border-radius: 50%;
}

/* Custom finger cursor */
* {
    cursor: pointer;
}

/* ========================================
   Base Styles
   ======================================== */
body {
    margin: 0;
    background: var(--bg-black);
    color: var(--text-white);
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 24px;
    overflow: hidden;
}

/* ========================================
   Game Container - Screenshot Design
   ======================================== */
#game-container {
    position: relative;
    width: 1054px;
    height: 634px;
    margin: 20px auto;
    background: var(--bg-black);
    border: none;
    outline: none;
}

/* Remove any blue borders from game elements */
#game-container *:not(.frame-outer-top):not(.frame-outer-bottom):not(.frame-outer-left):not(.frame-outer-right):not(.frame-inner-top):not(.frame-inner-bottom):not(.frame-inner-left):not(.frame-inner-right):not(.frame-divider) {
    border-color: transparent;
}

/* ========================================
   Frame Lines - Separate Divs mit Lücken
   ======================================== */

/* Äußerer Rahmen - heller (#666) - mit abgeschrägten Ecken (Spitzen nach außen) */
.frame-outer-top {
    position: absolute;
    top: 0;
    left: 4px;
    right: 4px;
    height: 4px;
    background: #666;
    z-index: 150;
    clip-path: polygon(0 0, 100% 0, calc(100% - 4px) 100%, 4px 100%);
}

.frame-outer-bottom {
    position: absolute;
    bottom: 0;
    left: 4px;
    right: 4px;
    height: 4px;
    background: #666;
    z-index: 150;
    clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 100%, 0 100%);
}

.frame-outer-left {
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 4px;
    background: #666;
    z-index: 150;
    clip-path: polygon(0 0, 100% 4px, 100% calc(100% - 4px), 0 100%);
}

.frame-outer-right {
    position: absolute;
    right: 0;
    top: 4px;
    bottom: 4px;
    width: 4px;
    background: #666;
    z-index: 150;
    clip-path: polygon(0 4px, 100% 0, 100% 100%, 0 calc(100% - 4px));
}

/* Innerer Rahmen - dunkler (#282828) - mit abgeschrägten Ecken (Spitzen nach außen) */
.frame-inner-top {
    position: absolute;
    top: 8px;
    left: 12px;
    right: 12px;
    height: 4px;
    background: #282828;
    z-index: 150;
    clip-path: polygon(0 0, 100% 0, calc(100% - 4px) 100%, 4px 100%);
}

.frame-inner-bottom {
    position: absolute;
    bottom: 8px;
    left: 12px;
    right: 12px;
    height: 4px;
    background: #282828;
    z-index: 150;
    clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 100%, 0 100%);
}

.frame-inner-left {
    position: absolute;
    left: 8px;
    top: 12px;
    bottom: 12px;
    width: 4px;
    background: #282828;
    z-index: 150;
    clip-path: polygon(0 0, 100% 4px, 100% calc(100% - 4px), 0 100%);
}

.frame-inner-right {
    position: absolute;
    right: 8px;
    top: 12px;
    bottom: 12px;
    width: 4px;
    background: #282828;
    z-index: 150;
    clip-path: polygon(0 4px, 100% 0, 100% 100%, 0 calc(100% - 4px));
}

/* Vertikale Trennlinien zwischen UI und Canvas */
.frame-divider {
    position: absolute;
    top: 8px;
    bottom: 8px;
    width: 4px;
    background: #282828;
    z-index: 150;
}

.frame-divider-1 {
    left: 330px;
}

.frame-divider-2 {
    left: 334px;
    border-left: solid 4px #000;
}

/* ========================================
   Top Bar Elements (separate layers)
   ======================================== */
.top-bar-title {
    position: absolute;
    top: -10px;
    left: 66%;
    transform: translateX(-50%);
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 32px;
    color: #DAA520;
    text-shadow: 1px 1px 0 #353535;
    background: #000;
    padding: 0px 10px;
    z-index: 200;
}

/* ========================================
   Sky Clock - Time Display
   ======================================== */
.sky-clock {
    position: absolute;
    top: 30px;
    right: 30px;
    width: 50px;
    height: 90px;
    z-index: 200;
}

/* Day display above the clock */
.sky-clock .sky-day {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    color: #DAA520;
    font-size: 14px;
    font-family: 'Alagard', 'Press Start 2P', monospace;
    white-space: nowrap;
    text-shadow: 1px 1px 0 #353535;
    line-height: 12px;
    z-index: 201;
}

/* Sky window - contains stars and disc, clips everything */
.sky-clock .sky-window {
    position: absolute;
    top: 15px;
    left: 0;
    width: 50px;
    height: 50px;
    overflow: hidden;
    z-index: 12;
    border: 3px solid #666 !important;
    box-sizing: border-box;
}

/* Sky background with stars */
.sky-clock .sky-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg,
        #0a0a18 0%,
        #12122a 50%,
        #0a0a18 100%
    );
    z-index: 1;
}

/* Twinkling stars */
.sky-clock .star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: #fff;
    border-radius: 50%;
    animation: starTwinkle 2s ease-in-out infinite;
}

.sky-clock .star:nth-child(1) { animation: starTwinkle 1.8s ease-in-out infinite; animation-delay: 0.0s; }
.sky-clock .star:nth-child(2) { animation: starTwinkle 2.5s ease-in-out infinite; animation-delay: 0.4s; }
.sky-clock .star:nth-child(3) { animation: starTwinkle 1.5s ease-in-out infinite; animation-delay: 0.2s; }
.sky-clock .star:nth-child(4) { animation: starTwinkle 3.0s ease-in-out infinite; animation-delay: 0.7s; }
.sky-clock .star:nth-child(5) { animation: starTwinkle 2.2s ease-in-out infinite; animation-delay: 1.0s; }
.sky-clock .star:nth-child(6) { animation: starTwinkle 1.7s ease-in-out infinite; animation-delay: 0.3s; }
.sky-clock .star:nth-child(7) { animation: starTwinkle 2.8s ease-in-out infinite; animation-delay: 0.5s; }
.sky-clock .star:nth-child(8) { animation: starTwinkle 2.0s ease-in-out infinite; animation-delay: 0.9s; }

@keyframes starTwinkle {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.5); }
}

/* Rotating disc - center at bottom of window */
.sky-clock .sky-disc {
    position: absolute;
    width: 80px;
    height: 80px;
    left: 25px;
    top: 50px;
    transform: translate(-50%, -50%) rotate(0deg);
    transition: transform 0.5s ease-out;
    z-index: 5;
    pointer-events: none;
}

/* Sun - icon positioned at top of disc (12 o'clock) */
.sky-clock .celestial.sun {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 26px;
    color: #FFD700;
    text-shadow: 0 0 8px #FFD700, 0 0 15px #FFA500;
    z-index: 10;
}

/* Moon - icon positioned at bottom of disc (6 o'clock) */
.sky-clock .celestial.moon {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 20px;
    color: #E8E8F0;
    text-shadow: 0 0 8px #AAAACC, 0 0 15px #8888AA;
    z-index: 10;
}

/* Time display below the clock */
.sky-clock .sky-time {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 14px;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
    z-index: 15;
    border: 1px solid #666;
    padding: 2px 6px;
    background: #000;
    min-width: 50px;
    text-align: center;
    box-sizing: border-box;
}

/* Frame - outer */
.sky-clock .sky-frame-outer {
    position: absolute;
    top: 0;
    left: 0;
    width: 80px;
    height: 80px;
    border: 4px solid #666;
    box-sizing: border-box;
    pointer-events: none;
    z-index: 10;
}

/* Frame - inner */
.sky-clock .sky-frame-inner {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 72px;
    height: 72px;
    border: 3px solid #282828;
    box-sizing: border-box;
    pointer-events: none;
    z-index: 11;
}

/* Day/Night sky color transitions */
.sky-clock.sky-day .sky-stars {
    background: linear-gradient(180deg,
        #4A90D9 0%,
        #87CEEB 50%,
        #B0E0E6 100%
    );
}

.sky-clock.sky-dawn .sky-stars {
    background: linear-gradient(180deg,
        #2a1a40 0%,
        #6B4080 30%,
        #FF8866 70%,
        #FFCC66 100%
    );
}

.sky-clock.sky-dusk .sky-stars {
    background: linear-gradient(180deg,
        #1a1030 0%,
        #5B2060 30%,
        #DD6644 70%,
        #FF8844 100%
    );
}

.sky-clock.sky-night .sky-stars {
    background: linear-gradient(180deg,
        #0a0a18 0%,
        #12122a 50%,
        #0a0a18 100%
    );
}

/* Hide stars during day */
.sky-clock.sky-day .star,
.sky-clock.sky-dawn .star {
    opacity: 0 !important;
}

.sky-clock.sky-dusk .star {
    opacity: 0.4 !important;
}

/* ========================================
   Main Game Area (Left Panel + Canvas)
   ======================================== */
#game-main {
    display: flex;
    height: calc(100% - 25px);
    border: none !important;
    outline: none !important;
    width: calc(100% - 10px);
}

/* ========================================
   UI Panel (Left Side)
   ======================================== */
#ui {
    width: 340px;
    display: flex;
    flex-direction: column;
    padding: 12px 15px 8px 15px;
    box-sizing: border-box;
    height: 100%;
    overflow: hidden;
}

#map-title {
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 24px;
    color: #DAA520;
    text-shadow: 1px 1px 0 #353535;
    padding: 4px 8px;
    min-height: 50px;
    flex-shrink: 0;
}

#map-title-divider {
    height: 3px;
    background: #282828;
    margin: 4px 8px 8px 8px;
    flex-shrink: 0;
}

/* Log Area */
#log {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 6px 8px;
    font-size: 16px;
    line-height: 1.6;
    color: #ccc;
    min-height: 120px;
}

#log .log-timestamp {
    color: #DAA520;
    font-weight: normal;
    display: block;
}

#log .log-message {
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 16px;
    color: #ccc;
    display: block;
    margin-bottom: 8px;
    line-height: 1.4;
}

#log .log-prompt {
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 16px;
    color: #22d3ee;
    display: block;
    line-height: 1.4;
    margin-top: 4px;
}

#log .log-cursor.barber-pole {
    display: inline-block;
    width: 8px;
    height: 16px;
    vertical-align: middle;
    background: repeating-linear-gradient(
        -45deg,
        #ffffff 0px,
        #ffffff 2px,
        #000000 2px,
        #000000 4px
    );
    background-size: 5.66px 5.66px;
    animation: barber-spin 0.3s linear infinite;
}

@keyframes barber-spin {
    from { background-position: 0 0; }
    to { background-position: 0 5.66px; }
}

#log .npc-name {
    color: #4ade80;
    font-weight: bold;
}

#log .cyan-text {
    color: #22d3ee;
}

/* Font toggle for dev mode */
#log.font-2p .log-timestamp,
#log.font-2p .log-message {
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
}

/* Debug Panel Font Switch */
.debug-toggle {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 6px;
}

.font-switch {
    display: flex;
    align-items: center;
    gap: 8px;
}

.font-label {
    font-size: 12px;
    color: #666;
    transition: color 0.2s;
}

.font-label.active {
    color: #DAA520;
}

/* Toggle Switch Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333;
    border: 1px solid #555;
    transition: 0.3s;
}

.switch .slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: #DAA520;
    transition: 0.3s;
}

.switch input:checked + .slider {
    background-color: #444;
}

.switch input:checked + .slider:before {
    transform: translateX(20px);
}

/* Log scrollbar */
#log::-webkit-scrollbar {
    width: 6px;
}

#log::-webkit-scrollbar-track {
    background: #111;
}

#log::-webkit-scrollbar-thumb {
    background: #444;
}

#log::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* Player Stats Section */
#stats-divider {
    height: 3px;
    background: #282828;
    margin: 8px;
    flex-shrink: 0;
}

#player-stats {
    padding: 4px 8px;
    font-family: 'Alagard', 'Press Start 2P', monospace;
    font-size: 15px;
    flex-shrink: 0;
}

#player-stats .stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
    line-height: 1.2;
}

#player-stats .stat-label {
    color: #DAA520;
    text-shadow: 1px 1px 0 #353535;
}

#player-stats .stat-value {
    color: #ccc;
    text-shadow: 1px 1px 0 #353535;
    min-width: 50px;
    text-align: right;
}

/* Level display - golden highlight */
#player-stats .stat-value.stat-level {
    color: #FFAA00;
    font-weight: bold;
}

/* Controls Section */
#controls-divider {
    height: 3px;
    background: #282828;
    margin: 8px;
    flex-shrink: 0;
}

#controls {
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 14px;
    color: #ccc;
    padding: 4px 8px;
    flex-shrink: 0;
}

.control-row {
    margin-bottom: 0;
    line-height: 1.5;
}

.control-row .key {
    color: #DAA520;
    margin-right: 3px;
}

.control-row-save {
    margin-top: 4px;
    padding-top: 4px;
}

/* Hidden stats container for JS */
#stats {
    display: none;
}

/* Music Volume (hidden) */
.volume-container {
    display: none;
}

/* ========================================
   Canvas
   ======================================== */
#game-container canvas,
#game-container canvas:focus,
#game-container canvas:active {
    width: 704px;
    height: 608px;
    flex: none;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    image-rendering: -moz-crisp-edges;
    cursor: crosshair;
    background: var(--bg-black);
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    position: relative;
    top: 15px;
}

/* Standalone canvas (for loading screens etc) */
canvas:not(#game-container canvas) {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    image-rendering: -moz-crisp-edges;
}

/* ========================================
   Death Screen
   ======================================== */
#death-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(85, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.death-content {
    text-align: center;
    animation: slideDown 0.8s ease-out;
}

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

.death-title {
    font-size: 72px;
    color: var(--danger-bright);
    text-shadow: 4px 4px 0px var(--bg-black), 0 0 20px var(--danger-bright);
    margin: 0 0 20px;
    animation: pulse 2s infinite;
}

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

.death-message {
    font-size: 28px;
    color: var(--text-white);
    margin: 0 0 40px;
    text-shadow: 2px 2px 0px var(--bg-black);
}

.retry-btn {
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 32px;
    padding: 15px 40px;
    background: var(--danger-red);
    color: var(--text-white);
    border: 4px solid var(--bg-black);
    cursor: pointer;
    text-shadow: 2px 2px 0px var(--bg-black);
    box-shadow: 4px 4px 0px var(--bg-black);
    transition: all 0.2s;
}

.retry-btn:hover {
    background: var(--danger-bright);
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px var(--bg-black);
}

.retry-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px var(--bg-black);
}

/* ========================================
   Window Manager - Unified Window System
   Uses same frame design as game container
   ======================================== */

/* Container for all windows - inside game container */
#window-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2000;
}

/* Window Overlay (backdrop) - covers game container */
.game-window-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 60px;
    pointer-events: auto;
    transition: background 0.2s ease;
}

.game-window-overlay.visible {
    background: rgba(0, 0, 0, 0.85);
}

/* Base Window - with double frame like game container */
.game-window {
    position: relative;
    background: #000;
    min-width: 300px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.8) translateY(-20px);
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                opacity 0.2s ease;
    /* Space for frames: outer 4px + gap 4px + inner 4px = 12px each side */
    padding: 12px;
}

.game-window.visible {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.game-window.closing {
    transform: scale(0.9) translateY(-10px);
    opacity: 0;
}

/* Window Outer Frame - heller (#666) */
.game-window-frame-outer-top,
.game-window-frame-outer-bottom,
.game-window-frame-outer-left,
.game-window-frame-outer-right {
    position: absolute;
    background: #666;
    z-index: 10;
}

.game-window-frame-outer-top {
    top: 0;
    left: 4px;
    right: 4px;
    height: 4px;
    clip-path: polygon(0 0, 100% 0, calc(100% - 4px) 100%, 4px 100%);
}

.game-window-frame-outer-bottom {
    bottom: 0;
    left: 4px;
    right: 4px;
    height: 4px;
    clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 100%, 0 100%);
}

.game-window-frame-outer-left {
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 4px;
    clip-path: polygon(0 0, 100% 4px, 100% calc(100% - 4px), 0 100%);
}

.game-window-frame-outer-right {
    right: 0;
    top: 4px;
    bottom: 4px;
    width: 4px;
    clip-path: polygon(0 4px, 100% 0, 100% 100%, 0 calc(100% - 4px));
}

/* Window Inner Frame - dunkler (#282828) */
.game-window-frame-inner-top,
.game-window-frame-inner-bottom,
.game-window-frame-inner-left,
.game-window-frame-inner-right {
    position: absolute;
    background: #282828;
    z-index: 10;
}

.game-window-frame-inner-top {
    top: 8px;
    left: 12px;
    right: 12px;
    height: 4px;
    clip-path: polygon(0 0, 100% 0, calc(100% - 4px) 100%, 4px 100%);
}

.game-window-frame-inner-bottom {
    bottom: 8px;
    left: 12px;
    right: 12px;
    height: 4px;
    clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 100%, 0 100%);
}

.game-window-frame-inner-left {
    left: 8px;
    top: 12px;
    bottom: 12px;
    width: 4px;
    clip-path: polygon(0 0, 100% 4px, 100% calc(100% - 4px), 0 100%);
}

.game-window-frame-inner-right {
    right: 8px;
    top: 12px;
    bottom: 12px;
    width: 4px;
    clip-path: polygon(0 4px, 100% 0, 100% 100%, 0 calc(100% - 4px));
}

/* Window Inner Container (inside frames) */
.game-window-inner {
    display: flex;
    flex-direction: column;
    background: #0a0a0a;
    flex: 1;
    overflow: hidden;
}

/* Window Header */
.game-window-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #1a1a1a;
    border-bottom: 2px solid #282828;
}

.game-window-header-gold {
    background: linear-gradient(180deg, #3a2a00 0%, #1a1500 100%);
    border-bottom-color: #AA5500;
}

.game-window-header-danger {
    background: linear-gradient(180deg, #3a0000 0%, #1a0000 100%);
    border-bottom-color: #880000;
}

.game-window-header-info {
    background: linear-gradient(180deg, #003333 0%, #001a1a 100%);
    border-bottom-color: #006666;
}

.game-window-title {
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 18px;
    color: #ccc;
    text-shadow: 1px 1px 0 #000;
    letter-spacing: 1px;
}

.game-window-header-gold .game-window-title {
    color: #DAA520;
}

.game-window-header-danger .game-window-title {
    color: #ff6666;
}

.game-window-header-info .game-window-title {
    color: #00AAAA;
}

.game-window-close {
    font-size: 24px;
    color: #666;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
    padding: 0 5px;
}

.game-window-close:hover {
    color: #fff;
}

/* Window Content */
.game-window-content {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 14px;
    color: #ccc;
    line-height: 1.5;
}

.game-window-message {
    text-align: center;
    margin: 10px 0;
}

/* Window Footer */
.game-window-footer {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 12px 15px;
    border-top: 2px solid #282828;
    background: #0f0f0f;
}

/* Window Buttons */
.game-window-btn {
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 14px;
    padding: 8px 20px;
    background: #1a1a1a;
    color: #888;
    border: 2px solid #333;
    cursor: pointer;
    transition: all 0.2s;
}

.game-window-btn:hover {
    background: #2a2a2a;
    color: #ccc;
    border-color: #555;
}

.game-window-btn-primary {
    background: #2a2a2a;
    color: #ccc;
    border-color: #555;
}

.game-window-btn-primary:hover {
    background: #3a3a3a;
    color: #fff;
    border-color: #666;
}

.game-window-btn-danger {
    background: #2a0000;
    color: #ff6666;
    border-color: #550000;
}

.game-window-btn-danger:hover {
    background: #3a0000;
    color: #ff8888;
    border-color: #880000;
}

/* ========================================
   Inventory System
   ======================================== */
.inventory-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2500;
    animation: fadeIn 0.2s ease-in;
}

.inventory-window {
    background: var(--bg-black);
    border: 4px solid #4a55bb;
    outline: 4px solid #1a1f4d;
    box-shadow:
        0 0 0 8px #313a92,
        0 0 40px rgba(49, 58, 146, 0.5),
        inset 0 0 30px rgba(26, 31, 77, 0.8);
    padding: 20px;
    min-width: 480px;
    animation: slideDown 0.3s ease-out;
}

.inventory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #4a55bb;
}

.inventory-title {
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 28px;
    color: var(--ultima-gold-bright);
    text-shadow: 2px 2px 0px var(--bg-black);
}

.inventory-close {
    font-size: 32px;
    color: #888;
    cursor: pointer;
    line-height: 1;
}

.inventory-close:hover {
    color: var(--danger-bright);
}

/* Selected Item Display */
.inventory-selected {
    display: flex;
    gap: 15px;
    padding: 15px;
    margin-bottom: 15px;
    background: rgba(49, 58, 146, 0.2);
    border: 2px solid #4a55bb;
    min-height: 90px;
}

.inventory-selected-icon {
    width: 64px;
    height: 64px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #666;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.inventory-selected-icon img {
    max-width: 100%;
    max-height: 100%;
    image-rendering: pixelated;
}

.inventory-selected-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.inventory-selected-name {
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 20px;
    color: var(--ultima-gold-bright);
    margin-bottom: 8px;
}

.inventory-selected-desc {
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 14px;
    color: #aaa;
    line-height: 1.4;
}

/* Item Grid */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(6, 64px);
    grid-template-rows: repeat(5, 64px);
    gap: 6px;
    justify-content: center;
    margin-bottom: 15px;
}

.inventory-slot {
    width: 64px;
    height: 64px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #444;
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.1s;
}

.inventory-slot:hover {
    border-color: #666;
}

.inventory-slot.selected {
    border-color: var(--ultima-gold-bright);
    box-shadow: 0 0 10px rgba(218, 165, 32, 0.5);
}

.inventory-slot img {
    max-width: 56px;
    max-height: 56px;
    image-rendering: pixelated;
}

/* Item Badge (E, Q) - Triangle in top-left */
.inventory-badge {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 24px 24px 0 0;
    border-color: transparent;
    z-index: 1;
}

.inventory-badge-letter {
    position: absolute;
    top: 2px;
    left: 3px;
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 11px;
    color: #fff;
    text-shadow: 1px 1px 0px rgba(0,0,0,0.8);
    z-index: 2;
}

/* Badge Colors */
.inventory-badge.equipped {
    border-color: var(--ultima-gold-bright) transparent transparent transparent;
}

.inventory-badge.quest {
    border-color: #9b59b6 transparent transparent transparent;
}

/* Stack Count - Bottom right */
.inventory-stack {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 12px;
    color: #fff;
    text-shadow:
        1px 1px 0px #000,
        -1px -1px 0px #000,
        1px -1px 0px #000,
        -1px 1px 0px #000;
    z-index: 2;
}

/* Controls Footer */
.inventory-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding-top: 10px;
    border-top: 2px solid #4a55bb;
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 14px;
    color: #888;
}

.inventory-controls .key {
    background: #333;
    padding: 2px 6px;
    border: 1px solid #555;
    color: #ccc;
    font-size: 12px;
    margin-right: 4px;
}

/* ========================================
   Combat Log Text Colors
   ======================================== */
.red-text {
    color: var(--danger-bright);
    text-shadow: 1px 1px 0px var(--bg-black);
}

.green-text {
    color: var(--heal-bright);
}

.yellow-text {
    color: var(--warning-bright);
}

.gold-text {
    color: var(--ultima-gold-bright);
    text-shadow: 1px 1px 2px #AA5500;
}

/* ========================================
   Level-Up Window Content (for WindowManager)
   ======================================== */
.levelup-content {
    text-align: center;
}

.levelup-icon {
    font-size: 42px;
    color: #DAA520;
    text-shadow: 0 0 20px rgba(218, 165, 32, 0.8);
    animation: levelupGlow 1.5s ease-in-out infinite;
    margin-bottom: 5px;
}

@keyframes levelupGlow {
    0%, 100% {
        text-shadow: 0 0 20px rgba(218, 165, 32, 0.8);
    }
    50% {
        text-shadow: 0 0 40px rgba(218, 165, 32, 1), 0 0 60px rgba(255, 170, 0, 0.6);
    }
}

.levelup-level {
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 24px;
    color: #FFAA00;
    text-shadow: 2px 2px 0 #AA5500;
    margin-bottom: 10px;
}

.levelup-divider {
    height: 2px;
    background: linear-gradient(90deg, transparent, #DAA520, transparent);
    margin: 15px 0;
}

.levelup-stats {
    text-align: left;
    padding: 5px 0;
}

.levelup-stat-row {
    display: flex;
    justify-content: space-between;
    margin: 8px 0;
    font-size: 14px;
}

.levelup-stat-name {
    color: #888;
    min-width: 80px;
}

.levelup-stat-values {
    text-align: right;
}

.levelup-stat-old {
    color: #666;
}

.levelup-stat-arrow {
    color: #DAA520;
    margin: 0 8px;
}

.levelup-stat-new {
    color: #00FF00;
}

.levelup-stat-diff {
    color: #00FF00;
    font-size: 12px;
    margin-left: 5px;
}

.levelup-bonus {
    font-size: 14px;
    color: #00FFFF;
    margin-top: 5px;
}

/* ========================================
   Death Window Content
   ======================================== */
.death-content {
    text-align: center;
    padding: 10px 0;
}

.death-message {
    font-size: 16px;
    color: #ff6666;
    margin-bottom: 20px;
}

.death-stats {
    font-size: 14px;
    color: #888;
    line-height: 1.8;
}

/* ========================================
   Save/Load Slot List (WindowManager)
   ======================================== */
.slot-list {
    max-height: 300px;
    overflow-y: auto;
}

.slot-item {
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #151515;
    border: 1px solid #333;
    cursor: pointer;
    transition: all 0.15s ease;
}

.slot-item:hover {
    background: #1f1f1f;
    border-color: #555;
}

.slot-item:last-child {
    margin-bottom: 0;
}

.slot-empty-slot {
    opacity: 0.6;
}

.slot-empty-slot:hover {
    opacity: 1;
}

.slot-title {
    font-size: 14px;
    color: #ccc;
    margin-bottom: 4px;
}

.slot-info {
    font-size: 12px;
    color: #888;
    margin-bottom: 2px;
}

.slot-date {
    font-size: 11px;
    color: #555;
}

.slot-empty {
    text-align: center;
    color: #666;
    padding: 20px;
    font-size: 14px;
}

/* ========================================
   Inventory Window (WindowManager)
   ======================================== */
.inv-selected {
    display: flex;
    gap: 12px;
    padding: 10px;
    margin-bottom: 10px;
    background: rgba(40, 40, 40, 0.5);
    border: 1px solid #333;
}

.inv-selected-icon {
    width: 56px;
    height: 56px;
    background: #000;
    border: 2px solid #444;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.inv-selected-icon img {
    max-width: 48px;
    max-height: 48px;
    image-rendering: pixelated;
}

.inv-selected-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.inv-selected-name {
    font-size: 16px;
    color: #DAA520;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inv-selected-desc {
    font-size: 12px;
    color: #888;
    line-height: 1.3;
}

.inv-grid {
    display: grid;
    grid-template-columns: repeat(6, 56px);
    grid-template-rows: repeat(5, 56px);
    gap: 4px;
    justify-content: center;
    padding: 5px 0;
}

.inv-slot {
    width: 56px;
    height: 56px;
    background: #1a1a2e;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    /* Doppelrahmen wie Game-UI: außen hell (#666), innen dunkel (#282828) */
    border: 2px solid #666;
    box-shadow: inset 0 0 0 2px #282828;
}

.inv-slot:hover {
    border-color: #888;
    box-shadow: inset 0 0 0 2px #383838;
}

.inv-slot.selected {
    border-color: #DAA520;
    box-shadow: inset 0 0 0 2px #8B6914, 0 0 12px rgba(218, 165, 32, 0.6);
}

.inv-slot img {
    max-width: 48px;
    max-height: 48px;
    image-rendering: pixelated;
}

.inv-badge {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 2px;
}

.inv-badge.equipped {
    background: #006600;
    border: 1px solid #00aa00;
}

.inv-badge.quest {
    background: #666600;
    border: 1px solid #aaaa00;
}

.inv-badge-letter {
    position: absolute;
    top: 2px;
    left: 5px;
    font-size: 10px;
    color: #fff;
    font-weight: bold;
    text-shadow: 1px 1px 0 #000;
}

.inv-stack {
    position: absolute;
    bottom: 2px;
    right: 3px;
    font-size: 11px;
    color: #fff;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}

.inv-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding-top: 10px;
    border-top: 1px solid #333;
    margin-top: 5px;
    font-size: 12px;
    color: #666;
}

.inv-controls .key {
    background: #222;
    padding: 2px 5px;
    border: 1px solid #444;
    color: #aaa;
    font-size: 10px;
    margin-right: 3px;
}

/* ========================================
   Dialog System - Ornate Ultima Style
   ======================================== */
.map-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease-in;
}

.dialog-content {
    background: var(--bg-black);
    border: 4px solid #4a55bb;
    outline: 4px solid #1a1f4d;
    box-shadow:
        0 0 0 8px #313a92,
        0 0 40px rgba(49, 58, 146, 0.5),
        inset 0 0 30px rgba(26, 31, 77, 0.8);
    padding: 30px;
    min-width: 500px;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideDown 0.4s ease-out;
}

.dialog-title {
    font-size: 48px;
    color: var(--ultima-gold-bright);
    text-align: center;
    margin: 0 0 25px;
    text-shadow: 3px 3px 0px var(--bg-black), 0 0 15px var(--ultima-gold);
    letter-spacing: 3px;
}

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

.dialog-form label {
    font-size: 24px;
    color: #4a55bb;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.dialog-form input[type="text"],
.dialog-form input[type="number"],
.dialog-form textarea {
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 24px;
    padding: 10px;
    background: #1a1f4d;
    border: 3px solid #313a92;
    color: var(--text-white);
    outline: none;
    width: 100%;
    box-sizing: border-box;
}

.dialog-form input[type="text"]:focus,
.dialog-form input[type="number"]:focus,
.dialog-form textarea:focus {
    border-color: #4a55bb;
    box-shadow: 0 0 15px rgba(49, 58, 146, 0.6);
}

.dialog-form textarea {
    resize: vertical;
    font-size: 20px;
    line-height: 1.5;
}

.dialog-buttons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    justify-content: center;
}

.dialog-btn {
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 28px;
    padding: 12px 30px;
    border: 3px solid #1a1f4d;
    cursor: pointer;
    text-shadow: 2px 2px 0px var(--bg-black);
    box-shadow: 4px 4px 0px var(--bg-black);
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.dialog-btn-primary {
    background: #313a92;
    color: #4a55bb;
    border-color: #4a55bb;
}

.dialog-btn-primary:hover {
    background: #4a55bb;
    color: var(--text-white);
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px var(--bg-black);
}

.dialog-btn-secondary {
    background: var(--danger-red);
    color: var(--text-white);
    border-color: var(--danger-bright);
}

.dialog-btn-secondary:hover {
    background: var(--danger-bright);
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px var(--bg-black);
}

.dialog-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px var(--bg-black);
}

/* ========================================
   Map List
   ======================================== */
.map-list {
    max-height: 400px;
    overflow-x: hidden;
    overflow-y: auto;
    margin-bottom: 15px;
}

.map-item {
    background: var(--ultima-dark);
    border: 3px solid var(--ultima-blue);
    padding: 15px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.map-item:hover {
    border-color: var(--ultima-bright);
    background: var(--ultima-blue);
    transform: translateX(5px);
    box-shadow: -5px 0 15px rgba(85, 85, 255, 0.4);
}

.map-item-title {
    font-size: 28px;
    color: var(--ultima-gold-bright);
    margin-bottom: 8px;
    text-shadow: 2px 2px 0px var(--bg-black);
}

.map-item-info {
    font-size: 20px;
    color: var(--text-gray);
    margin-bottom: 5px;
}

.map-item-date {
    font-size: 18px;
    color: var(--text-dark);
}

.map-delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 20px;
    padding: 5px 10px;
    background: var(--danger-red);
    color: var(--text-white);
    border: 2px solid var(--bg-black);
    cursor: pointer;
    box-shadow: 2px 2px 0px var(--bg-black);
}

.map-delete-btn:hover {
    background: var(--danger-bright);
}

.no-maps {
    text-align: center;
    color: var(--text-dark);
    font-size: 24px;
    padding: 40px;
}

/* ========================================
   Scrollbar - Ultima Style
   ======================================== */
.dialog-content::-webkit-scrollbar,
.map-list::-webkit-scrollbar {
    width: 12px;
}

.dialog-content::-webkit-scrollbar-track,
.map-list::-webkit-scrollbar-track {
    background: var(--ultima-dark);
}

.dialog-content::-webkit-scrollbar-thumb,
.map-list::-webkit-scrollbar-thumb {
    background: var(--ultima-blue);
    border: 2px solid var(--ultima-dark);
}

.dialog-content::-webkit-scrollbar-thumb:hover,
.map-list::-webkit-scrollbar-thumb:hover {
    background: var(--ultima-bright);
}

/* ========================================
   Corner Ornaments (for future panels)
   ======================================== */
.ornate-panel {
    position: relative;
    background: var(--bg-black);
    border: 4px solid var(--ultima-bright);
    outline: 4px solid var(--ultima-dark);
    box-shadow: 0 0 0 8px var(--ultima-blue);
    padding: 20px;
}

.ornate-panel::before,
.ornate-panel::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--ultima-gold-bright);
    box-shadow: 2px 2px 0px var(--bg-black);
}

.ornate-panel::before {
    top: -8px;
    left: -8px;
}

.ornate-panel::after {
    top: -8px;
    right: -8px;
}

/* Bottom corners via additional elements */
.ornate-corners::before,
.ornate-corners::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--ultima-gold-bright);
    box-shadow: 2px 2px 0px var(--bg-black);
}

.ornate-corners::before {
    bottom: -8px;
    left: -8px;
}

.ornate-corners::after {
    bottom: -8px;
    right: -8px;
}

/* ========================================
   Main Menu Styles (for Phase 3)
   ======================================== */
.main-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-black);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.menu-title {
    font-size: 72px;
    color: var(--ultima-gold-bright);
    text-shadow:
        4px 4px 0px var(--bg-black),
        0 0 30px var(--ultima-gold);
    margin-bottom: 60px;
    letter-spacing: 4px;
}

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

.menu-option {
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 32px;
    padding: 15px 50px;
    background: var(--ultima-dark);
    color: var(--ultima-bright);
    border: 3px solid var(--ultima-blue);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.menu-option:hover,
.menu-option.selected {
    background: var(--ultima-blue);
    color: var(--text-white);
    border-color: var(--ultima-bright);
    transform: translateX(10px);
    box-shadow: -5px 0 20px rgba(85, 85, 255, 0.5);
}

.menu-option .key {
    color: var(--ultima-gold-bright);
    margin-right: 15px;
}

/* ========================================
   Dev Console - Debug Output
   ======================================== */
#dev-console {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    min-height: 80px;
    max-height: 80vh;
    background: rgba(0, 0, 30, 0.95);
    border-top: 3px solid var(--ultima-bright);
    font-family: 'Consolas', 'Monaco', monospace;
    z-index: 9999;
    display: flex;
    flex-direction: column;
}

.dev-console-header {
    cursor: ns-resize;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    background: var(--ultima-dark);
    border-bottom: 2px solid var(--ultima-blue);
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 24px;
    color: var(--ultima-gold-bright);
}

.dev-console-btn {
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 20px;
    padding: 4px 8px;
    background: var(--ultima-blue);
    color: var(--text-white);
    border: 2px solid var(--ultima-bright);
    cursor: pointer;
}

.dev-console-btn:hover {
    background: var(--ultima-bright);
}

#dev-console-log {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    font-size: 18px;
    line-height: 1.4;
}

.dev-log-entry {
    margin-bottom: 2px;
    padding: 2px 5px;
    border-left: 3px solid var(--ultima-blue);
}

.dev-log-entry.log {
    color: #aaaaaa;
    border-left-color: var(--ultima-blue);
}

.dev-log-entry.info {
    color: #55aaff;
    border-left-color: #55aaff;
}

.dev-log-entry.warn {
    color: #ffaa00;
    border-left-color: #ffaa00;
}

.dev-log-entry.error {
    color: #ff5555;
    border-left-color: #ff5555;
    background: rgba(255, 0, 0, 0.1);
}

/* Combat-specific log colors */
.dev-log-entry.combat {
    color: #00cccc;
    border-left-color: #00cccc;
    background: rgba(0, 204, 204, 0.05);
}

.dev-log-entry.hit {
    color: #55ff55;
    border-left-color: #55ff55;
    background: rgba(85, 255, 85, 0.1);
}

.dev-log-entry.miss {
    color: #ffff55;
    border-left-color: #ffff55;
    background: rgba(255, 255, 85, 0.05);
}

.dev-log-entry.damage {
    color: #ff6666;
    border-left-color: #ff6666;
    background: rgba(255, 102, 102, 0.1);
}

.dev-log-entry.loot {
    color: #cc66ff;
    border-left-color: #cc66ff;
    background: rgba(204, 102, 255, 0.1);
}

.dev-log-entry.magic {
    color: #6699ff;
    border-left-color: #6699ff;
    background: rgba(102, 153, 255, 0.1);
}

.dev-log-time {
    color: #666666;
    margin-right: 8px;
}

#dev-console-log::-webkit-scrollbar {
    width: 8px;
}

#dev-console-log::-webkit-scrollbar-track {
    background: var(--bg-black);
}

#dev-console-log::-webkit-scrollbar-thumb {
    background: var(--ultima-blue);
}

/* ========================================
   Loading Screen - Database Tile Loading
   ======================================== */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-black);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease-in;
}

.loading-content {
    text-align: center;
    animation: slideDown 0.5s ease-out;
}

.loading-title {
    font-size: 28px;
    color: var(--ultima-gold-bright);
    text-shadow:
        4px 4px 0px var(--bg-black),
        0 0 30px var(--ultima-gold);
    margin-bottom: 40px;
    letter-spacing: 3px;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 30px;
    border: 6px solid var(--ultima-dark);
    border-top: 6px solid var(--ultima-bright);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-message {
    font-size: 24px;
    color: var(--ultima-bright);
    margin-bottom: 25px;
    text-shadow: 2px 2px 0px var(--bg-black);
}

.loading-bar {
    width: 300px;
    height: 20px;
    margin: 0 auto;
    background: var(--ultima-dark);
    border: 3px solid var(--ultima-blue);
    box-shadow: 0 0 10px rgba(85, 85, 255, 0.3);
}

.loading-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(
        90deg,
        var(--ultima-blue) 0%,
        var(--ultima-bright) 50%,
        var(--ultima-blue) 100%
    );
    transition: width 0.3s ease;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { background-position: -100% 0; }
    100% { background-position: 100% 0; }
}

/* ========================================
   NPC Dialogue System
   ======================================== */
.dialogue-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    animation: dialogueOverlayFadeIn 0.35s ease-out;
}

@keyframes dialogueOverlayFadeIn {
    0% {
        opacity: 0;
        background: rgba(0, 0, 0, 0);
    }
    100% {
        opacity: 1;
        background: rgba(0, 0, 0, 0.85);
    }
}

.dialogue-overlay.closing {
    animation: dialogueOverlayFadeOut 0.25s ease-in forwards;
}

@keyframes dialogueOverlayFadeOut {
    0% {
        opacity: 1;
        background: rgba(0, 0, 0, 0.85);
    }
    100% {
        opacity: 0;
        background: rgba(0, 0, 0, 0);
    }
}

.dialogue-box {
    background: var(--bg-black);
    padding: 24px;
    min-width: 400px;
    max-width: 600px;
    position: relative;
    animation: dialogueBoxEnter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dialog Frame - Outer (heller #888) */
.dlg-frame-outer-top {
    position: absolute;
    top: 0;
    left: 4px;
    right: 4px;
    height: 4px;
    background: #666;
    clip-path: polygon(0 0, 100% 0, calc(100% - 4px) 100%, 4px 100%);
}

.dlg-frame-outer-bottom {
    position: absolute;
    bottom: 0;
    left: 4px;
    right: 4px;
    height: 4px;
    background: #666;
    clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 100%, 0 100%);
}

.dlg-frame-outer-left {
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 4px;
    background: #666;
    clip-path: polygon(0 0, 100% 4px, 100% calc(100% - 4px), 0 100%);
}

.dlg-frame-outer-right {
    position: absolute;
    right: 0;
    top: 4px;
    bottom: 4px;
    width: 4px;
    background: #666;
    clip-path: polygon(0 4px, 100% 0, 100% 100%, 0 calc(100% - 4px));
}

/* Dialog Frame - Inner (dunkler #555) */
.dlg-frame-inner-top {
    position: absolute;
    top: 8px;
    left: 12px;
    right: 12px;
    height: 4px;
    background: #282828;
    clip-path: polygon(0 0, 100% 0, calc(100% - 4px) 100%, 4px 100%);
}

.dlg-frame-inner-bottom {
    position: absolute;
    bottom: 8px;
    left: 12px;
    right: 12px;
    height: 4px;
    background: #282828;
    clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 100%, 0 100%);
}

.dlg-frame-inner-left {
    position: absolute;
    left: 8px;
    top: 12px;
    bottom: 12px;
    width: 4px;
    background: #282828;
    clip-path: polygon(0 0, 100% 4px, 100% calc(100% - 4px), 0 100%);
}

.dlg-frame-inner-right {
    position: absolute;
    right: 8px;
    top: 12px;
    bottom: 12px;
    width: 4px;
    background: #282828;
    clip-path: polygon(0 4px, 100% 0, 100% 100%, 0 calc(100% - 4px));
}

@keyframes dialogueBoxEnter {
    0% {
        opacity: 0;
        transform: translateY(-30px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.dialogue-overlay.closing .dialogue-box {
    animation: dialogueBoxExit 0.2s ease-in forwards;
}

@keyframes dialogueBoxExit {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
}

.dialogue-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--ultima-blue);
    animation: dialogueHeaderFadeIn 0.5s ease-out 0.15s both;
}

@keyframes dialogueHeaderFadeIn {
    0% {
        opacity: 0;
        transform: translateX(-10px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.dialogue-portrait {
    width: 64px;
    height: 64px;
    background: var(--bg-black);
    border: 3px solid #282828;
    padding: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--ultima-gold-bright);
    text-shadow: 2px 2px 0px var(--bg-black);
    flex-shrink: 0;
    box-sizing: border-box;
}

.dialogue-portrait:hover {
    border-color: #444;
}

.dialogue-portrait.has-portrait {
    background: none;
}

.dialogue-portrait.has-portrait img,
.dialogue-portrait.has-portrait .portrait-sprite {
    display: block;
    width: 48px;
    height: 48px;
    image-rendering: pixelated;
}

.dialogue-portrait .portrait-sprite {
    background-repeat: no-repeat;
    background-size: auto 48px;
}

.dialogue-speaker {
    font-size: 28px;
    color: var(--ultima-gold-bright);
    text-shadow: 2px 2px 0px var(--bg-black);
    text-transform: uppercase;
    letter-spacing: 2px;
    animation: dialogueSpeakerGlow 2.5s ease-in-out infinite;
}

@keyframes dialogueSpeakerGlow {
    0%, 100% {
        text-shadow: 2px 2px 0px var(--bg-black);
    }
    50% {
        text-shadow: 2px 2px 0px var(--bg-black), 0 0 8px var(--ultima-gold);
    }
}

.dialogue-text {
    font-size: 22px;
    line-height: 1.6;
    color: var(--text-white);
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(0, 0, 85, 0.5);
    border: 2px solid var(--ultima-dark);
    min-height: 60px;
    animation: dialogueTextFadeIn 0.5s ease-out 0.2s both;
    transition: border-color 0.3s ease;
}

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

.dialogue-choices {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dialogue-choice {
    font-size: 22px;
    padding: 10px 15px;
    background: var(--ultima-dark);
    color: var(--ultima-bright);
    border: 2px solid var(--ultima-blue);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    opacity: 0;
    animation: dialogueChoiceSlideIn 0.35s ease-out forwards;
    position: relative;
    overflow: hidden;
}

/* Staggered animation for choices */
.dialogue-choice:nth-child(1) { animation-delay: 0.3s; }
.dialogue-choice:nth-child(2) { animation-delay: 0.4s; }
.dialogue-choice:nth-child(3) { animation-delay: 0.5s; }
.dialogue-choice:nth-child(4) { animation-delay: 0.6s; }
.dialogue-choice:nth-child(5) { animation-delay: 0.7s; }
.dialogue-choice:nth-child(6) { animation-delay: 0.8s; }

@keyframes dialogueChoiceSlideIn {
    0% {
        opacity: 0;
        transform: translateX(-15px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Shine effect on hover */
.dialogue-choice::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(85, 85, 255, 0.2),
        transparent
    );
    transition: left 0.4s ease;
}

.dialogue-choice:hover::before,
.dialogue-choice.highlighted::before {
    left: 100%;
}

.dialogue-choice:hover,
.dialogue-choice.highlighted {
    background: var(--ultima-blue);
    color: var(--text-white);
    border-color: var(--ultima-bright);
    transform: translateX(8px);
    box-shadow:
        -4px 0 15px rgba(85, 85, 255, 0.5),
        0 0 20px rgba(85, 85, 255, 0.2);
}

/* Active/pressed state */
.dialogue-choice:active {
    transform: translateX(4px) scale(0.98);
    transition: all 0.1s ease;
}

.dialogue-notification {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    background: linear-gradient(180deg, var(--ultima-gold-bright) 0%, var(--ultima-gold) 100%);
    color: var(--text-white);
    padding: 8px 18px;
    font-size: 22px;
    border: 2px solid var(--ultima-gold-bright);
    box-shadow:
        0 0 20px rgba(255, 170, 0, 0.6),
        0 4px 8px rgba(0, 0, 0, 0.4);
    animation: notificationPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);
}

/* Subtle glow pulse on notifications */
.dialogue-notification::after {
    content: '';
    position: absolute;
    inset: -3px;
    border: 2px solid var(--ultima-gold-bright);
    opacity: 0;
    animation: notificationGlow 1.5s ease-in-out 0.4s infinite;
}

@keyframes notificationGlow {
    0%, 100% { opacity: 0; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.02); }
}

@keyframes notificationPop {
    0% {
        transform: translateX(-50%) translateY(15px) scale(0.7);
        opacity: 0;
    }
    70% {
        transform: translateX(-50%) translateY(-3px) scale(1.05);
        opacity: 1;
    }
    100% {
        transform: translateX(-50%) translateY(0) scale(1);
        opacity: 1;
    }
}

.dialogue-notification.fade-out {
    animation: notificationFade 0.4s ease-in forwards;
}

@keyframes notificationFade {
    0% {
        transform: translateX(-50%) translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateX(-50%) translateY(-15px) scale(0.9);
        opacity: 0;
    }
}

/* =========================================================
   NPC Dialogue - WindowManager Integration (dlg-* classes)
   ========================================================= */

.dlg-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--ultima-blue);
}

.dlg-portrait {
    width: 64px;
    height: 64px;
    background: var(--bg-black);
    border: 2px solid #666;
    box-shadow: inset 0 0 0 2px #282828;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: var(--ultima-gold);
    flex-shrink: 0;
}

.dlg-portrait.has-portrait {
    background: #1a1a2e;
    padding: 8px;
}

.dlg-portrait.has-portrait img,
.dlg-portrait.has-portrait .portrait-sprite {
    display: block;
    width: 48px;
    height: 48px;
    image-rendering: pixelated;
}

.dlg-portrait .portrait-sprite {
    background-repeat: no-repeat;
    background-size: auto 48px;
}

.dlg-speaker {
    font-size: 24px;
    color: var(--ultima-gold-bright);
    text-shadow: 2px 2px 0px var(--bg-black);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.dlg-text {
    font-size: 18px;
    line-height: 1.6;
    color: var(--text-white);
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(0, 0, 85, 0.4);
    border: 2px solid #666;
    box-shadow: inset 0 0 0 2px #282828;
    min-height: 50px;
}

.dlg-choices {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dlg-choice {
    font-size: 18px;
    padding: 8px 12px;
    background: var(--ultima-dark);
    color: var(--ultima-bright);
    border: 2px solid #666;
    box-shadow: inset 0 0 0 2px #282828;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    overflow: hidden;
}

.dlg-choice:hover,
.dlg-choice.highlighted {
    background: var(--ultima-blue);
    color: var(--text-white);
    border-color: var(--ultima-bright);
    transform: translateX(5px);
    box-shadow: inset 0 0 0 2px #282828, -3px 0 10px rgba(85, 85, 255, 0.4);
}

.dlg-choice:active {
    transform: translateX(3px) scale(0.98);
}

.dlg-notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(180deg, var(--ultima-gold-bright) 0%, var(--ultima-gold) 100%);
    color: var(--text-white);
    padding: 8px 16px;
    font-size: 18px;
    border: 2px solid var(--ultima-gold-bright);
    box-shadow: 0 0 15px rgba(255, 170, 0, 0.5);
    animation: dlgNotifPop 0.3s ease-out;
    white-space: nowrap;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

@keyframes dlgNotifPop {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Notification type variants */
.dialogue-notification.notification-gold {
    background: linear-gradient(180deg, var(--ultima-gold-bright) 0%, var(--ultima-gold) 100%);
    border-color: var(--ultima-gold-bright);
    box-shadow: 0 0 20px rgba(255, 170, 0, 0.6), 0 4px 8px rgba(0, 0, 0, 0.4);
}

.dialogue-notification.notification-heal {
    background: linear-gradient(180deg, var(--heal-bright) 0%, var(--heal-green) 100%);
    border-color: var(--heal-bright);
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.4), 0 4px 8px rgba(0, 0, 0, 0.4);
}

.dialogue-notification.notification-quest {
    background: linear-gradient(180deg, var(--ultima-bright) 0%, var(--ultima-blue) 100%);
    border-color: var(--ultima-bright);
    box-shadow: 0 0 20px rgba(85, 85, 255, 0.5), 0 4px 8px rgba(0, 0, 0, 0.4);
}

/* Item pickup notification with icon */
.dialogue-notification.item-notification {
    display: inline-flex;
    align-items: center;
    padding: 10px 20px;
    gap: 12px;
    position: fixed;
    top: 15%;
    left: 58%;
    transform: translateX(-50%);
    z-index: 99999;
}

.dialogue-notification.item-notification .item-notification-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.4);
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.dialogue-notification.item-notification .item-notification-text {
    font-size: 20px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
}

.dialogue-notification.item-notification canvas {
    display: block;
    width: 32px;
    height: 32px;
}

/* ========================================
   NPC Interaction Prompts
   ======================================== */
.interaction-prompt {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: var(--ultima-gold-bright);
    padding: 5px 12px;
    font-size: 22px;
    font-family: 'Alagard', 'Press Start 2P', cursive;
    border: 2px solid var(--ultima-gold-bright);
    pointer-events: none;
    z-index: 100;
    text-shadow: 1px 1px 0px var(--bg-black);
    box-shadow:
        0 0 15px rgba(255, 215, 0, 0.4),
        0 2px 6px rgba(0, 0, 0, 0.5);
    animation:
        prompt-appear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        prompt-bob 1.5s ease-in-out 0.3s infinite,
        prompt-glow 2s ease-in-out infinite;
}

@keyframes prompt-appear {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes prompt-glow {
    0%, 100% {
        box-shadow:
            0 0 15px rgba(255, 215, 0, 0.4),
            0 2px 6px rgba(0, 0, 0, 0.5);
    }
    50% {
        box-shadow:
            0 0 20px rgba(255, 215, 0, 0.6),
            0 2px 6px rgba(0, 0, 0, 0.5);
    }
}

.interaction-prompt::before {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 7px solid var(--ultima-gold-bright);
}

.interaction-prompt::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid rgba(0, 0, 0, 0.9);
}

@keyframes prompt-bob {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

/* ========================================
   Debug Panel (Dev Mode)
   ======================================== */
#debug-panel {
    position: fixed;
    top: 10px;
    right: 10px;
    width: 280px;
    background: rgba(0, 0, 85, 0.95);
    border: 3px solid var(--ultima-bright);
    box-shadow:
        inset 2px 2px 0px var(--ultima-blue),
        inset -2px -2px 0px var(--ultima-dark),
        4px 4px 0px rgba(0, 0, 0, 0.7),
        0 0 20px rgba(85, 85, 255, 0.3);
    z-index: 1000;
    font-family: 'Alagard', 'Press Start 2P', cursive;
    font-size: 16px;
}

.debug-header {
    background: linear-gradient(180deg, var(--ultima-bright) 0%, var(--ultima-blue) 100%);
    color: var(--text-white);
    padding: 6px 8px;
    text-align: center;
    font-size: 18px;
    letter-spacing: 1px;
    border-bottom: 2px solid var(--ultima-dark);
    text-shadow: 1px 1px 0 var(--bg-black);
}

.debug-content {
    padding: 8px;
    max-height: 500px;
    overflow-y: auto;
}

.debug-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    padding: 2px 0;
}

.debug-label {
    color: var(--text-gray);
    font-size: 14px;
    text-transform: uppercase;
}

.debug-value {
    color: var(--ultima-gold-bright);
    font-size: 16px;
    text-align: right;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.debug-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--ultima-bright) 50%, transparent 100%);
    margin: 6px 0;
}

/* Highlight styles for special values */
.debug-value.highlight-green {
    color: var(--heal-bright);
}

.debug-value.highlight-red {
    color: var(--danger-bright);
}

.debug-value.highlight-yellow {
    color: var(--warning-bright);
}

.debug-value.highlight-cyan {
    color: #55FFFF;
}

/* Scrollbar styling for debug panel */
.debug-content::-webkit-scrollbar {
    width: 6px;
}

.debug-content::-webkit-scrollbar-track {
    background: var(--ultima-dark);
}

.debug-content::-webkit-scrollbar-thumb {
    background: var(--ultima-bright);
    border-radius: 0;
}

.debug-content::-webkit-scrollbar-thumb:hover {
    background: var(--ultima-gold-bright);
}

/* ========================================
   Day/Night Sky Indicator (in Interface Frame)
   ======================================== */
#sky-indicator {
    position: absolute;
    top: 0px;
    left: 64%;
    transform: translate(-50%, 0);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    z-index: 150;
}

/* Old sky-window styles removed - now using .sky-clock .sky-window */
