* {
    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;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #233347 0%, #2d4a67 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

header h1 {
    font-size: 1.8em;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.stats {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: nowrap;
    width: 100%;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 5px;
    border-radius: 10px;
    flex: 1 1 33.33%;
    max-width: 33.33%;
    min-width: 0;
}

.stat-item .label {
    font-size: 0.85em;
    opacity: 0.8;
    margin-bottom: 3px;
}

.stat-item .value {
    font-size: 1.5em;
    font-weight: bold;
    color: #FFD700;
}

/* Tutorial Section */
.tutorial-section {
    padding: 25px;
}

.tutorial-section h2 {
    color: #233347;
    margin-bottom: 15px;
    font-size: 1.6em;
    text-align: center;
}

.tutorial-section > p {
    text-align: center;
    font-size: 1.1em;
    color: #666;
    margin-bottom: 20px;
}

.pattern-explanations {
    margin-bottom: 20px;
}

.pattern-example {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    border: 2px solid #e9ecef;
}

.pattern-example h3 {
    color: #667eea;
    margin-bottom: 8px;
    font-size: 1.2em;
}

.pattern-example > p {
    color: #666;
    margin-bottom: 15px;
    font-size: 1em;
}

.example-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 15px;
    max-width: 350px;
    margin-left: auto;
    margin-right: auto;
}

.hint {
    text-align: center;
    color: #28a745;
    font-weight: bold;
    font-size: 0.95em;
    margin-top: 10px;
}

.highlight-odd {
    border: 2px solid #28a745 !important;
    box-shadow: 0 0 15px rgba(40, 167, 69, 0.5);
}

/* Game Section */
.game-section {
    padding: 20px;
    padding-bottom: 60px;
}

.game-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.btn-control {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 8px 20px;
    font-size: 0.95em;
    font-weight: 600;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-control:hover {
    background: #f0f4ff;
    transform: translateY(-1px);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.2);
}

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

.btn-control.paused {
    background: #667eea;
    color: white;
}

.game-grid {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 500px;
}

/* Tiles */
.tile {
    background: rgba(139, 126, 184, 0.3);
    border-radius: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 10px;
    opacity: 0;
}

.tile.active {
    opacity: 1;
}

.tile:hover {
    background: rgba(139, 126, 184, 0.5);
}

.shapes-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-items: center;
}

.shape-item {
    width: 100%;
    height: 100%;
    max-width: 20px;
    max-height: 20px;
}

/* Feedback */
.feedback {
    text-align: center;
    font-size: 1.2em;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 8px;
    transition: opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
    margin: 20px auto;
    width: 390px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback.correct,
.feedback.incorrect {
    opacity: 1;
}

.feedback.correct {
    color: white;
    background: #28a745;
}

.feedback.incorrect {
    color: white;
    background: #dc3545;
}

/* Explanation Panel */
.explanation-panel {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid #667eea;
    border-radius: 15px;
    padding: 25px;
    margin: 20px auto 0;
    width: 390px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease;
}

.explanation-panel h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3em;
    text-align: center;
}

.explanation-panel p {
    color: #333;
    font-size: 1em;
    line-height: 1.6;
    margin-bottom: 0;
    text-align: left;
}

.explanation-panel .pattern-name {
    font-weight: 700;
    color: #667eea;
    font-size: 1.1em;
    margin-bottom: 10px;
}

.explanation-panel .pattern-details {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    border-left: 4px solid #667eea;
}

.explanation-panel .btn-primary {
    display: block;
    margin: 20px auto 0;
    width: 100%;
    max-width: 200px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tile.highlight-correct {
    border: 8px solid #28a745 !important;
    box-shadow: 0 0 30px rgba(40, 167, 69, 1), inset 0 0 20px rgba(40, 167, 69, 0.2) !important;
    background: linear-gradient(135deg, rgba(40, 167, 69, 0.15) 0%, rgba(40, 167, 69, 0.05) 100%), linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%) !important;
}

.tile.disabled {
    pointer-events: none;
    opacity: 0.5;
}

.tile.highlight-correct.disabled {
    opacity: 1 !important;
}

/* Game Over Section */
.game-over-section {
    padding: 40px 25px;
    text-align: center;
}

.game-over-section h2 {
    color: #233347;
    font-size: 2em;
    margin-bottom: 20px;
}

.game-over-section p {
    font-size: 1.2em;
    color: #666;
    margin-bottom: 15px;
}

.game-over-section span {
    color: #667eea;
    font-weight: bold;
    font-size: 1.2em;
}

.percentile-message {
    color: #28a745;
    font-weight: 600;
    font-size: 1.1em;
    margin: 10px 0 20px;
    padding: 15px;
    background: rgba(40, 167, 69, 0.1);
    border-radius: 10px;
    border: 2px solid rgba(40, 167, 69, 0.3);
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.1em;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    display: block;
    margin: 20px auto 0;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

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

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 10px 25px;
    font-size: 1em;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: block;
    margin: 15px auto;
}

