:root {
    --bg: #0c0c0c;
    --panel: #1a1c2c;
    --border: #ffffff;
    --accent: #22c55e;
    --accent-glow: #166534;
    --zelda-gold: #c39b33;
}

* {
    box-sizing: border-box;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background: #000;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Courier New', Courier, monospace;
    position: fixed;
}

#game-container {
    width: 100%;
    height: 100dvh;
    max-width: 500px;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    border-left: 2px solid #333;
    border-right: 2px solid #333;
}

canvas {
    width: 100%;
    flex-grow: 1;
    background: #4a7c44;
    display: block;
}

.code-box {
    background: #2a2d3e;
    border: 1px solid #444;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: #fff;
    font-size: 0.9em;
}

#ui-layer {
    flex-basis: 42%;
    min-height: 320px;
    background: var(--panel);
    border: 2px solid var(--border);
    outline: 1px solid #555;
    outline-offset: -6px;
    border-radius: 4px;
    margin: 5px;
    display: flex;
    flex-direction: column;
    padding: 20px;
    z-index: 10;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

#ui-layer::before {
    content: "◈";
    position: absolute;
    top: 6px;
    left: 6px;
    color: var(--zelda-gold);
    font-size: 10px;
}

#dialogue-container {
    position: relative;
    min-height: 100px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
}

#dialogue-text {
    color: #ffffff;
    font-size: 1rem;
    line-height: 1.5;
    letter-spacing: 0.5px;
    font-family: 'Garamond', 'Georgia', serif;
    padding-bottom: 30px;
    text-shadow: 2px 2px #000;
}

.diag-nav {
    position: absolute;
    bottom: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
}

#back-diag-btn, #next-diag-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    padding: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#back-diag-btn { color: #666; visibility: hidden; }

#next-diag-btn {
    color: var(--accent);
    font-weight: bold;
    animation: blink 1s infinite;
    text-shadow: 0 0 5px var(--accent-glow), 0 0 10px var(--accent-glow);
}

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

textarea {
    flex-grow: 1;
    background: rgba(0,0,0,0.6);
    border: 1px solid #444;
    color: var(--accent);
    padding: 12px;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    resize: none;
    outline: none;
    border-radius: 0px;
    appearance: none;
}

.controls {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    padding-bottom: 5px;
}

button.game-btn {
    flex: 1;
    padding: 15px 10px;
    font-weight: bold;
    cursor: pointer;
    border: 1px solid #fff;
    box-shadow: inset 0 -4px 0 rgba(0,0,0,0.3);
    border-radius: 2px;
    font-size: 0.8rem;
    text-transform: uppercase;
    transition: transform 0.1s;
}

button.game-btn:active {
    transform: translateY(2px);
    box-shadow: none;
}

#run-btn { background: #4a7c44; color: white; border: none; }
#reset-btn { background: #555; color: #fff; border: none; }

#modal-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
}

#modal-box {
    background: var(--panel);
    border: 2px solid var(--border);
    padding: 20px;
    width: 80%;
    max-width: 300px;
    text-align: center;
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#modal-title { color: var(--zelda-gold); font-weight: bold; font-size: 1.2rem; }
#modal-msg { color: white; font-size: 0.9rem; line-height: 1.4; }

#intro-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--panel);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 4px double var(--zelda-gold);
}

#loading-msg {
    color: white;
    font-family: 'Garamond', serif;
    font-size: 1.2rem;
    display: none;
}

#intro-content {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    width: 85%;
    text-align: center;
}

#intro-text-lines {
    color: white;
    font-family: 'Garamond', serif;
    font-size: 1.1rem;
    line-height: 1.6;
    border-top: 1px solid var(--zelda-gold);
    border-bottom: 1px solid var(--zelda-gold);
    padding: 20px 0;
    width: 100%;
}

#intro-text-lines p { margin: 10px 0; }

#intro-next-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: transparent;
    border: 2px solid #666;
    color: #888;
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

#intro-next-btn.active {
    width: auto;
    height: auto;
    border-radius: 4px;
    padding: 10px 20px;
    background: white;
    border-color: white;
    color: black;
    font-size: 1rem;
    cursor: pointer;
}

#pickup-hint {
    position: absolute;
    display: none;
    color: black;
    background: white;
    padding: 4px 8px;
    border-radius: 2px;
    border: 1px solid black;
    font-size: 12px;
    animation: float 1s infinite alternate;
    z-index: 100;
    left: 20%;
    transform: translateX(-50%);
    bottom: 500px;
    pointer-events: none;
}

.intro-big-bold {
    font-size: 1.2rem;
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
}

.intro-bold {
    font-weight: bold;
}

#intro-link {
    top: -40px;
    right: 10px;
    width: 100px;
    height: auto;
    z-index: 2001;
}

@keyframes float { from { margin-bottom: 0; } to { margin-bottom: 5px; } }