/* Main styles */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

body {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #1a1a1a;
    font-family: Arial, sans-serif;
    color: #fff;
    overflow: hidden;
    touch-action: manipulation;
}

/* Snow canvas */
#snowCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

/* Main menu */
#mainMenu {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
}

.title {
    font-size: 52px;
    margin: 0;
    background: linear-gradient(135deg, #ff6b6b, #ffd93d, #6bcb77, #4d96ff, #9b59b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(77, 150, 255, 0.3);
    animation: titleGlow 3s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    from { filter: drop-shadow(0 0 10px rgba(77, 150, 255, 0.3)); }
    to { filter: drop-shadow(0 0 20px rgba(155, 89, 182, 0.4)); }
}

/* Server Stats */
.server-stats {
    display: flex;
    gap: 20px;
    font-size: 13px;
    color: #888;
}

.server-stat {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

.stat-dot.online {
    background: #4ade80;
    box-shadow: 0 0 8px #4ade80;
}

.stat-dot.playing {
    background: #60a5fa;
    box-shadow: 0 0 8px #60a5fa;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Buttons */
.btn {
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    background: #444;
    color: #fff;
    border: none;
    border-radius: 5px;
    touch-action: manipulation;
}

.btn-play {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 70px;
    font-size: 22px;
    font-weight: bold;
    cursor: pointer;
    background: linear-gradient(135deg, #4d96ff, #9b59b6);
    color: #fff;
    border: none;
    border-radius: 14px;
    transition: transform 0.2s, box-shadow 0.2s;
    touch-action: manipulation;
    box-shadow: 0 4px 15px rgba(77, 150, 255, 0.3);
}

.btn-play:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(77, 150, 255, 0.5);
}

.btn-play:active {
    transform: scale(0.98);
}

/* Menu Button Rows */
.menu-buttons-row {
    display: flex;
    gap: 12px;
}

.menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    color: #fff;
    border: none;
    border-radius: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
    touch-action: manipulation;
    min-width: 140px;
}

.menu-btn:hover {
    transform: translateY(-2px);
}

.menu-btn:active {
    transform: translateY(0);
}

.menu-btn-purple {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    box-shadow: 0 4px 12px rgba(155, 89, 182, 0.3);
}

.menu-btn-purple:hover {
    box-shadow: 0 6px 18px rgba(155, 89, 182, 0.5);
}

.menu-btn-orange {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.3);
}

.menu-btn-orange:hover {
    box-shadow: 0 6px 18px rgba(243, 156, 18, 0.5);
}

.menu-btn-cyan {
    background: linear-gradient(135deg, #00bcd4, #0097a7);
    box-shadow: 0 4px 12px rgba(0, 188, 212, 0.3);
}

.menu-btn-cyan:hover {
    box-shadow: 0 6px 18px rgba(0, 188, 212, 0.5);
}

.menu-btn-gold {
    background: linear-gradient(135deg, #ffd700, #ffb300);
    color: #333;
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

.menu-btn-gold:hover {
    box-shadow: 0 6px 18px rgba(255, 215, 0, 0.5);
}

/* Settings Button */
.menu-btn-settings {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    color: #aaa;
    border: 1px solid #444;
    border-radius: 8px;
    transition: all 0.2s;
}

.menu-btn-settings:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-color: #666;
}

/* Options Panel Overlay */
.options-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 400;
}

.options-overlay.open {
    display: block;
}

/* Options Panel */
.settings-panel {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #222;
    border: 2px solid #444;
    border-radius: 12px;
    padding: 25px 20px 20px 20px;
    min-width: 280px;
    z-index: 401;
}

.settings-panel.open {
    display: block;
}

.options-title {
    margin: 0 0 15px 0;
    font-size: 18px;
    text-align: center;
    color: #fff;
}

.beta-tag {
    font-size: 10px;
    color: #4d96ff;
    font-weight: normal;
    vertical-align: middle;
}

.settings-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1;
}

.settings-close:hover {
    color: #fff;
}

.settings-section {
    margin-bottom: 20px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section h4 {
    margin: 0 0 12px 0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666;
}

/* Toggle Switch */
.toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    cursor: pointer;
}

.toggle-item span:first-child {
    font-size: 14px;
    color: #ddd;
}

.toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    background: #444;
    border-radius: 12px;
    transition: background 0.3s;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
}

.toggle-input:checked + .toggle-slider {
    background: #4d96ff;
}

.toggle-input:checked + .toggle-slider::after {
    transform: translateX(20px);
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
}

.setting-row > span {
    font-size: 14px;
    color: #ddd;
}

/* Legacy styles kept for compatibility */
.btn-options {
    display: none;
}

.options-wrapper {
    position: relative;
}

#optionsPanel {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 10px;
    background: #333;
    border-radius: 8px;
    padding: 15px;
    min-width: 200px;
    z-index: 10;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin-bottom: 10px;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

