* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.start-screen {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 100%;
}

.game-title {
    font-size: 3rem;
    color: #333;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.author {
    margin-bottom: 30px;
    color: #666;
}

.author a {
    color: #667eea;
    text-decoration: none;
}

.author a:hover {
    color: #f14af1;
}

.modes-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin: 50px 0 30px;
}

.mode-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.mode-card:hover {
    transform: translateY(-5px);
    border-color: #667eea;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.mode-card h2 {
    color: #333;
    margin-bottom: 10px;
}

.mode-card p {
    color: #666;
    font-size: 0.8rem;
}

.continue-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.3s ease;
    margin-top: 20px;
    width: 100%;
}

.continue-btn:hover {
    background: #45a049;
}

.user-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.2s ease;
}

.icon-btn:hover {
    transform: scale(1.1);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 15px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    max-height: 95vh;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px;
    display: flex;
    gap: 10px;
    justify-content: space-between;
    border-top: 1px solid #eee;
}

.setting-group {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.setting-group:last-child {
    border-bottom: none;
}

.setting-group h3 {
    margin-bottom: 10px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-description {
    margin: 8px 0 0 0;
    color: #666;
    font-size: 0.85rem;
    font-style: italic;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #667eea;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

select {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
}

select:focus {
    border-color: #667eea;
    outline: none;
}

.theme-options {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.theme-option input {
    display: none;
}

.theme-preview {
    width: 60px;
    height: 40px;
    border-radius: 8px;
    border: 3px solid transparent;
    transition: all 0.3s ease;
}

.theme-option input:checked + .theme-preview {
    border-color: #667eea;
}

.light-theme {
    background: linear-gradient(135deg, #66eae6, #dbe8b7 100%);
    border: 1px solid #ddd;
}

.dark-theme {
    background: linear-gradient(135deg, #2d3748, #4a5568);
}

.save-btn, .cancel-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.save-btn {
    background: #4CAF50;
    color: white;
}

.save-btn:hover {
    background: #45a049;
}

.cancel-btn {
    background: #6c757d;
    color: white;
}

.cancel-btn:hover {
    background: #5a6268;
}

html.theme-light {
    background: linear-gradient(135deg, #66eae6 0%, #dbe8b7 100%);
}

html.theme-dark {
    background: linear-gradient(135deg, #0f192b 0%, #4a5568 100%);
}

html.theme-dark .start-screen{
    background: linear-gradient(135deg, #2b3e55 0%, #47546b 100%);
}

html.theme-dark .game-title {
    color: #dde6dd;
}

html.theme-dark .author {
    color: #dde6dd;
}

html.theme-dark .author a {
    color: #8397ed;
}

html.theme-dark .author a:hover {
    color: #ed89ed;
}

html.theme-dark .mode-card {
    background: #7488a9;
}

html.theme-dark .mode-card:hover {
    border-color: #c3c8de;
}

html.theme-dark .mode-card p {
    color: #e6e7f0;
}

html.theme-dark .modal-content {
    background: #0f192b 0%;
    border: #88898b 1px solid;
}

html.theme-dark .modal-header {
    background: linear-gradient(135deg, #6571a2, #795b97);
}

html.theme-dark .modal-header {
    background: linear-gradient(135deg, #6571a2, #795b97);
}

html.theme-dark .setting-group h3 {
    color: #e6e7f0;
}

.game-screen {
    min-height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.game-top-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.game-info {
    display: flex;
    gap: 20px;
    font-size: 1.1rem;
    font-weight: bold;
}

.control-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s ease;
}

.control-btn:hover {
    background: #5a6fd8;
}

.game-container {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    min-height: auto;
}

.game-row {
    display: flex;
    justify-content: center;
    margin-bottom: 5px;
}

.game-cell {
    width: 50px;
    height: 50px;
    border: 2px solid #ddd;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 3px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.game-cell.has-number {
    background: white;
    color: #333;
}

.game-cell.has-number:hover {
    background: #f0f0f0;
    transform: scale(1.05);
}

.game-cell.selected {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.game-cell.selected:hover {
    background: #5771db;
}

.game-cell.empty {
    background: #f8f9fa;
    border-color: #e9ecef;
    cursor: default;
}

.tools-panel {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 20px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.assist-tools {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.assist-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    position: relative;
}

.assist-btn:hover {
    background: #218838;
}

.assist-btn::after {
    content: attr(data-count);
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

html.theme-dark .game-top-panel,
html.theme-dark .game-container,
html.theme-dark .tools-panel {
    background: rgba(45, 55, 72, 0.95);
    color: white;
}

html.theme-dark .game-cell.has-number {
    background: #4a5568;
    color: white;
    border-color: #718096;
}

html.theme-dark .game-cell.selected {
    background: #8824be;
    color: white;
    border-color: #ba66ea;
}

html.theme-dark .game-cell.empty {
    background: #2d3748;
    border-color: #4a5568;
}

.hint-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: bold;
    z-index: 1000;
    animation: fadeInOut 3s ease-in-out;
    pointer-events: none;
}

.results-modal {
    max-width: 800px;
}

.results-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 10px;
    color: white;
}

.stat-item {
    text-align: center;
}

.stat-item h3 {
    margin: 0 0 5px 0;
    font-size: 0.9rem;
    opacity: 0.9;
}

.stat-item span {
    font-size: 1.5rem;
    font-weight: bold;
}

.results-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn.active {
    border-bottom-color: #667eea;
    color: #667eea;
    font-weight: bold;
}

.results-table-container {
    max-height: 400px;
    overflow-y: auto;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
}

.results-table th,
.results-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.results-table th {
    background: #f8f9fa;
    font-weight: bold;
    position: sticky;
    top: 0;
}

.mode-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: capitalize;
}

.mode-classic {
    background: #e3f2fd;
    color: #1976d2;
}

.mode-random {
    background: #f3e5f5;
    color: #7b1fa2;
}

.mode-chaotic {
    background: #fff3e0;
    color: #f57c00;
}

.win-indicator {
    color: #4caf50;
    font-weight: bold;
}

.loss-indicator {
    color: #f44336;
    font-weight: bold;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

.clear-results-btn {
    background: #b04883;
    color: white;
    padding: 10px 10px;
    border-radius: 8px;
    border: none;
}

.clear-results-btn:hover {
    background: #c82333;
}

.close-results-btn {
    background: #48b08c;
    color: white;
    padding: 10px 10px;
    border-radius: 8px;
    border: none;
}

html.theme-dark .results-stats {
    background: linear-gradient(135deg, #4a5568, #2d3748);
}

html.theme-dark .results-table th {
    background: #4a5568;
    color: white;
}

html.theme-dark .results-table {
    color: white;
}

html.theme-dark .tab-btn {
    color: white;
}

.top-time {
    font-weight: bold;
    color: #ffd700;
}

@media (max-width: 768px) {
    .start-screen {
        padding: 20px;
        margin: 10px;
    }
    
    .game-title {
        font-size: 2rem;
    }
    
    .modes-container {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .theme-options {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .theme-option {
        flex-direction: row;
        gap: 10px;
    }
    
    .modal-footer {
        flex-direction: column;
    }
}

@media (max-width: 550px) {
    .results-table th,
    .results-table td {
        padding: 7px;
        text-align: center;
    }
}

@media (max-width: 545px) {
    .game-cell {
        width: 35px;
        height: 35px;
    }
}

@media (max-width: 485px) {
    .results-table th,
    .results-table td {
        padding: 3px;
        text-align: center;
    }
}

@media (max-width: 445px) {
    .game-cell {
        width: 25px;
        height: 25px;
    }

    .control-btn {
        padding: 10px;
        font-size: 0.7rem;
    }

    .assist-btn {
        padding: 10px;
        font-size: 0.7rem;
    }

    .game-info {
        font-size: 0.9rem;
    }
}

@media (max-width: 380px) {
    body {
        padding: 10px;
    }
    
    .start-screen {
        padding: 15px;
    }
}

@media (hover: none) and (pointer: coarse) {
    .mode-card:hover {
        transform: none;
        border-color: transparent;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    }
    
    .game-cell.has-number:hover {
        background: white;
        transform: none;
    }
    
    .control-btn:hover,
    .assist-btn:hover,
    .icon-btn:hover {
        transform: none;
    }
    
    .icon-btn:hover {
        transform: none;
    }
    
    .save-btn:hover,
    .cancel-btn:hover,
    .default-btn:hover {
        transform: none;
    }

    *:hover {
        transform: none !important;
    }
}