@import url('https://fonts.googleapis.com/css2?family=VT323&family=Space+Mono:wght@400;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Prevent iOS bounce/rubber-band scrolling */
    -webkit-overflow-scrolling: touch;
}

/* CSS Custom Properties for viewport height fallback */
:root {
    --vh: 1vh;
}

body {
    background: #050505;
    min-height: 100vh;
    font-family: 'Space Mono', monospace;
    color: #888;
    overflow-x: hidden;
}

/* ============================================
   ATMOSPHERIC PAGE WRAPPER
   ============================================ */

.page-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    position: relative;
}

/* Ambient background */
.ambient-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(20, 40, 20, 0.3) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(10, 30, 10, 0.2) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 50%, rgba(5, 15, 5, 0.1) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* Floating particles */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: rgba(51, 255, 51, 0.3);
    border-radius: 50%;
    animation: float 20s infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(100vh) translateX(0);
        opacity: 0;
    }
    10% { opacity: 0.5; }
    90% { opacity: 0.5; }
    100% {
        transform: translateY(-100px) translateX(100px);
        opacity: 0;
    }
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
    z-index: 10;
    position: relative;
}

.header h1 {
    font-family: 'VT323', monospace;
    font-size: 48px;
    color: #33ff33;
    text-shadow:
        0 0 10px rgba(51, 255, 51, 0.8),
        0 0 20px rgba(51, 255, 51, 0.5),
        0 0 40px rgba(51, 255, 51, 0.3);
    letter-spacing: 15px;
    margin-bottom: 10px;
    animation: titlePulse 4s ease-in-out infinite;
}

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

.header .subtitle {
    font-size: 12px;
    color: #666;
    letter-spacing: 8px;
    text-transform: uppercase;
}

/* Status bar */
.status-bar {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 20px;
    font-size: 11px;
    color: #555;
    z-index: 10;
    position: relative;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 6px;
    height: 6px;
    background: #33ff33;
    border-radius: 50%;
    animation: blink 2s infinite;
}

.status-dot.found {
    background: #ffaa00;
    animation: none;
}

/* ============================================
   TERMINAL CONTAINER
   ============================================ */

.terminal-wrapper {
    position: relative;
    z-index: 10;
    max-width: 100%;
    /* Only hide horizontal overflow, allow vertical */
    overflow-x: hidden;
    overflow-y: visible;
}

/* Terminal frame */
.terminal-frame {
    background: linear-gradient(145deg, #1a1a1a, #0a0a0a);
    border-radius: 12px;
    padding: 15px;
    max-width: 100%;
    /* Only hide horizontal overflow */
    overflow-x: hidden;
    overflow-y: visible;
    box-shadow:
        0 0 0 1px rgba(51, 255, 51, 0.1),
        0 20px 60px rgba(0, 0, 0, 0.8),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.terminal-container {
    position: relative;
    width: 850px;
    max-width: 100%;
    height: 550px;
    border-radius: 6px;
    overflow: hidden;
}

.terminal {
    width: 100%;
    height: 100%;
    background: #0a120a;
    padding: 20px;
    padding-bottom: 80px;
    font-family: 'VT323', monospace;
    font-size: 20px;
    color: #33ff33;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    image-rendering: pixelated;
    filter: blur(0.3px);
    /* Ensure text wraps properly on mobile */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.terminal::-webkit-scrollbar {
    width: 6px;
}

.terminal::-webkit-scrollbar-track {
    background: #0a0a0a;
}

.terminal::-webkit-scrollbar-thumb {
    background: #1a3a1a;
    border-radius: 3px;
}

/* Scanlines */
.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1),
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 10;
}

/* Noise overlay */
.noise {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 11;
    opacity: 0.05;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* Glitch lines */
.glitch-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 12;
}

.glitch-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(51, 255, 51, 0.2);
    opacity: 0;
    animation: glitchLine 10s infinite;
}

.glitch-line:nth-child(1) { animation-delay: 0s; }
.glitch-line:nth-child(2) { animation-delay: 3s; }
.glitch-line:nth-child(3) { animation-delay: 6s; }

@keyframes glitchLine {
    0%, 100% { opacity: 0; top: 0; }
    1% { opacity: 1; top: 15%; }
    2% { opacity: 0; }
    50% { opacity: 0; }
    51% { opacity: 1; top: 70%; }
    52% { opacity: 0; }
}

/* Flicker */
.flicker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 13;
    animation: flicker 0.1s infinite;
    background: transparent;
}

