/* Indigo Rising - Cyberpunk UI Theme */

:root {
    --cyan: #00ffff;
    --magenta: #ff00ff;
    --neon-pink: #ff0088;
    --neon-blue: #4488ff;
    --neon-green: #00ff88;
    --gold: #ffaa00;
    --dark-bg: #0a0a1a;
    --panel-bg: rgba(10, 10, 30, 0.92);
    --panel-border: rgba(0, 255, 255, 0.3);
    --text-primary: #e0e0ff;
    --text-secondary: #8888bb;
    --font-main: 'Courier New', 'Consolas', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--dark-bg);
    font-family: var(--font-main);
    color: var(--text-primary);
    cursor: crosshair;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
}

#ui-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* Overlay base */
.morpheis-overlay {
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

/* Dialogue System */
.dialogue-overlay {
    justify-content: flex-end !important;
    padding: 0 5% 3%;
}

.dialogue-box {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 20px 24px;
    max-width: 900px;
    width: 100%;
    position: relative;
    box-shadow:
        0 0 20px rgba(0, 255, 255, 0.1),
        inset 0 0 30px rgba(0, 0, 0, 0.5);
    animation: dialogueSlideIn 0.3s ease;
}

.dialogue-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 255, 255, 0.015) 2px,
        rgba(0, 255, 255, 0.015) 4px
    );
    pointer-events: none;
    border-radius: 8px;
}

.dialogue-portrait-container {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
}

.dialogue-portrait {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid var(--cyan);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

.dialogue-content {
    flex: 1;
    min-width: 0;
}

.dialogue-name {
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
    text-shadow: 0 0 10px currentColor;
}

.dialogue-text {
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    min-height: 48px;
}

.dialogue-indicator {
    position: absolute;
    bottom: 10px;
    right: 16px;
    color: var(--cyan);
    font-size: 12px;
    animation: dialogueBlink 1s ease infinite;
    opacity: 0;
}

/* HUD */
.hud-overlay {
    pointer-events: none;
}

.hud-element {
    font-family: var(--font-main);
    color: var(--text-primary);
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.5);
}

.hud-score {
    font-size: 24px;
    font-weight: bold;
    color: var(--gold);
    text-shadow: 0 0 10px rgba(255, 170, 0, 0.5);
    background: rgba(0, 10, 20, 0.7);
    border: 1px solid rgba(255, 170, 0, 0.3);
    border-radius: 4px;
    padding: 8px 16px;
}

.hud-shots {
    font-size: 18px;
    display: flex;
    gap: 8px;
    background: rgba(0, 10, 20, 0.7);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 4px;
    padding: 8px 12px;
}

.hud-shot-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.5);
    transition: opacity 0.3s;
}

.hud-shot-icon.used {
    opacity: 0.2;
    background: #444;
    box-shadow: none;
}

.ability-indicator {
    background: rgba(0, 20, 30, 0.8);
    border: 1px solid rgba(0, 255, 255, 0.5);
    border-radius: 4px;
    padding: 10px 24px;
    text-shadow: 0 0 10px #00ffff, 0 0 20px rgba(0, 255, 255, 0.3);
    animation: glowPulse 2s ease infinite;
}

/* Menu/Screen panels */
.screen-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    box-shadow:
        0 0 40px rgba(0, 255, 255, 0.1),
        inset 0 0 60px rgba(0, 0, 0, 0.5);
    max-width: 600px;
    width: 90%;
}

.screen-title {
    font-size: 48px;
    font-weight: bold;
    color: var(--cyan);
    text-transform: uppercase;
    letter-spacing: 6px;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
    margin-bottom: 8px;
}

.screen-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 40px;
}

/* Buttons */
.cyber-btn {
    display: inline-block;
    padding: 14px 36px;
    font-family: var(--font-main);
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--cyan);
    background: rgba(0, 255, 255, 0.05);
    border: 1px solid var(--cyan);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    pointer-events: auto;
    text-decoration: none;
    margin: 6px;
}

.cyber-btn:hover {
    background: rgba(0, 255, 255, 0.15);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
    transform: translateY(-2px);
}

.cyber-btn:active {
    transform: translateY(0);
}

.cyber-btn--primary {
    color: var(--dark-bg);
    background: var(--cyan);
    border-color: var(--cyan);
}

.cyber-btn--primary:hover {
    background: #33ffff;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.5);
}

.cyber-btn--danger {
    color: var(--neon-pink);
    border-color: var(--neon-pink);
    background: rgba(255, 0, 136, 0.05);
}

.cyber-btn--danger:hover {
    background: rgba(255, 0, 136, 0.15);
    box-shadow: 0 0 20px rgba(255, 0, 136, 0.3);
}

.cyber-btn.locked {
    pointer-events: none;
    opacity: 0.4;
    cursor: not-allowed;
}

/* Star ratings */
.stars-container {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin: 20px 0;
}

.star {
    font-size: 40px;
    color: #333;
    transition: all 0.3s ease;
}

.star.earned {
    color: var(--gold);
    text-shadow: 0 0 15px rgba(255, 170, 0, 0.5);
    animation: starPop 0.5s ease;
}

/* Level grid */
.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
    max-width: 500px;
    margin: 0 auto;
}

