/* ── Virtual Community Pharmacy Simulator Premium Styles ── */


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

:root {
    --sim-gold: #f9df7b;
    --sim-gold-glow: rgba(249, 223, 123, 0.3);
    --sim-teal: #00c2a8;
    --sim-teal-glow: rgba(0, 194, 168, 0.2);
    --sim-card-bg: rgba(17, 22, 37, 0.65);
    --sim-border-soft: rgba(255, 255, 255, 0.08);
    --sim-border-gold: rgba(249, 223, 123, 0.3);
    --sim-bg-dark: #0b0e14;
    --sim-bg-surface: #111625;
    --sim-text-muted: #94a3b8;
    --sim-text-light: #e2e8f0;

    --success-green: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    --danger-red: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.2);

    --font-heading: 'Outfit', 'Inter', sans-serif;
}

.pharmacy-sim-page {
    max-width: 1300px;
    margin: 85px auto 50px;
    padding: 0 20px;
    font-family: var(--font-heading);
    color: var(--sim-text-light);
}

/* Nav Header */
.sim-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.sim-nav-header .back-link {
    color: var(--sim-teal);
    text-decoration: none;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    transition: transform 0.2s, color 0.2s;
}

.sim-nav-header .back-link:hover {
    color: #00e5c7;
    transform: translateX(-4px);
}

.user-stats-pill {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--sim-border-soft);
    padding: 6px 16px;
    border-radius: 20px;
}

.user-stats-pill .xp-count {
    font-weight: 700;
    color: var(--sim-gold);
    display: flex;
    align-items: center;
    gap: 6px;
}

.text-gold {
    color: var(--sim-gold) !important;
}

/* ────────────────────────────────────────────────────────
   SELECTION SCREEN
   ──────────────────────────────────────────────────────── */

.welcome-banner {
    text-align: center;
    padding: 40px 30px;
    background: linear-gradient(135deg, rgba(20, 24, 40, 0.8) 0%, rgba(10, 12, 22, 0.95) 100%);
    border-radius: 24px;
    border: 1px solid var(--sim-border-soft);
    margin-bottom: 35px;
    position: relative;
    overflow: hidden;
}

.welcome-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0, 194, 168, 0.05) 0%, transparent 60%);
    pointer-events: none;
}

.banner-icon {
    font-size: 3.5rem;
    color: var(--sim-teal);
    text-shadow: 0 0 25px var(--sim-teal-glow);
    margin-bottom: 16px;
}

.welcome-banner h1 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 10px;
    background: linear-gradient(to right, #fff, #b2d5e7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-banner p {
    font-size: 1.05rem;
    color: var(--sim-text-muted);
    max-width: 750px;
    margin: 0 auto;
    line-height: 1.6;
}

.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--sim-border-soft);
    padding-bottom: 12px;
}

.section-title-row h2 {
    font-size: 1.4rem;
    font-weight: 700;
}

.badge-total-cases {
    font-size: 0.82rem;
    font-weight: 700;
    background: rgba(0, 194, 168, 0.1);
    color: var(--sim-teal);
    border: 1px solid rgba(0, 194, 168, 0.25);
    padding: 4px 12px;
    border-radius: 20px;
}

/* Scenarios Grid */
.scenarios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 25px;
}

.scenario-card {
    background: var(--sim-card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--sim-border-soft);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 250px;
    position: relative;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer;
}

.scenario-card:hover {
    transform: translateY(-6px);
    border-color: var(--sim-border-gold);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), 0 0 15px rgba(249, 223, 123, 0.05);
}

.sc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.sc-num {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--sim-teal);
    letter-spacing: 0.5px;
}

.sc-status-badge {
    font-size: 0.72rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 12px;
}

.sc-status-badge.completed {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success-green);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.sc-status-badge.pending {
    background: rgba(255, 255, 255, 0.03);
    color: var(--sim-text-muted);
    border: 1px solid var(--sim-border-soft);
}

.scenario-card h3 {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 8px;
    color: #fff;
}

