body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
    font-family: 'Press Start 2P', cursive;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #0a0a0a;
}

#game-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: radial-gradient(circle, transparent 20%, rgba(0,0,0,0.8) 100%);
    z-index: 20;
}

#arcade-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 25;
    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));
    background-size: 100% 4px, 3px 100%;
    opacity: 0.3;
}

canvas {
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    display: block;
    background-color: #111;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
    border-left: 1px solid #333;
    border-right: 1px solid #333;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#score-container {
    position: relative;
    margin-top: 20px;
    text-align: center;
    background: rgba(0,0,0,0.8);
    padding: 10px 20px;
    border: 2px solid #555;
    min-width: 220px;
}

#pause-btn {
    position: absolute;
    right: -70px;
    top: 0;
    height: 100%;
    background: #000;
    color: #fff;
    border: 2px solid #555;
    font-family: inherit;
    font-size: 0.5rem;
    cursor: pointer;
    pointer-events: auto;
}

#pause-btn:hover {
    background: #222;
}

@media (max-width: 500px) {
    #pause-btn {
        right: 0;
        top: -40px;
        height: 30px;
        width: 100px;
    }
}

#currency-container {
    margin-top: 5px;
    font-size: 0.5rem;
    color: #ffd700;
}

#currency-label {
    color: #aaa;
    margin-right: 5px;
}

#mode-display-tag {
    font-size: 0.4rem;
    color: #aaa;
    margin-bottom: 5px;
    border-bottom: 1px solid #333;
    padding-bottom: 4px;
}

#area-intro-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    pointer-events: none;
    text-align: center;
    width: 100%;
}

#area-intro-title {
    font-size: 1.4rem;
    color: #fff;
    white-space: nowrap;
    margin-bottom: 10px;
}

.wavy-letter {
    display: inline-block;
    animation: wavyLetter 0.4s ease-in-out infinite alternate;
}

@keyframes wavyLetter {
    from { transform: translateY(0); }
    to { transform: translateY(-8px); }
}

#area-intro-quote {
    font-size: 0.6rem;
    color: #aaa;
    font-style: italic;
    letter-spacing: 1px;
}

.intro-anim {
    animation: areaIntroAnim 3s forwards;
}

@keyframes areaIntroAnim {
    0% { opacity: 0; transform: translate(-50%, -70%); }
    20% { opacity: 1; transform: translate(-50%, -50%); }
    80% { opacity: 1; transform: translate(-50%, -50%); }
    100% { opacity: 0; transform: translate(-50%, -30%); }
}

#timer-display {
    color: #ffcc00;
    font-size: 0.8rem;
    margin-top: 5px;
}

#score-label {
    color: #ff3333;
    font-size: 0.6rem;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

#score {
    color: #00ff00;
    font-size: 1.8rem;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.7);
    font-weight: normal;
}

#game-over, #pause-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 30px;
    text-align: center;
    border: 4px solid #fff;
    box-shadow: 0 0 40px rgba(255, 255, 255, 0.5);
    pointer-events: auto;
    width: 85%;
    max-width: 340px;
    z-index: 2000;
}

#pause-menu h1 {
    color: #fff;
    margin-bottom: 30px;
}

#pause-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#pause-actions button {
    background: #fff;
    color: #000;
    border: none;
    padding: 15px;
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
}

#pause-menu-btn {
    background: transparent !important;
    color: #fff !important;
    border: 2px solid #fff !important;
}

#game-over.slam {
    animation: slamEffect 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes slamEffect {
    0% { transform: translate(-50%, -50%) scale(5); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes cardSlam {
    0% { transform: scale(5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

#death-message {
    font-size: 0.5rem;
    line-height: 1.4;
    color: #aaa;
    margin: 15px 0;
    font-style: italic;
    min-height: 2.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

#game-over h1 {
    margin-top: 0;
    color: #ff3333;
}

#game-over button {
    background: #fff;
    color: #000;
    border: none;
    padding: 15px 30px;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    margin-top: 20px;
    width: 100%;
}

#game-over button:active {
    background: #ccc;
}

#game-over-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#game-over-menu-btn {
    background: transparent !important;
    border: 2px solid #fff !important;
    color: #fff !important;
}

#game-over-menu-btn:hover {
    background: rgba(255,255,255,0.1) !important;
}