.btn-secondary:hover {
    background: #f0f4ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

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

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.5em;
    }

    .stats {
        gap: 8px;
    }

    .stat-item {
        padding: 8px 5px;
        flex: 1 1 33.33%;
        max-width: 33.33%;
    }

    .stat-item .value {
        font-size: 1.3em;
    }

    .tutorial-section,
    .game-section,
    .game-over-section {
        padding: 15px;
    }

    .pattern-example h3 {
        font-size: 1.1em;
    }

    .example-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        max-width: 100%;
    }

    .game-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        width: 100%;
        /* max-width: 320px; */
    }

    .feedback {
        width: 90%;
        max-width: 305px;
    }

    .tile {
        padding: 8px;
        width: 100%;
    }

    .shape-item {
        max-width: 16px;
        max-height: 16px;
    }

    .game-over-section h2 {
        font-size: 1.6em;
    }

    .game-over-section p {
        font-size: 1em;
    }

    .btn-secondary {
        padding: 8px 20px;
        font-size: 0.95em;
    }

    .game-controls {
        gap: 10px;
    }

    .btn-control {
        padding: 6px 15px;
        font-size: 0.9em;
    }

    .explanation-panel {
        padding: 20px;
        width: 90%;
        max-width: 305px;
    }

    .explanation-panel h3 {
        font-size: 1.1em;
    }

    .explanation-panel p {
        font-size: 0.95em;
    }

    .explanation-panel .pattern-details {
        padding: 12px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.3em;
    }

    .stats {
        gap: 5px;
    }

    .stat-item {
        padding: 8px 3px;
        flex: 1 1 33.33%;
        max-width: 33.33%;
    }

    .stat-item .label {
        font-size: 0.75em;
    }

    .stat-item .value {
        font-size: 1.2em;
    }

    .example-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        max-width: 100%;
    }

    .game-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        width: 100%;
        /* max-width: 240px; */
    }

    .feedback {
        width: 90%;
        max-width: 271px;
    }

    .tile {
        padding: 6px;
        width: 100%;
    }

    .shapes-container {
        gap: 2px;
    }

    .shape-item {
        max-width: 14px;
        max-height: 14px;
    }

    .btn-primary {
        padding: 10px 25px;
        font-size: 1em;
    }

    .btn-secondary {
        padding: 8px 20px;
        font-size: 0.95em;
    }

    .game-controls {
        flex-direction: column;
        gap: 8px;
    }

    .btn-control {
        padding: 8px 20px;
        font-size: 0.9em;
        width: 100%;
        max-width: 250px;
    }

    .explanation-panel {
        padding: 15px;
        width: 90%;
        max-width: 271px;
    }

    .explanation-panel h3 {
        font-size: 1em;
    }

    .explanation-panel p {
        font-size: 0.9em;
    }

    .explanation-panel .pattern-details {
        padding: 10px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pattern-example {
    animation: fadeIn 0.5s ease;
}

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

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 30px rgba(40, 167, 69, 0.9), 0 0 60px rgba(40, 167, 69, 0.6), inset 0 0 20px rgba(40, 167, 69, 0.2);
        border-width: 5px;
    }
    50% {
        box-shadow: 0 0 40px rgba(40, 167, 69, 1), 0 0 80px rgba(40, 167, 69, 0.8), inset 0 0 30px rgba(40, 167, 69, 0.3);
        border-width: 6px;
    }
}

.feedback.correct,
.feedback.incorrect {
    animation: pulse 0.5s ease;
}

/* Settings and Home Buttons */
.settings-btn,
.home-btn {
    position: fixed;
    top: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease, background 0.3s ease;
    z-index: 100;
    text-decoration: none;
}

.settings-btn {
    right: 20px;
}

.home-btn {
    left: 20px;
}

.settings-btn:hover {
    transform: rotate(90deg);
    background: white;
}

.home-btn:hover {
    transform: scale(1.1);
    background: white;
}

.settings-btn svg,
.home-btn svg {
    width: 24px;
    height: 24px;
    color: #667eea;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 1px solid #eee;
}

.modal-header h2 {
    font-size: 1.8rem;
    color: #333;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: #999;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease, color 0.2s ease;
}

.close-btn:hover {
    background: #f5f5f5;
    color: #333;
}

.modal-body {
    padding: 30px;
}

.setting-item {
    margin-bottom: 20px;
}

.setting-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.setting-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
    accent-color: #667eea;
}

.setting-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.setting-description {
    color: #666;
    font-size: 0.9rem;
    margin: 8px 0 0 32px;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #eee;
    text-align: right;
}

.btn-save {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 30px;
    border-radius: 25px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.3s ease, transform 0.2s ease;
}

.btn-save:hover {
    opacity: 0.9;
    transform: scale(1.05);
}
