body {
    background-color: skyblue;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}

/* Language Selector - Fixed Top Right */
.language-selector-fixed {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1002;
    display: flex;
    gap: 8px;
    background: white;
    padding: 8px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.lang-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.lang-btn:hover {
    background: #f8f9ff;
    transform: scale(1.05);
}

.lang-btn input[type="radio"] {
    display: none;
}

.lang-btn input[type="radio"]:checked + span {
    transform: scale(1.15);
}

.lang-btn input[type="radio"]:checked {
    & + span {
        filter: drop-shadow(0 2px 4px rgba(102, 126, 234, 0.4));
    }
}

.lang-btn span {
    font-size: 24px;
    transition: all 0.2s;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    width: 50px;
    height: 50px;
    background: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 0;
}

.mobile-menu-btn:hover {
    transform: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.mobile-menu-btn .hamburger {
    width: 25px;
    height: 3px;
    background: #667eea;
    border-radius: 2px;
    transition: all 0.3s;
}

/* Mobile Timer (floats next to hamburger) */
.mobile-timer {
    display: none;
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1001;
    font-size: 20px;
    font-weight: bold;
    color: white;
    font-variant-numeric: tabular-nums;
    text-align: center;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 80px;
}

/* Desktop Timer */
.desktop-only {
    display: block;
}

/* Mobile Bottom Toolbar */
.mobile-toolbar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
    padding: 8px;
    justify-content: space-around;
    align-items: center;
    gap: 8px;
}

.toolbar-btn {
    flex: 1;
    max-width: 70px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 20px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: auto;
}

.toolbar-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

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

.toolbar-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Menu Overlay */
.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s;
}

.menu-overlay.active {
    display: block;
    opacity: 1;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Left Sidebar */
.sidebar {
    width: 300px;
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    padding: 25px 18px;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 999;
    position: relative;
}

.sidebar-close {
    display: none;
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    width: auto;
    padding: 8px;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    z-index: 1;
}

.sidebar-close:hover {
    color: #667eea;
    transform: none;
    box-shadow: none;
}

.sidebar-close span {
    display: block;
}

.sidebar h1 {
    color: #667eea;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 25px;
    padding-bottom: 18px;
    border-bottom: 2px solid #f0f0f0;
}

.settings-section {
    margin-bottom: 25px;
}

.settings-section h3 {
    color: #667eea;
    font-size: 16px;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Language Selector */
.language-section {
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 20px;
}

/* Removed old language selector styles */

/* Complexity Buttons - Single Row */
.complexity-buttons {
    display: flex;
    gap: 8px;
}

.complexity-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
    font-weight: 500;
}

.complexity-btn:hover {
    border-color: #667eea;
    background: #f8f9ff;
    transform: translateY(-2px);
}

.complexity-btn input[type="radio"] {
    display: none;
}

.complexity-btn input[type="radio"]:checked ~ span {
    color: white;
}

.complexity-btn input[type="radio"]:checked {
    & ~ span {
        color: white;
        font-weight: 600;
    }
}

.complexity-btn:has(input[type="radio"]:checked) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.complexity-btn span {
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    color: #666;
    transition: all 0.2s;
}

/* Player Section */
.player-section {
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 20px;
}

.player-greeting {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.player-greeting:hover {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea25 0%, #764ba225 100%);
    transform: translateY(-1px);
}

.player-greeting .greeting-icon {
    font-size: 24px;
}

.player-greeting span[data-puzzle-target="greetingText"] {
    font-size: 14px;
    font-weight: 500;
    color: #667eea;
    flex: 1;
}

.settings-group {
    margin-bottom: 15px;
}

.settings-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
    font-size: 14px;
}

.settings-group input[type="number"] {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.settings-group input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
}

.operations-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.checkbox-label:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-label span {
    font-size: 14px;
    font-weight: 500;
}

.complexity-selector {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.complexity-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
}

.complexity-option:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.complexity-option input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.complexity-option input[type="radio"]:checked + span {
    color: #667eea;
    font-weight: 600;
}

.complexity-option span {
    font-size: 14px;
    font-weight: 500;
    flex: 1;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

button {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

button:active {
    transform: translateY(0);
}

button.hint-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

button.check-btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

button.history-btn {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
}

/* Fixed Timer Above Puzzle */
.timer-fixed {
    font-size: 32px;
    font-weight: bold;
    color: white;
    font-variant-numeric: tabular-nums;
    text-align: center;
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 120px;
    flex-shrink: 0;
}

.puzzle-container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: flex;
    min-height: 500px;
    width: 100%;
    overflow: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    scroll-behavior: smooth;
}

/* Custom scrollbar for webkit browsers */
.puzzle-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.puzzle-container::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 4px;
}

.puzzle-container::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.puzzle-container::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

.puzzle-grid {
    display: inline-block;
    margin: 0 auto;
    min-width: min-content;
}

.grid-row {
    display: flex;
}

.cell {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    border: 1px solid #ddd;
}

.cell-empty {
    background: transparent;
    border: none;
}

.cell-operator {
    background: #f0f0f0;
    color: #667eea;
    font-size: 22px;
}

.cell-number {
    background: #fff;
    color: #333;
}

.cell-obfuscated {
    background: #667eea;
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: not-allowed;
}

.cell-input {
    background: #fffef0;
    padding: 0;
}

.cell-input input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    background: transparent;
    outline: none;
}