/* Game screen */
#gameScreen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    padding: 10px;
    box-sizing: border-box;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

#status {
    margin: 10px 5px 8px 5px;
    font-size: 16px;
    min-height: 20px;
}

.game-buttons {
    display: flex;
    gap: 15px;
    margin: 0 5px 12px 5px;
}

.game-buttons .btn {
    padding: 8px 20px;
}

/* Canvas container */
#canvasContainer {
    position: relative;
    display: inline-block;
}

#canvas {
    border: 2px solid #444;
    background: #000;
    image-rendering: crisp-edges;
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 100px);
    touch-action: none;
}

/* Modal */
#modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background: #000;
    text-align: center;
    position: relative;
    border: 2px solid #444;
    min-width: 280px;
}

.modal-header {
    background: #1a7a3a;
    padding: 10px 40px 10px 20px;
    position: relative;
}

.modal-header h2 {
    color: #fff;
    font-size: 24px;
    margin: 0;
}

.modal-close {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
}

.modal-body {
    padding: 30px 20px;
}

.modal-body p {
    font-size: 18px;
    margin: 0 0 25px 0;
}

.btn-next {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    cursor: pointer;
    background: transparent;
    color: #fff;
    border: 2px solid #fff;
    margin-bottom: 10px;
}

/* Stats section */
.stats-section {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #555;
}

.stats-title {
    font-size: 14px;
    color: #888;
    margin-bottom: 8px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 4px;
}

.stat-row span:last-child {
    color: #4d96ff;
    font-weight: bold;
}

/* Stats Button and Panel */
.stats-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 8px;
    margin-top: 10px;
}

#statsPanel {
    position: fixed;
    top: 0;
    left: -320px;
    width: 300px;
    height: 100vh;
    background: #222;
    border-right: 2px solid #444;
    transition: left 0.3s ease;
    z-index: 200;
    display: flex;
    flex-direction: column;
}

#statsPanel.open {
    left: 0;
}

.stats-panel-header {
    padding: 20px;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stats-panel-header h3 {
    margin: 0;
    font-size: 20px;
}

.stats-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
}

.stats-panel-content {
    padding: 20px;
}

.stats-panel-content .stat-row {
    padding: 10px 0;
    border-bottom: 1px solid #333;
}

/* Achievements Panel */
.achievements-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 8px;
    margin-top: 10px;
}

#achievementsPanel {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100vh;
    background: #222;
    border-left: 2px solid #444;
    transition: right 0.3s ease;
    z-index: 200;
    display: flex;
    flex-direction: column;
}

#achievementsPanel.open {
    right: 0;
}

.achievements-header {
    padding: 20px;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.achievements-header h3 {
    margin: 0;
    font-size: 20px;
}

.achievements-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
}

#achievementsList {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    scroll-behavior: smooth;
}

.achievement-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 10px;
    background: #333;
    border-radius: 8px;
    transition: transform 0.2s, background 0.2s;
}

