/* ==========================================
   1. VARIABLEN & GRUNDGERÜST
   ========================================== */
:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-color: #ffffff;
    --theme-color: #00f2ff; /* Dynamisch via JS */
    --success-color: #39ff14;
    --error-color: #ff0000;
}

body {
    margin: 0;
    font-family: -apple-system, system-ui, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    touch-action: none; /* Verhindert ungewolltes Scrollen/Zoomen am iPad */
}

.stage {
    width: 100%;
    max-width: 800px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}

.hidden { display: none !important; }

/* ==========================================
   2. WELTKARTE & PORTALE
   ========================================== */
.portal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 50px;
}

.portal {
    background: var(--card-bg);
    border: 3px solid var(--color);
    color: var(--color);
    padding: 40px 20px;
    border-radius: 15px;
    font-size: 1.5rem;
    box-shadow: 0 0 10px var(--color), inset 0 0 5px var(--color);
    text-shadow: 0 0 5px var(--color);
    transition: transform 0.2s;
    cursor: pointer;
}

.portal:active { transform: scale(0.95); }

/* ==========================================
   3. POV-TUNNEL (RUNNING STATE)
   ========================================== */
#tunnel-scene {
    position: relative;
    height: 300px;
    background: radial-gradient(circle, #1e1e1e 0%, #000 100%);
    border-radius: 20px;
    overflow: hidden;
    perspective: 1000px;
    border: 2px solid rgba(255,255,255,0.1);
    transition: box-shadow 0.3s; /* Für Treffer-Flash */
}

/* Die fliegenden Einheiten */
.collectible {
    position: absolute;
    left: 50%;
    top: 50%;
    transform-origin: center;
    color: var(--theme-color);
    text-shadow: 0 0 10px var(--theme-color);
    font-weight: bold;
    pointer-events: none;
    animation: flyForward 2s cubic-bezier(0.55, 0.055, 0.675, 0.19) forwards;
}

.collectible.obstacle {
    color: var(--error-color);
    text-shadow: 0 0 10px var(--error-color);
}

@keyframes flyForward {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    20% { opacity: 1; }
    100% { 
        transform: translate(calc(-50% + var(--target-x)), calc(-50% + 150px)) scale(5); 
        opacity: 0; 
    }
}

/* Der Spieler (POV Hände/Marker) */
#pov-character {
    position: absolute;
    bottom: 20px;
    left: 50%;
    width: 80px;
    height: 10px;
    background: var(--theme-color);
    border-radius: 5px;
    box-shadow: 0 0 20px var(--theme-color);
    transition: transform 0.15s ease-out;
    transform: translateX(-50%);
}

/* ==========================================
   4. GAME-UI & RECHNEN (GATE STATE)
   ========================================== */
.hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

#level-title { font-weight: bold; color: var(--theme-color); }

.task-display {
    font-size: 2.5rem;
    text-align: center;
    margin: 30px 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.unit-label {
    font-size: 1.2rem;
    margin-left: 8px;
    color: var(--theme-color);
    opacity: 0.8;
}

.input-box {
    min-width: 140px;
    padding: 10px;
    background: #000;
    border-bottom: 4px solid var(--theme-color);
    margin: 0 15px;
    color: var(--theme-color);
    text-shadow: 0 0 10px var(--theme-color);
}

/* Fortschritts-Punkte am Tor */
#progress-dots {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.dot {
    width: 15px;
    height: 15px;
    border: 2px solid #333;
    border-radius: 50%;
    transition: all 0.3s;
}

.dot.filled {
    background: var(--theme-color);
    border-color: var(--theme-color);
    box-shadow: 0 0 15px var(--theme-color);
}

/* ==========================================
   5. NUMPAD
   ========================================== */
.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: auto;
    padding-bottom: 20px;
}

.numpad button {
    background: #333;
    border: none;
    color: white;
    padding: 25px;
    border-radius: 12px;
    font-size: 1.6rem;
    touch-action: manipulation;
}

.numpad button:active { background: #444; }

.numpad .confirm {
    grid-column: span 3;
    background: #28a745;
    font-weight: bold;
}

.numpad .confirm:active { background: #218838; }

/* ==========================================
   6. EFFEKTE & ANIMATIONEN
   ========================================== */
.shake { animation: shakeAnim 0.5s; }
@keyframes shakeAnim {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.success-flash { animation: successAnim 0.6s ease-out; }
@keyframes successAnim {
    50% { background-color: rgba(40, 167, 69, 0.2); }
}

/* Für das iPad-Feeling beim Tippen */
button { -webkit-tap-highlight-color: transparent; }