.sc-desc {
    font-size: 0.88rem;
    color: var(--sim-text-muted);
    line-height: 1.5;
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.sc-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.sc-difficulty {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.sc-difficulty.easy {
    color: #34d399;
}

.sc-difficulty.medium {
    color: #fbbf24;
}

.sc-difficulty.hard {
    color: #f87171;
}

.btn-start-case {
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.2s;
}

.scenario-card:hover .btn-start-case {
    color: var(--sim-gold);
    transform: translateX(4px);
}

/* ────────────────────────────────────────────────────────
   GAME ACTIVE PLAYING SCREEN
   ──────────────────────────────────────────────────────── */

.simulator-workspace {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Game HUD */
.game-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, rgba(17, 22, 37, 0.9) 0%, rgba(12, 16, 28, 0.95) 100%);
    border: 1px solid var(--sim-border-soft);
    border-radius: 16px;
    padding: 16px 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.hud-case-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.case-number-tag {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--sim-teal);
    letter-spacing: 1px;
}

#hudCaseTitle {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
}

.hud-stats {
    display: flex;
    align-items: center;
    gap: 40px;
}

.hud-stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--sim-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 800;
}

.hearts-container {
    display: flex;
    gap: 6px;
    font-size: 1.15rem;
    height: 25px;
    align-items: center;
}

.hearts-container .fa-heart {
    transition: transform 0.2s, color 0.2s;
}

.heart-active {
    color: var(--danger-red);
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.heart-empty {
    color: rgba(255, 255, 255, 0.12);
    transform: scale(0.9);
}

.timer-box {
    width: 120px;
}

.timer-bar-container {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4px;
}

.timer-bar {
    height: 100%;
    background: var(--sim-teal);
    border-radius: 2px;
    transition: width 1s linear, background-color 0.3s;
}

.timer-critical {
    background: var(--danger-red) !important;
    box-shadow: 0 0 5px var(--danger-red);
}

/* Split Layout */
.interaction-layout {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 24px;
}

@media (max-width: 992px) {
    .interaction-layout {
        grid-template-columns: 1fr;
    }
}

/* Viewport Card */
.viewport-card {
    background: var(--sim-bg-surface);
    border: 1px solid var(--sim-border-soft);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.viewport-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.25);
    padding: 12px 20px;
    border-bottom: 1px solid var(--sim-border-soft);
}

.live-tag {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--sim-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--danger-red);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--danger-red);
    animation: pulse 1.5s infinite alternate;
}

@keyframes pulse {
    from {
        opacity: 0.4;
    }

    to {
        opacity: 1;
    }
}

.hud-audio-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--sim-border-soft);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: var(--sim-text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.hud-audio-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--sim-gold);
}

/* 3D Wrapper */
.viewport-3d-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16/10;
    background: radial-gradient(circle at center, #1b233a 0%, #0d111d 100%);
    overflow: hidden;
}

/* 3D Room Container */
.pharmacy-3d-room {
    position: absolute;
    inset: 0;
    perspective: 1000px;
    transform-style: preserve-3d;
}

/* Shelves Background */
.shelves-background {
    position: absolute;
    top: 5%;
    left: 5%;
    right: 5%;
    height: 55%;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.03);
    padding: 10px;
    border-radius: 8px;
    transform: translateZ(-200px);
}

.shelf-row {
    height: 25%;
    background: rgba(139, 92, 26, 0.2);
    border-bottom: 4px solid #5a3c10;
    border-radius: 2px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 0 10px 2px;
}