@keyframes flicker {
    0%, 100% { opacity: 0; }
    50% { opacity: 0.015; background: #33ff33; }
}

/* Glitch effects */
.terminal.glitch-active {
    animation: colorShift 0.08s ease-out;
}

@keyframes colorShift {
    0% { text-shadow: -1px 0 rgba(255,0,0,0.4), 1px 0 rgba(0,255,255,0.4); }
    50% { text-shadow: 1px 0 rgba(255,0,0,0.2), -1px 0 rgba(0,255,255,0.2); }
    100% { text-shadow: 0 0 5px rgba(51, 255, 51, 0.5); }
}

.terminal.glitch-heavy {
    animation: colorShiftHeavy 0.15s ease-out;
}

@keyframes colorShiftHeavy {
    0% {
        text-shadow: -3px 0 #ff0000, 3px 0 #00ffff;
        filter: blur(2px);
    }
    50% {
        text-shadow: 2px 0 #ff0000, -2px 0 #00ffff;
        filter: blur(3px);
    }
    100% {
        text-shadow: 0 0 5px rgba(51, 255, 51, 0.5);
        filter: blur(0.3px);
    }
}

/* Vignette */
.vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 14;
    background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.4) 100%);
}

/* Text styles */
.output-line {
    line-height: 1.5;
    margin-bottom: 1px;
    text-shadow: 0 0 5px rgba(51, 255, 51, 0.4);
    /* Ensure text wraps on mobile */
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.output-line.location {
    color: #66ff66;
    font-size: 24px;
    margin-top: 12px;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.output-line.description {
    color: #33cc33;
    opacity: 0.9;
}

.output-line.system {
    color: #ffaa00;
}

.output-line.error {
    color: #ff4444;
}

.output-line.item {
    color: #33dddd;
}

.output-line.story {
    color: #aa88ff;
    font-style: italic;
}

.output-line.found {
    color: #ffdd00;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 221, 0, 0.5);
}

/* Quiz Option Styling */
.output-line.quiz-option {
    color: #88ccff;
    padding: 8px 12px;
    margin: 4px 0;
    border: 1px solid #446688;
    border-radius: 6px;
    background: rgba(68, 102, 136, 0.15);
    transition: all 0.2s ease;
}

.output-line.quiz-option.clickable-quiz-option {
    cursor: pointer;
}

.output-line.quiz-option:hover,
.output-line.quiz-option:active {
    color: #aaddff;
    border-color: #66aaff;
    background: rgba(102, 170, 255, 0.25);
    text-shadow: 0 0 8px rgba(102, 170, 255, 0.6);
    transform: translateX(5px);
}

/* Touch-friendly quiz options */
@media (pointer: coarse) {
    .output-line.quiz-option {
        padding: 12px 16px;
        margin: 6px 0;
        font-size: 18px;
        -webkit-tap-highlight-color: rgba(102, 170, 255, 0.3);
        touch-action: manipulation;
    }
}

/* Input */
.input-area {
    display: flex;
    margin-top: 15px;
    border-top: 1px solid #1a2a1a;
    padding-top: 10px;
}

.prompt {
    color: #33ff33;
    margin-right: 8px;
    text-shadow: 0 0 5px rgba(51, 255, 51, 0.5);
}

#input {
    flex: 1;
    background: transparent;
    border: none;
    color: #33ff33;
    font-family: 'VT323', monospace;
    font-size: 17px;
    outline: none;
    caret-color: #33ff33;
    text-shadow: 0 0 5px rgba(51, 255, 51, 0.5);
}

/* Boot animation */
.startup {
    animation: bootup 1.5s ease-out;
}

@keyframes bootup {
    0% { filter: blur(8px) brightness(2); opacity: 0; }
    30% { filter: blur(4px) brightness(1.5); opacity: 0.5; }
    100% { filter: blur(0.3px) brightness(1); opacity: 1; }
}

@keyframes blink {
    50% { opacity: 0; }
}

.glitch-block {
    position: absolute;
    background: rgba(51, 255, 51, 0.1);
    pointer-events: none;
    z-index: 15;
}

/* ============================================
   BAND MEMBER TRACKER
   ============================================ */

.tracker {
    margin-top: 30px;
    z-index: 10;
    position: relative;
}

.tracker-title {
    font-size: 10px;
    color: #444;
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-bottom: 15px;
    text-align: center;
}

.members {
    display: flex;
    gap: 30px;
    justify-content: center;
}

.member {
    text-align: center;
    opacity: 0.3;
    transition: opacity 0.5s, transform 0.3s;
}

.member.found {
    opacity: 1;
}

.member-icon {
    width: 50px;
    height: 50px;
    border: 1px solid #333;
    border-radius: 50%;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: #0a0a0a;
    transition: all 0.5s;
}

.member.found .member-icon {
    border-color: #33ff33;
    box-shadow: 0 0 15px rgba(51, 255, 51, 0.3);
    background: #0a1a0a;
}

.member-name {
    font-size: 10px;
    color: #555;
    letter-spacing: 2px;
}

.member.found .member-name {
    color: #33ff33;
}

/* Footer */
.footer {
    margin-top: 40px;
    text-align: center;
    z-index: 10;
    position: relative;
}

.footer p {
    font-size: 10px;
    color: #333;
    letter-spacing: 2px;
}

.hint-text {
    margin-top: 20px;
    font-size: 11px;
    color: #444;
}

.hint-text span {
    color: #33ff33;
}

.glitch-toggle {
    margin-top: 15px;
    background: transparent;
    border: 1px solid #333;
    color: #33ff33;
    font-family: 'VT323', monospace;
    font-size: 12px;
    padding: 8px 16px;
    cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.2s;
}

.glitch-toggle:hover {
    border-color: #33ff33;
    box-shadow: 0 0 10px rgba(51, 255, 51, 0.3);
}

.glitch-toggle.off {
    color: #666;
    border-color: #222;
}

/* Disable effects when glitch is off */
.glitch-disabled .scanlines,
.glitch-disabled .noise,
.glitch-disabled .glitch-overlay,
.glitch-disabled .flicker {
    display: none;
}

.glitch-disabled .terminal {
    filter: none;
}

.glitch-disabled .terminal.glitch-active,
.glitch-disabled .terminal.glitch-heavy {
    animation: none;
}

/* ============================================
   DIALOG MODE STYLES
   ============================================ */

.output-line.dialog-header {
    color: #ff88ff;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 136, 255, 0.5);
    letter-spacing: 2px;
}

.output-line.dialog-player {
    color: #88ccff;
    padding-left: 20px;
    text-shadow: 0 0 5px rgba(136, 204, 255, 0.4);
}

.output-line.dialog-npc {
    color: #ffcc88;
    padding-left: 20px;
    text-shadow: 0 0 5px rgba(255, 204, 136, 0.4);
}

/* Dialog hint */
.output-line.dialog-hint {
    color: #666;
    font-size: 14px;
    font-style: italic;
}

/* NPC Mood colors - dialog-{mood} format */
.output-line.dialog-friendly {
    color: #88ff88;
    padding-left: 20px;
    text-shadow: 0 0 5px rgba(136, 255, 136, 0.4);
}

.output-line.dialog-neutral {
    color: #ffcc88;
    padding-left: 20px;
    text-shadow: 0 0 5px rgba(255, 204, 136, 0.4);
}

.output-line.dialog-suspicious {
    color: #ffaa66;
    padding-left: 20px;
    text-shadow: 0 0 5px rgba(255, 170, 102, 0.4);
}

.output-line.dialog-excited {
    color: #ffff66;
    padding-left: 20px;
    text-shadow: 0 0 8px rgba(255, 255, 102, 0.5);
}

.output-line.dialog-sad {
    color: #8888cc;
    padding-left: 20px;
    text-shadow: 0 0 5px rgba(136, 136, 204, 0.4);
}

.output-line.dialog-angry {
    color: #ff6666;
    padding-left: 20px;
    text-shadow: 0 0 8px rgba(255, 102, 102, 0.5);
}

.output-line.dialog-drunk {
    color: #cc88ff;
    padding-left: 20px;
    text-shadow: 0 0 5px rgba(204, 136, 255, 0.4);
    font-style: italic;
}

.output-line.dialog-mysterious {
    color: #66ffcc;
    padding-left: 20px;
    text-shadow: 0 0 10px rgba(102, 255, 204, 0.6);
}

/* Dialog prompt styling */
.prompt.dialog-prompt {
    color: #ff88ff;
    text-shadow: 0 0 8px rgba(255, 136, 255, 0.5);
}

#input::placeholder {
    color: #555;
    font-style: italic;
}

