/* ==========================================================================
   Grendizer Epic - Master Stylesheet
   Designed by Antigravity (Senior Level UI/UX)
   ========================================================================== */

/* --- 1. CSS VARIABLES & TOKENS --- */
:root {
    /* Colors */
    --bg-dark: #050914;
    --bg-darker: #02040a;
    --primary-blue: #00d2ff;
    --primary-blue-glow: rgba(0, 210, 255, 0.6);
    --secondary-blue: #3a7bd5;
    --accent-red: #ff2a2a;
    --accent-red-glow: rgba(255, 42, 42, 0.6);
    --gold: #ffd700;
    --gold-glow: rgba(255, 215, 0, 0.6);
    --silver: #c0c0c0;
    --health-green: #00ff88;
    --energy-cyan: #00e5ff;
    --text-main: #ffffff;
    --text-muted: #a0aec0;
    --glass-bg: rgba(16, 25, 48, 0.65);
    --glass-border: rgba(0, 210, 255, 0.2);
    
    /* Typography */
    --font-arabic: 'Cairo', sans-serif;
    --font-en: 'Orbitron', sans-serif;
    
    /* Spacing & Borders */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- 2. RESET & BASE --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-arabic);
    overflow: hidden; /* Prevent scrolling, app-like feel */
    height: 100vh;
    width: 100vw;
    user-select: none;
}

#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

#dynamic-bg-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    background-color: var(--bg-dark);
}

#dynamic-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.3;
    transition: opacity 1s ease, transform 10s ease-in-out;
    transform: scale(1.05);
}

#dynamic-bg.bg-zoom {
    transform: scale(1.15);
}

#fx-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s ease-out;
}
.flash-red { background-color: rgba(255, 0, 0, 0.4); opacity: 1 !important; }
.flash-white { background-color: rgba(255, 255, 255, 0.6); opacity: 1 !important; }

#app-container {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
}

/* --- 3. GLASSMORPHISM UTILITIES --- */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(0, 210, 255, 0.05);
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
}
.glass-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.05), transparent);
    transform: skewX(-20deg);
    animation: glassShine 6s infinite;
}

@keyframes glassShine {
    0% { left: -100%; }
    20% { left: 200%; }
    100% { left: 200%; }
}

/* --- 4. TYPOGRAPHY & GLOW --- */
h1, h2, h3, h4 {
    font-weight: 700;
    letter-spacing: 1px;
}

.text-glow {
    text-shadow: 0 0 10px currentColor;
}
.text-gold { color: var(--gold); }
.text-silver { color: var(--silver); }
.text-blue { color: var(--primary-blue); }

.glitch {
    position: relative;
    font-size: 3.5rem;
    font-weight: 900;
    text-transform: uppercase;
    color: var(--text-main);
    text-shadow: 0 0 20px var(--primary-blue);
    margin-bottom: 0.5rem;
}
.glitch::before, .glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
}
.glitch::before {
    left: 2px;
    text-shadow: -2px 0 var(--accent-red);
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-anim-2 3s infinite linear alternate-reverse;
}
.glitch::after {
    left: -2px;
    text-shadow: -2px 0 var(--primary-blue);
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-anim 2.5s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% { clip: rect(10px, 9999px, 83px, 0); }
    20% { clip: rect(61px, 9999px, 15px, 0); }
    40% { clip: rect(98px, 9999px, 2px, 0); }
    60% { clip: rect(35px, 9999px, 92px, 0); }
    80% { clip: rect(5px, 9999px, 54px, 0); }
    100% { clip: rect(72px, 9999px, 46px, 0); }
}
@keyframes glitch-anim-2 {
    0% { clip: rect(65px, 9999px, 100px, 0); }
    20% { clip: rect(12px, 9999px, 59px, 0); }
    40% { clip: rect(83px, 9999px, 4px, 0); }
    60% { clip: rect(48px, 9999px, 72px, 0); }
    80% { clip: rect(2px, 9999px, 27px, 0); }
    100% { clip: rect(91px, 9999px, 66px, 0); }
}