.achievement-item.unlocked {
    background: linear-gradient(135deg, #2d5a3d, #1a3a2a);
    border: 1px solid #4a8a5a;
}

.achievement-item.locked {
    opacity: 0.6;
}

.achievements-divider {
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666;
    padding: 15px 0 10px 0;
    border-bottom: 1px solid #444;
    margin-bottom: 10px;
}

.achievements-divider:first-child {
    padding-top: 0;
}

.achievements-empty {
    color: #555;
    font-size: 13px;
    text-align: center;
    padding: 15px;
    font-style: italic;
}

.achievement-icon {
    font-size: 28px;
    width: 40px;
    text-align: center;
}

.achievement-info {
    flex: 1;
}

.achievement-name {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 2px;
}

.achievement-desc {
    font-size: 12px;
    color: #aaa;
}

/* Achievement Popup */
.achievement-popup {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: linear-gradient(135deg, #2d5a3d, #1a3a2a);
    border: 2px solid #4a8a5a;
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1000;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    max-width: calc(100vw - 40px);
    box-sizing: border-box;
}

.achievement-popup.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.achievement-popup-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.achievement-popup-icon svg {
    width: 28px;
    height: 28px;
}

.achievement-popup-text {
    text-align: left;
    min-width: 0;
}

.achievement-popup-title {
    font-size: 10px;
    color: #8f8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.achievement-popup-name {
    font-size: 16px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Custom Confirm Dialog */
.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.confirm-overlay.show {
    opacity: 1;
}

.confirm-dialog {
    background: #222;
    border: 2px solid #444;
    border-radius: 12px;
    padding: 30px;
    max-width: 320px;
    text-align: center;
}

.confirm-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    color: #fff;
}

.confirm-message {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 25px;
    line-height: 1.5;
}

.confirm-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-btn {
    padding: 12px 28px;
    font-size: 14px;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    transition: transform 0.15s, opacity 0.15s;
    font-weight: 500;
}

.confirm-btn:hover {
    opacity: 0.9;
}

.confirm-btn:active {
    transform: scale(0.98);
}

.confirm-no {
    background: #444;
    color: #fff;
}

.confirm-yes {
    background: #4d96ff;
    color: #fff;
}

/* Custom Dropdown */
.custom-dropdown {
    position: relative;
    display: inline-block;
    min-width: 100px;
}

.dropdown-selected {
    padding: 8px 30px 8px 12px;
    font-size: 14px;
    cursor: pointer;
    background: #444;
    color: #fff;
    border: none;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    position: relative;
    white-space: nowrap;
}

.dropdown-selected::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-top-color: #fff;
    transition: transform 0.2s;
}

.custom-dropdown.open .dropdown-selected::after {
    transform: translateY(-50%) rotate(180deg);
}

.dropdown-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: #444;
    border-radius: 5px;
    overflow: hidden;
    z-index: 100;
    min-width: 100%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.custom-dropdown.open .dropdown-options {
    display: block;
}

.dropdown-option {
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.dropdown-option:hover {
    background: #555;
}

.dropdown-option.selected {
    background: #4d96ff;
}

.dropdown-option-title {
    font-size: 14px;
    font-weight: bold;
}

.dropdown-option-desc {
    font-size: 11px;
    color: #aaa;
    margin-top: 2px;
}

.dropdown-option:hover .dropdown-option-desc {
    color: #ccc;
}

.dropdown-option.selected .dropdown-option-desc {
    color: #ddd;
}

/* Version dropdown wider */
.version-dropdown {
    min-width: 180px;
}

.version-dropdown .dropdown-options {
    min-width: 280px;
}

/* Version list (non-selectable) */
.version-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.version-item {
    font-size: 12px;
    color: #888;
    padding: 2px 0;
}

/* Level Select Screen */
#levelSelectScreen {
    display: none;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    padding: 20px;
    width: 100%;
    max-width: 400px;
}

.level-select-header {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 10px;
}

.back-btn {
    background: none;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    padding: 0;
}

.level-select-title {
    flex: 1;
    text-align: center;
    font-size: 28px;
    margin: 0;
    color: #4a4;
    margin-right: 40px;
}

.level-progress {
    font-size: 24px;
    color: #fff;
    margin-bottom: 20px;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 320px;
}

.level-btn {
    aspect-ratio: 1;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    border: 3px solid #b86;
    border-radius: 8px;
    background: #654;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, background 0.2s;
}

.level-btn:hover {
    transform: scale(1.05);
}

.level-btn.completed {
    background: #864;
    border-color: #c96;
}

.level-btn.current {
    background: #fff;
    color: #333;
    border-color: #fff;
}

.level-section-divider {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 22px;
    font-weight: bold;
    color: #4d96ff;
    padding: 15px 0 10px 0;
    margin-top: 5px;
    border-bottom: 2px solid #4d96ff;
    margin-bottom: 5px;
}

.level-section-divider:first-child {
    margin-top: 0;
    padding-top: 0;
}

/* Mobile Responsive Styles */
@media (max-width: 480px) {
    .title {
        font-size: 36px;
    }
    
    .menu-controls {
        width: 90vw;
        max-width: 300px;
    }
    
    .btn-play {
        padding: 12px 50px;
        font-size: 18px;
    }
    
    .btn-options,
    .stats-btn,
    .achievements-btn {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    #optionsPanel {
        min-width: 180px;
        padding: 12px;
    }
    
    .option-row {
        flex-wrap: wrap;
    }
    
    .version-dropdown {
        min-width: 140px;
    }
    
    .version-dropdown .dropdown-options {
        min-width: 240px;
        right: 0;
        left: auto;
    }
    
    #status {
        font-size: 14px;
    }
    
    .game-buttons .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .modal-content {
        min-width: 250px;
        max-width: 90vw;
    }
    
    .modal-header h2 {
        font-size: 20px;
    }
    
    .modal-body {
        padding: 20px 15px;
    }
    
    .modal-body p {
        font-size: 16px;
    }
    
    .btn-next {
        padding: 12px;
        font-size: 16px;
    }
    
    /* Achievement popup mobile */
    .achievement-popup {
        top: 10px;
        padding: 10px 15px;
        gap: 10px;
        max-width: calc(100vw - 20px);
    }
    
    .achievement-popup-icon {
        font-size: 24px;
    }
    
    .achievement-popup-icon svg {
        width: 24px;
        height: 24px;
    }
    
    .achievement-popup-title {
        font-size: 9px;
    }
    
    .achievement-popup-name {
        font-size: 14px;
    }
    
    /* Stats and Achievements panels mobile */
    #statsPanel,
    #achievementsPanel {
        width: 100vw;
        max-width: 300px;
    }
    
    .achievement-item {
        padding: 10px;
        gap: 10px;
    }
    
    .achievement-icon {
        font-size: 24px;
        width: 32px;
    }
    
    .achievement-name {
        font-size: 13px;
    }
    
    .achievement-desc {
        font-size: 11px;
    }
    
    /* Custom dropdown mobile */
    .dropdown-selected {
        padding: 6px 24px 6px 10px;
        font-size: 13px;
    }
    
    .dropdown-option {
        padding: 8px 10px;
    }
    
    .dropdown-option-title {
        font-size: 13px;
    }
    
    .dropdown-option-desc {
        font-size: 10px;
    }
    
    /* Gold display mobile */
    .gold-display {
        padding: 4px 10px;
    }
    
    .gold-display span:last-child {
        font-size: 12px;
    }
    
    .gold-earned {
        font-size: 18px;
    }
    
    .gold-earned .gold-icon {
        font-size: 20px;
    }
    
    /* Modal slider mobile */
    .modal-slider-row {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px;
    }
    
    .custom-slider-container {
        width: 100px;
    }
    
    .slider-value {
        font-size: 13px;
        min-width: 40px;
    }
    
    /* Game header mobile */
    .game-header {
        gap: 12px;
        flex-wrap: wrap;
    }
}

