/* Root Variables */
:root {
    --secondary-color: #2ecc71;
    --dark-color: #2c3e50;
    --primary-blue: #3498db;
    --light-bg: #f8f9fa;
    --border-radius: 10px;

    /* Image size variables */
    --image-max-height: 40vh;
    --image-max-width: 500px;

    /* Z-index layers */
    --z-intro: 1000;
    --z-controls: 200;
    --z-character: 150;
    --z-steps: 100;

    /* Spacing */
    --container-padding: 15px;
    --element-margin: 10px;
    --compact-margin: 5px;
}

/* Base Styles */
body {
    margin: 0;
    padding: 0;
    background: linear-gradient(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.9)),
        url('/uploads/Skill01/images/hospitalRoom.webp');
    background-size: cover;
    background-position: center;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
}

/* Game Grid Layout */
.game-grid {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    height: calc(100vh - 40px);
    gap: 5px;
}

.game-header {
    grid-row: 1;
}

.game-main {
    grid-row: 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.game-footer {
    grid-row: 3;
    margin-top: auto;
    padding: 5px 0;
}

/* Introduction Styles */
.intro-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: var(--z-intro);
    opacity: 1;
    transition: opacity 0.5s ease;
}

.intro-screen {
    text-align: center;
    padding: 2rem;
    max-height: 90vh;
    overflow-y: auto;
}

.intro-features {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.intro-text {
    font-size: 1.3em;
    color: var(--dark-color);
    text-align: center;
    margin: 10px auto;
    max-width: 800px;
    line-height: 1.5;
}

.intro-highlight {
    font-size: 1.2em;
    color: var(--primary-blue);
    font-weight: bold;
    margin: 15px 0;
}

.intro-title {
    color: var(--dark-color);
    font-size: 2.2em;
    margin-bottom: 15px;
}

.feature {
    text-align: center;
}

.feature-icon {
    font-size: 2.2em;
}

#intro-tips {
    background-color: #f7f7f7;
    padding: 15px;
    line-height: 1.4;
    font-weight: bold;
    border: 1px solid #ddd;
    margin-top: 10px;
    font-size: 0.9em;
}

/* Instructions Box Styles */
.instructions-box {
    background-color: var(--light-bg);
    border: 2px solid var(--primary-blue);
    border-radius: var(--border-radius);
    padding: 15px;
    margin: 15px auto;
    max-width: 90%;
    text-align: left;
}

.instructions-box h3 {
    color: var(--dark-color);
    margin-top: 0;
    text-align: center;
}

.instructions-box ol {
    padding-left: 25px;
    margin-bottom: 0;
}

.instructions-box li {
    margin-bottom: 8px;
    line-height: 1.4;
}

/* Button Styles */
#beginTrainingBtn, .play-again-btn, #fullscreenToggle {
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Update this existing rule */
#beginTrainingBtn, #fullscreenToggle {
    background-color: #4CAF50;
}

/* Update this existing rule */
#beginTrainingBtn:hover, .play-again-btn:hover, #fullscreenToggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.2);
}

/* Update this existing rule */
#beginTrainingBtn:hover, #fullscreenToggle:hover {
    background-color: #45a049;
}

/* Update this existing rule */
#beginTrainingBtn:active, .play-again-btn:active, #fullscreenToggle:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}


#beginTrainingBtn {
    background-color: #4CAF50;
}

.play-again-btn {
    background-color: var(--primary-blue);
    margin: 10px auto;
    display: block;
    font-size: 1.2em;
    letter-spacing: 1px;
}

#beginTrainingBtn:hover, .play-again-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.2);
}

#beginTrainingBtn:hover {
    background-color: #45a049;
}

.play-again-btn:hover {
    background-color: #2980b9;
}