.shelf-med {
    width: 16px;
    height: 25px;
    border-radius: 2px;
    opacity: 0.75;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.shelf-med.green-box {
    background: linear-gradient(135deg, #10b981, #047857);
}

.shelf-med.blue-box {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.shelf-med.red-box {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
}

.shelf-med.yellow-box {
    background: linear-gradient(135deg, #f59e0b, #b45309);
}

.shelf-med.white-box {
    background: linear-gradient(135deg, #f1f5f9, #cbd5e1);
}

/* Isometric Counter Desk */
.counter-desk-3d {
    position: absolute;
    bottom: 0;
    left: 10%;
    right: 10%;
    height: 35%;
    transform-style: preserve-3d;
    transform: translateZ(50px);
}

.counter-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 25px;
    background: linear-gradient(90deg, #1e293b 0%, #334155 50%, #1e293b 100%);
    border-bottom: 2px solid #475569;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
    transform: rotateX(60deg);
    transform-origin: top center;
    border-radius: 6px 6px 0 0;
}

.counter-front {
    position: absolute;
    top: 13px;
    left: 1%;
    right: 1%;
    bottom: 0;
    background: linear-gradient(180deg, #111827 0%, #030712 100%);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-top: none;
    border-radius: 0 0 12px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.counter-logo {
    font-size: 2.2rem;
    color: rgba(0, 194, 168, 0.15);
    animation: glowLogo 3s infinite alternate;
}

@keyframes glowLogo {
    from {
        color: rgba(0, 194, 168, 0.12);
        text-shadow: none;
    }

    to {
        color: rgba(0, 194, 168, 0.35);
        text-shadow: 0 0 15px rgba(0, 194, 168, 0.3);
    }
}

/* Patient Avatar placement */
.patient-character-container {
    position: absolute;
    bottom: 25%;
    left: 50%;
    transform: translateX(-50%) translateZ(-50px);
    width: 140px;
    height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    pointer-events: none;
    z-index: 10;
}

.character-svg-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.character-svg-wrapper svg {
    width: auto;
    height: 90%;
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.6));
}

.patient-shadow {
    position: absolute;
    bottom: -6px;
    width: 70px;
    height: 12px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    filter: blur(3px);
}

/* Character Animation classes */
.walk-in {
    animation: animWalkIn 1.5s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

.walk-out {
    animation: animWalkOut 1.5s cubic-bezier(0.7, 0.0, 0.9, 0.2) forwards;
}

.idle-bounce {
    animation: animIdleBounce 1.5s infinite alternate ease-in-out;
}

@keyframes animWalkIn {
    0% {
        transform: translateX(-200%) scale(0.8) translateZ(-50px);
        opacity: 0;
    }

    100% {
        transform: translateX(-50%) scale(1) translateZ(-50px);
        opacity: 1;
    }
}

@keyframes animWalkOut {
    0% {
        transform: translateX(-50%) scale(1) translateZ(-50px);
        opacity: 1;
    }

    100% {
        transform: translateX(200%) scale(0.8) translateZ(-50px);
        opacity: 0;
    }
}

@keyframes animIdleBounce {
    0% {
        transform: translateX(-50%) translateY(0) scale(1) translateZ(-50px);
    }

    100% {
        transform: translateX(-50%) translateY(-6px) scale(1) translateZ(-50px);
    }
}

/* Speech Bubble hover style */
.speech-bubble-container {
    position: absolute;
    top: 10%;
    left: 10%;
    right: 10%;
    z-index: 20;
    animation: floatBubble 0.3s ease-out forwards;
}

.speech-bubble {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--sim-teal);
    box-shadow: 0 6px 20px rgba(0, 194, 168, 0.15), inset 0 0 10px rgba(0, 194, 168, 0.05);
    border-radius: 16px;
    padding: 16px 20px;
    position: relative;
    text-align: center;
}

.speech-bubble p {
    font-size: 0.98rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.6;
    direction: rtl;
    /* For Arabic dialect readability */
}

.speech-bubble-arrow {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    margin-left: -10px;
    border-width: 10px 10px 0;
    border-style: solid;
    border-color: rgba(15, 23, 42, 0.95) transparent;
    display: block;
    width: 0;
    z-index: 21;
}

@keyframes floatBubble {
    from {
        transform: translateY(10px);
        opacity: 0;
    }

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

/* ────────────────────────────────────────────────────────
   RIGHT PANEL: VITALS MONITOR & CONTROLS
   ──────────────────────────────────────────────────────── */

.control-card {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Vitals Monitor */
.vitals-monitor-panel {
    background: rgba(17, 22, 37, 0.7);
    border: 1px solid var(--sim-border-soft);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.vitals-monitor-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 2;
    background-size: 100% 3px, 3px 100%;
    pointer-events: none;
}

.panel-header {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--sim-teal);
    letter-spacing: 1px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
    text-transform: uppercase;
}

.vitals-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px 20px;
}

.vital-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.vital-item.full-width {
    grid-column: span 2;
}

.vital-lbl {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--sim-text-muted);
}

.vital-val {
    font-size: 0.92rem;
    font-weight: 700;
    color: #fff;
}

/* Action Console */
.action-console-panel {
    background: rgba(17, 22, 37, 0.7);
    border: 1px solid var(--sim-border-soft);
    border-radius: 20px;
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 350px;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    flex-grow: 1;
    justify-content: center;
}

/* Option Buttons styling */
.option-btn {
    width: 100%;
    padding: 14px 20px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--sim-border-soft);
    border-radius: 12px;
    color: #fff;
    font-size: 0.92rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 12px;
    direction: rtl;
    /* For Arabic option text readability */
}

.option-btn:hover {
    background: rgba(0, 194, 168, 0.06);
    border-color: var(--sim-teal);
    transform: translateX(4px);
    box-shadow: 0 2px 10px rgba(0, 194, 168, 0.08);
}

.option-btn.opt-blue:hover {
    background: rgba(59, 130, 246, 0.06);
    border-color: #3b82f6;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.08);
}

.option-btn.opt-red:hover {
    background: rgba(239, 68, 68, 0.06);
    border-color: var(--danger-red);
    box-shadow: 0 2px 10px rgba(239, 68, 68, 0.08);
}

.option-btn.opt-green:hover {
    background: rgba(16, 185, 129, 0.06);
    border-color: var(--success-green);
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.08);
}

.opt-prefix {
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--sim-text-muted);
    background: rgba(255, 255, 255, 0.06);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.option-btn:hover .opt-prefix {
    background: var(--sim-teal);
    color: #111;
}

.option-btn.opt-blue:hover .opt-prefix {
    background: #3b82f6;
    color: #fff;
}

.option-btn.opt-red:hover .opt-prefix {
    background: var(--danger-red);
    color: #fff;
}

.option-btn.opt-green:hover .opt-prefix {
    background: var(--success-green);
    color: #fff;
}

/* Counseling Log */
.counseling-log {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 12px;
}

.log-header {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--sim-text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.log-entries {
    max-height: 100px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 6px;
}

.log-entries::-webkit-scrollbar {
    width: 4px;
}

.log-entries::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.log-entry {
    font-size: 0.8rem;
    line-height: 1.4;
    padding: 4px 8px;
    border-radius: 4px;
}

.system-entry {
    background: rgba(255, 255, 255, 0.02);
    color: var(--sim-text-muted);
}

.correct-entry {
    background: rgba(16, 185, 129, 0.08);
    color: #34d399;
}

.incorrect-entry {
    background: rgba(239, 68, 68, 0.08);
    color: #f87171;
}

/* ────────────────────────────────────────────────────────
   VICTORY / DEFEAT MODAL OVERLAY (PREMIUM & COMPACT UPGRADE)
   ──────────────────────────────────────────────────────── */

.result-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 8, 14, 0.85);
    backdrop-filter: blur(16px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 20px; /* Generous padding to enforce top/bottom margins */
    overflow-y: auto; /* Fallback scroll inside overlay if screen is tiny */
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.result-modal-card {
    background: linear-gradient(135deg, rgba(17, 24, 39, 0.96) 0%, rgba(9, 12, 22, 0.99) 100%);
    border: 1px solid rgba(0, 194, 168, 0.22);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.75), 0 0 40px rgba(0, 194, 168, 0.08);
    border-radius: 24px;
    width: 100%;
    max-width: 560px; /* Slightly narrower to look more cohesive */
    padding: 28px 30px 24px; /* Compact padding */
    text-align: center;
    position: relative;
    margin: auto; /* Crucial for vertical centering with margins in flex */
    animation: scaleUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

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

@keyframes scaleUp {
    from { transform: scale(0.94); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Glowing Rotating Badge for Icon */
.result-icon-circle {
    width: 64px; /* Scaled down from 80px */
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin: 0 auto 16px;
    position: relative;
    z-index: 1;
}

/* Glow outer layers */
.result-icon-circle::before {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    background: inherit;
    opacity: 0.22;
    z-index: -1;
    animation: pulseGlow 2s infinite ease-in-out;
}

.result-icon-circle::after {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 1.2px dashed rgba(255, 255, 255, 0.12);
    z-index: -2;
    animation: rotateDashed 20s linear infinite;
}

.result-icon-circle.bg-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #111827;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.35);
}

.result-icon-circle.bg-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.35);
}

@keyframes pulseGlow {
    0%, 100% { transform: scale(1); opacity: 0.2; }
    50% { transform: scale(1.12); opacity: 0.32; }
}

@keyframes rotateDashed {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.result-modal-card h2 {
    font-size: 1.65rem; /* Scaled down */
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, #e2e8f0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#modalDesc {
    font-size: 0.92rem;
    color: var(--sim-text-muted);
    margin-bottom: 20px;
    line-height: 1.5;
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
}

/* Glassmorphic Metrics */
.modal-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.04);
    padding: 14px;
    border-radius: 14px;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.3);
}