/* --- 5. BUTTONS & INPUTS --- */
.cyber-btn {
    position: relative;
    padding: 1rem 2rem;
    background: transparent;
    border: 1px solid var(--primary-blue);
    color: var(--primary-blue);
    font-family: var(--font-arabic);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    overflow: hidden;
    transition: var(--transition-smooth);
    border-radius: 4px;
    box-shadow: inset 0 0 0 rgba(0,210,255,0), 0 0 10px rgba(0,210,255,0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
}
.cyber-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-blue);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.4s cubic-bezier(0.86, 0, 0.07, 1);
    z-index: -1;
}
.cyber-btn:hover {
    color: var(--bg-dark);
    box-shadow: 0 0 20px var(--primary-blue-glow);
}
.cyber-btn:hover::before {
    transform: scaleX(1);
    transform-origin: left;
}
.cyber-btn.secondary {
    border-color: var(--silver);
    color: var(--silver);
}
.cyber-btn.secondary::before {
    background: var(--silver);
}
.cyber-btn.danger {
    border-color: var(--accent-red);
    color: var(--accent-red);
}
.cyber-btn.danger::before {
    background: var(--accent-red);
}
.cyber-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #555;
    color: #888;
}

.input-group {
    position: relative;
    margin-bottom: 1.5rem;
    width: 100%;
}
.input-group i {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-blue);
    font-size: 1.2rem;
}
.input-group input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem; /* Right padding for arabic */
    padding-right: 2.5rem;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(0, 210, 255, 0.3);
    border-radius: 4px;
    color: white;
    font-family: var(--font-arabic);
    font-size: 1.1rem;
    transition: var(--transition-fast);
    outline: none;
}
.input-group input:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.4);
    background: rgba(0,0,0,0.5);
}

/* --- 6. SCREENS & LAYOUT --- */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease, transform 0.5s ease;
    transform: scale(0.95);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: var(--primary-blue) var(--bg-dark); /* Firefox */
}

/* Custom Scrollbar for Chrome/Safari/Edge */
.screen::-webkit-scrollbar {
    width: 8px;
}
.screen::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
.screen::-webkit-scrollbar-thumb {
    background-color: var(--primary-blue);
    border-radius: 10px;
}
.screen.active {
    opacity: 1;
    pointer-events: all;
    transform: scale(1);
}

/* --- LOGIN SCREEN --- */
.login-panel {
    margin: auto;
    width: 400px;
    max-width: 90%;
    padding: 3rem 2rem;
    text-align: center;
    border-top: 3px solid var(--primary-blue);
}
.logo-container { margin-bottom: 2rem; }
.subtitle {
    color: var(--primary-blue);
    font-size: 1.2rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    opacity: 0.8;
}

.auth-toggle-text {
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.auth-toggle-text a {
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: bold;
    transition: 0.3s;
}
.auth-toggle-text a:hover {
    color: var(--gold);
    text-shadow: 0 0 5px var(--gold-glow);
}
.hidden {
    display: none !important;
}

/* --- DASHBOARD SCREEN --- */
#menu-screen {
    padding: 2rem;
    align-items: center;
}
.top-nav {
    width: 100%;
    max-width: 1000px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--primary-blue);
}
.pilot-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.pilot-info img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid var(--primary-blue);
    box-shadow: 0 0 10px var(--primary-blue-glow);
}
.nav-actions .icon-btn {
    background: none;
    border: none;
    color: var(--accent-red);
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s;
}
.nav-actions .icon-btn:hover { transform: scale(1.2); text-shadow: 0 0 10px var(--accent-red-glow); }

.dashboard-content {
    width: 100%;
    max-width: 1000px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}
.stat-card {
    padding: 1.5rem;
    text-align: center;
    border-top: 2px solid rgba(255,255,255,0.1);
    transition: transform 0.3s;
}
.stat-card:hover {
    transform: translateY(-5px);
    border-top-color: var(--primary-blue);
}
.stat-card i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}
.stat-card h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.stat-card p {
    font-size: 1.8rem;
    font-weight: 900;
    font-family: var(--font-en);
}
.action-area { text-align: center; margin-top: 2rem; }
.primary-action { font-size: 1.5rem; padding: 1.5rem 4rem; width: auto; border-radius: 50px; }

/* --- MAIN GAME SCREEN --- */
#game-screen {
    padding: 1rem;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto auto;
    gap: 1rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    min-height: min-content;
}