#beginTrainingBtn:active, .play-again-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Game Container and Controls */
.game-container {
    position: relative;
    width: 90vw;
    max-width: 800px;
    margin: 10px auto;
    padding: var(--container-padding);
    background: rgba(180, 210, 219, 0.4);
    border-radius: var(--border-radius);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.game-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.game-heading {
    text-align: center;
    color: var(--dark-color);
    font-family: 'Impact', 'Arial Black', Helvetica, sans-serif;
    font-size: 24px;
    font-weight: bold;
    margin: 5px 0;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: var(--element-margin) 0;
    gap: 15px;
}

/* Main Image and Step Display */
#mainImage {
    width: 100%;
    max-width: var(--image-max-width);
    height: auto;
    max-height: var(--image-max-height);
    aspect-ratio: 1;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    margin: 5px auto;
    border: 2px solid var(--primary-blue);
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
}

#stepHint {
    text-align: center;
    font-size: 15px;
    color: var(--dark-color);
    margin: 0;
    font-weight: bold;
    padding: 2px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 5px;
    border: 2px solid var(--primary-blue);
}

/* Navigation Buttons */
.start-btn {
    background-color: var(--primary-blue);
    padding: 5px 10px;
    border: 2px solid #000000;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.5s ease;
    color: white;
}

.start-btn:hover {
    transform: scale(1.05);
    background-color: #27ae60;
}

.hint-btn {
    padding: 5px 10px;
    background-color: #cef8cc;
    border: 2px solid #000000;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.5s ease;
}

.hint-btn:hover {
    transform: scale(1.05);
    background-color: #f39c12;
}

/* Steps Dropdown */
.steps-dropdown {
    padding: 5px;
    font-size: 14px;
    border-radius: 5px;
    border: 2px solid var(--primary-blue);
    cursor: pointer;
    width: 100%;
    max-width: 100%;
}

.steps-dropdown option {
    white-space: normal;
    word-wrap: break-word;
    max-width: 100%;
    padding: 8px;
    line-height: 1.3;
}

.steps-menu {
    text-align: center;
    margin: 10px 0;
}

/* Progress Bar */
.progress-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 5px 0;
    width: 100%;
    height: 15px;
    background-color: #f0f0f0;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background-color: var(--primary-blue);
    transition: width 0.5s ease-in-out;
}

.progress-bar-container {
    flex-grow: 1;
}

.progress-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.progress-label {
    font-weight: bold;
    color: var(--dark-color);
    white-space: nowrap;
    font-size: 14px;
}

/* Score Display */
.score-display {
    position: absolute;
    top: 0px;
    right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px;
    font-weight: bold;
    font-size: 1.3rem;
    background-color: #ffffff;
    border: 2px solid var(--primary-blue);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: var(--z-controls);
}

.score-btn {
    display: inline-flex;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    padding: 3px;
}

.score-icon {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--dark-color);
}

.score {
    display: inline-block;
    font-weight: bold;
    color: var(--dark-color);
    padding: 3px 8px;
    background-color: var(--light-bg);
    border: 2px solid var(--primary-blue);
    border-radius: var(--border-radius);
    min-width: 30px;
    text-align: center;
}

/* Timer */
#timer {
    border: 2px solid var(--primary-blue);
    padding: 5px;
    border-radius: var(--border-radius);
    font-size: 1.4em;
    background-color: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 130px;
    text-align: center;
    color: var(--dark-color);
    font-weight: bold;
}

.timer-label {
    font-size: 0.7em;
    text-transform: uppercase;
    color: var(--dark-color);
    font-weight: bold;
}

.timer-value {
    font-size: 0.8em;
    font-weight: bold;
}

/* Noise Controls */
.noise-controls {
    position: absolute;
    top: 60px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 6px;
    border: 2px solid var(--primary-blue);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: var(--z-controls);
}

.noise-toggle {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 2px;
    transition: transform 0.2s;
}

.volume-slider {
    width: 80px;
    height: 5px;
}

/* Animations */
@keyframes correctPulse {
    0% { transform: scale(1); }

    50% {
        transform: scale(1.1);
        background-color: #2ecc71;
    }
    100% { transform: scale(1); }
}

