/* Boot Screen */
#boot-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #000;
}

.loading-bar {
    width: 300px;
    height: 20px;
    border: 2px solid var(--secondary-color);
    margin: 20px 0;
    padding: 2px;
}

.progress {
    width: 0%;
    height: 100%;
    background-color: var(--secondary-color);
    transition: width 0.5s;
    animation: load-progress 3s forwards;
}

@keyframes load-progress {
    0% {
        width: 0%;
    }

    100% {
        width: 100%;
    }
}

/* Terminal Layout */
#terminal-screen {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 20px;
}

.terminal-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.terminal-body {
    display: flex;
    flex: 1;
    gap: 20px;
}

.sidebar {
    width: 200px;
    border-right: 1px dashed #333;
}

.menu-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: none;
    border: 1px solid transparent;
    color: var(--text-color);
    text-align: left;
    font-family: var(--font-mono);
    cursor: pointer;
    margin-bottom: 5px;
}

.menu-btn:hover,
.menu-btn.active {
    border: 1px solid var(--primary-color);
    background: rgba(176, 38, 255, 0.1);
    color: var(--primary-color);
}

.content-area {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #333;
    padding: 20px;
    overflow-y: auto;
}

.online {
    color: var(--secondary-color);
    text-shadow: 0 0 5px var(--secondary-color);
}

/* Terminal Cards */
.terminal-card,
.mission-card,
.team-card {
    background: rgba(0, 20, 0, 0.6);
    border: 1px solid var(--secondary-color);
    padding: 15px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
}

.mission-grid,
.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.mission-card.locked {
    border-color: #333;
    color: #666;
    opacity: 0.5;
    cursor: not-allowed;
}

.mission-card.unlocked:hover {
    background: rgba(0, 255, 65, 0.1);
    transform: translateY(-2px);
    cursor: pointer;
    box-shadow: 0 0 10px var(--secondary-color);
}

.mission-card.completed {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(176, 38, 255, 0.05);
    cursor: pointer;
}

.mission-card.completed:hover {
    background: rgba(176, 38, 255, 0.1);
}

.action-btn {
    background: var(--primary-color);
    color: #fff;
    border: none;
    padding: 10px 20px;
    font-family: var(--font-mono);
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
}

.action-btn:hover {
    background: #d46aff;
}

.reset-btn-main {
    background: transparent;
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
    margin-left: 10px;
    font-size: 0.8rem;
}

.reset-btn-main:hover {
    background: var(--danger-color);
    color: #fff;
}

/* Team Placeholders */
.team-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 10px;
    border: 2px solid #fff;
}

.avatar-placeholder {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.team-card.purple .avatar-placeholder {
    background: var(--primary-color);
    color: #fff;
}

.team-card.blue .avatar-placeholder {
    background: #00a8ff;
    color: #fff;
}

.team-card.yellow .avatar-placeholder {
    background: #fbc531;
    color: #000;
}

.team-card.red .avatar-placeholder {
    background: var(--danger-color);
    color: #fff;
}

/* Story Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.blur {
    filter: blur(5px);
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
}

#story-container {
    width: 90%;
    max-width: 800px;
    background: #111;
    border: 2px solid var(--primary-color);
    padding: 40px;
    max-height: 90vh;
    overflow-y: auto;
}

.dialog-line {
    margin-bottom: 20px;
    padding: 10px;
    border-left: 3px solid #333;
}

.dialog-line.mood-friendly {
    border-color: var(--secondary-color);
}

.dialog-line.mood-serious {
    border-color: #fbc531;
}

.dialog-line.mood-warning {
    border-color: var(--danger-color);
}

.speaker {
    display: block;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.choices {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 30px;
}

.choice-btn {
    flex: 1;
    min-width: 200px;
    padding: 15px;
    background: #222;
    border: 1px solid var(--text-color);
    color: var(--text-color);
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.2s;
}

.choice-btn:hover {
    background: var(--text-color);
    color: #000;
}

/* Minigame Styles */
.minigame-alert {
    border: 2px dashed var(--danger-color);
    padding: 20px;
    background: rgba(50, 0, 0, 0.3);
}

.profile-card-fake {
    background: #fff;
    color: #000;
    padding: 20px;
    border-radius: 10px;
    max-width: 400px;
    margin: 20px auto;
    font-family: var(--font-sans);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid #ccc;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.profile-pic {
    width: 60px;
    height: 60px;
    background: #ccc;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: crosshair;
}

.profile-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 15px;
}

.glitch-target {
    cursor: crosshair;
    padding: 2px 5px;
    border: 2px solid transparent;
}

.glitch-target:hover {
    background: rgba(255, 0, 0, 0.1);
}