/* ============================================
   MOBILE UI - Atmospheric CRT Interface
   ============================================ */

/* Mode Toggle Button */
.mode-toggle {
    background: rgba(10, 20, 10, 0.9);
    border: 1px solid #33ff33;
    color: #33ff33;
    padding: 8px 16px;
    font-family: 'VT323', monospace;
    font-size: 14px;
    cursor: pointer;
    margin-right: 10px;
    transition: all 0.3s;
    text-shadow: 0 0 8px rgba(51, 255, 51, 0.8);
}

.mode-toggle:hover {
    background: rgba(51, 255, 51, 0.15);
    box-shadow: 0 0 15px rgba(51, 255, 51, 0.3);
}

.mode-toggle.active {
    background: rgba(51, 255, 51, 0.2);
    border-color: #66ff66;
    animation: buttonGlow 2s ease-in-out infinite;
}

@keyframes buttonGlow {
    0%, 100% { box-shadow: 0 0 5px rgba(51, 255, 51, 0.3); }
    50% { box-shadow: 0 0 15px rgba(51, 255, 51, 0.6); }
}

/* Hide input in simple mode */
.simple-mode .input-area.hidden-mobile {
    display: none;
}

/* Mobile Panel Container */
.mobile-panel {
    background:
        linear-gradient(180deg, rgba(5, 15, 5, 0.98) 0%, rgba(0, 5, 0, 0.99) 100%);
    border-top: 2px solid #33ff33;
    padding: 12px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    /* Fixed at bottom of screen */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow:
        0 -5px 30px rgba(51, 255, 51, 0.15),
        inset 0 1px 0 rgba(51, 255, 51, 0.1);
}