/* Debug mode styles */
.debug-option {
    color: #ff6b6b;
    border-top: 1px solid #444;
    padding-top: 10px;
    margin-top: 5px;
}

.debug-btn {
    background: #ff6b6b !important;
    color: #fff !important;
}

/* Prevent pull-to-refresh and overscroll */
html, body {
    overscroll-behavior: none;
}

/* Room Panel Overlay */
.room-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 199;
}

.room-overlay.open {
    display: block;
}

/* Room Panel */
#roomPanel {
    position: fixed;
    top: 0;
    right: -360px;
    width: 340px;
    height: 100vh;
    background: #222;
    border-left: 2px solid #444;
    transition: right 0.3s ease;
    z-index: 200;
    display: flex;
    flex-direction: column;
}

#roomPanel.open {
    right: 0;
}

.room-header {
    padding: 20px;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.room-header h3 {
    margin: 0;
    font-size: 20px;
}

.room-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
}

.room-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Room Join/Create */
.room-input-group {
    margin-bottom: 15px;
}

.room-input-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #aaa;
}

.room-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    background: #333;
    border: 1px solid #555;
    border-radius: 6px;
    color: #fff;
    box-sizing: border-box;
}

.room-input:focus {
    outline: none;
    border-color: #4d96ff;
}

.room-btn {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    cursor: pointer;
    border: none;
    border-radius: 6px;
    margin-bottom: 10px;
    transition: transform 0.2s, opacity 0.2s;
}

.room-btn:hover {
    transform: scale(1.02);
}

.room-btn-primary {
    background: linear-gradient(135deg, #4d96ff, #9b59b6);
    color: #fff;
}

.room-btn-secondary {
    background: #444;
    color: #fff;
}

.room-divider {
    text-align: center;
    margin: 20px 0;
    color: #666;
    position: relative;
}

.room-divider::before,
.room-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: #444;
}

.room-divider::before {
    left: 0;
}

.room-divider::after {
    right: 0;
}

/* Room Lobby */
#roomLobby {
    display: none;
}

.room-code-display {
    background: #333;
    border: 2px dashed #4d96ff;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    margin-bottom: 20px;
}

.room-code-label {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 8px;
}

.room-code-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.room-code-input {
    font-size: 24px;
    font-weight: bold;
    letter-spacing: 4px;
    color: #4d96ff;
    background: transparent;
    border: none;
    text-align: center;
    width: 140px;
    cursor: text;
    -webkit-user-select: text;
    user-select: text;
}

.room-code-input:focus {
    outline: none;
}

.room-code-copy {
    background: #444;
    border: none;
    color: #fff;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.room-code-copy:hover {
    background: #555;
}

.room-code-copy.copied {
    background: #4ade80;
    color: #000;
}

.room-code {
    font-size: 28px;
    font-weight: bold;
    letter-spacing: 4px;
    color: #4d96ff;
}

/* Room Toggle */
.room-toggle {
    background: #2a2a2a;
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.room-btn-leave {
    width: 100%;
    margin-top: 20px;
    background: #444;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.room-btn-leave:hover {
    background: #5a2d2d;
}

.room-players-section {
    margin-bottom: 20px;
}

.room-players-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.room-players-header h4 {
    margin: 0;
    font-size: 14px;
    color: #aaa;
}

#playerCount {
    font-size: 14px;
    color: #4d96ff;
}

#roomPlayersList {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.room-player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #333;
    border-radius: 6px;
}

.player-name {
    flex: 1;
    font-size: 14px;
}

.host-badge {
    font-size: 10px;
    background: #ffd93d;
    color: #333;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

.you-badge {
    font-size: 10px;
    background: #4d96ff;
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Host Controls */
#hostControls {
    display: none;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #444;
}

#hostControls label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #aaa;
}

#multiplayerLevelSelect {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    background: #333;
    border: 1px solid #555;
    border-radius: 6px;
    color: #fff;
    margin-bottom: 15px;
}