.cell-input input:focus {
    background: #fff9e6;
    box-shadow: inset 0 0 0 2px #667eea;
}

.cell-input input.correct {
    background: #d4edda;
    color: #155724;
}

.cell-input input.incorrect {
    background: #f8d7da;
    color: #721c24;
}

.cell-input input.hint {
    background: #cce5ff;
    color: #004085;
}

.loading, .error {
    padding: 40px;
    text-align: center;
    font-size: 18px;
    color: #667eea;
}

.error {
    color: #dc3545;
}

/* Custom Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: 15px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    text-align: center;
}

.modal h2 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 24px;
}

.modal p {
    color: #555;
    margin-bottom: 25px;
    font-size: 16px;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-buttons button {
    width: auto;
    padding: 12px 30px;
}

.modal-buttons .btn-secondary {
    background: #6c757d;
}

/* Name Input Modal */
.name-modal {
    max-width: 450px;
}

.name-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 20px;
    transition: border-color 0.3s;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.name-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.name-input::placeholder {
    color: #999;
}

/* History Panel */
.history-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0,0,0,0.2);
    transition: right 0.3s ease;
    z-index: 999;
    display: flex;
    flex-direction: column;
}

.history-panel.visible {
    right: 0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.history-header h2 {
    color: #667eea;
    font-size: 22px;
    margin: 0;
}

.close-history {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    width: auto;
    padding: 0;
    line-height: 1;
}

.close-history:hover {
    color: #667eea;
    transform: none;
}

.history-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.no-history {
    text-align: center;
    color: #999;
    padding: 40px 20px;
}

.history-item {
    background: #f8f9ff;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: all 0.3s;
}

.history-item:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.history-date {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 8px;
    font-size: 14px;
}

.history-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 13px;
    color: #666;
}

.history-stats span {
    display: flex;
    align-items: center;
    gap: 5px;
}