/* CRT Scanline effect on panel */
.mobile-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1),
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 1;
}

.mobile-panel.hidden {
    display: none;
}

/* ============================================
   GLITCHY INPUT AREA
   ============================================ */
.mobile-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 10, 0, 0.8);
    border: 1px solid #33ff33;
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
    box-shadow:
        inset 0 0 20px rgba(51, 255, 51, 0.1),
        0 0 10px rgba(51, 255, 51, 0.2);
}

/* Flicker effect on input area */
.mobile-input-area::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(51, 255, 51, 0.03);
    animation: inputFlicker 4s infinite;
    pointer-events: none;
}

@keyframes inputFlicker {
    0%, 100% { opacity: 0; }
    92% { opacity: 0; }
    93% { opacity: 1; }
    94% { opacity: 0; }
    96% { opacity: 0.5; }
    97% { opacity: 0; }
}

/* ============================================
   COMMAND DISPLAY (anstelle Input-Feld)
   ============================================ */
.command-display {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 20, 0, 0.8);
    border: 1px solid #1a4a1a;
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 10px;
}

.command-prompt {
    color: #33ff33;
    font-family: 'VT323', monospace;
    font-size: 24px;
    text-shadow: 0 0 10px rgba(51, 255, 51, 0.8);
    animation: promptBlink 1s step-end infinite;
}

@keyframes promptBlink {
    50% { opacity: 0.7; }
}

