/* ===== Memory Grid Game Styles ===== */

/* ===== Game Board Layout ===== */
#game-board {
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
}

#game-board.active {
    display: flex;
}

/* ===== Instruction Panel ===== */
.instruction-panel {
    background: linear-gradient(135deg, #7A9CB8 0%, #6B8BA8 100%);
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.instruction-text {
    color: white;
    font-size: 24px;
    font-weight: bold;
    margin: 0;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
}

.countdown-text {
    color: white;
    font-size: 48px;
    font-weight: bold;
    margin: 10px 0 0 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: countdown-pulse 1s ease-in-out;
}

@keyframes countdown-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

/* ===== Grid Container ===== */
.grid-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    min-height: 0;
    overflow: hidden;
}

.memory-grid {
    display: grid;
    gap: 10px;
    max-width: 100%;
    max-height: 100%;
}

.memory-grid.size-4 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

.memory-grid.size-6 {
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(6, 1fr);
}

.memory-grid.size-9 {
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 6px;
}

/* ===== Grid Tile Styles ===== */
.grid-tile {
    background: white;
    border: 3px solid #E0E0E0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    aspect-ratio: 1;
    min-width: 60px;
    min-height: 60px;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Smaller tiles for 9×9 grid */
.memory-grid.size-9 .grid-tile {
    min-width: 40px;
    min-height: 40px;
    border-width: 2px;
    border-radius: 8px;
}

.grid-tile:hover:not(.showing-pattern):not(.feedback-mode) {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border-color: var(--secondary-color);
}

/* ===== Tile States ===== */
.grid-tile.pattern-highlight {
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    border-color: #2E6DA4;
    box-shadow: 0 0 25px rgba(74, 144, 226, 0.6);
    animation: pattern-glow 0.5s ease-in-out;
}

@keyframes pattern-glow {
    0%, 100% {
        box-shadow: 0 0 25px rgba(74, 144, 226, 0.6);
    }
    50% {
        box-shadow: 0 0 35px rgba(74, 144, 226, 0.9);
        transform: scale(1.05);
    }
}

.grid-tile.user-selected {
    background: linear-gradient(135deg, #A8E6CF 0%, #88D4AB 100%);
    border-color: #5FB883;
    box-shadow: 0 4px 12px rgba(168, 230, 207, 0.4);
}

.grid-tile.correct-feedback {
    background: linear-gradient(135deg, #4CAF50 0%, #45A049 100%);
    border-color: #2E7D32;
    animation: correct-pop 0.6s ease;
}

.grid-tile.correct-feedback::after {
    content: '✓';
    color: white;
    font-size: 48px;
    font-weight: bold;
    position: absolute;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.grid-tile.wrong-feedback {
    background: linear-gradient(135deg, #E57373 0%, #D32F2F 100%);
    border-color: #B71C1C;
    animation: wrong-shake 0.6s ease;
}

.grid-tile.wrong-feedback::after {
    content: '✗';
    color: white;
    font-size: 48px;
    font-weight: bold;
    position: absolute;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.grid-tile.missed-feedback {
    background: linear-gradient(135deg, #FFA726 0%, #F57C00 100%);
    border-color: #E65100;
    animation: missed-pulse 0.6s ease;
}

.grid-tile.missed-feedback::after {
    content: '○';
    color: white;
    font-size: 48px;
    font-weight: bold;
    position: absolute;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

@keyframes correct-pop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes wrong-shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-8px);
    }
    75% {
        transform: translateX(8px);
    }
}

@keyframes missed-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

/* ===== Action Panel ===== */
.action-panel {
    background: white;
    padding: 20px;
    display: flex;
    gap: 15px;
    justify-content: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.action-panel.hidden {
    display: none;
}

.action-btn {
    padding: 15px 40px;
    border: none;
    border-radius: 12px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    min-width: 180px;
}

.action-btn.primary {
    background: linear-gradient(135deg, #4CAF50 0%, #45A049 100%);
    color: white;
}

.action-btn.primary:hover {
    background: linear-gradient(135deg, #5CBF60 0%, #55B059 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.action-btn.primary:disabled {
    background: linear-gradient(135deg, #9E9E9E 0%, #757575 100%);
    cursor: not-allowed;
    opacity: 0.6;
}

.action-btn.secondary {
    background: linear-gradient(135deg, #7A9CB8 0%, #6B8BA8 100%);
    color: white;
}

.action-btn.secondary:hover {
    background: linear-gradient(135deg, #8AACC8 0%, #7B9BB8 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* ===== Responsive Styles ===== */

/* Tablet */
@media (max-width: 1024px) {
    .grid-tile {
        min-width: 70px;
        min-height: 70px;
    }

    .memory-grid.size-9 .grid-tile {
        min-width: 35px;
        min-height: 35px;
    }

    .instruction-text {
        font-size: 22px;
    }

    .countdown-text {
        font-size: 42px;
    }

    .action-btn {
        padding: 12px 30px;
        font-size: 18px;
        min-width: 150px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .grid-container {
        padding: 15px 10px;
    }

    .memory-grid {
        gap: 8px;
    }

    .memory-grid.size-9 {
        gap: 4px;
    }

    .grid-tile {
        min-width: 60px;
        min-height: 60px;
        border-width: 2px;
        border-radius: 10px;
    }

    .memory-grid.size-9 .grid-tile {
        min-width: 30px;
        min-height: 30px;
    }

    .grid-tile.correct-feedback::after,
    .grid-tile.wrong-feedback::after,
    .grid-tile.missed-feedback::after {
        font-size: 36px;
    }

    .memory-grid.size-9 .grid-tile.correct-feedback::after,
    .memory-grid.size-9 .grid-tile.wrong-feedback::after,
    .memory-grid.size-9 .grid-tile.missed-feedback::after {
        font-size: 24px;
    }

    .instruction-text {
        font-size: 20px;
    }

    .countdown-text {
        font-size: 36px;
    }

    .action-panel {
        padding: 15px;
        gap: 10px;
        flex-wrap: wrap;
    }

    .action-btn {
        padding: 12px 25px;
        font-size: 16px;
        min-width: 120px;
        flex: 1;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .grid-container {
        padding: 10px;
    }

    .memory-grid {
        gap: 6px;
    }

    .memory-grid.size-9 {
        gap: 3px;
    }

    .grid-tile {
        min-width: 50px;
        min-height: 50px;
        border-radius: 8px;
    }

    .memory-grid.size-9 .grid-tile {
        min-width: 25px;
        min-height: 25px;
        border-radius: 6px;
    }

    .grid-tile.correct-feedback::after,
    .grid-tile.wrong-feedback::after,
    .grid-tile.missed-feedback::after {
        font-size: 28px;
    }

    .memory-grid.size-9 .grid-tile.correct-feedback::after,
    .memory-grid.size-9 .grid-tile.wrong-feedback::after,
    .memory-grid.size-9 .grid-tile.missed-feedback::after {
        font-size: 18px;
    }

    .instruction-text {
        font-size: 18px;
    }

    .countdown-text {
        font-size: 32px;
    }

    .action-panel {
        flex-direction: column;
    }

    .action-btn {
        width: 100%;
        min-width: 100%;
    }
}