#main-menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('boilfootmenu.png') no-repeat center center;
    background-size: cover;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    pointer-events: auto;
    z-index: 40;
}

#menu-background-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 40%, transparent 100%);
    pointer-events: none;
}

#menu-sidebar {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 450px;
    padding: 60px 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.6) 80%, transparent 100%);
    backdrop-filter: blur(12px);
    border-right: 4px solid #d2b48c;
    box-shadow: 20px 0 50px rgba(0,0,0,0.5);
    animation: menuRelaxed 8s ease-in-out infinite;
}

@keyframes menuRelaxed {
    0%, 100% { border-color: #d2b48c; }
    50% { border-color: #a89070; }
}

#menu-logo {
    width: 100%;
    max-width: 320px;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 10px rgba(210, 180, 140, 0.4));
}

#menu-stats {
    margin-bottom: 40px;
    border-left: 2px solid #d2b48c;
    padding-left: 15px;
}

.menu-stat-label {
    font-size: 0.45rem;
    color: #888;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

#menu-total-height-display {
    font-size: 1.2rem;
    color: #fff;
    text-shadow: 0 0 10px rgba(210, 180, 140, 0.3);
}

@keyframes logoSway {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-40px); }
    to { opacity: 1; transform: translateX(0) skewX(0); }
}

#menu-nav {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 40px;
}

.menu-item {
    background: transparent;
    border: none;
    color: #888;
    font-family: inherit;
    font-size: 0.8rem;
    text-align: left;
    padding: 10px 0;
    cursor: default;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

#start-btn {
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    border-left: 4px solid #d2b48c;
    padding-left: 20px;
    background: linear-gradient(90deg, rgba(210, 180, 140, 0.15) 0%, transparent 100%);
}

#start-btn:hover {
    padding-left: 30px;
    color: #d2b48c;
    background: linear-gradient(90deg, rgba(210, 180, 140, 0.25) 0%, transparent 100%);
}

#start-btn:active {
    transform: scale(0.98);
    color: #fff;
}

.locked {
    opacity: 0.4;
    font-size: 0.7rem;
}

#menu-footer {
    margin-top: auto;
    color: #444;
    font-size: 0.5rem;
    line-height: 1.6;
    letter-spacing: 1px;
}

#menu-footer p {
    margin: 5px 0;
}

#motivational-quote {
    color: #d2b48c;
    font-style: italic;
    opacity: 0.8;
}

#char-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 100;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    overflow: hidden;
    --char-theme-color: #ff3333;
}

#char-bg-color-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--char-theme-color);
    opacity: 0.2;
    transition: background-color 0.6s ease;
    z-index: 1;
}

#char-bg-scroller {
    position: absolute;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    background-image: url('/characterselectbgrick (3).png');
    background-size: 512px 512px;
    opacity: 0.1;
    mix-blend-mode: color-dodge;
    animation: diagScroll 60s linear infinite;
    z-index: 2;
    pointer-events: none;
}

@keyframes diagScroll {
    from { background-position: 0 0; }
    to { background-position: 512px 512px; }
}

#char-modal-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 20%, rgba(0,0,0,0.95) 90%);
    z-index: 3;
    pointer-events: none;
}

#char-modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    flex-direction: column;
    padding: 30px;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#char-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid rgba(255,255,255,0.1);
    padding-bottom: 15px;
}

#char-selection-title {
    font-size: 0.8rem;
    color: #fff;
    letter-spacing: 2px;
}

#close-char-modal {
    background: transparent;
    color: #888;
    border: 1px solid #444;
    padding: 8px 15px;
    font-family: inherit;
    font-size: 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
}

#close-char-modal:hover {
    color: #fff;
    border-color: #fff;
    background: rgba(255,255,255,0.05);
}

#selection-main-layout {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    gap: 60px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 768px) {
    #selection-main-layout {
        flex-direction: column;
        gap: 30px;
        overflow-y: auto;
        justify-content: flex-start;
        padding-bottom: 50px;
    }
    #char-big-preview {
        max-height: 55vh;
        width: 100%;
        object-fit: contain;
    }
    #preview-wrapper::before {
        width: 320px;
        height: 320px;
    }
    #selection-right {
        width: 100%;
        box-sizing: border-box;
    }
}

