/* Containment Crew Stylesheet - Science Games Lab Standard */

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    box-sizing: border-box;
}

body {
    font-family: 'Fredoka', system-ui, -apple-system, sans-serif;
    background-color: #18181b;
    color: #f4f4f5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    user-select: none;
}

/* Page Layout */
.page-container {
    width: 100%;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.leaderboard-panel {
    display: none;
}

.game-wrapper {
    width: 100%;
    max-width: 64rem;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    box-sizing: border-box;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Centered Footer */
footer {
    flex-shrink: 0;
    padding: 0.5rem 1rem 1rem 1rem;
    box-sizing: border-box;
    width: 100%;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.footer-content img {
    height: 4rem;
    width: auto;
    object-fit: contain;
    transition: transform 0.2s ease-in-out;
}

.footer-content a:hover img {
    transform: scale(1.05);
}

/* HUD Header */
.hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.65rem;
    gap: 0.75rem;
    flex-wrap: nowrap;
}

.hud-element {
    font-family: 'Fredoka', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    background: rgba(24, 24, 27, 0.85);
    backdrop-filter: blur(6px);
    padding: 0.45rem 0.9rem;
    border-radius: 0.75rem;
    border: 2px solid #52525b;
    letter-spacing: 0.5px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    color: #f4f4f5;
    transition: all 0.2s ease;
}

.hud-center {
    flex-grow: 1;
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
    max-width: 28rem;
}

.status-bar-container {
    flex: 1 1 0;
    min-width: 120px;
}

.hud-label {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    display: block;
    margin-bottom: 0.2rem;
    letter-spacing: 0.5px;
}

.status-bar {
    width: 100%;
    height: 1.25rem;
    background-color: rgba(0, 0, 0, 0.6);
    border: 2px solid #52525b;
    border-radius: 0.5rem;
    padding: 2px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
}

.status-bar-fill {
    height: 100%;
    width: 100%;
    border-radius: 0.25rem;
    transition: width 0.3s ease-in-out, background-color 0.3s ease-in-out;
}

.status-bar-fill.containment {
    background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
}

.status-bar-fill.containment.warning {
    background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.status-bar-fill.containment.danger {
    background: linear-gradient(90deg, #dc2626 0%, #ef4444 100%);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.streak-badge {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.25) 0%, rgba(217, 119, 6, 0.35) 100%);
    border-color: #f59e0b;
    color: #fde047;
    text-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
    animation: pulse-wiggle 1.2s infinite ease-in-out;
}

.hud-mute-button {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.65rem;
}

.hud-mute-button:hover {
    background: rgba(39, 39, 42, 0.9);
    border-color: #a1a1aa;
    transform: scale(1.05);
}

/* Game Area Container */
.game-area-wrapper {
    position: relative;
    width: 100%;
    flex-grow: 1;
    aspect-ratio: 16 / 9;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 0.85rem;
    overflow: hidden;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    border: 2px solid #52525b;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    min-height: 0;
    touch-action: none;
}

#game-container {
    width: 100%;
    height: 100%;
    position: relative;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 0.75rem;
    padding: 0.75rem 0.75rem 4.5rem 0.75rem;
}

#game-container.cursor-active {
    cursor: none;
}

/* Themed Location Boxes */
.location-box {
    position: relative;
    border-radius: 0.85rem;
    background-color: rgba(24, 24, 27, 0.5);
    backdrop-filter: blur(4px);
    transition: all 0.3s ease-out;
    overflow: hidden;
    border: 2px solid;
}

.location-park {
    border-color: rgba(34, 197, 94, 0.35);
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.08) 0%, rgba(15, 23, 42, 0.6) 100%);
}

.location-school {
    border-color: rgba(245, 158, 11, 0.35);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(15, 23, 42, 0.6) 100%);
}

.location-office {
    border-color: rgba(56, 189, 248, 0.35);
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.08) 0%, rgba(15, 23, 42, 0.6) 100%);
}

.location-market {
    border-color: rgba(251, 146, 60, 0.35);
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.08) 0%, rgba(15, 23, 42, 0.6) 100%);
}

.location-box.high-risk {
    border-color: #ef4444 !important;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.22) 0%, rgba(15, 23, 42, 0.7) 100%) !important;
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.5), inset 0 0 15px rgba(239, 68, 68, 0.3);
    animation: pulse-border-red 1s infinite alternate;
}

