:root {
    --primary: #008080;
    --secondary: #FF8C00;
    --success: #4CAF50;
    --danger: #FF5252;
    --warning: #FFD740;
    --info: #2196F3;
    --bg-dark: #000000;
    --glass: rgba(0, 0, 0, 0.82);
    --glass-extra: rgba(0, 0, 0, 0.9);
    --glass-border: rgba(255, 255, 255, 0.15);
    --font-main: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: white;
    font-family: var(--font-main);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.mobile-frame {
    width: 100%;
    max-width: 420px;
    height: 100vh;
    background: #000;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#game-content {
    position: relative;
    flex: 1;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

@media (min-width: 421px) {
    .mobile-frame {
        height: 92vh;
        border-radius: 40px;
        border: 10px solid #1a1a1a;
        box-shadow: 0 0 100px rgba(0, 128, 128, 0.2);
    }
}

/* --- Stats Header --- */

#game-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 40px 15px 15px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.9) 0%, transparent 100%);
    z-index: 500;
    pointer-events: none;
    display: none; /* Hide the top bars */
}

.stats-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    padding: 5px 12px;
    border-radius: 20px;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 800;
    opacity: 0.7;
}

.stat-value {
    color: var(--warning);
    font-weight: 900;
    font-size: 0.8rem;
}

.progress-bar-bg {
    width: 60%;
    height: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    transition: width 0.3s ease;
}

.blue {
    background: var(--info);
    box-shadow: 0 0 10px var(--info);
}

.green {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.red {
    background: var(--danger);
    box-shadow: 0 0 10px var(--danger);
}

.orange {
    background: var(--secondary);
    box-shadow: 0 0 10px var(--secondary);
}

/* --- Screens & Backgrounds --- */

.screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 30px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 300;
    animation: fadeIn 0.8s ease;
}

#login-screen {
    background-image: url('assets/login.png');
    z-index: 600;
}

.screen::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, transparent 60%);
    z-index: 1;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* --- Dialogue --- */

.dialogue-box {
    position: relative;
    z-index: 2;
    background: var(--glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 25px;
    border-radius: 25px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    overflow-x: hidden;
    /* Hide scrollbar but keep scrolling */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.dialogue-box::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.cinematic-in {
    animation: slideUp 0.6s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.dialogue-text {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 20px;
    color: #ddd;
}

.dialogue-text b {
    color: var(--secondary);
}

/* --- Inputs & Buttons --- */

input[type="text"] {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 15px;
    border-radius: 15px;
    color: white;
    font-family: inherit;
    margin-bottom: 20px;
    outline: none;
}

button {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), #00a0a0);
    color: white;
    border: none;
    padding: 18px;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
}

button.secondary {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    margin-top: 10px;
}

/* --- Map Selection --- */

#map-selection {
    z-index: 400;
    background: #000;
    justify-content: flex-start;
    padding-top: 150px;
    pointer-events: auto;
    overflow-y: auto;
}

.title {
    font-size: 2rem;
    font-weight: 900;
    text-align: center;
    margin-bottom: 30px;
    background: linear-gradient(to right, #fff, #555);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.map-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 2;
}

.map-card {
    height: 130px;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.map-card:hover {
    transform: scale(1.02);
    border-color: var(--secondary);
}

.map-card .card-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
}

.map-card .card-content {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.2) 100%);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.map-card h3 {
    font-size: 1.4rem;
    font-weight: 900;
}

.map-card p {
    font-size: 0.8rem;
    opacity: 0.8;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

#confirm-popup {
    z-index: 700 !important;
    background: rgba(0, 0, 0, 0.95) !important;
    justify-content: center;
    align-items: center;
    pointer-events: auto !important;
}

#confirm-popup:not(.hidden) {
    display: flex !important;
}

.warning-tag {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 8px;
}

.warning-tag.high-risk {
    background: rgba(255, 82, 82, 0.2);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.warning-tag.med-risk {
    background: rgba(255, 140, 0, 0.2);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.warning-tag.low-risk {
    background: rgba(76, 175, 80, 0.2);
    color: var(--success);
    border: 1px solid var(--success);
}

.risk-hint {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 6px;
    font-style: italic;
    opacity: 0.8;
}

.warning-tag.old {
    position: absolute;
    top: 10px;
    right: 15px;
    background: var(--danger);
    font-size: 0.6rem;
    font-weight: 900;
    padding: 4px 8px;
    border-radius: 5px;
    text-transform: uppercase;
}

/* --- Final Badges --- */

.badge-icon {
    font-size: 4rem;
    margin-bottom: 15px;
    text-shadow: 0 0 20px var(--warning);
}

.highlight {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--warning);
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
    z-index: 2;
    pointer-events: auto;
}

#dialog-overlay {
    position: absolute;
    inset: 0;
    z-index: 450;
    pointer-events: none;
}

#dialog-overlay.active {
    pointer-events: auto;
}

#video-container {
    padding: 0 !important;
    background: #000;
}

#transition-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#video-scenario-overlay {
    position: absolute;
    bottom: 40px;
    left: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 20px;
    border-radius: 20px;
    z-index: 600;
}

#video-scenario-text {
    margin-bottom: 0;
    font-weight: 600;
    text-align: center;
}

/* Blur Dissolve Animations */
.blur-in {
    animation: blurDissolveIn 0.8s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.blur-out {
    animation: blurDissolveOut 0.8s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes blurDissolveIn {
    from {
        filter: blur(30px);
        opacity: 0;
        transform: scale(1.1);
    }

    to {
        filter: blur(0);
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Mobile Control Buttons --- */

#mobile-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 200;
    pointer-events: none;
}

#mobile-controls:not(.hidden) {
    pointer-events: auto;
}

.control-buttons-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.control-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.control-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--glass);
    backdrop-filter: blur(20px);
    border: 2px solid var(--glass-border);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
    user-select: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.control-btn:active,
.control-btn.active {
    background: var(--secondary);
    border-color: var(--secondary);
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(255, 140, 0, 0.5);
}

.control-btn svg {
    width: 28px;
    height: 28px;
    stroke-width: 2.5;
}

/* Hide controls on desktop (show only on touch devices) */
@media (min-width: 768px) {
    #mobile-controls {
        display: none;
    }
}

/* Show controls on mobile */
@media (max-width: 767px) {
    #mobile-controls {
        display: block;
    }
}

@keyframes blurDissolveOut {
    from {
        filter: blur(0);
        opacity: 1;
        transform: scale(1);
    }

    to {
        filter: blur(30px);
        opacity: 0;
        transform: scale(0.95);
    }
}

.hidden {
    display: none !important;
}