.metric-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.metric-box:last-child {
    border-right: none;
}

.metric-lbl {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--sim-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.metric-val {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.text-gold {
    color: var(--sim-gold) !important;
    text-shadow: 0 0 8px rgba(249, 223, 123, 0.1);
}

.text-green {
    color: #34d399 !important;
    text-shadow: 0 0 8px rgba(52, 211, 153, 0.1);
}

/* Feedback Clinical Box (Extremely Premium & Capped) */
.feedback-review-box {
    text-align: right;
    background: rgba(10, 15, 26, 0.5);
    border: 1px solid rgba(0, 194, 168, 0.18);
    border-left: 4px solid var(--sim-teal);
    border-radius: 14px;
    padding: 16px 20px;
    margin-bottom: 24px;
    direction: rtl; /* For Arabic rationale */
    box-shadow: 0 6px 15px rgba(0,0,0,0.15);
}

.feedback-review-box h4 {
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--sim-teal);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    direction: ltr; /* keep label LTR but text inside box RTL */
    justify-content: flex-end;
}

.feedback-review-box h4 i {
    font-size: 1rem;
}

.feedback-review-box p {
    font-size: 0.88rem;
    color: #cbd5e1;
    line-height: 1.6;
    text-align: justify;
    max-height: 90px; /* Cap height to prevent viewport scrollbar overflow */
    overflow-y: auto;
    padding-left: 6px;
}

/* Custom scrollbar for rationale box */
.feedback-review-box p::-webkit-scrollbar {
    width: 4px;
}

.feedback-review-box p::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.02);
}

