html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body {
    font-family: 'Fredoka', system-ui, -apple-system, sans-serif;
    background-color: #18181b;
    color: #f4f4f5;
    display: flex;
    flex-direction: column;
}

.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: 1rem;
    box-sizing: border-box;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

footer {
    flex-shrink: 0;
    padding: 1rem;
    padding-top: 0;
    box-sizing: border-box;
}

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

.footer-logo {
    height: 2rem;
    transition: transform 0.2s ease-in-out;
}

.footer-logo.large {
    height: 2.25rem;
}

.footer-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #a1a1aa;
    transition: color 0.2s;
}

.footer-link:hover {
    color: #f4f4f5;
}

.footer-link:hover .footer-logo {
    transform: scale(1.08);
}

/* 2-Column Desktop Grid 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);
    }
}

/* In-game HUD */
.hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 0.75rem;
    flex-shrink: 0;
}

.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.5rem 1rem;
    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);
}

.integrity-container {
    flex-grow: 1;
    text-align: center;
    min-width: 100px;
}

.hud-label {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
    letter-spacing: 0.5px;
    color: #e4e4e7;
}

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

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

.integrity-fill.critical {
    animation: critical-pulse 0.8s infinite alternate;
}

@keyframes critical-pulse {
    0% { opacity: 1; filter: brightness(1); }
    100% { opacity: 0.6; filter: brightness(1.4); }
}

.combo-badge {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.25) 0%, rgba(249, 115, 22, 0.3) 100%);
    border-color: #eab308;
    color: #fef08a;
    animation: pulse-glow 1.2s infinite alternate;
}

@keyframes pulse-glow {
    0% { transform: scale(1); box-shadow: 0 0 8px rgba(234, 179, 8, 0.4); }
    100% { transform: scale(1.05); box-shadow: 0 0 16px rgba(234, 179, 8, 0.7); }
}

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

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

.w-5 { width: 1.25rem; }
.h-5 { height: 1.25rem; }
.w-4 { width: 1rem; }
.h-4 { height: 1rem; }

/* Game Container and Aspect Ratio */
.game-area-wrapper {
    position: relative;
    width: 100%;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    touch-action: none;
}

.game-area-wrapper.shake {
    animation: screen-shake 0.2s ease-in-out;
}

@keyframes screen-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

#game-container {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 16 / 9;
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-radius: 0.85rem;
    overflow: hidden;
    background: radial-gradient(circle at center, #27272a 0%, #18181b 100%);
    border: 2px solid #52525b;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* Floating Notification Container */
#notification-container {
    position: absolute;
    top: 8%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
    z-index: 100;
}

.notification-item {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    padding: 0.4rem 1rem;
    border-radius: 9999px;
    background: rgba(15, 6, 26, 0.85);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    animation: ready-pulse 0.4s ease-out, fade-in 0.3s ease-out;
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.notification-item.fade-out {
    opacity: 0;
    transform: translateY(-10px);
}

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

@keyframes fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Floating Gene Activator Power-up */
#gene-activator-icon {
    position: absolute;
    width: 3.5rem;
    height: 3.5rem;
    cursor: pointer;
    z-index: 50;
    animation: pulse-activator 1s infinite alternate, bob-float 2s infinite ease-in-out;
    filter: drop-shadow(0 0 12px #facc15);
    transition: transform 0.15s ease;
}

#gene-activator-icon:hover {
    transform: scale(1.15);
}

#gene-activator-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

@keyframes pulse-activator {
    0% { filter: drop-shadow(0 0 8px #facc15); }
    100% { filter: drop-shadow(0 0 18px #fef08a); }
}

@keyframes bob-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* Visual Molecular Workbench / Assembly Line */
.workbench-container {
    width: 100%;
    max-width: 52rem;
    margin: 0 auto;
    background: rgba(24, 24, 27, 0.7);
    backdrop-filter: blur(8px);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    border-radius: 1rem;
    padding: 1rem 1.25rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35);
}

.order-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    text-align: center;
    position: relative;
}

.order-target-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
}

.order-target-img-box {
    width: 3.5rem;
    height: 3.5rem;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(250, 204, 21, 0.45);
    border-radius: 0.75rem;
    padding: 0.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(250, 204, 21, 0.25);
    animation: pulse-order-img 2.5s infinite ease-in-out;
    flex-shrink: 0;
}

@keyframes pulse-order-img {
    0%, 100% { transform: scale(1); border-color: rgba(250, 204, 21, 0.4); box-shadow: 0 4px 15px rgba(250, 204, 21, 0.2); }
    50% { transform: scale(1.06); border-color: rgba(250, 204, 21, 0.8); box-shadow: 0 6px 20px rgba(250, 204, 21, 0.4); }
}

.order-target-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.order-target-details {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
}

.order-badge-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.order-type-badge {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.15rem 0.65rem;
    border-radius: 9999px;
    background: rgba(56, 189, 248, 0.2);
    color: #7dd3fc;
    border: 1px solid rgba(56, 189, 248, 0.4);
}

.order-reward-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.65rem;
    border-radius: 9999px;
    background: rgba(234, 179, 8, 0.2);
    color: #facc15;
    border: 1px solid rgba(234, 179, 8, 0.4);
}

