/* ==================== Reset & Base ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #fd79a8 0%, #e84393 100%);
    min-height: 100vh;
    padding: 0;
    margin: 0;
}

/* ==================== Page Layout with Sidebars ==================== */
.page-wrapper {
    display: grid;
    grid-template-columns: 160px 1fr 160px;
    gap: 20px;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.sidebar {
    min-height: 100vh;
}

.sidebar-left,
.sidebar-right {
    display: flex;
    align-items: flex-start;
    padding-top: 80px;
}

.sticky-ad {
    position: sticky;
    top: 20px;
    width: 160px;
    min-height: 600px;
}

.main-content {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
}

/* Responsive: Hide sidebars on tablets and mobile */
@media (max-width: 1024px) {
    .page-wrapper {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .sidebar {
        display: none;
    }
}

.container {
    max-width: 550px;
    width: 100%;
}

/* ==================== Header ==================== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.back-button {
    text-decoration: none;
    color: white;
    font-size: 1.1em;
    font-weight: 600;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.title {
    font-size: 2.5em;
    color: white;
    text-align: center;
    flex: 1;
    font-weight: 800;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

/* ==================== Game Info ==================== */
.game-info {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.info-box {
    background: rgba(255, 255, 255, 0.9);
    padding: 15px 30px;
    border-radius: 10px;
    text-align: center;
    min-width: 100px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.info-box.highlight {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
}

.label {
    font-size: 0.9em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
    opacity: 0.8;
}

.value {
    font-size: 2em;
    font-weight: 800;
}

/* ==================== Instructions ==================== */
.instructions {
    background: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.instructions p {
    font-size: 1.1em;
    font-weight: 600;
    color: #2d3436;
}

/* ==================== Game Board ==================== */
.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

.card {
    aspect-ratio: 1;
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.card:hover:not(.flipped):not(.matched) {
    transform: scale(1.05);
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.5s;
    transform-style: preserve-3d;
}

.card.flipped .card-inner,
.card.matched .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 3em;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.card-front {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    color: #e84393;
    font-weight: 800;
    font-size: 2.5em;
}

.card-back {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    transform: rotateY(180deg);
}

.card.matched .card-back {
    background: linear-gradient(135deg, #55efc4 0%, #00b894 100%);
    animation: matchPulse 0.5s ease;
}

@keyframes matchPulse {
    0%, 100% {
        transform: rotateY(180deg) scale(1);
    }
    50% {
        transform: rotateY(180deg) scale(1.1);
    }
}

/* ==================== Controls ==================== */
.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.control-btn {
    padding: 15px 30px;
    font-size: 1.1em;
    font-weight: 700;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.start-btn {
    background: linear-gradient(135deg, #55efc4 0%, #00b894 100%);
    color: white;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

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

/* ==================== Game Over Overlay ==================== */
.game-over-overlay {
    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: 1000;
    animation: fadeIn 0.3s ease;
}

.game-over-overlay.show {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.game-over-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.game-over-title {
    font-size: 2.5em;
    color: #e84393;
    margin-bottom: 20px;
    font-weight: 800;
}

.final-score,
.final-time {
    font-size: 1.3em;
    color: #2d3436;
    margin: 10px 0;
    font-weight: 600;
}

.final-score span,
.final-time span {
    color: #e84393;
    font-weight: 800;
}

.play-again-btn {
    margin-top: 25px;
    padding: 15px 40px;
    font-size: 1.2em;
    font-weight: 700;
    background: linear-gradient(135deg, #fd79a8 0%, #e84393 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(232, 67, 147, 0.4);
}

.play-again-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(232, 67, 147, 0.6);
}

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

/* ==================== Responsive Design ==================== */
@media (max-width: 600px) {
    .title {
        font-size: 2em;
    }

    .game-board {
        gap: 10px;
        padding: 15px;
    }

    .card-front,
    .card-back {
        font-size: 2.5em;
    }

    .card-front {
        font-size: 2em;
    }

    .info-box {
        padding: 10px 20px;
        min-width: 80px;
    }

    .value {
        font-size: 1.5em;
    }

    .label {
        font-size: 0.8em;
    }

    .control-btn {
        padding: 12px 25px;
        font-size: 1em;
    }

    .game-over-content {
        padding: 30px;
    }

    .game-over-title {
        font-size: 2em;
    }
}

@media (max-width: 400px) {
    .game-board {
        gap: 8px;
        padding: 10px;
    }

    .card-back {
        font-size: 2em;
    }

    .card-front {
        font-size: 1.5em;
    }

    .info-box {
        padding: 8px 15px;
        min-width: 70px;
    }

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