#selection-left {
    flex: 1.2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

#preview-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 40px;
}

#preview-wrapper::before {
    content: '';
    position: absolute;
    width: 550px;
    height: 550px;
    background: var(--char-theme-color);
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.4;
    z-index: -1;
    animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.3); opacity: 0.6; }
}

#char-big-preview {
    max-height: 85vh;
    image-rendering: pixelated;
    animation: charFloating 4s ease-in-out infinite;
    filter: drop-shadow(0 0 30px rgba(0,0,0,0.6));
}

@keyframes charFloating {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

#nav-controls {
    display: flex;
    align-items: center;
    gap: 30px;
}

.nav-arrow {
    background: transparent;
    border: 2px solid #fff;
    color: #fff;
    font-family: inherit;
    font-size: 0.7rem;
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-arrow:hover {
    background: #fff;
    color: #000;
}

#char-index-indicator {
    font-size: 0.7rem;
    color: #fff;
    min-width: 100px;
    text-align: center;
}

#selection-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(0,0,0,0.8);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 40px;
    position: relative;
    border-top: 4px solid var(--char-theme-color);
}

#char-branding {
    margin-bottom: 30px;
    text-align: center;
}

#char-logo-preview {
    max-width: 100%;
    max-height: 240px;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: pixelated;
    filter: drop-shadow(0 0 15px var(--char-theme-color));
}

#char-info-card {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.info-section h3 {
    font-size: 0.6rem;
    color: var(--char-theme-color);
    margin-bottom: 10px;
    letter-spacing: 1px;
}

#char-lore-text {
    font-size: 0.6rem;
    line-height: 1.6;
    color: #bbb;
}

.shaky-red {
    display: inline-block;
    color: #ff0000;
    font-weight: bold;
    animation: shakyRed 0.1s infinite;
}

@keyframes shakyRed {
    0% { transform: translate(0, 0); }
    25% { transform: translate(2px, -2px); }
    50% { transform: translate(-2px, 2px); }
    75% { transform: translate(2px, 2px); }
    100% { transform: translate(-2px, -2px); }
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-item label {
    font-size: 0.45rem;
    color: #666;
}

.stat-item span {
    font-size: 0.6rem;
    color: #fff;
}

#char-ability-container {
    margin-top: 5px;
    border: 1px dashed var(--char-theme-color);
    padding: 10px;
}

#hat-selection-container {
    margin-top: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(135deg, rgba(20, 20, 20, 0.9) 0%, rgba(40, 40, 40, 0.7) 100%);
    padding: 20px;
    border-radius: 8px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
    position: relative;
}

#hat-label {
    font-size: 0.5rem;
    color: var(--char-theme-color);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 8px;
}

#hat-scroll-wrapper {
    width: 100%;
    overflow-x: auto;
    padding-top: 10px;
    padding-bottom: 25px;
    margin-bottom: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--char-theme-color) rgba(0,0,0,0.3);
}

#hat-scroll-wrapper::-webkit-scrollbar {
    height: 4px;
}

#hat-scroll-wrapper::-webkit-scrollbar-thumb {
    background: var(--char-theme-color);
    border-radius: 10px;
}

#hat-list {
    display: flex;
    gap: 12px;
    min-height: 80px;
    padding: 5px;
}

.hat-item-card {
    width: 72px;
    height: 72px;
    background: rgba(0,0,0,0.4);
    border: 2px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    border-radius: 4px;
}

.hat-item-card.unlocked:hover {
    background: rgba(255,255,255,0.05);
    border-color: #888;
    transform: translateY(-4px) scale(1.05);
}

.hat-item-card.selected {
    border-color: var(--char-theme-color);
    background: rgba(255,255,255,0.08);
    box-shadow: 0 0 15px var(--char-theme-color), inset 0 0 10px var(--char-theme-color);
}

.hat-item-card.selected::after {
    content: 'EQUIPPED';
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 8px;
    color: var(--char-theme-color);
    white-space: nowrap;
}

.hat-item-card.locked {
    filter: grayscale(1) brightness(0.2);
    cursor: not-allowed;
    border-style: dashed;
}