#waitingMessage {
    text-align: center;
    color: #888;
    font-size: 14px;
    padding: 20px 0;
}

/* Chat */
.room-chat {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #444;
}

.room-chat h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #aaa;
}

#chatMessages {
    height: 120px;
    overflow-y: auto;
    background: #1a1a1a;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 10px;
}

.chat-message {
    font-size: 13px;
    margin-bottom: 5px;
    word-break: break-word;
}

.chat-message strong {
    color: #4d96ff;
}

.chat-input-row {
    display: flex;
    gap: 8px;
}

#chatInput {
    flex: 1;
    padding: 8px 10px;
    font-size: 13px;
    background: #333;
    border: 1px solid #555;
    border-radius: 6px;
    color: #fff;
}

#chatInput:focus {
    outline: none;
    border-color: #4d96ff;
}

.chat-send-btn {
    padding: 8px 15px;
    font-size: 13px;
    background: #4d96ff;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

/* Room Notification */
.room-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 1000;
    display: none;
}

.room-notification.success {
    background: #2d5a3d;
    border: 1px solid #4a8a5a;
    color: #8f8;
}

.room-notification.error {
    background: #5a2d2d;
    border: 1px solid #8a4a4a;
    color: #f88;
}

/* Connection Status */
.connection-status {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    margin-left: 10px;
}

.connection-status.connected {
    background: #2d5a3d;
    color: #8f8;
}

.connection-status.disconnected {
    background: #5a2d2d;
    color: #f88;
}

/* Multiplayer Button */
.multiplayer-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    background: linear-gradient(135deg, #6bcb77, #4d96ff);
    color: #fff;
    border: none;
    border-radius: 8px;
    margin-top: 10px;
}

.multiplayer-btn:hover {
    transform: scale(1.05);
}

/* Room panel mobile */
@media (max-width: 480px) {
    #roomPanel {
        width: 100vw;
        max-width: 340px;
    }
    
    .room-code {
        font-size: 24px;
    }
}

/* Level Editor Panel */
#editorPanel {
    position: fixed;
    top: 0;
    left: -400px;
    width: 380px;
    height: 100vh;
    background: #222;
    border-right: 2px solid #444;
    transition: left 0.3s ease;
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

#editorPanel.open {
    left: 0;
}

.editor-header {
    padding: 20px;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-header h3 {
    margin: 0;
    font-size: 20px;
}

.editor-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
}

.editor-content {
    padding: 20px;
}

.editor-controls {
    margin-bottom: 20px;
}

.editor-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.editor-row label {
    font-size: 14px;
    color: #aaa;
}

.editor-row select {
    padding: 8px 12px;
    font-size: 14px;
    background: #333;
    border: 1px solid #555;
    border-radius: 6px;
    color: #fff;
}

.editor-colors {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.editor-color-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 3px solid transparent;
    transition: transform 0.2s, border-color 0.2s;
}

.editor-color-btn:hover {
    transform: scale(1.1);
}

.editor-color-btn.selected {
    border-color: #fff;
    transform: scale(1.15);
}

.editor-color-btn.used {
    opacity: 0.3;
    cursor: not-allowed;
}

.editor-color-btn.used::after {
    content: '✓';
    position: absolute;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
}

.editor-status {
    font-size: 14px;
    color: #4d96ff;
    margin-bottom: 5px;
}

.editor-pairs {
    font-size: 12px;
    color: #888;
}

.editor-canvas-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

#editorCanvas {
    border: 2px solid #444;
    cursor: crosshair;
}

.editor-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.editor-btn {
    flex: 1;
    padding: 10px;
    font-size: 14px;
    cursor: pointer;
    background: #444;
    color: #fff;
    border: none;
    border-radius: 6px;
    transition: transform 0.2s, background 0.2s;
}

.editor-btn:hover {
    transform: scale(1.02);
    background: #555;
}

.editor-btn.primary {
    background: linear-gradient(135deg, #4d96ff, #9b59b6);
}

.editor-btn.primary:hover {
    background: linear-gradient(135deg, #5da6ff, #ab69c6);
}

.editor-import {
    border-top: 1px solid #444;
    padding-top: 20px;
}

.editor-import h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #aaa;
}

.editor-import textarea {
    width: 100%;
    height: 80px;
    padding: 10px;
    font-size: 12px;
    font-family: monospace;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 6px;
    color: #fff;
    resize: vertical;
    margin-bottom: 10px;
    box-sizing: border-box;
}

.editor-btn-main {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    background: linear-gradient(135deg, #ff6b6b, #ffd93d);
    color: #333;
    border: none;
    border-radius: 8px;
    margin-top: 10px;
    font-weight: bold;
}

.editor-btn-main:hover {
    transform: scale(1.05);
}

/* Export Modal */
.export-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 300;
}

.export-modal-content {
    background: #222;
    border: 2px solid #444;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.export-modal-header {
    padding: 20px;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.export-modal-header h3 {
    margin: 0;
}

.export-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
}

.export-section {
    padding: 20px;
    border-bottom: 1px solid #333;
}

.export-section:last-child {
    border-bottom: none;
}

.export-section label {
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
    color: #aaa;
}

.export-section textarea {
    width: 100%;
    height: 120px;
    padding: 10px;
    font-size: 11px;
    font-family: monospace;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 6px;
    color: #4d96ff;
    resize: vertical;
    margin-bottom: 10px;
    box-sizing: border-box;
}

/* Saved Levels Section */
.editor-saved-section {
    border-top: 1px solid #444;
    padding-top: 15px;
    margin-top: 15px;
}

.editor-saved-section h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #aaa;
}