.feedback-review-box p::-webkit-scrollbar-thumb {
    background: rgba(0, 194, 168, 0.25);
    border-radius: 2px;
}

.feedback-review-box p::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 194, 168, 0.5);
}

/* Modal Action Buttons */
.modal-actions {
    display: flex;
    gap: 16px;
}

.btn-modal {
    flex: 1;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-outline {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--sim-teal) 0%, #059669 100%);
    border: none;
    color: #111827;
    box-shadow: 0 4px 15px rgba(0, 194, 168, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 194, 168, 0.4);
    filter: brightness(1.1);
}

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

/* Modal Open state on body to lock main page scrollbar */
body.modal-open {
    overflow: hidden !important;
}

/* Compact layout scaling for screens with short height */
@media (max-height: 820px) {
    .result-modal-overlay {
        padding: 15px;
    }
    .result-modal-card {
        padding: 20px 24px 16px;
        border-radius: 20px;
    }
    .result-icon-circle {
        width: 48px;
        height: 48px;
        font-size: 1.4rem;
        margin: 0 auto 10px;
    }
    .result-icon-circle::before {
        inset: -3px;
    }
    .result-icon-circle::after {
        inset: -6px;
    }
    .result-modal-card h2 {
        font-size: 1.35rem;
        margin-bottom: 4px;
    }
    #modalDesc {
        font-size: 0.85rem;
        margin-bottom: 12px;
    }
    .modal-metrics {
        padding: 10px;
        margin-bottom: 12px;
        border-radius: 10px;
        gap: 8px;
    }
    .metric-val {
        font-size: 1.05rem;
    }
    .feedback-review-box {
        padding: 10px 14px;
        margin-bottom: 14px;
        border-radius: 10px;
    }
    .feedback-review-box h4 {
        font-size: 0.8rem;
        margin-bottom: 4px;
    }
    .feedback-review-box p {
        font-size: 0.8rem;
        max-height: 60px;
    }
    .btn-modal {
        padding: 10px 16px;
        font-size: 0.85rem;
        border-radius: 10px;
    }
}