.hat-icon {
    max-width: 85%;
    max-height: 85%;
    object-fit: contain;
    image-rendering: pixelated;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

#selected-hat-info {
    font-size: 0.45rem;
    color: #eee;
    margin-top: 15px;
    text-align: center;
    min-height: 1.2rem;
    line-height: 1.4;
    padding: 10px;
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
    border-left: 2px solid var(--char-theme-color);
}

#ability-label {
    font-size: 0.45rem;
    color: var(--char-theme-color);
    margin-bottom: 8px;
}

#detail-ability {
    font-size: 0.7rem;
    color: #fff;
    text-shadow: 0 0 10px var(--char-theme-color);
}

#confirm-char-btn {
    margin-top: 20px;
    background: var(--char-theme-color);
    border: none;
    color: #000;
    font-family: inherit;
    font-size: 0.8rem;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
}

.char-locked-state {
    filter: brightness(0) !important;
}

#gacha-controls {
    margin-top: 20px;
    text-align: center;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 15px;
}

#roll-gacha-btn {
    background: #ffd700;
    color: #000;
    border: none;
    padding: 10px 20px;
    font-family: inherit;
    font-size: 0.6rem;
    cursor: pointer;
    width: 100%;
}

#roll-gacha-btn:hover:not(:disabled) {
    background: #fff;
}

#roll-gacha-btn:disabled {
    background: #444;
    color: #888;
    cursor: not-allowed;
}

#gacha-hint {
    font-size: 0.4rem;
    color: #666;
    margin-top: 8px;
}

#gacha-result-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

#gacha-result-card {
    background: #000;
    border: 6px solid #ffd700;
    padding: 0;
    text-align: center;
    animation: cardSlam 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    box-shadow: 0 0 100px rgba(255, 215, 0, 0.4);
    width: 280px;
    height: 420px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

#card-inner-glow {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at center, rgba(255,255,255,0.1) 0%, transparent 70%);
    pointer-events: none;
}

.gacha-rolling-animation {
    animation: gachaShake 0.1s infinite !important;
}

@keyframes gachaShake {
    0% { transform: translate(2px, 2px) rotate(0deg); }
    25% { transform: translate(-2px, -2px) rotate(1deg); }
    50% { transform: translate(2px, -2px) rotate(-1deg); }
    75% { transform: translate(-2px, 2px) rotate(0deg); }
    100% { transform: translate(2px, 2px) rotate(1deg); }
}

#result-rarity-badge {
    font-size: 0.5rem;
    margin: 0;
    padding: 15px;
    background: #ffd700;
    color: #000;
    width: 100%;
    box-sizing: border-box;
    letter-spacing: 2px;
}

#result-img-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#result-icon {
    width: 200px;
    height: 200px;
    image-rendering: pixelated;
    filter: drop-shadow(0 0 25px rgba(255,255,255,0.3));
}

#result-name {
    font-size: 1rem;
    margin: 0 0 15px 0;
    color: #fff;
    padding: 0 10px;
}

#result-dup-msg {
    color: #ff3333;
    font-size: 0.4rem;
    margin-bottom: 15px;
    padding: 0 10px;
}

#close-gacha-result {
    background: #fff;
    border: none;
    padding: 20px;
    font-family: inherit;
    font-size: 0.7rem;
    cursor: pointer;
    width: 100%;
}

#confirm-char-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    filter: brightness(1.2);
}

#confirm-char-btn:active {
    transform: translateY(0);
}

#char-select-btn, #extras-btn, #achievements-btn {
    color: #aaa;
    cursor: pointer;
}

#char-select-btn:hover, #extras-btn:hover, #achievements-btn:hover {
    color: #fff;
    padding-left: 10px;
}

/* Mode Selection UI */
#mode-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 110;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    overflow: hidden;
}

#mode-bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #333;
    opacity: 0.3;
}

#mode-bg-scroller {
    position: absolute;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    background-image: url('/characterselectbgrick (3).png');
    background-size: 512px 512px;
    opacity: 0.15;
    animation: diagScroll 40s linear infinite reverse;
}

#mode-modal-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 20%, rgba(0,0,0,0.9) 100%);
}

#mode-modal-content {
    position: relative;
    z-index: 10;
    padding: 40px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

#mode-modal-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 40px;
}