.hud {
    display: flex;
    justify-content: space-between;
    padding: 1rem 2rem;
    border-bottom: 2px solid var(--primary-blue);
    gap: 1rem;
}
.hud-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}
.progress-bar {
    flex: 1;
    height: 12px;
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    border: 1px solid #333;
    overflow: hidden;
    position: relative;
}
.progress-fill {
    height: 100%;
    width: 100%;
    transition: width 0.3s ease-out, background-color 0.3s;
    position: relative;
}
.progress-fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: barShine 2s infinite linear;
}
@keyframes barShine { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

.health-fill { background-color: var(--health-green); box-shadow: 0 0 10px var(--health-green); }
.energy-fill { background-color: var(--energy-cyan); box-shadow: 0 0 10px var(--energy-cyan); }
.icon-health { color: var(--health-green); font-size: 1.5rem; }
.icon-energy { color: var(--energy-cyan); font-size: 1.5rem; }
.score-container { justify-content: flex-end; }
.score-glow { font-family: var(--font-en); font-size: 1.5rem; font-weight: 900; color: var(--gold); text-shadow: 0 0 15px var(--gold-glow); }

#scene-visuals {
    display: flex;
    flex-direction: column;
    min-height: 250px;
    border: 1px solid var(--primary-blue);
    position: relative;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background-image 0.5s ease;
}
.visual-fx-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, rgba(0, 210, 255, 0.1) 0%, transparent 70%);
}
.radar-scan {
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 1px solid rgba(0, 210, 255, 0.3);
    box-shadow: inset 0 0 40px rgba(0, 210, 255, 0.1);
}
.radar-scan::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-blue));
    transform-origin: left center;
    animation: radarSpin 4s infinite linear;
}
@keyframes radarSpin { 100% { transform: rotate(360deg); } }

/* CSS Art for Entities (Enemies/Player) inside Visual FX */
.entity {
    position: absolute;
    width: 80px;
    height: 80px;
    transition: all 0.5s ease-out;
}
.grendizer-ship {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path fill="%2300d2ff" d="M50 10 L80 90 L50 70 L20 90 Z"/><circle cx="50" cy="60" r="10" fill="%23ffd700"/></svg>') no-repeat center;
    background-size: contain;
    filter: drop-shadow(0 0 10px var(--primary-blue));
    animation: hoverPlayer 2s infinite alternate ease-in-out;
}
.enemy-ship {
    top: 20px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path fill="%23ff2a2a" d="M20 20 L80 20 L50 80 Z"/><circle cx="50" cy="40" r="8" fill="%23000"/></svg>') no-repeat center;
    background-size: contain;
    filter: drop-shadow(0 0 10px var(--accent-red));
    animation: hoverEnemy 1.5s infinite alternate ease-in-out;
}
@keyframes hoverPlayer { 0% { transform: translate(-50%, 0); } 100% { transform: translate(-50%, -10px); } }
@keyframes hoverEnemy { 0% { transform: translateY(0); } 100% { transform: translateY(10px); } }
.shoot-laser {
    position: absolute;
    width: 4px;
    height: 40px;
    background: var(--primary-blue);
    box-shadow: 0 0 10px var(--primary-blue), 0 0 20px #fff;
    border-radius: 4px;
    animation: fireLaser 0.3s linear forwards;
}
@keyframes fireLaser { 0% { bottom: 100px; opacity: 1; } 100% { bottom: 300px; opacity: 0; } }
.explosion-fx {
    position: absolute;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, #fff 10%, #ffeb3b 40%, #f44336 70%, transparent 100%);
    border-radius: 50%;
    animation: explodeAnim 0.5s ease-out forwards;
}
@keyframes explodeAnim { 0% { transform: scale(0.1); opacity: 1; } 100% { transform: scale(2); opacity: 0; } }

.inventory-panel {
    background: rgba(0,0,0,0.4);
    padding: 0.5rem;
    border-top: 1px solid #333;
}
.inventory-title {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-align: center;
}
.items-grid {
    display: flex;
    justify-content: center;
    gap: 1rem;
}
.item-slot {
    width: 40px;
    height: 40px;
    border: 1px solid #555;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.05);
    cursor: pointer;
    transition: 0.2s;
    position: relative;
}
.item-slot:hover { border-color: var(--gold); box-shadow: 0 0 10px var(--gold-glow); transform: scale(1.1); }
.item-slot i { font-size: 1.2rem; }
.item-slot .count {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: var(--primary-blue);
    color: #000;
    font-size: 0.7rem;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#narrative-box {
    padding: 1.5rem;
    border-right: 4px solid var(--primary-blue);
    min-height: 120px;
}
.speaker-name {
    color: var(--primary-blue);
    font-weight: 900;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}