.order-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #facc15;
    margin: 0;
    text-shadow: 0 0 10px rgba(250, 204, 21, 0.4);
    letter-spacing: 0.5px;
}

.order-title.urgent {
    color: #f87171;
    text-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
    animation: pulse-urgent 0.8s infinite alternate;
}

@keyframes pulse-urgent {
    0% { transform: scale(1); }
    100% { transform: scale(1.04); }
}

.urgent-order-timer-container {
    width: 100%;
    max-width: 18rem;
    height: 8px;
    background-color: rgba(0, 0, 0, 0.5);
    border: 1.5px solid #ef4444;
    border-radius: 9999px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.urgent-order-timer-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #ef4444 0%, #f87171 100%);
    transition: width 0.1s linear;
}

/* Assembly Track */
.assembly-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.assembly-track-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #a1a1aa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.assembly-track {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    flex-wrap: wrap;
    min-height: 4rem;
}

.assembly-slot {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1.5px dashed rgba(255, 255, 255, 0.2);
    border-radius: 0.75rem;
    padding: 0.4rem 0.75rem;
    min-width: 7.5rem;
    box-sizing: border-box;
    transition: all 0.25s ease;
}

.assembly-slot.active {
    border-style: solid;
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.1);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

.assembly-slot.completed {
    border-style: solid;
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.3);
    animation: slot-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slot-pop {
    0% { transform: scale(0.92); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.slot-step-badge {
    font-size: 0.7rem;
    font-weight: 700;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    color: #a1a1aa;
    flex-shrink: 0;
}

.assembly-slot.active .slot-step-badge {
    background: #38bdf8;
    color: #0f172a;
}

.assembly-slot.completed .slot-step-badge {
    background: #22c55e;
    color: #0f172a;
}

.slot-icon-box {
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 0.5rem;
    padding: 0.15rem;
    box-sizing: border-box;
    flex-shrink: 0;
}

.slot-gene-icon {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain;
    flex-shrink: 0;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.assembly-slot.active .slot-gene-icon {
    transform: scale(1.15);
    filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.6));
}

.assembly-slot.completed .slot-gene-icon {
    filter: drop-shadow(0 0 6px rgba(34, 197, 94, 0.6));
}

.slot-info {
    display: flex;
    flex-direction: column;
}

.slot-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #f4f4f5;
    line-height: 1.2;
}

.slot-gene-hint {
    font-size: 0.68rem;
    font-weight: 500;
    color: #94a3b8;
}

.recipe-hint {
    font-size: 0.75rem;
    color: #94a3b8;
    text-align: center;
    font-style: italic;
}

/* Interactive Gene Buttons */
.gene-controls {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    width: 100%;
}

.gene-btn {
    position: relative;
    font-family: 'Fredoka', sans-serif;
    width: 8.5rem;
    height: 7.5rem;
    border-radius: 1rem;
    border: 2px solid transparent;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    box-sizing: border-box;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, border-color 0.2s ease;
    overflow: hidden;
    user-select: none;
    touch-action: manipulation;
}

.gene-btn:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}

.gene-btn:active {
    transform: translateY(1px) scale(0.97);
}

.gene-btn[data-gene="A"] {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.3) 0%, rgba(185, 28, 28, 0.4) 100%);
    border-color: rgba(239, 68, 68, 0.5);
}
.gene-btn[data-gene="A"]:hover {
    border-color: #ef4444;
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.35);
}