#close-mode-modal {
    background: transparent;
    color: #fff;
    border: 1px solid #fff;
    padding: 10px;
    font-family: inherit;
    font-size: 0.6rem;
    cursor: pointer;
}

#mode-selection-title {
    font-size: 1rem;
    color: #fff;
}

#mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    flex: 1;
}

.mode-card {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #444;
    padding: 20px;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    justify-content: center;
    font-family: inherit;
}

.mode-card:hover {
    background: rgba(255, 51, 51, 0.15);
    border-color: #ff3333;
    transform: scale(1.02) rotate(1deg);
    box-shadow: 0 0 20px rgba(255, 51, 51, 0.3);
}

.mode-card:active {
    transform: scale(0.98);
}

.mode-name {
    font-size: 0.8rem;
    color: #ff3333;
    margin-bottom: 15px;
}

.mode-desc {
    font-size: 0.45rem;
    color: #bbb;
    line-height: 1.5;
}

#loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #fff;
    pointer-events: auto;
    overflow: hidden;
}

#loading-bg-tint {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#loading-bg-scroller {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background-image: url('loadingbg.png');
    background-size: 256px auto;
    background-repeat: repeat;
    opacity: 0.4;
    z-index: 2;
    mix-blend-mode: multiply;
    animation: diagScroll 15s linear infinite;
}

#loading-content {
    position: relative;
    z-index: 10;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#loading-bar-container {
    width: 70%;
    height: 24px;
    background: rgba(0,0,0,0.05);
    border: 4px solid #000;
    position: relative;
    box-shadow: 8px 8px 0 rgba(0,0,0,0.1);
}

#loading-bar-fill {
    width: 0%;
    height: 100%;
    background: #000;
    transition: width 0.1s linear;
}

#extras-modal, #achievements-modal {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 150;
    color: #fff;
    pointer-events: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

#extras-modal-content, #achievements-modal-content {
    max-width: 600px;
    width: 90%;
    background: #1a1510 url('brickwalls.png');
    background-blend-mode: multiply;
    padding: 40px;
    border: 8px double #d2b48c;
    box-shadow: 0 0 100px rgba(0,0,0,0.8), inset 0 0 50px rgba(0,0,0,0.9);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    position: relative;
    border-radius: 4px;
    animation: bookOpen 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes bookOpen {
    0% { transform: scale(0.8) rotateY(-90deg); opacity: 0; }
    100% { transform: scale(1) rotateY(0deg); opacity: 1; }
}

#achievements-header-title {
    font-size: 0.9rem;
    color: #d2b48c;
    text-align: center;
    margin-top: 15px;
    letter-spacing: 2px;
    text-shadow: 2px 2px 0 #000;
}

#achievements-scroll-area {
    flex: 1;
    overflow-y: auto;
    margin-top: 20px;
    padding-right: 15px;
    scrollbar-width: thin;
    scrollbar-color: #d2b48c rgba(0,0,0,0.3);
}

#achievements-scroll-area::-webkit-scrollbar { width: 6px; }
#achievements-scroll-area::-webkit-scrollbar-thumb { background: #d2b48c; }

#achievements-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

@media (min-width: 600px) {
    #achievements-grid { grid-template-columns: 1fr 1fr; }
}

#achievements-stats-summary {
    font-size: 0.45rem;
    color: #8a735c;
    text-align: center;
    margin-top: 15px;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(210, 180, 140, 0.2);
    padding-bottom: 10px;
}

.stat-highlight {
    color: #fff;
    font-weight: bold;
}

#achievements-footer {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #d2b48c;
    text-align: center;
    font-size: 0.4rem;
    color: #8a735c;
}

.achievement-card {
    background: rgba(0,0,0,0.4);
    border: 2px solid #332b21;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    filter: grayscale(1) contrast(0.5) opacity(0.3);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
}

.achievement-card.unlocked {
    filter: grayscale(0) contrast(1) opacity(1);
    border-color: #d2b48c;
    background: rgba(210, 180, 140, 0.05);
    box-shadow: inset 0 0 15px rgba(210, 180, 140, 0.1);
}

.achievement-card.unlocked:hover {
    transform: translateX(5px);
    background: rgba(210, 180, 140, 0.15);
}