/* Difficulty Filters UI */
.difficulty-filters {
    display: flex;
    gap: 8px;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 999px;
    backdrop-filter: blur(10px);
}

.filter-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted, #94a3b8);
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: 999px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.filter-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.filter-btn.active {
    color: #fff;
    background: rgba(13, 148, 136, 0.15);
    border-color: rgba(13, 148, 136, 0.35);
    box-shadow: 0 0 12px rgba(13, 148, 136, 0.2);
}

.difficulty-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.difficulty-dot.easy {
    background: #34d399;
    box-shadow: 0 0 6px #34d399;
}

.difficulty-dot.medium {
    background: #fbbf24;
    box-shadow: 0 0 6px #fbbf24;
}

.difficulty-dot.hard {
    background: #f87171;
    box-shadow: 0 0 6px #f87171;
}

/* responsive alignment */
@media (max-width: 768px) {
    .section-title-row {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }
    .difficulty-filters {
        width: 100%;
        justify-content: space-between;
    }
}

/* ================================================================
   RESPONSIVE DESIGN FOR VIRTUAL PHARMACY SIMULATOR
   ================================================================ */

@media (max-width: 991px) {
    .pharmacy-sim-page {
        margin-top: 75px;
        padding: 0 16px;
    }
    .welcome-banner {
        padding: 30px 20px;
        margin-bottom: 25px;
    }
    .welcome-banner h1 {
        font-size: 1.8rem;
    }
    .welcome-banner p {
        font-size: 0.95rem;
    }
}

@media (max-width: 768px) {
    .pharmacy-sim-page {
        margin-top: 70px;
        padding: 0 12px;
    }
    .welcome-banner {
        padding: 24px 16px;
    }
    .welcome-banner h1 {
        font-size: 1.6rem;
    }
    .game-hud {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        padding: 16px;
    }
    .hud-stats {
        justify-content: space-between;
        gap: 15px;
    }
    .timer-box {
        width: auto;
        flex: 1;
    }
}

@media (max-width: 480px) {
    .pharmacy-sim-page {
        margin-top: 65px;
        padding: 0 10px;
    }
    .scenario-card {
        min-height: 220px;
        height: auto;
        padding: 20px;
    }
    .scenarios-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .difficulty-filters {
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        padding: 4px 8px;
    }
    .filter-btn {
        padding: 5px 12px;
        font-size: 0.75rem;
    }
    .speech-bubble {
        padding: 10px;
        border-radius: 12px;
    }
    .speech-bubble p {
        font-size: 0.8rem;
    }
    .modal-actions {
        flex-direction: column;
        gap: 10px;
    }
    .btn-modal {
        width: 100%;
    }
}