.active-pulse {
    animation: pulse 1s infinite;
    background: var(--secondary-color) !important;
    color: #000 !important;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* Photo Minigame */
.photo-frame {
    width: 100%;
    height: 300px;
    background: #000;
    position: relative;
    border: 2px solid #555;
    margin-bottom: 20px;
    background-image: repeating-linear-gradient(45deg, #111 25%, transparent 25%, transparent 75%, #111 75%, #111), repeating-linear-gradient(45deg, #111 25%, #222 25%, #222 75%, #111 75%, #111);
    background-position: 0 0, 10px 10px;
    background-size: 20px 20px;
}

.photo-frame.blurred {
    filter: blur(10px) grayscale(100%);
    transition: all 1s ease;
}

.photo-frame.enhanced {
    filter: blur(0px) grayscale(0%);
    /* Simulate the room photo with CSS gradients/shapes if no image */
    background: radial-gradient(circle at 50% 50%, #2a2a2a 0%, #000 100%);
}

.evidence-clue {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
}

.evidence-clue:hover {
    border-color: var(--secondary-color);
    background: rgba(0, 255, 65, 0.2);
}

.evidence-clue.found {
    border-color: var(--primary-color);
    border-style: solid;
    animation: flash 0.5s;
}

.clue-label {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: #fff;
    padding: 2px 5px;
    font-size: 0.8rem;
    white-space: nowrap;
    border-radius: 4px;
}

@keyframes flash {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

/* Evidence Board */
.evidence-board {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.evidence-pool {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.evidence-item {
    background: rgba(0, 255, 65, 0.1);
    border: 1px solid var(--primary-color);
    padding: 10px;
    text-align: center;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.evidence-item:hover {
    background: var(--primary-color);
    color: #000;
}

.evidence-folder {
    flex: 1;
    background: #8b0000;
    /* Dark Red */
    border: 2px solid #ff4444;
    padding: 15px;
    min-height: 200px;
    position: relative;
}

.folder-label {
    text-align: center;
    font-weight: bold;
    border-bottom: 2px solid #ff4444;
    margin-bottom: 10px;
    padding-bottom: 5px;
}

.folder-item {
    background: #fff;
    color: #000;
    margin: 5px 0;
    padding: 5px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    transform: rotate(-2deg);
}

.certificate-preview {
    border: 10px solid #ddd;
    background: #fff;
    background-image: url('../assets/images/certificate_bg.png');
    background-size: cover;
    background-position: center;
    color: #222;
    padding: 40px;
    width: 80%;
    margin: 0 auto;
    font-family: 'Courier New', serif;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    min-height: 400px;
    /* Ensure aspect ratio */
}

/* The following line was malformed and outside a CSS rule, it has been removed for syntactic correctness */
/* transform: rotate(1deg); */

/* Timeline Minigame */
.timeline-area {
    margin-top: 20px;
}

.timeline-slots {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.timeline-slot {
    border: 1px dashed var(--secondary-color);
    padding: 10px;
    width: 23%;
    text-align: center;
    font-size: 0.8rem;
}

.timeline-slot.filled {
    border-style: solid;
    background: rgba(0, 255, 65, 0.1);
}

.timeline-cards {
    display: flex;
    gap: 10px;
}

.timeline-card {
    background: #222;
    border: 1px solid #555;
    padding: 10px;
    font-size: 0.8rem;
    cursor: pointer;
    flex: 1;
}

.timeline-card:hover {
    border-color: #fff;
}

/* Password Minigame */
.password-area {
    text-align: center;
    margin-top: 20px;
}

.password-display {
    font-size: 1.5rem;
    font-family: monospace;
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.password-strength-meter {
    height: 10px;
    background: #333;
    margin: 10px auto;
    width: 80%;
    border-radius: 5px;
}

#strength-bar {
    height: 100%;
    width: 0%;
    background: red;
    border-radius: 5px;
    transition: width 0.3s;
}

.password-blocks {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.pass-block {
    background: #000;
    border: 1px solid var(--secondary-color);
    color: var(--secondary-color);
    padding: 10px 15px;
    cursor: pointer;
}

.pass-block:hover {
    background: var(--secondary-color);
    color: #000;
}

.reset-btn {
    border-color: red;
    color: red;
}

/* Print Styles */
@media print {

    body,
    html {
        background: white !important;
        background-color: white !important;
        margin: 0;
        padding: 0;
        height: 100%;
        overflow: visible !important;
    }

    /* Hide everything by default */
    body * {
        visibility: hidden;
    }

    #story-overlay,
    .minigame-alert,
    #minigame-area,
    .certificate-area,
    .certificate-preview,
    .certificate-preview * {
        visibility: visible;
    }

    /* Remove black overlays */
    #story-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: none !important;
        /* Fixes black bar */
        z-index: 100;
        display: block !important;
    }

    .minigame-alert {
        background: none !important;
        /* Fixes potential grey bars */
        border: none !important;
        padding: 0;
        margin: 0;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
    }

    .certificate-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .certificate-preview {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        width: 100%;
        max-width: 800px;
        /* Limit width */
        margin: 20px auto;
        border: 2px solid #000;
        /* Ensure Aspect Ratio */
        aspect-ratio: 1.414 / 1;
        /* A4 Landscape-ish */
        background-size: 100% 100% !important;
        /* Force fit */
    }

    /* Hide UI Elements expressly */
    #story-container {
        display: contents !important;
        /* Unwrap container to avoid black boxes */
        background: none !important;
        border: none !important;
        box-shadow: none !important;
    }

    /* Hide non-cert text during print if needed, or just hide specific things */
    .cert-header,
    .cert-body,
    .cert-footer {
        color: black;
    }

    #print-btn,
    #restart-btn,
    #minigame-continue,
    .terminal-header,
    .sidebar,
    .choices,
    .blink,
    .logo,
    .status {
        display: none !important;
    }
}

/* Mobile Responsiveness */
@media screen and (max-width: 768px) {
    #boot-screen {
        height: 100dvh;
        /* Dynamic viewport height for mobile */
    }

    #terminal-screen {
        padding: 10px;
        height: 100dvh;
        /* Fix for mobile browser bars */
    }

    .terminal-header {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 10px;
        gap: 5px;
    }

    .logo {
        font-size: 1.2rem;
    }

    .status {
        font-size: 0.8rem;
    }

    .terminal-body {
        flex-direction: column;
        gap: 10px;
        overflow: hidden;
        /* Prevent body scroll */
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px dashed #333;
        flex: 0 0 auto;
        /* Don't grow */
    }

    .menu {
        display: flex;
        overflow-x: auto;
        gap: 10px;
        padding-bottom: 5px;
    }

    .menu-btn {
        width: auto;
        white-space: nowrap;
        padding: 8px 12px;
        font-size: 0.9rem;
        background: rgba(0, 0, 0, 0.5);
        border: 1px solid #333;
    }

    .menu-btn.active {
        border-color: var(--primary-color);
    }

    .content-area {
        padding: 10px;
        /* Ensure it takes remaining space but scrolls internally */
        flex: 1;
        min-height: 0;
    }

    /* Adjust Card Grids */
    .mission-grid,
    .team-grid {
        grid-template-columns: 1fr;
        /* Stack cards */
    }

    /* Text Sizing */
    h2 {
        font-size: 1.2rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    p {
        font-size: 0.9rem;
    }

    /* Story Overlay Mobile */
    #story-container {
        width: 100%;
        height: 100%;
        max-height: 100%;
        padding: 20px;
        border: none;
        background: #050505;
    }

    .dialog-line {
        margin-bottom: 15px;
        padding: 8px;
    }

    .choices {
        flex-direction: column;
    }

    .choice-btn {
        width: 100%;
        padding: 12px;
    }

    /* Minigame Adjustments */
    .profile-card-fake {
        width: 100%;
        padding: 10px;
    }

    .profile-stats {
        flex-wrap: wrap;
        gap: 5px;
    }

    .stat {
        font-size: 0.8rem;
    }

    /* Touch optimizations */
    button,
    .menu-btn,
    .mission-card,
    .evidence-item,
    .timeline-card {
        touch-action: manipulation;
        /* Prevent double-tap zoom delay */
    }

    /* Chapter 8: Timeline Mobile Fix */
    .timeline-slots {
        flex-wrap: wrap;
        gap: 10px;
    }

    .timeline-slot {
        width: 48%;
        /* 2 per row */
        font-size: 0.8rem;
    }

    .timeline-cards {
        flex-direction: column;
        /* Stack cards vertically */
    }

    .timeline-card {
        width: 100%;
        margin-bottom: 5px;
        padding: 15px;
        /* Larger touch target */
    }

    /* Certificate Mobile Preview Fix */
    .certificate-preview {
        width: 100% !important;
        padding: 20px !important;
        /* Reduce padding */
        min-height: auto !important;
        background-size: 100% 100% !important;
        aspect-ratio: 1.414 / 1;
    }

    .cert-header {
        font-size: 0.9rem !important;
        /* Smaller header */
        margin-top: 20px !important;
    }

    .cert-icon {
        font-size: 1.5rem !important;
        margin: 5px 0 !important;
    }

    .cert-body {
        font-size: 0.7rem !important;
        /* Smaller body text */
        line-height: 1.4 !important;
        margin-top: 10px !important;
        margin-bottom: 10px !important;
    }

    #player-name-input {
        font-size: 0.8rem !important;
        width: 60% !important;
    }

    .cert-footer {
        font-size: 0.6rem !important;
        margin-top: 10px !important;
    }
}

/* Certificate Adjustments */
.cert-body {
    font-size: 1.2rem;
    line-height: 1.8;
    margin-bottom: 40px;
    margin-top: 60px;
    /* Moved down by request */
}

/* Mobile Boot Screen Text */
.blink {
    animation: blinker 1s linear infinite;
    font-family: 'Courier New', Courier, monospace;
    color: var(--secondary-color);
    margin-top: 10px;
    font-size: 1.2rem;
}

@media (max-width: 600px) {
    .blink {
        font-size: 1rem;
    }
}

.cert-header {
    margin-top: 80px;
    /* Moved down significantly */
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.5rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
}