.command-text {
    flex: 1;
    color: #1a5a1a;
    font-family: 'VT323', monospace;
    font-size: 22px;
    font-style: italic;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.command-text.has-command {
    color: #33ff33;
    font-style: normal;
    text-shadow: 0 0 8px rgba(51, 255, 51, 0.6);
}

.command-execute {
    background: linear-gradient(180deg, #1a3a1a 0%, #0a2a0a 100%);
    border: 2px solid #33ff33;
    border-radius: 6px;
    color: #33ff33;
    font-family: 'VT323', monospace;
    font-size: 22px;
    padding: 6px 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-shadow: 0 0 8px rgba(51, 255, 51, 0.8);
}

.command-execute:disabled {
    border-color: #1a3a1a;
    color: #1a3a1a;
    cursor: not-allowed;
    text-shadow: none;
}

.command-execute:not(:disabled):hover,
.command-execute:not(:disabled):active {
    background: rgba(51, 255, 51, 0.3);
    box-shadow: 0 0 15px rgba(51, 255, 51, 0.5);
}

/* Dialog-Mode: verstecke Command Display */
.mobile-panel.dialog-mode .command-display {
    display: none;
}

/* ============================================
   MOBILE CONTROLS LAYOUT - Unified Grid
   ============================================ */
.mobile-controls {
    display: grid;
    /* 2 verb cols | 3 dpad cols | 2 vert cols = 7 cols total */
    grid-template-columns: repeat(2, 1fr) 4px repeat(3, 1fr) 4px repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px;
    position: relative;
    z-index: 2;
    margin-top: 8px;
    max-width: 340px;
    margin-left: auto;
    margin-right: auto;
}

.verb-buttons {
    display: contents;
}

.verb-btn {
    background: linear-gradient(180deg, #1a2a1a 0%, #0a1a0a 100%);
    border: 2px solid #2a5a2a;
    border-radius: 6px;
    padding: 4px 2px;
    color: #5a8a5a;
    font-family: 'VT323', monospace;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    gap: 1px;
}

/* Verb button grid positions */
.verb-btn:nth-child(1) { grid-column: 1; grid-row: 1; }
.verb-btn:nth-child(2) { grid-column: 2; grid-row: 1; }
.verb-btn:nth-child(3) { grid-column: 1; grid-row: 2; }
.verb-btn:nth-child(4) { grid-column: 2; grid-row: 2; }
.verb-btn:nth-child(5) { grid-column: 1; grid-row: 3; }
.verb-btn.inv-btn { grid-column: 2; grid-row: 3; }

.verb-btn:active,
.verb-btn.selected {
    background: linear-gradient(180deg, #2a4a2a 0%, #1a3a1a 100%);
    border-color: #33ff33;
    color: #33ff33;
    text-shadow: 0 0 10px rgba(51, 255, 51, 0.8);
    box-shadow: 0 0 15px rgba(51, 255, 51, 0.3), inset 0 0 10px rgba(51, 255, 51, 0.1);
}

.verb-icon {
    font-size: 18px;
    line-height: 1;
}

.verb-label {
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 0px;
}

/* Inventory Button */
.inv-btn {
    background: linear-gradient(180deg, #2a3a2a 0%, #1a2a1a 100%) !important;
    border-color: #4a8a4a !important;
}

.inv-btn:hover,
.inv-btn:active {
    border-color: #66ff66 !important;
}

/* ============================================
   D-PAD NAVIGATION
   ============================================ */
.dpad-area {
    display: contents;
}

.dpad-with-vertical {
    display: contents;
}

.dpad {
    display: contents;
}

/* D-Pad button grid positions (columns 4-6) */
.dpad-nw { grid-column: 4; grid-row: 1; }
.dpad-up { grid-column: 5; grid-row: 1; }
.dpad-no { grid-column: 6; grid-row: 1; }
.dpad-left { grid-column: 4; grid-row: 2; }
.dpad-center { grid-column: 5; grid-row: 2; }
.dpad-right { grid-column: 6; grid-row: 2; }
.dpad-sw { grid-column: 4; grid-row: 3; }
.dpad-down { grid-column: 5; grid-row: 3; }
.dpad-so { grid-column: 6; grid-row: 3; }

/* Vertikale Richtungsbuttons (columns 8-9) */
.vertical-dirs {
    display: contents;
}

/* Vertical button grid positions */
.dir-btn-vert[data-dir="hoch"] { grid-column: 8; grid-row: 1; }
.dir-btn-vert[data-dir="runter"] { grid-column: 9; grid-row: 1; }
.dir-btn-vert[data-dir="rein"] { grid-column: 8; grid-row: 2; }
.dir-btn-vert[data-dir="raus"] { grid-column: 9; grid-row: 2; }

/* Empty space filler for row 3 columns 8-9 */
.vertical-dirs::after {
    content: '';
    grid-column: 8 / 10;
    grid-row: 3;
}

/* Tür-Buttons (REIN/RAUS) - deutlich anders gestylt */
.dir-btn-door {
    font-size: 11px !important;
    background: linear-gradient(180deg, #2a1a1a 0%, #1a0a0a 100%) !important;
    border-color: #664444 !important;
    color: #886666 !important;
}

.dir-btn-door.available {
    background: linear-gradient(180deg, #3a2a1a 0%, #2a1a0a 100%) !important;
    border-color: #cc8844 !important;
    color: #ffaa66 !important;
    text-shadow: 0 0 5px rgba(255, 170, 102, 0.5);
}

.dir-btn-door.available:active {
    background: rgba(255, 170, 102, 0.3) !important;
    box-shadow: 0 0 10px rgba(255, 170, 102, 0.5);
}

.dir-btn-vert {
    background: linear-gradient(180deg, #1a1a2a 0%, #0a0a1a 100%);
    border: 2px solid #333;
    border-radius: 6px;
    color: #444;
    font-family: 'VT323', monospace;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px 4px;
    white-space: nowrap;
}

.dir-btn-vert.available {
    color: #6688ff;
    border-color: #4466cc;
    text-shadow: 0 0 5px rgba(102, 136, 255, 0.5);
    background: linear-gradient(180deg, #1a1a3a 0%, #0a0a2a 100%);
}

.dir-btn-vert.available:active {
    background: rgba(102, 136, 255, 0.3);
    box-shadow: 0 0 10px rgba(102, 136, 255, 0.5);
    transform: scale(0.95);
}

.dir-btn-vert.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    color: #333;
    border-color: #222;
    background: linear-gradient(180deg, #121218 0%, #080810 100%);
}

.dpad-btn {
    background: linear-gradient(180deg, #1a1a2a 0%, #0a0a1a 100%);
    border: 2px solid #333;
    border-radius: 6px;
    color: #444;
    font-family: 'VT323', monospace;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
}

.dpad-center {
    background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
    border-color: #555;
    color: #888;
    font-size: 14px;
}

.dpad-btn.available {
    color: #6688ff;
    border-color: #4466cc;
    text-shadow: 0 0 5px rgba(102, 136, 255, 0.5);
    background: linear-gradient(180deg, #1a1a3a 0%, #0a0a2a 100%);
}

.dpad-btn.available:active {
    background: rgba(102, 136, 255, 0.3);
    box-shadow: 0 0 10px rgba(102, 136, 255, 0.5);
    transform: scale(0.95);
}

.dpad-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    color: #333;
    border-color: #222;
    background: linear-gradient(180deg, #121218 0%, #080810 100%);
}

.dpad-center.available {
    color: #aaa;
    border-color: #666;
}


/* Clickable Objects in Text */
.clickable-object {
    color: #ffcc00;
    text-decoration: underline;
    text-decoration-style: dotted;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0 2px;
}

.clickable-object:hover,
.clickable-object:active {
    color: #ffff00;
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.8);
    background: rgba(255, 204, 0, 0.1);
}

/* Clickable Locations/Directions in Text */
.clickable-location {
    color: #66aaff;
    text-decoration: underline;
    text-decoration-style: dotted;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0 2px;
}

.clickable-location:hover,
.clickable-location:active {
    color: #99ccff;
    text-shadow: 0 0 10px rgba(102, 170, 255, 0.8);
    background: rgba(102, 170, 255, 0.1);
}

/* Inventory Panel */
.inventory-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 20, 20, 0.98);
    border: 2px solid #66ff66;
    border-radius: 8px;
    padding: 0;
    min-width: 280px;
    max-width: 90vw;
    max-height: 70vh;
    z-index: 2000;
    box-shadow: 0 0 40px rgba(102, 255, 102, 0.3);
    overflow: hidden;
}

.inventory-panel.hidden {
    display: none;
}

.inv-header {
    background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #444;
    color: #66ff66;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(102, 255, 102, 0.5);
}

.inv-close {
    background: none;
    border: none;
    color: #888;
    font-size: 18px;
    cursor: pointer;
    padding: 0 5px;
}

.inv-close:hover {
    color: #ff6666;
}

.inv-items {
    padding: 10px;
    max-height: 50vh;
    overflow-y: auto;
}

.inv-item {
    background: rgba(40, 40, 40, 0.8);
    border: 1px solid #444;
    border-radius: 4px;
    padding: 12px 15px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.inv-item:hover,
.inv-item:active {
    border-color: #66ff66;
    background: rgba(102, 255, 102, 0.1);
}

.inv-item-name {
    color: #ddd;
    font-family: 'Courier New', monospace;
}

.inv-empty {
    color: #666;
    text-align: center;
    padding: 20px;
    font-style: italic;
}

/* Dialog Mode in Mobile */
.mobile-panel.dialog-mode .mobile-controls {
    display: none;
}

/* Dialog Controls - nur im Dialog-Modus sichtbar */
.dialog-controls {
    display: none;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.mobile-panel.dialog-mode .dialog-controls {
    display: flex;
}

/* Dialog Input Area - nur im Dialog sichtbar */
.dialog-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    background: rgba(0, 20, 0, 0.8);
    border: 2px solid #33ff33;
    border-radius: 8px;
    padding: 8px 12px;
}

.dialog-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #33ff33;
    font-family: 'VT323', monospace;
    font-size: 20px;
    outline: none;
    caret-color: #33ff33;
    text-shadow: 0 0 8px rgba(51, 255, 51, 0.6);
    min-width: 0;
}

.dialog-input::placeholder {
    color: #1a5a1a;
    font-style: italic;
}

.dialog-send {
    background: linear-gradient(180deg, #1a3a1a 0%, #0a2a0a 100%);
    border: 2px solid #33ff33;
    border-radius: 6px;
    color: #33ff33;
    font-size: 20px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.dialog-send:active {
    background: rgba(51, 255, 51, 0.3);
    box-shadow: 0 0 15px rgba(51, 255, 51, 0.5);
}

/* Audio Record Button */
.dialog-record-btn {
    background: linear-gradient(180deg, #2a1a2a 0%, #1a0a1a 100%);
    border: 2px solid #aa44aa;
    border-radius: 6px;
    color: #cc66cc;
    font-size: 18px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.dialog-record-btn:hover {
    border-color: #cc66cc;
    box-shadow: 0 0 10px rgba(204, 102, 204, 0.3);
}

.dialog-record-btn:active {
    background: rgba(204, 102, 204, 0.3);
}

/* Recording state - pulsing red */
.dialog-record-btn.recording {
    background: linear-gradient(180deg, #3a1a1a 0%, #2a0a0a 100%);
    border-color: #ff4444;
    color: #ff6666;
    animation: recordingPulse 1s ease-in-out infinite;
}

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

/* Processing state */
.dialog-record-btn.processing {
    background: linear-gradient(180deg, #2a2a1a 0%, #1a1a0a 100%);
    border-color: #aaaa44;
    color: #cccc66;
    cursor: wait;
    animation: processingPulse 0.5s ease-in-out infinite;
}

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

.dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.dialog-exit-btn {
    background: linear-gradient(180deg, #2a1a1a 0%, #1a0a0a 100%);
    border: 2px solid #ff6666;
    border-radius: 8px;
    padding: 10px 16px;
    color: #ff6666;
    font-family: 'VT323', monospace;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dialog-exit-btn:hover,
.dialog-exit-btn:active {
    background: rgba(255, 102, 102, 0.2);
    box-shadow: 0 0 15px rgba(255, 102, 102, 0.3);
    text-shadow: 0 0 8px rgba(255, 102, 102, 0.8);
}

/* Hint Button */
.dialog-hint-btn {
    background: linear-gradient(180deg, #2a2a1a 0%, #1a1a0a 100%);
    border: 2px solid #ffcc00;
    border-radius: 8px;
    padding: 10px 14px;
    color: #ffcc00;
    font-family: 'VT323', monospace;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.dialog-hint-btn:hover,
.dialog-hint-btn:active {
    background: rgba(255, 204, 0, 0.2);
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.3);
    text-shadow: 0 0 8px rgba(255, 204, 0, 0.8);
}

.dialog-hint-btn.active {
    background: rgba(255, 204, 0, 0.3);
    border-color: #ffdd44;
    box-shadow: 0 0 10px rgba(255, 204, 0, 0.4);
}

.dialog-hint-btn.has-hint {
    animation: hintPulse 2s ease-in-out infinite;
}

@keyframes hintPulse {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 204, 0, 0.2); }
    50% { box-shadow: 0 0 15px rgba(255, 204, 0, 0.5); }
}

/* Verstecke Hints standardmäßig im Simple Mode */
.simple-mode .output-line.dialog-hint {
    display: none;
}

/* Zeige Hints wenn aktiviert */
.simple-mode.show-hints .output-line.dialog-hint {
    display: block;
    background: rgba(255, 204, 0, 0.1);
    border-left: 3px solid #ffcc00;
    padding-left: 10px;
    margin: 5px 0;
}

/* ============================================
   MOBILE-OPTIMIZED TERMINAL
   ============================================ */

/* Simple mode: Classic flexbox sticky footer layout */
body.simple-mode {
    /* Flex container for sticky footer pattern */
    display: flex;
    flex-direction: column;
    /* Full viewport height */
    height: 100vh;
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100);
    /* Prevent scrolling on body itself */
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Content area: takes all available space */
.simple-mode .page-container {
    flex: 1;
    min-height: 0; /* Critical for flex children to shrink */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 6px;
    padding-top: calc(6px + env(safe-area-inset-top, 0px));
    padding-bottom: 0;
}

/* Panel: fixed height at bottom */
.simple-mode .mobile-panel {
    flex-shrink: 0;
    position: relative; /* Not fixed! Part of flex layout */
    bottom: auto;
    left: auto;
    right: auto;
    /* Extra padding for browser toolbar on iOS */
    padding-bottom: calc(130px + env(safe-area-inset-bottom, 0px));
}

.simple-mode .terminal-wrapper {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.simple-mode .terminal-frame {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 4px;
    overflow: hidden;
}

.simple-mode .terminal-container {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.simple-mode .terminal {
    height: 100%;
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 10px;
    /* Extra space at bottom so text doesn't stick to edge */
    padding-bottom: 40px;
}

.simple-mode .header {
    margin-bottom: 4px;
    flex-shrink: 0;
}

.simple-mode .header h1 {
    font-size: 18px;
    letter-spacing: 4px;
    margin-bottom: 2px;
}

.simple-mode .header .subtitle {
    display: none;
}

.simple-mode .status-bar {
    margin-bottom: 4px;
    gap: 10px;
    font-size: 9px;
    flex-shrink: 0;
}

.simple-mode .tracker,
.simple-mode .footer {
    display: none;
}


/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

/* Mobile viewport */
@media (max-width: 768px) {
    .page-container {
        padding: 10px;
    }

    .header h1 {
        font-size: 28px;
        letter-spacing: 6px;
    }

    .header .subtitle {
        font-size: 9px;
        letter-spacing: 3px;
    }

    .terminal-container {
        width: 100%;
    }

    .terminal {
        font-size: 18px;
        padding: 10px;
        line-height: 1.4;
    }

    .output-line.location {
        font-size: 22px;
    }

    .footer {
        flex-wrap: wrap;
        gap: 8px;
    }

    .mode-toggle {
        order: -1;
        width: 100%;
        text-align: center;
        padding: 10px;
        font-size: 14px;
    }

    /* Mobile Controls Grid - passt sich automatisch an */
    .mobile-controls {
        max-width: 100%;
        gap: 2px;
    }

    .verb-btn {
        min-height: 38px;
    }

    .verb-icon {
        font-size: 16px;
    }

    .verb-label {
        font-size: 9px;
    }

    .dpad-btn {
        font-size: 10px;
        min-height: 38px;
    }

    .dir-btn-vert {
        font-size: 12px;
    }

    .dir-btn-door {
        font-size: 9px !important;
    }

    /* Command Display */
    .command-text {
        font-size: 18px;
    }

    .command-execute {
        font-size: 18px;
        padding: 4px 10px;
    }

    /* Dialog Input */
    .dialog-input {
        font-size: 16px;
    }

    .mobile-panel {
        padding: 10px;
        padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    }

    .simple-mode .page-container {
        padding: 5px;
        padding-top: calc(5px + env(safe-area-inset-top, 0px));
    }

    .simple-mode .header h1 {
        font-size: 16px;
        letter-spacing: 3px;
    }

    .simple-mode .status-bar {
        font-size: 8px;
        gap: 8px;
        margin-bottom: 3px;
    }
}

/* Small phones */
@media (max-width: 400px) {
    .header h1 {
        font-size: 20px;
        letter-spacing: 4px;
    }

    .terminal {
        font-size: 16px;
        padding: 8px;
        padding-bottom: 60px;
    }

    /* Kleines Grid für kleine Phones */
    .mobile-controls {
        gap: 2px;
    }

    .verb-btn {
        min-height: 34px;
    }

    .verb-icon {
        font-size: 14px;
    }

    .verb-label {
        font-size: 7px;
    }

    .dpad-btn {
        font-size: 9px;
        min-height: 34px;
    }

    .dir-btn-vert {
        font-size: 11px;
    }

    .dir-btn-door {
        font-size: 8px !important;
    }

    /* Command Display */
    .command-display {
        padding: 6px 8px;
    }

    .command-text {
        font-size: 16px;
    }

    .command-execute {
        font-size: 16px;
        padding: 3px 8px;
    }

    /* Dialog */
    .dialog-input {
        font-size: 16px;
    }

    .dialog-exit-btn {
        font-size: 16px;
        padding: 8px 12px;
    }

    .dialog-hint-btn {
        font-size: 18px;
        padding: 8px 12px;
    }

    .mobile-panel {
        padding: 8px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    .simple-mode .page-container {
        padding: 4px;
        padding-top: calc(4px + env(safe-area-inset-top, 0px));
    }

    .simple-mode .header h1 {
        font-size: 14px;
        letter-spacing: 2px;
    }

    .simple-mode .status-bar {
        font-size: 7px;
        gap: 6px;
        margin-bottom: 2px;
    }
}

/* Landscape phone */
@media (max-height: 500px) and (orientation: landscape) {
    .mobile-panel {
        padding: 6px 10px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .mobile-input-area {
        padding: 3px 6px;
        margin-bottom: 4px;
    }

    .mobile-controls {
        gap: 2px;
        margin-top: 2px;
        max-width: 400px;
    }

    .verb-btn {
        min-height: 26px;
    }

    .verb-icon {
        font-size: 12px;
    }

    .verb-label {
        display: none;
    }

    .dpad-btn {
        font-size: 8px;
        min-height: 26px;
    }

    .dir-btn-vert {
        font-size: 10px;
    }

    .dir-btn-door {
        font-size: 7px !important;
    }

    .simple-mode .page-container {
        padding: 3px;
    }

    .simple-mode .header {
        display: none;
    }

    .simple-mode .status-bar {
        display: none;
    }

    .command-display {
        padding: 4px 6px;
        margin-bottom: 2px;
    }

    .command-text {
        font-size: 14px;
    }

    .command-execute {
        font-size: 12px;
        padding: 2px 6px;
    }
}

/* Touch-friendly hit areas */
@media (pointer: coarse) {
    .clickable-object {
        padding: 3px 5px;
        margin: -3px -5px;
        display: inline-block;
        /* Fix iOS click delay */
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(255, 204, 0, 0.3);
    }

    .clickable-location {
        /* Fix iOS click delay */
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(102, 170, 255, 0.3);
    }

    .verb-btn {
        min-width: 40px;
        min-height: 40px;
        /* iOS touch improvements */
        -webkit-tap-highlight-color: rgba(51, 255, 51, 0.3);
        touch-action: manipulation;
    }

    .dpad-btn {
        min-width: 28px;
        min-height: 24px;
        /* iOS touch improvements */
        -webkit-tap-highlight-color: rgba(102, 136, 255, 0.3);
        touch-action: manipulation;
    }

    .dir-btn-vert {
        /* iOS touch improvements */
        -webkit-tap-highlight-color: rgba(102, 136, 255, 0.3);
        touch-action: manipulation;
    }

    /* Fix 300ms click delay on iOS */
    button, .clickable-object, .clickable-location, .inv-item {
        touch-action: manipulation;
    }
}

/* Prevent text selection on buttons */
button, .verb-btn, .dpad-btn, .dir-btn-vert, .clickable-object, .clickable-location {
    -webkit-user-select: none;
    user-select: none;
}

/* Fix for iOS Safari address bar issues */
@supports (-webkit-touch-callout: none) {
    /* iOS specific fixes */
    .simple-mode .page-container {
        /* Use -webkit-fill-available as additional fallback */
        min-height: -webkit-fill-available;
    }

    .mobile-panel {
        /* Ensure panel stays at bottom on iOS */
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 20px));
    }
}
