/* Mini game (/mini-game): papan Memory Hutan dan arena Tangkap Kunang-kunang. Hanya dimuat di halaman mini game. */

/* ---------- bagian bersama ---------- */
.mg-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.mg-level { display: flex; flex-wrap: wrap; gap: 8px; }
.mg-level button {
    min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
    font-family: var(--f-ui); font-weight: 700; font-size: 15px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.mg-level button:hover, .mg-level a:hover { border-color: var(--gold-deep); }
/* tautan (halaman papan skor) tampil sama dengan tombol tingkat */
.mg-level a {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 6px 18px; border-radius: 999px; border: 1px solid var(--line); text-align: center; line-height: 1.15;
    background: var(--bg-2); color: var(--text); font-family: var(--f-ui); font-weight: 700; font-size: 15px; text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.mg-level a[aria-current="true"] { border-color: var(--gold-deep); background: color-mix(in srgb, var(--gold) 16%, var(--bg-2)); color: var(--gold); box-shadow: 0 0 0 1px var(--gold-deep) inset; }
.mg-level a:focus-visible { outline: 3px solid var(--moss); outline-offset: 3px; }
.mg-pil-baris { margin-bottom: 10px; }
@media (max-width: 480px) {
    /* HP: tiga tingkat sebaris selebar kolom, tombol "Acak ulang" di bawahnya selebar kolom juga */
    .mg-bar { flex-direction: column; align-items: stretch; }
    .mg-level { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
    .mg-level button { padding: 0 4px; font-size: 14px; }
    .mg-level a { padding: 6px 6px; font-size: 14px; }
    .mg-level.mg-pil-baris:has(> a:nth-child(2):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }   /* pilihan periode: dua tombol */
    .mg-bar > .btn-ghost { width: 100%; }
}
.mg-level button[aria-pressed="true"] {
    border-color: var(--gold-deep); background: color-mix(in srgb, var(--gold) 16%, var(--bg-2)); color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold-deep) inset;
}
.mg-level button:focus-visible, .mg-kartu:focus-visible, .mg-k:focus-visible { outline: 3px solid var(--moss); outline-offset: 3px; }

.mg-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.mg-stat { min-width: 0; padding: 8px 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-2); text-align: center; }
.mg-stat .l { font-family: var(--f-ui); font-weight: 600; font-size: 12px; line-height: 1.2; color: var(--text-dim); overflow-wrap: break-word; }
.mg-stat .v { margin-top: 2px; font-family: var(--f-display); font-weight: 700; font-size: 20px; line-height: 1.2; color: var(--gold); overflow-wrap: break-word; }
.mg-stat .v--kecil { font-family: var(--f-ui); font-size: 13px; line-height: 1.3; }

.mg-aksi { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.mg-ringkas { margin-top: 14px; }

/* ---------- Memory Hutan ---------- */
.mg-papan { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; max-width: 440px; margin: 16px auto 0; }
@media (min-width: 400px) { .mg-papan { gap: 10px; } }
.mg-kartu {
    position: relative; display: block; width: 100%; aspect-ratio: 1 / 1; padding: 0; border: 0; border-radius: 10px; background: none; cursor: pointer;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.mg-belakang, .mg-muka { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; border-radius: 10px; }
.mg-belakang {
    background: radial-gradient(circle at 50% 40%, #2c5a3a 0%, #17301f 70%); border: 2px solid var(--gold-deep);
    animation: mg-balik .25s ease-out;
}
.mg-belakang svg { width: 52%; height: 52%; fill: none; stroke: #8fc58a; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }
.mg-muka { display: none; background: #f4eed2; border: 2px solid #c9a74f; }
.mg-muka svg { width: 66%; height: 66%; }
.mg-kartu.buka .mg-belakang, .mg-kartu.cocok .mg-belakang { display: none; }
.mg-kartu.buka .mg-muka, .mg-kartu.cocok .mg-muka { display: flex; animation: mg-balik .25s ease-out; }
.mg-kartu.cocok .mg-muka { background: #e3f1d2; border-color: #6fae7a; box-shadow: 0 0 12px rgba(143, 197, 138, .65); }
.mg-kartu.cocok { cursor: default; }
@media (hover: hover) {
    .mg-kartu:not(.buka):not(.cocok):hover .mg-belakang { border-color: var(--gold); filter: brightness(1.18); }
}
@keyframes mg-balik { from { transform: scaleX(.05); } to { transform: scaleX(1); } }

.mg-menang { margin-top: 16px; padding: 14px 16px; border: 1px solid var(--gold-deep); border-radius: 10px; background: color-mix(in srgb, var(--gold) 10%, var(--bg-2)); }
.mg-menang:focus { outline: none; }
.mg-menang .judul { font-family: var(--f-display); font-weight: 700; font-size: 22px; color: var(--gold); }

/* ---------- Tangkap Kunang-kunang ---------- */
.mg-arena {
    position: relative; width: 100%; aspect-ratio: 1 / 1; margin-top: 14px; overflow: hidden; border-radius: 12px; border: 2px solid var(--gold-deep);
    background:
        radial-gradient(circle at 18% 28%, rgba(215, 255, 90, .16) 0 2px, transparent 3px),
        radial-gradient(circle at 76% 18%, rgba(215, 255, 90, .12) 0 2px, transparent 3px),
        radial-gradient(circle at 60% 72%, rgba(215, 255, 90, .14) 0 2px, transparent 3px),
        radial-gradient(circle at 30% 84%, rgba(215, 255, 90, .1) 0 2px, transparent 3px),
        radial-gradient(ellipse at 50% 105%, #20472b 0%, #0e1f14 60%, #070d09 100%);
    touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
@media (min-width: 640px) { .mg-arena { aspect-ratio: 16 / 10; } }
.mg-arena.getar { animation: mg-getar .28s linear; }
.mg-k {
    position: absolute; width: 60px; height: 60px; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation; animation: mg-muncul .14s ease-out;
}
.mg-k svg { display: block; width: 100%; height: 100%; pointer-events: none; }
.mg-k--biasa svg { filter: drop-shadow(0 0 8px rgba(215, 255, 90, .95)); animation: mg-denyut 1s ease-in-out infinite; }
.mg-k--emas { width: 54px; height: 54px; }
.mg-k--emas svg { filter: drop-shadow(0 0 10px rgba(255, 213, 74, 1)); animation: mg-denyut .7s ease-in-out infinite; }
.mg-k--ngengat svg { filter: drop-shadow(0 0 3px rgba(0, 0, 0, .7)); }
.mg-k.pudar { opacity: .4; transition: opacity .25s ease; }
.mg-pop { position: absolute; z-index: 3; transform: translate(-50%, -50%); font-family: var(--f-ui); font-weight: 800; font-size: 22px; pointer-events: none; text-shadow: 0 1px 5px #000; animation: mg-naik .7s ease-out forwards; }
.mg-pop--plus { color: #e4ff6a; }
.mg-pop--minus { color: #ff8f7e; }
.mg-mulai { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; background: rgba(5, 10, 7, .6); }
.mg-mulai[hidden] { display: none; }
.mg-legenda { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; font-family: var(--f-ui); font-size: 13px; color: var(--text-dim); }
.mg-legenda span { display: inline-flex; align-items: center; gap: 6px; }
.mg-legenda svg { width: 26px; height: 26px; flex: none; }

@keyframes mg-muncul { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes mg-denyut { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes mg-naik { from { transform: translate(-50%, -50%); opacity: 1; } to { transform: translate(-50%, -190%); opacity: 0; } }
@keyframes mg-getar { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---------- susunan halaman game: game di kiri, papan skor langsung di kanan (di HP: papan di bawah game) ---------- */
.mg-duo { display: grid; gap: 24px; max-width: 42rem; margin: 0 auto; }
.mg-kepala, .mg-game, .mg-side { min-width: 0; }
@media (min-width: 1024px) {
    .mg-duo { max-width: 64rem; grid-template-columns: minmax(0, 42rem) minmax(0, 20rem); grid-template-areas: "kepala kepala" "game side"; justify-content: center; column-gap: 28px; align-items: start; }
    .mg-duo--tunggal { max-width: 42rem; grid-template-columns: minmax(0, 1fr); grid-template-areas: "kepala" "game"; }
    .mg-kepala { grid-area: kepala; max-width: 42rem; }
    .mg-game { grid-area: game; }
    .mg-side { grid-area: side; }
}
.mg-side-kepala { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.mg-side-judul { font-family: var(--f-display); font-weight: 700; font-size: 19px; color: var(--gold); white-space: nowrap; }
.mg-live { display: inline-flex; align-items: center; gap: 6px; font-family: var(--f-ui); font-weight: 700; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--text-dim); }
.mg-live i { width: 8px; height: 8px; border-radius: 50%; background: #7bdc6a; box-shadow: 0 0 8px #7bdc6a; animation: mg-denyut 1.6s ease-in-out infinite; }
.mg-side .mg-skor { margin-top: 4px; }
.mg-side .mg-skor-baris { padding: 6px 8px; gap: 8px; grid-template-columns: 30px minmax(0, 1fr) auto; }
.mg-side .mg-no { width: 26px; height: 26px; font-size: 13px; }
.mg-side .mg-nama { font-size: 15px; }
.mg-side .mg-hasil { font-size: 14px; }
.mg-side .mg-level { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.mg-side .mg-level button { padding: 6px; font-size: 14px; line-height: 1.15; }

/* ---------- papan skor ---------- */
.mg-skor { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.mg-skor-baris { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); }
.mg-no { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); font-family: var(--f-ui); font-weight: 800; font-size: 14px; color: var(--text-dim); }
.mg-skor-baris:nth-child(1) .mg-no { background: #f2c14e; border-color: #b88f2e; color: #2a1d00; }
.mg-skor-baris:nth-child(2) .mg-no { background: #cfd6dc; border-color: #8a949e; color: #1f262c; }
.mg-skor-baris:nth-child(3) .mg-no { background: #d9965b; border-color: #9a5f2c; color: #2e1806; }
.mg-nama { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--f-ui); font-weight: 700; font-size: 16px; color: var(--text); }
.mg-hasil { text-align: right; font-family: var(--f-ui); font-weight: 800; font-size: 15px; line-height: 1.25; color: var(--gold); white-space: nowrap; }
.mg-hasil small { display: block; font-weight: 600; font-size: 12px; color: var(--text-dim); }
.mg-skor-baris--sorot { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; background: color-mix(in srgb, var(--gold) 12%, var(--bg-2)); }

/* halaman papan skor penuh: tombol pilihan rata selebar panel, dan tampilan kosong yang hidup di tengah */
.mg-pil-rata { display: grid; gap: 8px; }
.mg-pil-rata--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mg-pil-rata--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mg-kosong { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 26px 8px 4px; text-align: center; }
.mg-kosong-ikon { width: 76px; height: 76px; filter: drop-shadow(0 0 16px rgba(215, 255, 90, .6)); animation: mg-denyut 2.4s ease-in-out infinite; }
.mg-kosong-ikon svg { display: block; width: 100%; height: 100%; }
.mg-kosong-ikon--kartu { width: 104px; height: 78px; filter: drop-shadow(0 0 14px rgba(230, 220, 154, .4)); }
.mg-kosong-teks { max-width: 22rem; font-family: var(--f-display); font-weight: 700; font-size: 20px; line-height: 1.3; color: var(--gold); }
.mg-aksi--tengah { justify-content: center; margin-top: 20px; }

/* formulir nama di bawah hasil permainan */
.mg-kirim { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.mg-kirim-judul { margin-bottom: 10px; font-family: var(--f-display); font-weight: 700; font-size: 18px; color: var(--gold); }

/* kartu pilihan di halaman daftar mini game */
.mg-ikon-kartu { width: 44px; height: 44px; margin-bottom: 10px; }
.mg-ikon-kartu svg { width: 100%; height: 100%; display: block; }
.mg-rekor { margin-top: 10px; }
.mg-rekor:empty { display: none; }

/* pemain yang mematikan gerak di sistemnya: tanpa animasi, permainan tetap bisa dimainkan */
@media (prefers-reduced-motion: reduce) {
    .mg-belakang, .mg-kartu.buka .mg-muka, .mg-kartu.cocok .mg-muka, .mg-k, .mg-k--biasa svg, .mg-k--emas svg, .mg-arena.getar, .mg-kosong-ikon, .mg-live i { animation: none; }
    .mg-pop { animation-duration: .01s; animation-delay: .6s; }
}