@keyframes wrongShake {
    0% { transform: translateX(0); }
    25% {
        transform: translateX(-10px);
        background-color: #e74c3c;
    }
    75% {
        transform: translateX(10px);
        background-color: #e74c3c;
    }
    100% { transform: translateX(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Add these styles to properly set the background colors for correct and wrong answers */
.correct-answer {
    animation: correctPulse 0.5s ease-in-out;
    background-color: #2ecc71 !important; /* Green color for correct answers */
}

.wrong-answer {
    animation: wrongShake 0.5s ease-in-out;
    background-color: #e74c3c !important; /* Red color for wrong answers */
}

.slide-in {
    animation: slideIn 0.5s ease-in-out forwards;
}

/* Animation delays for sequenced animations */
.delay-100 {
    animation-delay: 100ms;
}

.delay-200 {
    animation-delay: 200ms;
}

.delay-300 {
    animation-delay: 300ms;
}

.delay-500 {
    animation-delay: 500ms;
}

/* Animation utilities */
.animated {
    animation-duration: 0.5s;
    animation-fill-mode: both;
}

.animated.infinite {
    animation-iteration-count: infinite;
}

.animated.fast {
    animation-duration: 0.3s;
}

.animated.slow {
    animation-duration: 0.8s;
}

/* Accessibility override for reduced motion */
@media (prefers-reduced-motion: reduce) {
    .animated,
    .correct-answer,
    .wrong-answer,
    .fade-in,
    .slide-in {
        animation: none !important;
        transition: none !important;
    }
}

/* Advice Character - updated to match previous positioning */
.advice-character {
    position: fixed;
    right: 20px;
    bottom: -350px; /* Move it completely off-screen initially */
    width: 350px;
    height: 350px;
    background-image: url('/uploads/Skill01/images/nurse.webp');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: var(--z-character);
    transition: bottom 0.5s ease-in-out;
    /* Make sure it's hidden by default */
    opacity: 0;
    visibility: hidden;
}

.advice-bubble {
    position: absolute;
    left: 50%; /* Center horizontally relative to the character */
    transform: translateX(-50%); /* Offset by half its own width */
    top: -100px; /* Position above the character */
    background: white;
    padding: 8px;
    border-radius: 15px;
    border: 2px solid var(--primary-blue);
    width: 200px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    display: none;
    font-size: 14px;
}

.advice-character.show {
    bottom: 20px;
    right: 20px;
    /* Make visible when shown */
    opacity: 1;
    visibility: visible;
}

.advice-bubble.show {
    display: block;
}

/* Steps Container */
.steps-container {
    position: absolute;
    border-radius: 5px;
    left: 0;
    top: 0;
    max-width: 200px;
    margin: 2px auto;
    padding: 2px;
    overflow-y: auto;
    max-height: 80vh;
    z-index: var(--z-steps);
}

.step-item {
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 2px;
    margin: 2px 0;
    font-size: 11px;
    color: #666;
    transform: translateX(-100%);
    opacity: 0;
    transition: all 0.5s ease;
}

.step-item.revealed {
    transform: translateX(0);
    opacity: 1;
    background-color: #e8f5e9;
    color: #0c400f;
    border-color: #81c784;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Add this to your CSS to hide scrollbars */
body, .game-content, .steps-container, .intro-screen {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

body::-webkit-scrollbar,
.game-content::-webkit-scrollbar,
.steps-container::-webkit-scrollbar,
.intro-screen::-webkit-scrollbar {
    display: none;  /* Chrome, Safari and Opera */
}

/* Responsive Design - Using a mobile-first approach with consolidated media queries */

/* Large screens (desktops) */
@media screen and (min-width: 1200px) {
    :root {
        --image-max-height: 60vh;
        --image-max-width: 700px;
    }

    .game-container {
        max-width: 1000px;
    }

    .game-heading {
        font-size: 28px;
    }

    .intro-text {
        font-size: 1.4em;
    }

    .intro-title {
        font-size: 2.5em;
    }
}

/* Medium screens (tablets) */
@media screen and (max-width: 992px) {
    :root {
        --container-padding: 12px;
        --element-margin: 8px;
    }

    .game-heading {
        font-size: 22px;
    }

    .intro-features {
        gap: 1.5rem;
    }
}

/* Small screens (mobile devices) */
@media screen and (max-width: 768px) {
    :root {
        --image-max-height: 40vh;
        --container-padding: 8px;
        --element-margin: 5px;
    }

    .game-container {
        width: 95%;
    }

    .game-controls {
        flex-direction: column;
        gap: 8px;
    }

    /* Reposition controls for mobile */
    .score-display,
    .noise-controls {
        position: static;
        margin: 2px auto;
        width: fit-content;
    }

    .steps-container {
        position: static;
        max-width: 100%;
        margin: 5px auto;
    }

    .steps-dropdown {
        max-width: 100%;
        font-size: 12px;
    }

    .game-heading {
        font-size: 18px;
    }

    .intro-features {
        flex-direction: column;
        gap: 10px;
    }

    .intro-text {
        font-size: 1.1em;
    }

    .intro-title {
        font-size: 1.8em;
    }

    /* Hide advice character on mobile */
    .advice-character {
        display: none;
    }

    .instructions-box {
        padding: 10px;
    }

    .instructions-box ol {
        padding-left: 20px;
    }
}

/* Very small screens */
@media screen and (max-width: 480px) {
    :root {
        --image-max-height: 35vh;
    }

    .game-heading {
        font-size: 16px;
        letter-spacing: 1px;
    }

    .start-btn, .hint-btn {
        font-size: 12px;
        padding: 4px 8px;
    }

    .progress-label {
        font-size: 12px;
    }

    #timer {
        font-size: 1.2em;
        min-width: 100px;
    }

    .score {
        min-width: 25px;
        font-size: 0.9em;
    }

    .score-icon {
        font-size: 0.9em;
    }

    #beginTrainingBtn, .play-again-btn {
        padding: 8px 15px;
        font-size: 14px;
    }

    .intro-screen {
        padding: 1rem;
    }

    .instructions-box h3 {
        font-size: 16px;
    }

    .instructions-box li {
        font-size: 14px;
        margin-bottom: 5px;
    }
}

/* Height-based media query for short screens */
@media screen and (max-height: 700px) {
    :root {
        --image-max-height: 50vh;
        --element-margin: 3px;
    }

    .game-heading {
        font-size: 18px;
        margin: 3px 0;
    }

    .game-controls {
        margin: 3px 0;
    }

    .start-btn, .hint-btn {
        padding: 3px 8px;
        font-size: 14px;
    }

    .advice-character {
        width: 150px;
        height: 150px;
    }

   .advice-bubble {
        width: 180px;
        font-size: 12px;
        /* Remove the left: -120px; line */
        /* Keep using the centering approach */
        left: 50%;
        transform: translateX(-50%);
    }

    .progress-wrapper {
        margin-top: 3px;
    }
}

/* Utility class for JavaScript-assisted layout */
.js-optimized {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .advice-character,
    .step-item,
    #mainImage,
    .start-btn,
    .hint-btn,
    #beginTrainingBtn,
    .play-again-btn {
        transition: none !important;
    }

    .progress-bar {
        transition-duration: 0.01ms !important;
    }

    @keyframes correctPulse {
        0%, 50%, 100% { transform: scale(1); }
    }

    @keyframes wrongShake {
        0%, 25%, 75%, 100% { transform: translateX(0); }
    }
}

/* Print styles */
@media print {
    body {
        background: white;
    }

    .game-container {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    /* Hide interactive elements when printing */
    .game-controls,
    .noise-controls,
    .advice-character,
    .advice-bubble,
    .steps-dropdown,
    .steps-container,
    .play-again-btn {
        display: none !important;
    }

    #mainImage {
        max-height: 50vh;
        border: 1px solid #000;
    }
}
/*
 *
    Uses CSS variables for consistent values like z-index, spacing, and image dimensions
    Consolidates media queries by screen size rather than scattering them throughout the code
    Follows a mobile-first approach with logical breakpoints
    Simplifies the accessibility overrides to target only elements with transitions/animations
    Resolves positioning conflicts between mobile and desktop layouts
    Creates a clear z-index hierarchy with named variables
    Improves print styles for better printed output
    Reduces redundancy by using variables for common values
    Provides consistent spacing through variables that adjust at different breakpoints
*/