.editor-save-buttons {
    margin-bottom: 10px;
}

.saved-levels-list {
    max-height: 150px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.no-saved-levels {
    font-size: 12px;
    color: #666;
    text-align: center;
    padding: 10px;
}

.saved-level-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #333;
    padding: 8px 10px;
    border-radius: 6px;
}

.saved-level-name {
    font-size: 13px;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.saved-level-actions {
    display: flex;
    gap: 4px;
}

.saved-level-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.saved-level-btn:hover {
    background: #444;
}

.saved-level-btn.delete:hover {
    background: #5a2d2d;
}

/* Editor Notification */
.editor-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 400;
    display: none;
}

.editor-notification.success {
    background: #2d5a3d;
    border: 1px solid #4a8a5a;
    color: #8f8;
}

.editor-notification.error {
    background: #5a2d2d;
    border: 1px solid #8a4a4a;
    color: #f88;
}

/* Editor panel mobile */
@media (max-width: 480px) {
    #editorPanel {
        width: 100vw;
    }
    
    .editor-color-btn {
        width: 32px;
        height: 32px;
    }
}

/* Grid Size Controls */
.game-controls {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

.grid-size-control {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #333;
    padding: 8px 15px;
    border-radius: 8px;
}

.grid-size-control label {
    font-size: 14px;
    color: #aaa;
}

.grid-size-control input[type="range"] {
    width: 80px;
    cursor: pointer;
    accent-color: #4d96ff;
}

.grid-size-control span {
    font-size: 14px;
    font-weight: bold;
    color: #4d96ff;
    min-width: 40px;
}

/* Skip button */
.btn-skip {
    background: #665544 !important;
    color: #ccc !important;
}

.btn-skip:hover {
    background: #776655 !important;
}

/* Modal grid size control */
.modal-grid-size {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #444;
}

.modal-grid-size label {
    font-size: 14px;
    color: #aaa;
}

.modal-grid-size input[type="range"] {
    width: 80px;
    cursor: pointer;
    accent-color: #4d96ff;
}

.modal-grid-size span {
    font-size: 14px;
    font-weight: bold;
    color: #4d96ff;
    min-width: 40px;
}

/* Custom Slider Styles */
/* Simple Slider (no glow, smooth animation) */
.simple-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 120px;
    height: 6px;
    background: #444;
    border-radius: 3px;
    cursor: pointer;
    outline: none;
}

.simple-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #4d96ff;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.simple-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.simple-slider::-webkit-slider-thumb:active {
    transform: scale(0.95);
}

.simple-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #4d96ff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: transform 0.15s ease;
}

.simple-slider::-moz-range-thumb:hover {
    transform: scale(1.1);
}

.simple-slider::-moz-range-track {
    background: #444;
    height: 6px;
    border-radius: 3px;
}

.slider-value {
    font-size: 14px;
    font-weight: bold;
    color: #4d96ff;
    min-width: 45px;
    text-align: center;
}

/* Game Grid Slider (below skip button) */
.game-grid-slider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 8px 0;
    font-size: 13px;
    color: #888;
}

.game-grid-slider .simple-slider {
    width: 100px;
}

/* Modal Buttons */
.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.modal-btn {
    padding: 12px 28px;
    font-size: 14px;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    transition: transform 0.15s, opacity 0.15s;
    font-weight: 500;
}

.modal-btn:hover {
    opacity: 0.9;
}

.modal-btn:active {
    transform: scale(0.98);
}

.modal-btn-primary {
    background: #4d96ff;
    color: #fff;
}

.modal-btn-secondary {
    background: #444;
    color: #fff;
}

/* Modal Slider Row */
.modal-slider-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 15px 0;
    padding: 12px;
    background: #1a1a1a;
    border-radius: 8px;
}

.modal-slider-row label {
    font-size: 14px;
    color: #aaa;
}

/* Gold Display Styles */
.gold-display {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #3d3520, #2a2515);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid #6b5a2a;
}

.gold-icon {
    font-size: 16px;
}

.gold-display span:last-child {
    font-size: 14px;
    font-weight: bold;
    color: #ffd700;
}

