@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap');

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

html, body {
    width: 100%;
    /* Mengizinkan tinggi halaman mengikuti konten */
    min-height: 100%;
    /* Aktifkan scroll vertikal dan hilangkan scroll horizontal */
    overflow-x: hidden;
    overflow-y: auto;
    background: #0d1117;
    font-family: 'Space Mono', monospace;
    color: white;
    user-select: none;
    /* Agar scroll terasa halus di HP */
    scroll-behavior: smooth;
}

.screen {
    width: 100%;
    max-width: 500px; /* Membatasi lebar di tablet/PC agar tetap rapi */
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 15px 50px 15px; /* Padding bawah lebih besar agar tidak mentok */
    gap: 20px;
}

/* Top Bar - Tetap di atas */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    flex-shrink: 0;
}

.back-btn, .restart-btn {
    border: 1px solid #333;
    background: transparent;
    color: #aaa;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.75em;
    text-decoration: none;
    font-family: inherit;
    transition: 0.3s;
}

.back-btn:hover, .restart-btn:hover {
    border-color: #e91e63;
    color: white;
}

.title {
    font-size: 1em;
    letter-spacing: 2px;
    color: #e91e63;
    text-shadow: 0 0 10px rgba(233, 30, 99, 0.3);
    font-weight: bold;
}

/* Stats */
.stats {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    width: 100%;
    justify-content: center;
}

.stat {
    text-align: center;
    background: #111827;
    border: 1px solid #1e2433;
    border-radius: 12px;
    padding: 8px;
    flex: 1;
    max-width: 100px;
}

.stat-label { font-size: 0.6em; color: #555; text-transform: uppercase; margin-bottom: 2px; }
.stat-value { font-size: 0.9em; color: #fff; font-weight: 700; }

/* Grid System - Responsif dan Bisa di-Scroll */
.grid-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.grid {
    display: grid;
    gap: 8px;
    width: 100%;
    /* Menyesuaikan grid agar pas di layar */
    margin: 0 auto;
}

/* Card Logic */
.card {
    position: relative;
    width: 100%;
    cursor: pointer;
    perspective: 1000px;
    -webkit-tap-highlight-color: transparent;
}

/* Ratio kartu 3:4 */
.card::before {
    content: "";
    display: block;
    padding-top: 130%;
}

.card-inner {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
}

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

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

.card-back {
    background: #111827;
    border: 2px solid #1e2433;
    font-size: 1.5em;
    color: #1e2433;
}

.card-front {
    background: #1a2233;
    border: 2px solid #2a3a50;
    transform: rotateY(180deg);
    font-size: 1.8em;
}

.card.matched .card-front {
    background: #0d2a1a;
    border-color: #4caf50;
}

/* Overlay & Menu - Tetap Fixed */
.overlay {
    position: fixed;
    top: 0; left: 0; 
    width: 100%; height: 100%;
    background: rgba(10, 14, 20, 0.98);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#overlay-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 25px;
    align-items: center;
    padding: 20px;
}

.overlay-title { font-size: 2em; color: #e91e63; letter-spacing: 4px; font-weight: bold; }
.overlay-sub { font-size: 0.9em; color: #aaa; line-height: 1.5; }

.start-btn {
    background: #e91e63;
    color: #fff;
    border: none;
    padding: 16px 50px;
    font-family: inherit;
    font-size: 1.1em;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.2s;
}

.start-btn:active { transform: scale(0.95); }

.diff-row { display: flex; gap: 12px; }
.diff-btn {
    background: #111827;
    border: 1px solid #333;
    color: #aaa;
    padding: 12px 20px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.85em;
    cursor: pointer;
}

.diff-btn.active { 
    border-color: #e91e63; 
    color: #e91e63; 
    background: rgba(233, 30, 99, 0.1); 
}

/* Animasi Salah */
@keyframes shake {
    0%, 100% { transform: rotateY(180deg) translateX(0); }
    25% { transform: rotateY(180deg) translateX(-6px); }
    75% { transform: rotateY(180deg) translateX(6px); }
}
.card.shake .card-inner { animation: shake 0.3s ease-in-out; }