@keyframes pulse-border-red {
    from { border-color: #ef4444; }
    to { border-color: #fca5a5; }
}

.location-header {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    z-index: 2;
    pointer-events: none;
}

.location-badge {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 9999px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    line-height: 1.2;
}

.badge-park {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.4);
}

.badge-school {
    background: rgba(245, 158, 11, 0.2);
    color: #fde047;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-office {
    background: rgba(56, 189, 248, 0.2);
    color: #7dd3fc;
    border: 1px solid rgba(56, 189, 248, 0.4);
}

.badge-market {
    background: rgba(251, 146, 60, 0.2);
    color: #fdba74;
    border: 1px solid rgba(251, 146, 60, 0.4);
}

.location-surge-tag {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 9999px;
    background: #ef4444;
    color: #ffffff;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    animation: ready-pulse 0.6s infinite alternate;
}

/* Custom Cursor */
.custom-cursor {
    position: absolute;
    width: 48px;
    height: 48px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
    z-index: 150;
    transform: translate(-50%, -50%);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.8));
    transition: transform 0.05s linear;
}

/* Outbreak Risk Icons */
.risk-icon {
    position: absolute;
    width: 62px;
    height: 62px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s ease;
    animation: spawn-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
    user-select: none;
}

@keyframes spawn-pop {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.18); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.risk-icon img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    pointer-events: none;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
    animation: gentle-wobble 2.5s infinite ease-in-out;
}

@keyframes gentle-wobble {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.04) rotate(-3deg); }
    75% { transform: scale(0.97) rotate(3deg); }
}

.risk-icon:hover {
    transform: scale(1.15);
    filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.6));
}

.risk-icon.warning {
    animation: pulse-red-icon 0.5s infinite alternate;
}