.gold-earned {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 20px;
    color: #ffd700;
    margin: 15px 0;
    animation: goldPulse 0.6s ease-out;
}

.gold-earned .gold-icon {
    font-size: 24px;
}

@keyframes goldPulse {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Game Header */
.game-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 10px 5px 8px 5px;
}

.game-header #status {
    margin: 0;
    font-size: 16px;
    min-height: 20px;
}

/* Gold stat in stats panel */
.gold-stat {
    color: #ffd700 !important;
}

/* Safe area insets for notched devices */
@supports (padding: env(safe-area-inset-top)) {
    #gameScreen {
        padding-top: max(10px, env(safe-area-inset-top));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }
    
    #mainMenu {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Auth Section */
.auth-section {
    margin-bottom: 15px;
}

.auth-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #444;
    border-radius: 20px;
    color: #aaa;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.user-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(77, 150, 255, 0.15);
    border: 1px solid #4d96ff;
    border-radius: 20px;
    color: #4d96ff;
    font-size: 13px;
}

.user-display .username {
    font-weight: bold;
}

.logout-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    margin-left: 4px;
}

.logout-btn:hover {
    color: #ff6b6b;
}

/* Auth Modal Overlay */
.auth-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 450;
}

.auth-overlay.open {
    display: block;
}

/* Auth Modal */
.auth-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #222;
    border: 2px solid #444;
    border-radius: 12px;
    padding: 30px;
    min-width: 280px;
    max-width: 320px;
    z-index: 451;
}

.auth-modal.open {
    display: block;
}

.auth-modal h3 {
    margin: 0 0 20px 0;
    text-align: center;
    font-size: 20px;
    color: #fff;
}

.auth-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
}

.auth-modal-close:hover {
    color: #fff;
}

.auth-error {
    display: none;
    background: rgba(255, 107, 107, 0.2);
    border: 1px solid #ff6b6b;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 15px;
    color: #ff6b6b;
    font-size: 13px;
    text-align: center;
}

.auth-modal form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-modal input {
    padding: 12px;
    background: #333;
    border: 1px solid #444;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
}

.auth-modal input:focus {
    outline: none;
    border-color: #4d96ff;
}

.auth-modal input::placeholder {
    color: #666;
}

.auth-submit {
    padding: 12px;
    background: #4d96ff;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
}

.auth-submit:hover {
    opacity: 0.9;
}

.auth-switch {
    margin: 10px 0 0 0;
    text-align: center;
    font-size: 12px;
    color: #888;
}

.auth-switch a {
    color: #4d96ff;
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* No Stats Message */
.no-stats-message {
    background: rgba(255, 107, 107, 0.15);
    border: 1px solid #ff6b6b;
    border-radius: 8px;
    padding: 10px 15px;
    margin: 10px 0;
    color: #ff6b6b;
    font-size: 13px;
    text-align: center;
}

/* Light Mode */
body.light-mode {
    background: #f5f5f5;
    color: #222;
}

body.light-mode #mainMenu,
body.light-mode .settings-panel,
body.light-mode .auth-modal,
body.light-mode #statsPanel,
body.light-mode #achievementsPanel,
body.light-mode #roomPanel,
body.light-mode .confirm-dialog,
body.light-mode #editorPanel {
    background: #fff;
    color: #222;
    border-color: #ddd;
}

body.light-mode .title {
    color: #333;
    text-shadow: none;
}

body.light-mode .btn-play {
    background: linear-gradient(135deg, #4d96ff, #3a7bd5);
    color: #fff;
}

body.light-mode .menu-btn {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
    border-color: #ddd;
}

body.light-mode .menu-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

body.light-mode .btn {
    background: #e8e8e8;
    color: #333;
    border-color: #ccc;
}

body.light-mode .btn:hover {
    background: #ddd;
}

body.light-mode .auth-btn {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
    border-color: #ddd;
}

body.light-mode .menu-btn-settings {
    background: rgba(0, 0, 0, 0.05);
    color: #666;
    border-color: #ddd;
}

body.light-mode .settings-section h4,
body.light-mode .options-title {
    color: #333;
}

body.light-mode .toggle-item span:first-child,
body.light-mode .setting-row span,
body.light-mode .stat-row span {
    color: #444;
}

body.light-mode .toggle-slider {
    background: #ccc;
}

body.light-mode .server-stats,
body.light-mode .server-stat {
    color: #666;
}

body.light-mode .dropdown-selected {
    background: #f0f0f0;
    color: #333;
    border-color: #ccc;
}

body.light-mode .dropdown-options {
    background: #fff;
    color: #333;
    border-color: #ccc;
}

body.light-mode .dropdown-option:hover {
    background: #f0f0f0;
}

body.light-mode .confirm-title {
    color: #333;
}

body.light-mode .confirm-message {
    color: #666;
}

body.light-mode .modal-content {
    background: #fff;
    color: #333;
}

body.light-mode .modal-content p {
    color: #444;
}

body.light-mode #canvas {
    background: #e0e0e0;
}