@media (max-width: 968px) {
    /* Show mobile menu button */
    .mobile-menu-btn {
        display: flex;
    }

    /* Show mobile timer */
    .mobile-timer {
        display: block;
    }
    
    /* Language selector adjustments for mobile */
    .language-selector-fixed {
        top: 10px;
        right: 10px;
        padding: 6px;
        gap: 6px;
    }
    
    .lang-btn {
        width: 36px;
        height: 36px;
    }
    
    .lang-btn span {
        font-size: 20px;
    }

    /* Hide desktop timer */
    .desktop-only {
        display: none;
    }

    /* Show mobile toolbar */
    .mobile-toolbar {
        display: flex;
    }

    /* Show sidebar close button */
    .sidebar-close {
        display: block;
    }

    /* Make sidebar an overlay - FLOATS OVER CONTENT */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        transform: translateX(-100%);
        box-shadow: 2px 0 20px rgba(0,0,0,0.3);
        padding: 60px 20px 20px;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Hide sidebar controls on mobile (moved to toolbar) */
    .sidebar .controls {
        display: none;
    }

    /* Main content stays in place - add bottom padding for toolbar */
    .main-content {
        padding: 75px 10px 70px;
        width: 100%;
        height: 100vh;
        overflow: hidden;
    }

    .puzzle-container {
        padding: 15px 10px;
        min-height: auto;
        max-height: 100%;
        width: 100%;
        overflow: auto;
        flex: 1;
    }

    .cell {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }

    .cell-operator {
        font-size: 18px;
    }

    .cell-obfuscated {
        font-size: 20px;
    }

    .cell-input input {
        font-size: 14px;
    }

    .operations-grid {
        grid-template-columns: 1fr;
    }

    .history-panel {
        width: 100%;
        right: -100%;
    }

    .history-panel.visible {
        right: 0;
    }
}

/* Tablet optimization */
@media (min-width: 481px) and (max-width: 968px) {
    .cell {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .cell-operator {
        font-size: 20px;
    }

    .cell-obfuscated {
        font-size: 22px;
    }

    .cell-input input {
        font-size: 16px;
    }

    .main-content {
        padding: 70px 15px 15px;
    }

    .puzzle-container {
        padding: 20px 15px;
    }
}

@media (max-width: 480px) {
    .mobile-menu-btn {
        top: 10px;
        left: 10px;
        width: 45px;
        height: 45px;
    }

    .mobile-timer {
        top: 10px;
        right: 10px;
        font-size: 18px;
        padding: 8px 12px;
        min-width: 70px;
    }

    .main-content {
        padding: 70px 5px 70px;
        height: 100vh;
    }

    .puzzle-container {
        padding: 10px 5px;
        border-radius: 10px;
        max-height: 100%;
    }

    .cell {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .cell-operator {
        font-size: 14px;
    }

    .cell-obfuscated {
        font-size: 16px;
    }

    .cell-input input {
        font-size: 12px;
    }

    .sidebar {
        width: 85%;
        max-width: 320px;
    }

    .sidebar h1 {
        font-size: 20px;
        margin-bottom: 20px;
    }

    .settings-section {
        margin-bottom: 20px;
    }

    .settings-section h3 {
        font-size: 14px;
        margin-bottom: 10px;
    }

    .sidebar button {
        padding: 12px 16px;
        font-size: 14px;
    }

    .mobile-toolbar {
        padding: 6px;
    }

    .toolbar-btn {
        max-width: 60px;
        height: 45px;
        font-size: 18px;
    }

    .modal {
        padding: 20px;
        max-width: 90%;
    }

    .modal h2 {
        font-size: 20px;
    }

    .modal p {
        font-size: 14px;
    }
}

/* Extra small screens (< 360px) */
@media (max-width: 360px) {
    .main-content {
        padding: 70px 3px 65px;
        height: 100vh;
    }

    .mobile-timer {
        font-size: 16px;
        padding: 6px 10px;
        min-width: 60px;
    }

    .puzzle-container {
        padding: 8px 3px;
        max-height: 100%;
    }

    .cell {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }

    .cell-operator {
        font-size: 12px;
    }

    .cell-obfuscated {
        font-size: 14px;
    }

    .cell-input input {
        font-size: 10px;
    }

    .toolbar-btn {
        max-width: 50px;
        height: 40px;
        font-size: 16px;
    }
}