.gene-btn[data-gene="B"] {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.3) 0%, rgba(2, 132, 199, 0.4) 100%);
    border-color: rgba(56, 189, 248, 0.5);
}
.gene-btn[data-gene="B"]:hover {
    border-color: #38bdf8;
    box-shadow: 0 8px 24px rgba(56, 189, 248, 0.35);
}

.gene-btn[data-gene="C"] {
    background: linear-gradient(135deg, rgba(250, 204, 21, 0.3) 0%, rgba(202, 138, 4, 0.4) 100%);
    border-color: rgba(250, 204, 21, 0.5);
}
.gene-btn[data-gene="C"]:hover {
    border-color: #facc15;
    box-shadow: 0 8px 24px rgba(250, 204, 21, 0.35);
}

.gene-icon-box {
    width: 3.25rem;
    height: 3.25rem;
    margin-bottom: 0.25rem;
}

.gene-btn-text {
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.1;
}

.gene-btn-subtext {
    font-size: 0.68rem;
    font-weight: 500;
    color: #d4d4d8;
}

/* Cooldown Animation */
.cooldown-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: rgba(0, 0, 0, 0.6);
    pointer-events: none;
    transition: height 0.05s linear;
}

.gene-btn.cooldown {
    cursor: not-allowed;
    opacity: 0.8;
}

.gene-btn.cooldown .cooldown-overlay {
    height: 100%;
    animation: cooldown-drain 1.5s linear forwards;
}

@keyframes cooldown-drain {
    from { height: 100%; }
    to { height: 0%; }
}

/* Overload Alert */
.gene-btn.overload {
    background: #7f1d1d !important;
    border-color: #ef4444 !important;
    cursor: not-allowed;
    animation: pulse-red 0.5s infinite alternate;
}

@keyframes pulse-red {
    0% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* Repressor Clamp Overlay */
.repressor-overlay {
    position: absolute;
    inset: 0;
    background: rgba(220, 38, 38, 0.85);
    backdrop-filter: blur(2px);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid #ef4444;
    border-radius: 0.9rem;
    z-index: 10;
    animation: repressor-pulse 1s infinite alternate;
    cursor: pointer;
}

.repressor-overlay:hover {
    background: rgba(239, 68, 68, 0.9);
}

.repressor-img-box {
    width: 2.85rem;
    height: 2.85rem;
    margin-bottom: 0.2rem;
    animation: wiggle 0.4s infinite ease-in-out;
}

.repressor-overlay-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.repressor-count-badge {
    font-size: 1.4rem;
    font-weight: 700;
    background: #ffffff;
    color: #991b1b;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.repressor-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@keyframes repressor-pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.02); }
}

/* Aspect-Ratio Preserving Sprite Container */
.icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 0.65rem;
    padding: 0.35rem;
    box-sizing: border-box;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

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

/* Modal System and Rules */
.modal {
    position: absolute;
    inset: 0;
    background-color: rgba(10, 10, 12, 0.92);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border-radius: 0.75rem;
    box-sizing: border-box;
    z-index: 100;
}

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

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

.modal-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 2.75rem;
    letter-spacing: 1px;
    font-weight: 700;
    color: white;
    margin-bottom: 0.2rem;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

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

.modal-loading-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.loading-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: #7dd3fc;
}

.modal-body {
    flex-grow: 1;
    overflow-y: auto;
    width: 100%;
    min-height: 0;
}

#game-over-modal .modal-body,
#mainLeaderboardModal .modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: #27272a;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background-color: #facc15;
    border-radius: 6px;
    border: 2px solid #27272a;
}

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

.modal-footer-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    max-width: 28rem;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .modal-footer-buttons {
        flex-direction: row;
        justify-content: center;
        align-items: center;
    }
}

@media (min-width: 1024px) {
    #leaderboardBtn,
    #leaderboardGameOverBtn {
        display: none !important;
    }
    #start-game-btn {
        margin: 0 auto;
        display: inline-block;
    }
}

/* Compact Character Trading Cards */
.intro-box {
    width: 100%;
    max-width: 56rem;
    margin: 0 auto 0.75rem auto;
    padding: 0.75rem;
    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.5rem;
    box-sizing: border-box;
}

.cards-hint {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.8rem;
    color: #a1a1aa;
    text-align: center;
    letter-spacing: 0.3px;
    font-weight: 500;
}

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

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

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

.character-card {
    position: relative;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.85rem;
    padding: 0.65rem 0.5rem 0.6rem 0.5rem;
    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.03);
    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); }
}