.typewriter-container {
    font-size: 1.2rem;
    line-height: 1.6;
    text-shadow: 0 0 2px rgba(255,255,255,0.3);
}

.choices-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}
.choice-btn {
    padding: 1.2rem;
    background: rgba(0, 30, 60, 0.6);
    border: 1px solid rgba(0, 210, 255, 0.3);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: var(--font-arabic);
    font-size: 1.1rem;
    text-align: right;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}
.choice-btn::before {
    content: '';
    position: absolute;
    left: 0; top: 0; width: 4px; height: 100%;
    background: var(--primary-blue);
    transition: width 0.3s;
}
.choice-btn:hover {
    background: rgba(0, 50, 100, 0.8);
    border-color: var(--primary-blue);
    padding-right: 1.5rem; /* Indent effect */
}
.choice-btn:hover::before { width: 100%; opacity: 0.1; }
.choice-req {
    font-size: 0.8rem;
    background: rgba(255,0,0,0.2);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    color: var(--accent-red);
}

/* --- END SCREEN --- */
.end-panel {
    margin: auto;
    width: 500px;
    max-width: 90%;
    padding: 3rem 2rem;
    text-align: center;
}
.end-stats {
    margin: 2rem 0;
    font-size: 1.5rem;
}
.end-desc {
    margin-top: 1rem;
    font-size: 1.2rem;
    color: var(--text-muted);
}
.end-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* --- ANIMATIONS --- */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}
.shake-effect { animation: shake 0.5s; }

/* Responsive adjustments */
@media (max-width: 1024px) {
    /* Tablets */
    .choices-container { gap: 0.5rem; }
    #scene-visuals { min-height: 200px; }
    .hud { padding: 1rem; }
    .stats-cards { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

@media (max-width: 768px) {
    /* Mobile Phones */
    body { height: 100dvh; } /* Handle dynamic viewport height on mobile */
    .screen { padding-bottom: 2rem; }
    
    .hud { flex-direction: column; gap: 0.8rem; padding: 0.8rem; align-items: stretch; }
    .hud-item { width: 100%; justify-content: space-between; }
    .progress-bar { flex: 0 1 70%; }
    
    .glitch { font-size: 2rem; }
    .primary-action { padding: 1rem; font-size: 1.1rem; width: 100%; }
    
    .choices-container { grid-template-columns: 1fr; } /* Stack choices vertically */
    .choice-btn { padding: 1rem; font-size: 1rem; }
    
    #scene-visuals { min-height: 180px; }
    .entity { width: 60px; height: 60px; } /* Smaller entities */
    .radar-scan { width: 150px; height: 150px; }
    
    .login-panel { padding: 2rem 1.5rem; }
    .top-nav { flex-direction: column; gap: 1rem; padding: 1rem; }
    .pilot-info { width: 100%; justify-content: space-between; }
    .nav-actions { width: 100%; display: flex; justify-content: flex-end; }
    
    #narrative-box { padding: 1rem; min-height: 100px; }
    .typewriter-container { font-size: 1rem; }
    
    .end-panel { padding: 2rem 1.5rem; }
}

@media (max-width: 480px) {
    /* Small Mobile Phones */
    .glitch { font-size: 1.5rem; }
    .subtitle { font-size: 1rem; }
    .cyber-btn { padding: 0.8rem 1rem; font-size: 1rem; }
    #scene-visuals { min-height: 150px; }
    .entity { width: 45px; height: 45px; }
    .radar-scan { width: 120px; height: 120px; }
    
    .stat-card p { font-size: 1.5rem; }
    .stats-cards { grid-template-columns: 1fr; } /* Stack stats vertically */
    
    .hud-item .label { display: none; } /* Hide labels to save space */
    .score-container { justify-content: center; }
    
    .top-nav { padding: 0.5rem; }
    .pilot-info img { width: 40px; height: 40px; }
    
    #game-screen { padding: 0.5rem; gap: 0.5rem; }
    .choices-container { gap: 0.5rem; }
    .choice-btn { padding: 0.8rem; font-size: 0.95rem; }
}