.achievement-icon {
    width: 40px;
    height: 40px;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.achievement-info h4 {
    margin: 0;
    font-size: 0.45rem;
    color: #fff;
    margin-bottom: 4px;
}

.achievement-info p {
    margin: 0;
    font-size: 0.35rem;
    color: #aaa;
    line-height: 1.2;
}

#achievement-toast {
    position: absolute;
    bottom: 30px;
    right: 30px;
    background: #000;
    border: 2px solid #d2b48c;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 10000;
    pointer-events: none;
    animation: toastSlideIn 4s forwards;
    box-shadow: 0 0 20px rgba(210, 180, 140, 0.4);
}

@keyframes toastSlideIn {
    0% { transform: translateX(120%); }
    10% { transform: translateX(0); }
    90% { transform: translateX(0); opacity: 1; }
    100% { transform: translateX(120%); opacity: 0; }
}

#toast-icon {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

#toast-title {
    font-size: 0.35rem;
    color: #d2b48c;
    margin-bottom: 5px;
}

#toast-name {
    font-size: 0.5rem;
    color: #fff;
}

#extras-modal header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}

#extras-modal h2 { font-size: 0.8rem; color: #d2b48c; margin: 0; }

#extras-modal header button {
    background: transparent;
    border: 1px solid #d2b48c;
    color: #d2b48c;
    padding: 5px 10px;
    font-family: inherit;
    font-size: 0.5rem;
    cursor: pointer;
}

#extras-warning {
    color: #ff3333;
    font-size: 0.4rem;
    margin-bottom: 20px;
    line-height: 1.2;
    text-align: center;
}

#extras-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

.extra-item {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255,255,255,0.03);
    padding: 12px;
    border: 1px solid #333;
    transition: border-color 0.2s;
}

.extra-item:hover {
    border-color: #d2b48c;
}

.extra-text h3 { font-size: 0.6rem; margin: 0; color: #fff; letter-spacing: 1px; }

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
    flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #333;
    transition: .4s;
}
.slider:before {
    position: absolute;
    content: "";
    height: 16px; width: 16px;
    left: 4px; bottom: 4px;
    background-color: white;
    transition: .4s;
}
input:checked + .slider { background-color: #d2b48c; }
input:checked + .slider:before { transform: translateX(26px); }

#blue-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 255, 0.4);
    mix-blend-mode: screen;
    pointer-events: none;
    z-index: 1000;
}

.rainbow-mode-bg {
    animation: rainbowBG 5s linear infinite !important;
}

@keyframes rainbowBG {
    0% { background-color: #ff0000; }
    20% { background-color: #ffff00; }
    40% { background-color: #00ff00; }
    60% { background-color: #00ffff; }
    80% { background-color: #0000ff; }
    100% { background-color: #ff00ff; }
}

.hidden {
    display: none !important;
}

.rainbow-text {
    background: linear-gradient(to right, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #8b00ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: rainbowShift 2s linear infinite, wavy 0.6s ease-in-out infinite alternate;
    display: inline-block;
    font-size: 1.2rem;
    background-size: 200% auto;
}

@keyframes rainbowShift {
    to { background-position: 200% center; }
}

@keyframes wavy {
    from { transform: translateY(0); }
    to { transform: translateY(-8px); }
}

#mobile-ui {
    position: fixed;
    bottom: 40px;
    left: 0;
    width: 100%;
    z-index: 1000;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    padding: 0 30px;
    box-sizing: border-box;
}

#mobile-movement-controls {
    display: flex;
    gap: 20px;
    pointer-events: auto;
}

.mobile-ctrl-btn {
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.6);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    color: #fff;
    font-family: inherit;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.8);
    outline: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.05s, background 0.1s;
}

.mobile-ctrl-btn:active {
    transform: translateY(2px);
    background: rgba(255, 255, 255, 0.2);
    border-color: #fff;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.8);
}

#mobile-jump-btn {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    font-size: 0.7rem;
    background: rgba(210, 180, 140, 0.2);
    border-color: rgba(210, 180, 140, 0.6);
}

#mobile-jump-btn:active {
    background: rgba(210, 180, 140, 0.4);
}

/* Hide mobile controls on mouse-based devices or if the screen is wide (desktop) */
@media (pointer: fine) {
    #mobile-ui {
        display: none !important;
    }
}