.card-gene-a { border-color: rgba(239, 68, 68, 0.4); }
.card-gene-a:hover { border-color: #ef4444; box-shadow: 0 8px 24px rgba(239, 68, 68, 0.25); }
.card-gene-b { border-color: rgba(56, 189, 248, 0.4); }
.card-gene-b:hover { border-color: #38bdf8; box-shadow: 0 8px 24px rgba(56, 189, 248, 0.25); }
.card-gene-c { border-color: rgba(250, 204, 21, 0.4); }
.card-gene-c:hover { border-color: #facc15; box-shadow: 0 8px 24px rgba(250, 204, 21, 0.25); }
.card-activator { border-color: rgba(250, 204, 21, 0.4); }
.card-activator:hover { border-color: #fef08a; box-shadow: 0 8px 24px rgba(250, 204, 21, 0.35); }
.card-repressor { border-color: rgba(248, 113, 113, 0.4); }
.card-repressor:hover { border-color: #f87171; box-shadow: 0 8px 24px rgba(248, 113, 113, 0.25); }

.card-product-red { border-color: rgba(244, 63, 94, 0.4); }
.card-product-red:hover { border-color: #f43f5e; box-shadow: 0 8px 24px rgba(244, 63, 94, 0.25); }
.card-product-blue { border-color: rgba(56, 189, 248, 0.4); }
.card-product-blue:hover { border-color: #38bdf8; box-shadow: 0 8px 24px rgba(56, 189, 248, 0.25); }
.card-product-coral { border-color: rgba(251, 146, 60, 0.4); }
.card-product-coral:hover { border-color: #fb923c; box-shadow: 0 8px 24px rgba(251, 146, 60, 0.25); }
.card-product-green { border-color: rgba(74, 222, 128, 0.4); }
.card-product-green:hover { border-color: #4ade80; box-shadow: 0 8px 24px rgba(74, 222, 128, 0.25); }
.card-product-gold { border-color: rgba(250, 204, 21, 0.4); }
.card-product-gold:hover { border-color: #facc15; box-shadow: 0 8px 24px rgba(250, 204, 21, 0.25); }

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

.badge-gene-a { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.4); }
.badge-gene-b { background: rgba(56, 189, 248, 0.2); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, 0.4); }
.badge-gene-c { background: rgba(250, 204, 21, 0.2); color: #fef08a; border: 1px solid rgba(250, 204, 21, 0.4); }
.badge-activator { background: rgba(234, 179, 8, 0.25); color: #fef08a; border: 1px solid rgba(234, 179, 8, 0.5); }
.badge-repressor { background: rgba(220, 38, 38, 0.2); color: #fca5a5; border: 1px solid rgba(220, 38, 38, 0.4); }

.badge-product-red { background: rgba(244, 63, 94, 0.2); color: #fda4af; border: 1px solid rgba(244, 63, 94, 0.4); }
.badge-product-blue { background: rgba(56, 189, 248, 0.2); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, 0.4); }
.badge-product-coral { background: rgba(251, 146, 60, 0.2); color: #fdba74; border: 1px solid rgba(251, 146, 60, 0.4); }
.badge-product-green { background: rgba(74, 222, 128, 0.2); color: #86efac; border: 1px solid rgba(74, 222, 128, 0.4); }
.badge-product-gold { background: rgba(250, 204, 21, 0.2); color: #fef08a; border: 1px solid rgba(250, 204, 21, 0.4); }

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

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

.card-name {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.2rem;
}

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

.text-coral { color: #f87171; }
.text-blue { color: #38bdf8; }
.text-yellow { color: #facc15; }
.text-gold { color: #fef08a; }
.text-red { color: #ef4444; }
.text-green { color: #22c55e; }

/* Buttons */
.btn-primary, .btn-secondary {
    font-family: 'Fredoka', cursive, sans-serif;
    color: white;
    font-weight: 700;
    padding: 0.75rem 1.75rem;
    border-radius: 0.75rem;
    font-size: 1.2rem;
    letter-spacing: 0.5px;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.2s;
}

.btn-primary {
    background-color: #22c55e;
}
.btn-primary:hover {
    background-color: #16a34a;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 18px rgba(34, 197, 94, 0.4);
}
.btn-primary:active {
    transform: translateY(1px) scale(0.98);
}

.btn-secondary {
    background-color: #0284c7;
}
.btn-secondary:hover {
    background-color: #0369a1;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 18px rgba(2, 132, 199, 0.4);
}
.btn-secondary:active {
    transform: translateY(1px) scale(0.98);
}

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

.player-name-input:focus {
    outline: none;
    border-color: #22c55e;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.35);
}

.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); }
}

.tutorial-corner-btn {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: auto;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(168, 85, 247, 0.2);
    border: 1.5px solid rgba(168, 85, 247, 0.6);
    border-radius: 9999px;
    padding: 0.45rem 1rem;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    color: #e9d5ff;
    cursor: pointer;
    backdrop-filter: blur(6px);
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.25);
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tutorial-corner-btn:hover {
    background: rgba(168, 85, 247, 0.35);
    border-color: #c084fc;
    transform: translateY(-2px) scale(1.03);
}

/* Mission Briefing and Fact Cards */
.how-to-card, .fact-card {
    position: relative;
    width: 100%;
    max-width: 44rem;
    max-height: 90vh;
    margin: auto;
    overflow-y: auto;
    background: linear-gradient(135deg, rgba(30, 10, 48, 0.96) 0%, rgba(15, 6, 26, 0.98) 100%);
    border: 2px solid rgba(6, 182, 212, 0.45);
    border-radius: 1.25rem;
    padding: 1.5rem 1.75rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(6, 182, 212, 0.25);
    text-align: center;
    box-sizing: border-box;
}

.fact-card {
    max-width: 28rem;
    border-color: rgba(250, 204, 21, 0.45);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(250, 204, 21, 0.25);
}

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

.how-to-header-badge {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 0.2rem 0.75rem;
    background: rgba(6, 182, 212, 0.2);
    color: #67e8f9;
    border: 1px solid rgba(6, 182, 212, 0.4);
    border-radius: 9999px;
}

.fact-close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.2rem;
    transition: color 0.15s ease;
}

.fact-close-btn:hover {
    color: #ffffff;
}

.how-to-subtitle {
    font-size: 0.95rem;
    color: #cbd5e1;
    margin: 0 0 1.25rem 0;
}

.tutorial-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    text-align: left;
}

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

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

.tutorial-step {
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(6, 182, 212, 0.2);
    color: #67e8f9;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.tutorial-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.tutorial-desc {
    font-size: 0.78rem;
    color: #d4d4d8;
    line-height: 1.3;
    margin: 0;
}

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

.fact-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #facc15;
    margin: 0 0 0.5rem 0;
}

.fact-text {
    font-size: 0.88rem;
    color: #e4e4e7;
    line-height: 1.4;
    margin: 0 0 1.25rem 0;
}

.fact-btn {
    width: 100%;
    max-width: 12rem;
    margin: 0 auto;
}

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

.final-score-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0.25rem 0;
}

.leaderboard-rank-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: #38bdf8;
    margin: 0.25rem 0 0.75rem 0;
}

.synthesized-shelf-box, .science-fact-box {
    width: 100%;
    max-width: 42rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.85rem;
    padding: 0.85rem 1rem;
    margin-bottom: 0.75rem;
    box-sizing: border-box;
}

.shelf-title, .science-fact-title {
    font-size: 1rem;
    font-weight: 700;
    color: #facc15;
    margin: 0 0 0.5rem 0;
    text-align: center;
}

.synthesized-shelf {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.5rem;
}

.synthesized-item {
    font-size: 0.78rem;
    font-weight: 600;
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: #86efac;
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.synthesized-item-img {
    width: 1.75rem;
    height: 1.75rem;
    object-fit: contain;
}

.synthesized-count-badge {
    background: rgba(34, 197, 94, 0.35);
    color: #ffffff;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 9999px;
    font-size: 0.72rem;
}

.science-fact-text {
    font-size: 0.82rem;
    color: #e4e4e7;
    line-height: 1.4;
    text-align: center;
    margin: 0;
}

/* Leaderboard Sidebar & Mobile Dialog */
.leaderboard-panel-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #facc15;
    text-align: center;
    margin: 0 0 0.75rem 0;
    letter-spacing: 0.5px;
}

.leaderboard-box {
    overflow-y: auto;
    flex-grow: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.leaderboard-box::-webkit-scrollbar {
    width: 6px;
}
.leaderboard-box::-webkit-scrollbar-thumb {
    background-color: #52525b;
    border-radius: 3px;
}

.leaderboard-podium-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 0.65rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.85rem;
    font-weight: 600;
}

.podium-rank-1 {
    background: linear-gradient(90deg, rgba(250, 204, 21, 0.2) 0%, rgba(35, 12, 50, 0.7) 100%);
    border: 1.5px solid rgba(250, 204, 21, 0.6);
}
.podium-rank-2 {
    background: linear-gradient(90deg, rgba(226, 232, 240, 0.15) 0%, rgba(35, 12, 50, 0.7) 100%);
    border: 1.5px solid rgba(226, 232, 240, 0.5);
}
.podium-rank-3 {
    background: linear-gradient(90deg, rgba(217, 119, 6, 0.15) 0%, rgba(35, 12, 50, 0.7) 100%);
    border: 1.5px solid rgba(217, 119, 6, 0.5);
}

.podium-badge {
    font-size: 0.7rem;
    font-weight: 700;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.4rem;
    flex-shrink: 0;
}

.podium-badge.rank-1 { background: #facc15; color: #1e092b; }
.podium-badge.rank-2 { background: #e2e8f0; color: #1e092b; }
.podium-badge.rank-3 { background: #d97706; color: #ffffff; }

.leaderboard-player-info {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    overflow: hidden;
}

.leaderboard-player-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-tip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(6, 182, 212, 0.1);
    border: 1px dashed rgba(6, 182, 212, 0.35);
    border-radius: 0.65rem;
    padding: 0.5rem 0.75rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: #67e8f9;
}

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

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

/* Device Orientation Warning */
@media (max-width: 640px) {
    #game-container {
        padding: 0.75rem;
    }
    .order-title {
        font-size: 1.25rem;
    }
    .gene-btn {
        width: 6.5rem;
        height: 6rem;
    }
    .gene-icon-box {
        width: 2.5rem;
        height: 2.5rem;
    }
    .gene-btn-text {
        font-size: 0.85rem;
    }
    .gene-btn-subtext {
        font-size: 0.6rem;
    }
    .modal-title {
        font-size: 1.75rem;
    }
}

.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;
    }
    .game-area-wrapper {
        min-height: 0;
        flex: 1 1 auto;
        height: 100%;
    }
    #game-container {
        min-height: 0;
        flex: 1 1 auto;
        padding: 0.35rem 0.6rem !important;
        border-radius: 0.65rem !important;
        justify-content: space-between !important;
    }
    .workbench-container {
        padding: 0.35rem 0.6rem !important;
        gap: 0.25rem !important;
        border-radius: 0.65rem !important;
        max-width: 100% !important;
    }
    .order-header {
        gap: 0.15rem !important;
    }
    .order-target-display {
        gap: 0.45rem !important;
    }
    .order-target-img-box {
        width: 2.1rem !important;
        height: 2.1rem !important;
        padding: 0.15rem !important;
        border-radius: 0.5rem !important;
    }
    .order-badge-row {
        gap: 0.3rem !important;
    }
    .order-type-badge,
    .order-reward-badge {
        font-size: 0.58rem !important;
        padding: 0.05rem 0.4rem !important;
    }
    .order-title {
        font-size: 0.95rem !important;
        line-height: 1.1 !important;
    }
    .urgent-order-timer-container {
        max-width: 10rem !important;
        height: 5px !important;
        margin-top: 0.1rem !important;
    }
    .assembly-area {
        gap: 0.15rem !important;
    }
    .assembly-track-label {
        font-size: 0.58rem !important;
        letter-spacing: 0.3px !important;
    }
    .assembly-track {
        gap: 0.3rem !important;
        min-height: 2rem !important;
        flex-wrap: nowrap !important;
        width: 100% !important;
        justify-content: center !important;
    }
    .assembly-slot {
        min-width: 0 !important;
        padding: 0.15rem 0.35rem !important;
        gap: 0.25rem !important;
        border-radius: 0.45rem !important;
        flex-shrink: 1 !important;
    }
    .slot-step-badge {
        width: 1.1rem !important;
        height: 1.1rem !important;
        font-size: 0.6rem !important;
    }
    .slot-icon-box {
        width: 1.35rem !important;
        height: 1.35rem !important;
        padding: 0.1rem !important;
    }
    .slot-gene-icon {
        width: 100% !important;
        height: 100% !important;
    }
    .slot-name {
        font-size: 0.62rem !important;
        line-height: 1.1 !important;
        white-space: nowrap !important;
    }
    .slot-gene-hint {
        font-size: 0.52rem !important;
        white-space: nowrap !important;
    }
    .recipe-hint {
        font-size: 0.58rem !important;
        margin-top: 0 !important;
    }
    .gene-controls {
        gap: 0.6rem !important;
        width: 100% !important;
        justify-content: center !important;
    }
    .gene-btn {
        width: 6.2rem !important;
        height: 4.4rem !important;
        padding: 0.25rem 0.35rem !important;
        border-radius: 0.65rem !important;
        touch-action: manipulation !important;
    }
    .gene-icon-box {
        width: 1.8rem !important;
        height: 1.8rem !important;
        padding: 0.15rem !important;
        margin-bottom: 0.1rem !important;
        border-radius: 0.45rem !important;
    }
    .gene-btn-text {
        font-size: 0.78rem !important;
        line-height: 1.1 !important;
    }
    .gene-btn-subtext {
        font-size: 0.52rem !important;
        line-height: 1.1 !important;
    }
    .repressor-overlay {
        border-radius: 0.6rem !important;
    }
    .repressor-img-box {
        width: 1.35rem !important;
        height: 1.35rem !important;
        margin-bottom: 0.05rem !important;
    }
    .repressor-count-badge {
        font-size: 0.85rem !important;
        width: 1.4rem !important;
        height: 1.4rem !important;
    }
    .repressor-label {
        font-size: 0.52rem !important;
    }
    #gene-activator-icon {
        width: 2.2rem !important;
        height: 2.2rem !important;
    }
    .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 {
        flex-direction: row !important;
        justify-content: center !important;
        align-items: center !important;
        margin-top: 0.25rem !important;
        gap: 0.5rem !important;
        width: auto !important;
    }
    .btn-primary, .btn-secondary {
        padding: 0.35rem 1rem;
        font-size: 0.88rem;
        border-radius: 0.5rem;
    }
    .game-over-title {
        font-size: 1.3rem;
    }
    .final-score-text {
        font-size: 0.95rem !important;
        margin-bottom: 0.15rem !important;
    }
    .leaderboard-rank-text {
        font-size: 0.75rem !important;
    }
    .synthesized-shelf-box,
    .science-fact-box {
        padding: 0.25rem 0.5rem !important;
        margin-bottom: 0.25rem !important;
        border-radius: 0.5rem !important;
        max-width: 28rem !important;
    }
    .shelf-title,
    .science-fact-title {
        font-size: 0.75rem !important;
        margin-bottom: 0.2rem !important;
    }
    .synthesized-shelf {
        gap: 0.25rem !important;
        min-height: 1.5rem !important;
    }
    .synthesized-item {
        font-size: 0.62rem !important;
        padding: 0.15rem 0.45rem !important;
        gap: 0.3rem !important;
    }
    .synthesized-item-img {
        width: 1.1rem !important;
        height: 1.1rem !important;
    }
    .synthesized-count-badge {
        font-size: 0.58rem !important;
        padding: 0.05rem 0.3rem !important;
    }
    .science-fact-text {
        font-size: 0.65rem !important;
        line-height: 1.2 !important;
    }
    #mainLeaderboardModal .modal-body,
    .how-to-card,
    .fact-card {
        max-height: 85vh;
        overflow-y: auto;
    }
    .tutorial-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.35rem !important;
        margin-bottom: 0.4rem !important;
    }
    .tutorial-card {
        padding: 0.35rem !important;
        gap: 0.25rem !important;
    }
    .tutorial-icon-box {
        width: 1.8rem !important;
        height: 1.8rem !important;
        padding: 0.1rem !important;
    }
    .tutorial-title {
        font-size: 0.72rem !important;
    }
    .tutorial-desc {
        font-size: 0.58rem !important;
        line-height: 1.2 !important;
    }
    .how-to-subtitle {
        font-size: 0.68rem !important;
    }
    .fact-card {
        padding: 0.75rem !important;
        max-width: 20rem !important;
    }
    .fact-portrait {
        width: 3rem !important;
        height: 3rem !important;
        margin-bottom: 0.35rem !important;
    }
    .fact-title {
        font-size: 1.1rem !important;
        margin-bottom: 0.25rem !important;
    }
    .fact-text {
        font-size: 0.75rem !important;
        line-height: 1.3 !important;
        margin-bottom: 0.5rem !important;
    }
}

.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; }