body.light-mode #status {
    color: #333;
}

body.light-mode .game-header {
    color: #333;
}

body.light-mode .game-grid-slider {
    color: #666;
}

body.light-mode .achievement-item {
    background: #f0f0f0;
    color: #333;
}

body.light-mode .achievement-item.locked {
    opacity: 0.5;
}

body.light-mode .achievements-divider {
    color: #888;
    border-color: #ddd;
}

body.light-mode .room-content,
body.light-mode .room-header {
    border-color: #ddd;
}

body.light-mode .room-btn {
    background: #f0f0f0;
    color: #333;
    border-color: #ccc;
}

body.light-mode .room-input {
    background: #f5f5f5;
    color: #333;
    border-color: #ccc;
}

body.light-mode .auth-modal input {
    background: #f5f5f5;
    color: #333;
    border-color: #ccc;
}

body.light-mode .options-overlay,
body.light-mode .auth-overlay,
body.light-mode .room-overlay,
body.light-mode .confirm-overlay {
    background: rgba(0, 0, 0, 0.5);
}

body.light-mode .settings-close,
body.light-mode .stats-close,
body.light-mode .achievements-close,
body.light-mode .room-close {
    color: #666;
}

body.light-mode .settings-close:hover,
body.light-mode .stats-close:hover,
body.light-mode .achievements-close:hover,
body.light-mode .room-close:hover {
    color: #333;
}

body.light-mode .achievement-item.unlocked {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    border-color: #28a745;
}

body.light-mode .achievement-name {
    color: #222;
}

body.light-mode .achievement-desc {
    color: #666;
}

body.light-mode .gold-earned {
    color: #333;
}

body.light-mode .slider-value {
    color: #333;
}

body.light-mode .modal-slider-row label {
    color: #444;
}

body.light-mode .no-stats-message {
    background: rgba(220, 53, 69, 0.1);
    border-color: #dc3545;
    color: #dc3545;
}

body.light-mode .user-display {
    background: rgba(77, 150, 255, 0.1);
    color: #2563eb;
    border-color: #2563eb;
}

body.light-mode .beta-tag {
    color: #2563eb;
}

/* Reduce Motion */
body.reduce-motion,
body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
    animation: none !important;
    animation-duration: 0s !important;
    animation-delay: 0s !important;
    transition: none !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
}

body.reduce-motion #snowCanvas {
    display: none !important;
}

body.reduce-motion .btn-play,
body.reduce-motion .menu-btn,
body.reduce-motion .btn,
body.reduce-motion .modal-btn,
body.reduce-motion .confirm-btn,
body.reduce-motion .room-btn,
body.reduce-motion .auth-btn,
body.reduce-motion .toggle-slider,
body.reduce-motion .dropdown-selected,
body.reduce-motion .dropdown-options {
    transition: none !important;
}

body.reduce-motion .achievement-popup {
    animation: none !important;
    opacity: 1 !important;
}

/* Debug Section */
.debug-section {
    border-top: 1px solid #444;
    padding-top: 15px;
}

.debug-section h4 {
    color: #ff6b6b;
}

.debug-btn {
    width: 100%;
    padding: 10px;
    margin-bottom: 8px;
    background: #333;
    border: 1px solid #444;
    border-radius: 6px;
    color: #aaa;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.debug-btn:hover {
    background: #444;
    color: #fff;
    border-color: #ff6b6b;
}

.debug-btn:last-child {
    margin-bottom: 0;
    background: #3a2020;
    border-color: #ff6b6b;
    color: #ff6b6b;
}

.debug-btn:last-child:hover {
    background: #ff6b6b;
    color: #fff;
}

/* Ready Overlay for Multiplayer */
.ready-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.ready-dialog {
    background: #2a2a2a;
    border-radius: 12px;
    padding: 24px 32px;
    min-width: 280px;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.ready-title {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #fff;
}

.ready-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.ready-player {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #333;
    border-radius: 8px;
    border: 2px solid #444;
    transition: all 0.3s;
}

.ready-player.is-ready {
    border-color: #4ade80;
    background: rgba(74, 222, 128, 0.1);
}

.ready-player-name {
    font-weight: 500;
    color: #fff;
}

.ready-player-status {
    font-size: 13px;
    color: #888;
}

.ready-player.is-ready .ready-player-status {
    color: #4ade80;
}

.ready-status {
    font-size: 14px;
    color: #888;
    margin-top: 8px;
}

.ready-btn {
    margin-top: 16px;
    padding: 12px 32px;
    font-size: 16px;
    font-weight: bold;
    background: linear-gradient(135deg, #4ade80, #22c55e);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

.ready-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(74, 222, 128, 0.4);
}

.host-start-hint {
    font-size: 13px;
    color: #888;
    text-align: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    margin-top: 10px;
}

.host-start-hint strong {
    color: #4ade80;
}