.level-btn {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 8px;
    font-family: var(--font-main);
    font-size: 24px;
    font-weight: bold;
    color: var(--cyan);
    background: rgba(0, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    cursor: pointer;
    transition: all 0.2s ease;
    pointer-events: auto;
}

.level-btn:hover {
    background: rgba(0, 255, 255, 0.15);
    border-color: var(--cyan);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
}

.level-btn.locked {
    color: #444;
    border-color: #222;
    cursor: not-allowed;
    pointer-events: none;
}

.level-btn .level-stars {
    font-size: 10px;
    color: var(--gold);
}

/* Progress bar */
.progress-bar {
    width: 300px;
    height: 6px;
    background: #1a1a2e;
    border-radius: 3px;
    overflow: hidden;
    margin: 20px auto;
    border: 1px solid var(--panel-border);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--cyan), var(--neon-blue));
    border-radius: 3px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

/* Lore text */
.lore-text {
    font-size: 18px;
    line-height: 1.8;
    color: var(--text-primary);
    max-width: 700px;
    margin: 0 auto;
    text-align: left;
}

.lore-highlight {
    color: var(--cyan);
    font-weight: bold;
}

/* Animations */
@keyframes dialogueSlideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

@keyframes starPop {
    0% { transform: scale(0); }
    60% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

@keyframes glowPulse {
    0%, 100% { text-shadow: 0 0 10px rgba(0, 255, 255, 0.3); }
    50% { text-shadow: 0 0 20px rgba(0, 255, 255, 0.6), 0 0 40px rgba(0, 255, 255, 0.2); }
}

@keyframes scanline {
    0% { background-position: 0 0; }
    100% { background-position: 0 4px; }
}

.glow-pulse {
    animation: glowPulse 2s ease infinite;
}

/* Pause overlay */
.pause-backdrop {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

/* Offline banner */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(40, 10, 0, 0.85);
    border-bottom: 1px solid rgba(255, 100, 0, 0.3);
    color: #ff8844;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-family: 'Rajdhani', 'Courier New', monospace;
    pointer-events: none;
    animation: offlineFadeIn 0.6s ease;
}

.offline-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ff4444;
    box-shadow: 0 0 6px #ff4444;
    animation: offlineBlink 1.5s ease infinite;
    flex-shrink: 0;
}

@keyframes offlineFadeIn {
    from { opacity: 0; transform: translateY(-100%); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* Touch active states (duplicate hover for touch) */
.cyber-btn:active {
    background: rgba(0, 255, 255, 0.15);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
}

.cyber-btn--primary:active {
    background: #33ffff;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.5);
}

.cyber-btn--danger:active {
    background: rgba(255, 0, 136, 0.15);
    box-shadow: 0 0 20px rgba(255, 0, 136, 0.3);
}

.level-btn:active:not(.locked) {
    background: rgba(0, 255, 255, 0.15);
    border-color: var(--cyan);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
}

/* Portrait orientation warning */
.portrait-warning {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 99999;
    background: var(--dark-bg);
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 20px;
    font-family: var(--font-main);
    color: var(--cyan);
    text-align: center;
    padding: 40px;
}

.portrait-warning-icon {
    font-size: 48px;
    animation: rotateDevice 2s ease infinite;
}

@keyframes rotateDevice {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-90deg); }
    75% { transform: rotate(-90deg); }
}

@media (orientation: portrait) and (max-width: 1024px) {
    .portrait-warning {
        display: flex;
    }
}

/* Phone: max-width 768px */
@media (max-width: 768px) {
    .screen-title {
        font-size: 28px !important;
        letter-spacing: 3px;
    }
    .screen-subtitle {
        font-size: 11px;
        margin-bottom: 24px;
    }
    .screen-panel {
        padding: 24px 16px;
    }
    .cyber-btn {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 24px;
        font-size: 13px;
    }
    .level-btn {
        min-width: 56px;
        min-height: 56px;
    }
    .level-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 8px;
    }
    .progress-bar {
        width: min(300px, 80vw);
    }
    .dialogue-box {
        padding: 14px 16px;
        gap: 12px;
    }
    .dialogue-portrait-container {
        width: 60px;
        height: 60px;
    }
    .dialogue-name {
        font-size: 11px;
    }
    .dialogue-text {
        font-size: 13px;
        line-height: 1.4;
    }
    .hud-score {
        font-size: 18px;
    }
    .lore-text {
        font-size: 14px;
        line-height: 1.6;
    }
    .offline-banner {
        font-size: 9px;
        padding: 6px 12px;
    }
}

/* Tablet: 769px - 1024px */
@media (min-width: 769px) and (max-width: 1024px) {
    .screen-title {
        font-size: 38px !important;
    }
    .cyber-btn {
        min-height: 44px;
        min-width: 44px;
    }
    .level-btn {
        min-width: 56px;
        min-height: 56px;
    }
    .progress-bar {
        width: min(300px, 85vw);
    }
}

/* iOS safe area insets */
@supports (padding-top: env(safe-area-inset-top)) {
    .offline-banner {
        padding-top: calc(8px + env(safe-area-inset-top));
    }
    .hud-element {
        padding-top: env(safe-area-inset-top);
    }
}