@keyframes pulse-red-icon {
    0% { filter: drop-shadow(0 0 6px #ef4444); transform: scale(1); }
    100% { filter: drop-shadow(0 0 16px #ef4444); transform: scale(1.1) rotate(2deg); }
}

.risk-icon-combo {
    border: 2px dashed rgba(168, 85, 247, 0.6);
    border-radius: 50%;
    background: rgba(168, 85, 247, 0.15);
}

.risk-icon-combo.partial {
    border: 2.5px solid #facc15;
    background-color: rgba(250, 204, 21, 0.25);
    box-shadow: 0 0 15px rgba(250, 204, 21, 0.5);
}

.risk-icon-powerup {
    animation: pulse-green-powerup 1.2s infinite alternate;
}

@keyframes pulse-green-powerup {
    from { filter: drop-shadow(0 0 6px #10b981); transform: scale(1); }
    to { filter: drop-shadow(0 0 18px #34d399); transform: scale(1.08); }
}

.risk-icon-hazard {
    animation: pulse-hazard-wobble 1.5s infinite ease-in-out;
}

@keyframes pulse-hazard-wobble {
    0%, 100% { filter: drop-shadow(0 0 6px #f43f5e); transform: rotate(0deg); }
    50% { filter: drop-shadow(0 0 14px #e11d48); transform: rotate(4deg) scale(1.05); }
}

/* Combo Badges above Sick Crowd */
.combo-status-pips {
    position: absolute;
    top: -14px;
    display: flex;
    gap: 3px;
    pointer-events: none;
    z-index: 12;
}

.combo-pip {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.58rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: 9999px;
    background: rgba(24, 24, 27, 0.85);
    border: 1px solid #71717a;
    color: #a1a1aa;
    white-space: nowrap;
}

.combo-pip.done {
    background: rgba(34, 197, 94, 0.85);
    border-color: #22c55e;
    color: #ffffff;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}

/* Tool Bay / Bottom Dock */
.tool-bay {
    position: absolute;
    bottom: 0.65rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 15;
    background: rgba(18, 18, 24, 0.9);
    backdrop-filter: blur(8px);
    border: 2px solid #52525b;
    border-radius: 0.85rem;
    padding: 0.4rem 0.65rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.55rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    max-width: 96%;
}

.tool-btn {
    width: 64px;
    height: 64px;
    border-radius: 0.65rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.68rem;
    font-weight: 700;
    text-align: center;
    border: 2px solid #52525b;
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease, background-color 0.2s ease, border-color 0.2s ease;
    user-select: none;
    padding: 0.2rem;
    box-sizing: border-box;
    position: relative;
    background: rgba(255, 255, 255, 0.04);
    color: #f4f4f5;
}

.tool-btn:hover:not(.initially-locked):not(.locked) {
    transform: translateY(-3px) scale(1.04);
    border-color: #f4f4f5;
    background: rgba(255, 255, 255, 0.08);
}

.tool-btn:active:not(.initially-locked):not(.locked) {
    transform: scale(0.95);
}

.tool-btn.selected {
    transform: translateY(-4px) scale(1.08);
    border-color: #facc15 !important;
    box-shadow: 0 0 16px rgba(250, 204, 21, 0.5);
    background: rgba(250, 204, 21, 0.12);
    animation: selected-pulse 1.2s infinite ease-in-out;
}

@keyframes selected-pulse {
    0%, 100% { transform: translateY(-4px) scale(1.08); }
    50% { transform: translateY(-6px) scale(1.12); }
}

.tool-soap { border-color: rgba(34, 211, 238, 0.5); }
.tool-soap.selected { border-color: #22d3ee; }
.tool-mask { border-color: rgba(56, 189, 248, 0.5); }
.tool-mask.selected { border-color: #38bdf8; }
.tool-distancing { border-color: rgba(96, 165, 250, 0.5); }
.tool-distancing.selected { border-color: #60a5fa; }
.tool-vaccine { border-color: rgba(52, 211, 153, 0.5); }
.tool-vaccine.selected { border-color: #34d399; }
.tool-repellent { border-color: rgba(45, 212, 191, 0.5); }
.tool-repellent.selected { border-color: #2dd4bf; }

.tool-key-badge {
    position: absolute;
    top: 3px;
    left: 4px;
    font-size: 0.55rem;
    font-weight: 700;
    color: #94a3b8;
    line-height: 1;
}

.tool-icon-box {
    width: 2.1rem;
    height: 2.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.1rem;
}

.tool-icon-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.tool-label {
    font-size: 0.65rem;
    line-height: 1.1;
}

.tool-btn.initially-locked {
    background-color: rgba(24, 24, 27, 0.8);
    border-color: #3f3f46;
    opacity: 0.55;
    cursor: not-allowed;
}

.tool-unlock-badge {
    position: absolute;
    bottom: 2px;
    right: 3px;
    font-size: 0.52rem;
    font-weight: 700;
    color: #facc15;
    background: rgba(0, 0, 0, 0.6);
    padding: 0.05rem 0.25rem;
    border-radius: 9999px;
}

.tool-btn.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Projectile Layer and Particle Animations */
#projectile-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 20;
}

.flying-projectile {
    position: absolute;
    width: 32px;
    height: 32px;
    object-fit: contain;
    transform: translate(-50%, -50%);
    filter: drop-shadow(0 0 8px currentColor);
    transition: transform 0.25s linear;
}

.cure-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    animation: particle-burst 0.5s ease-out forwards;
}

@keyframes particle-burst {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

/* Score Pops and Notifications */
#score-pop-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 25;
}

.score-pop {
    position: absolute;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    pointer-events: none;
    animation: score-pop-animation 0.9s ease-out forwards;
    white-space: nowrap;
}

.score-positive {
    color: #fde047;
    text-shadow: 0 0 6px #f59e0b, 0 0 12px #d97706;
}

.score-negative {
    color: #f87171;
    text-shadow: 0 0 6px #ef4444, 0 0 12px #b91c1c;
}

@keyframes score-pop-animation {
    0% { transform: translate(-50%, 0) scale(0.8); opacity: 1; }
    40% { transform: translate(-50%, -20px) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -50px) scale(1); opacity: 0; }
}

#notification-container {
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
    z-index: 30;
}

.notification-item {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.9), 0 0 20px rgba(0, 0, 0, 0.8);
    animation: ready-pulse 0.5s ease-out, fade-in 0.3s ease-out;
    background: rgba(24, 24, 27, 0.85);
    padding: 0.4rem 1.2rem;
    border-radius: 9999px;
    border: 2px solid currentColor;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.4s ease-out;
}

.notification-item.fade-out {
    opacity: 0;
}

@keyframes ready-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes fade-in {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

#screen-flasher {
    position: absolute;
    inset: 0;
    background-color: rgba(250, 204, 21, 0.35);
    opacity: 0;
    pointer-events: none;
    z-index: 99;
}

#screen-flasher.flash {
    animation: screen-flash-anim 0.4s ease-out;
}

@keyframes screen-flash-anim {
    0% { opacity: 0.7; }
    100% { opacity: 0; }
}

/* Modals */
.modal {
    position: absolute;
    inset: 0;
    background: rgba(12, 12, 16, 0.94);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    z-index: 50;
    border-radius: 0.85rem;
    box-sizing: border-box;
}

.modal-header {
    flex-shrink: 0;
    text-align: center;
    padding-bottom: 0.4rem;
}

.modal-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #ffffff;
    margin: 0 0 0.2rem 0;
}

.modal-subtitle {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #facc15;
    margin: 0;
}

#startContent {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
    width: 100%;
}

.modal-body {
    flex-grow: 1;
    overflow-y: auto;
    width: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.25rem 0.5rem 2rem 0.5rem;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.modal-footer {
    flex-shrink: 0;
    padding-top: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.tutorial-corner-btn {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: auto;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #f4f4f5;
    background: rgba(16, 185, 129, 0.3);
    border: 1.5px solid #34d399;
    border-radius: 9999px;
    padding: 0.35rem 1rem;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s ease, border-color 0.2s ease;
}

.tutorial-corner-btn:hover {
    background: rgba(16, 185, 129, 0.5);
    border-color: #6ee7b7;
    transform: translateY(-2px) scale(1.04);
}

.tutorial-corner-btn:active {
    transform: scale(0.96);
}

/* Character Intro Trading Cards */
.intro-box {
    width: 100%;
    max-width: 58rem;
    margin: 0 auto 1.5rem auto;
    padding: 0.5rem 0.65rem 0.75rem 0.65rem;
    background-color: rgba(24, 24, 27, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    box-sizing: border-box;
}

.cards-hint {
    text-align: center;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.3px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.45rem;
    width: 100%;
}

@media (min-width: 540px) {
    .cards-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 720px) {
    .cards-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 860px) {
    .cards-grid { grid-template-columns: repeat(5, 1fr); }
}

@media (min-width: 1024px) {
    .cards-grid { grid-template-columns: repeat(7, 1fr); }
}

.character-card {
    position: relative;
    background: rgba(255, 255, 255, 0.04);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.75rem;
    padding: 0.45rem 0.35rem 0.45rem 0.35rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.character-card:hover {
    animation: wiggle 0.4s ease-in-out;
    transform: translateY(-4px) scale(1.04);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

.character-card:active {
    transform: scale(0.96);
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-3deg) scale(1.03); }
    75% { transform: rotate(3deg) scale(1.03); }
}

@keyframes pulse-wiggle {
    0%, 100% { transform: scale(1) rotate(0deg); }
    20% { transform: scale(1.04) rotate(-2deg); }
    40% { transform: scale(1.04) rotate(2deg); }
    60% { transform: scale(1.02) rotate(-1deg); }
    80% { transform: scale(1.02) rotate(1deg); }
}

.card-hero { border-color: rgba(34, 211, 238, 0.4); }
.card-hero:hover { border-color: #22d3ee; box-shadow: 0 8px 24px rgba(34, 211, 238, 0.25); }

.card-threat { border-color: rgba(248, 113, 113, 0.4); }
.card-threat:hover { border-color: #f87171; box-shadow: 0 8px 24px rgba(248, 113, 113, 0.25); }

.card-bonus { border-color: rgba(250, 204, 21, 0.4); }
.card-bonus:hover { border-color: #facc15; box-shadow: 0 8px 24px rgba(250, 204, 21, 0.25); }

.card-combo { border-color: rgba(192, 132, 252, 0.4); }
.card-combo:hover { border-color: #c084fc; box-shadow: 0 8px 24px rgba(192, 132, 252, 0.25); }

.card-hazard { border-color: rgba(244, 63, 94, 0.4); }
.card-hazard:hover { border-color: #f43f5e; box-shadow: 0 8px 24px rgba(244, 63, 94, 0.25); }

.card-badge {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.12rem 0.45rem;
    border-radius: 9999px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
    line-height: 1.2;
}

.badge-hero { background: rgba(34, 211, 238, 0.2); color: #67e8f9; border: 1px solid rgba(34, 211, 238, 0.4); }
.badge-threat { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.4); }
.badge-bonus { background: rgba(250, 204, 21, 0.2); color: #fde047; border: 1px solid rgba(250, 204, 21, 0.4); }
.badge-combo { background: rgba(168, 85, 247, 0.2); color: #d8b4fe; border: 1px solid rgba(168, 85, 247, 0.4); }
.badge-hazard { background: rgba(244, 63, 94, 0.2); color: #fda4af; border: 1px solid rgba(244, 63, 94, 0.4); }

.card-portrait, .icon-container {
    width: 2.85rem;
    height: 2.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 0.55rem;
    padding: 0.25rem;
    box-sizing: border-box;
    margin-bottom: 0.25rem;
    transition: transform 0.2s ease;
}

.character-card:hover .card-portrait {
    transform: scale(1.08);
}

.card-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.card-name {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 0.12rem;
}

.card-ability {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.65rem;
    color: #d4d4d8;
    line-height: 1.2;
    font-weight: 500;
}

/* Player Input and Action Buttons */
.player-name-input {
    background-color: #27272a;
    color: #ffffff;
    width: 100%;
    max-width: 24rem;
    text-align: center;
    padding: 0.55rem 1rem;
    border-radius: 0.65rem;
    border: 2px solid #52525b;
    margin-bottom: 0.75rem;
    font-family: 'Fredoka', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.player-name-input:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.player-name-input.shake-input {
    animation: input-shake 0.4s;
}

@keyframes input-shake {
    10%, 90% { transform: translateX(-4px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-4px); }
    40%, 60% { transform: translateX(4px); }
}

.btn-primary, .btn-secondary {
    font-family: 'Fredoka', cursive, sans-serif;
    color: white;
    font-weight: 700;
    padding: 0.65rem 1.6rem;
    border-radius: 0.65rem;
    font-size: 1.05rem;
    letter-spacing: 0.5px;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease, background-color 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.5);
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
}

.btn-primary:active {
    transform: translateY(1px) scale(0.98);
}

.btn-secondary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.btn-secondary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 18px rgba(59, 130, 246, 0.5);
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
}

.btn-secondary:active {
    transform: translateY(1px) scale(0.98);
}

.modal-footer-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

/* Science Fact Modal and How to Play Modal Cards */
.fact-card, .how-to-card {
    position: relative;
    width: 100%;
    max-width: 44rem;
    max-height: 90vh;
    margin: auto;
    overflow-y: auto;
    background: linear-gradient(135deg, rgba(24, 24, 32, 0.98) 0%, rgba(15, 15, 20, 0.98) 100%);
    border: 2px solid rgba(52, 211, 153, 0.45);
    border-radius: 1.25rem;
    padding: 1.4rem 1.6rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(52, 211, 153, 0.2);
    text-align: center;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.fact-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.how-to-header-badge {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.65rem;
    border-radius: 9999px;
    background: rgba(52, 211, 153, 0.2);
    color: #6ee7b7;
    border: 1px solid rgba(52, 211, 153, 0.4);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.fact-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #a1a1aa;
    cursor: pointer;
    line-height: 1;
    padding: 0.2rem 0.4rem;
    border-radius: 0.35rem;
    transition: color 0.2s ease, transform 0.2s ease;
}

.fact-close-btn:hover {
    color: #f4f4f5;
    transform: scale(1.1);
}

.fact-portrait {
    width: 4.5rem;
    height: 4.5rem;
    margin-bottom: 0.75rem;
}

.fact-title, .how-to-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 0.35rem 0;
}

.how-to-subtitle {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.95rem;
    color: #facc15;
    margin: 0 0 1rem 0;
}

.fact-text {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.95rem;
    line-height: 1.45;
    color: #d4d4d8;
    max-width: 32rem;
    margin: 0 0 1.25rem 0;
}

.fact-btn {
    min-width: 140px;
}

/* Tutorial Grid inside How to Play */
.tutorial-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    width: 100%;
    margin-bottom: 1.25rem;
}

@media (min-width: 640px) {
    .tutorial-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.tutorial-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.85rem;
    padding: 0.75rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.tutorial-icon-box {
    width: 3.5rem;
    height: 3.5rem;
    margin-bottom: 0.4rem;
}

.tutorial-step-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: #6ee7b7;
    margin-bottom: 0.25rem;
}

.tutorial-step-desc {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.72rem;
    color: #cbd5e1;
    line-height: 1.3;
}

/* Game Over Modal Elements */
.game-over-title {
    font-size: 2rem;
    color: #fde047;
}

.final-score-text {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: #f4f4f5;
    margin: 0.25rem 0;
}

.leaderboard-rank-text {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: #facc15;
    margin: 0.25rem 0 0.75rem 0;
}

.science-fact-box {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    border: 1.5px solid #52525b;
    max-width: 34rem;
    margin: 0 auto;
    text-align: center;
}

.science-fact-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: #6ee7b7;
    margin: 0 0 0.4rem 0;
}

.science-fact-text {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.9rem;
    line-height: 1.45;
    color: #d4d4d8;
    margin: 0;
}

/* Leaderboard Sidebar & Podium Cards */
.leaderboard-panel-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    margin: 0 0 0.85rem 0;
    color: #facc15;
    letter-spacing: 0.5px;
}

.leaderboard-box {
    background: rgba(18, 18, 24, 0.75);
    padding: 0.65rem;
    border-radius: 0.65rem;
    border: 1px solid #3f3f46;
    overflow-y: auto;
    flex-grow: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.leaderboard-podium-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 0.55rem;
    background: rgba(255, 255, 255, 0.04);
    font-family: 'Fredoka', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.15s ease;
}

.leaderboard-podium-card:hover {
    transform: translateX(2px);
}

.podium-rank-1 {
    background: linear-gradient(90deg, rgba(250, 204, 21, 0.22) 0%, rgba(30, 20, 10, 0.7) 100%);
    border: 1.5px solid rgba(250, 204, 21, 0.6);
}

.podium-rank-2 {
    background: linear-gradient(90deg, rgba(203, 213, 225, 0.2) 0%, rgba(20, 25, 35, 0.7) 100%);
    border: 1.5px solid rgba(203, 213, 225, 0.5);
}

.podium-rank-3 {
    background: linear-gradient(90deg, rgba(217, 119, 6, 0.2) 0%, rgba(30, 15, 10, 0.7) 100%);
    border: 1.5px solid rgba(217, 119, 6, 0.5);
}

.podium-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    margin-right: 0.45rem;
}

.podium-badge.rank-1 { background: linear-gradient(135deg, #facc15 0%, #ca8a04 100%); color: #1c1917; }
.podium-badge.rank-2 { background: linear-gradient(135deg, #e2e8f0 0%, #94a3b8 100%); color: #0f172a; }
.podium-badge.rank-3 { background: linear-gradient(135deg, #d97706 0%, #92400e 100%); color: #ffffff; }

.leaderboard-tip {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px dashed rgba(16, 185, 129, 0.35);
    border-radius: 0.65rem;
    padding: 0.55rem 0.75rem;
    margin-top: 0.75rem;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.75rem;
    color: #6ee7b7;
    line-height: 1.35;
}

.leaderboard-tip-icon {
    width: 1.8rem;
    height: 1.8rem;
    flex-shrink: 0;
}

/* Modal Specificity and Visibility Rule */
.hidden,
.modal.hidden,
#factModal.hidden,
#howToModal.hidden,
#mainLeaderboardModal.hidden,
#start-modal.hidden,
#game-over-modal.hidden,
#loading-modal.hidden {
    display: none !important;
}

/* Custom Scrollbars */
.modal-body::-webkit-scrollbar,
.leaderboard-box::-webkit-scrollbar,
.fact-card::-webkit-scrollbar,
.how-to-card::-webkit-scrollbar {
    width: 7px;
}

.modal-body::-webkit-scrollbar-track,
.leaderboard-box::-webkit-scrollbar-track,
.fact-card::-webkit-scrollbar-track,
.how-to-card::-webkit-scrollbar-track {
    background: #18181b;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb,
.leaderboard-box::-webkit-scrollbar-thumb,
.fact-card::-webkit-scrollbar-thumb,
.how-to-card::-webkit-scrollbar-thumb {
    background-color: #34d399;
    border-radius: 6px;
    border: 2px solid #18181b;
}

/* Responsive Desktop Layout */
@media (min-width: 1024px) {
    .page-container {
        display: grid;
        grid-template-columns: minmax(0, 3.2fr) minmax(0, 1fr);
        width: 100%;
        max-width: 86rem;
        margin: 0 auto;
        padding: 0.75rem 1rem;
        gap: 1.25rem;
        flex: 1 1 auto;
        min-height: 0;
        box-sizing: border-box;
        align-items: stretch;
    }

    .game-wrapper {
        max-width: 100%;
        padding: 0;
    }

    .leaderboard-panel {
        display: flex !important;
        flex-direction: column;
        background-color: rgba(24, 24, 27, 0.85);
        backdrop-filter: blur(8px);
        border-radius: 0.85rem;
        padding: 1rem;
        border: 2px solid #52525b;
        min-height: 0;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    }
}

/* Mobile Rotation Warning */

@media (min-width: 1024px) {
    #leaderboardBtn,
    #leaderboardGameOverBtn {
        display: none !important;
    }
}

.hud-mute-button {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    transition: transform 0.15s ease, background-color 0.2s, border-color 0.2s;
}

.hud-mute-button:hover {
    transform: scale(1.06);
    background: rgba(39, 39, 42, 0.95);
    border-color: #a1a1aa;
}

.hud-mute-button:active {
    transform: scale(0.95);
}

.hud-mute-button svg {
    width: 1.25rem;
    height: 1.25rem;
    display: block;
}

#rotate-warning {
    display: none;
    position: fixed;
    inset: 0;
    background-color: #18181b;
    color: #f4f4f5;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 200;
    padding: 1.5rem;
    font-family: 'Fredoka', sans-serif;
}

.rotate-icon {
    width: 4.5rem;
    height: 4.5rem;
    margin-bottom: 1.25rem;
    color: #38bdf8;
    animation: rotate-pulse 2s infinite ease-in-out;
}

@keyframes rotate-pulse {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(90deg) scale(1.08); }
}

@media screen and (max-width: 1023px) and (orientation: portrait) {
    .page-container, footer {
        display: none !important;
    }
    #rotate-warning {
        display: flex !important;
    }
}

@media screen and (max-height: 540px) and (orientation: landscape) {
    footer {
        display: none !important;
    }
    .page-container {
        padding: 0.25rem 0.5rem;
    }
    .game-wrapper {
        max-width: 100%;
        height: 100%;
    }
    .leaderboard-panel {
        display: none !important;
    }
    .hud {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-bottom: 0.25rem !important;
        gap: 0.35rem !important;
    }
    .hud-element {
        font-size: 0.78rem;
        padding: 0.2rem 0.5rem;
        border-radius: 0.5rem;
    }
    .hud-label {
        display: none !important;
    }
    .integrity-container {
        min-width: 70px;
        max-width: 180px;
        flex-grow: 1;
    }
    .integrity-bar {
        height: 0.95rem;
        border-radius: 0.35rem;
    }
    .hud-mute-button {
        display: flex !important;
        padding: 0.2rem 0.4rem;
    }
    .canvas-container,
    .game-area-wrapper,
    #game-container {
        min-height: 0;
        flex: 1 1 auto;
    }
    canvas {
        max-height: 100%;
        max-width: 100%;
    }
    .modal {
        padding: 0.35rem 0.6rem;
    }
    .modal-header {
        padding-bottom: 0.15rem;
    }
    .modal-title {
        font-size: 1.3rem;
        line-height: 1.1;
    }
    .modal-subtitle {
        font-size: 0.7rem;
        margin: 0;
    }
    .tutorial-corner-btn {
        top: 0.35rem;
        left: 0.35rem;
        right: auto !important;
        padding: 0.2rem 0.5rem;
        font-size: 0.7rem;
    }
    .intro-box {
        padding: 0.3rem 0.4rem;
        margin-bottom: 0.25rem;
    }
    .cards-hint {
        font-size: 0.65rem;
        margin-bottom: 0.15rem;
    }
    .cards-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 0.25rem;
    }
    .character-card {
        padding: 0.25rem 0.2rem;
        border-radius: 0.5rem;
    }
    .card-badge {
        font-size: 0.5rem;
        padding: 0.05rem 0.25rem;
        margin-bottom: 0.15rem;
    }
    .card-portrait, .icon-container {
        width: 2rem;
        height: 2rem;
        padding: 0.15rem;
        margin-bottom: 0.15rem;
    }
    .card-name {
        font-size: 0.65rem;
        margin-bottom: 0.05rem;
    }
    .card-ability {
        font-size: 0.56rem;
        line-height: 1.1;
    }
    .modal-footer {
        padding-top: 0.25rem;
    }
    .player-name-input {
        padding: 0.3rem 0.6rem;
        font-size: 0.85rem;
        max-width: 16rem;
        border-radius: 0.5rem;
    }
    .modal-footer-buttons {
        margin-top: 0.25rem;
        gap: 0.5rem;
    }
    .btn-primary, .btn-secondary {
        padding: 0.35rem 1rem;
        font-size: 0.88rem;
        border-radius: 0.5rem;
    }
    .game-over-title {
        font-size: 1.3rem;
    }
    .game-over-fact-card {
        padding: 0.35rem 0.6rem;
        max-width: 22rem;
        margin: 0.2rem auto;
    }
    .game-over-fact-portrait {
        width: 2.75rem;
        height: 2.75rem;
        margin-bottom: 0.2rem;
    }
    .game-over-fact-title {
        font-size: 0.95rem;
        margin-bottom: 0.15rem;
    }
    .game-over-fact-text {
        font-size: 0.72rem;
        line-height: 1.25;
    }
    #mainLeaderboardModal .modal-body,
    .how-to-card,
    .fact-card {
        max-height: 85vh;
        overflow-y: auto;
    }
    .tutorial-cards {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.35rem;
    }
    .tutorial-card {
        padding: 0.4rem;
    }
    .tutorial-step-img {
        width: 2rem;
        height: 2rem;
    }
}

.science-corner-btn {
    position: absolute;
    top: 1rem;
    left: auto;
    right: 1rem;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #f4f4f5;
    background: rgba(5, 150, 105, 0.35);
    border: 1.5px solid #34d399;
    border-radius: 9999px;
    padding: 0.35rem 1rem;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
}
.science-corner-btn:hover {
    background: #059669;
    color: #ffffff;
    box-shadow: 0 0 15px rgba(52, 211, 153, 0.6);
    transform: translateY(-1px);
}
#scienceInfoModal {
    position: fixed;
    inset: 0;
    z-index: 110;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    box-sizing: border-box;
}
#scienceInfoModal.hidden {
    display: none !important;
}
.science-info-card {
    position: relative;
    background: #18181b;
    border: 2px solid #34d399;
    border-radius: 1.25rem;
    padding: 1.5rem;
    max-width: 48rem;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65);
    margin: auto;
}
.science-info-body {
    text-align: left;
    color: #d4d4d8;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.85rem;
    line-height: 1.55;
    width: 100%;
}
.science-info-body h3 {
    color: #6ee7b7;
    font-size: 0.95rem;
    font-weight: 700;
    margin: 1rem 0 0.4rem 0;
}
.science-info-body p { margin: 0.5rem 0; }
.science-info-body ul {
    margin: 0.3rem 0 0.6rem 1.1rem;
    list-style: disc;
}
.science-info-body li { margin: 0.2rem 0; }
.science-info-body a {
    color: #38bdf8;
    text-decoration: underline;
}
.science-info-body a:hover { color: #7dd3fc; }
.science-grade { font-size: 0.8rem; color: #a1a1aa; }
@media (max-width: 1024px) {
    .science-corner-btn {
        top: 0.35rem;
        right: 0.35rem;
        left: auto !important;
        padding: 0.2rem 0.5rem;
        font-size: 0.7rem;
    }
}

.footer-legal {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    margin-top: 0.4rem;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.7rem;
}
.footer-legal a, .footer-legal-btn {
    color: #71717a;
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
}
.footer-legal a:hover, .footer-legal-btn:hover { color: #34d399; }
