/* Panggung slot. Animasi hanya transform/opacity supaya ringan di Android. */

#game {
  position: fixed;
  inset: var(--pita-h) 0 0 0;
  z-index: 20;
  background: #0d0318;
}

.panggung {
  --sisi-x: 26px;
  --sisi-y: 318px;
  --cell: min(calc((100vw - var(--sisi-x)) / 6), calc((100dvh - var(--pita-h) - var(--sisi-y)) / 5));
  position: relative;
  height: 100%;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "top" "tengah" "kiri" "bar";
  background: #2a0a38 url("../assets/bg-senja.webp") center / cover no-repeat;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
}
.panggung.fs { background-image: url("../assets/bg-malam.webp"); }

.gm-top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 2px;
  z-index: 3;
}
.gm-logo {
  flex: 1;
  font: 900 13px/1 var(--font-d);
  letter-spacing: 0.04em;
  color: var(--cream);
  text-shadow: 0 2px 0 #4d2800, 0 0 12px rgba(255, 170, 40, 0.7);
}
.gm-logo span { color: var(--gold); font-size: 17px; }
.ikon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 214, 110, 0.5);
  border-radius: 50%;
  background: rgba(20, 4, 31, 0.65);
  color: var(--cream);
  cursor: pointer;
}
.ikon svg, .bulat svg, .spin svg {
  width: 62%;
  height: 62%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ikon[aria-pressed="false"] { opacity: 0.5; }

/* Tombol fitur */
.gm-kiri {
  grid-area: kiri;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 2px 8px 4px;
  z-index: 3;
}
.fitur {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  padding: 3px 10px;
  border: 2px solid var(--gold2);
  border-radius: 10px;
  background: linear-gradient(180deg, #7a1fa0, #3c0c5c);
  color: #fff;
  font-family: var(--font-u);
  text-align: left;
  cursor: pointer;
}
.fitur small { grid-column: 1 / 3; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: var(--cream); }
.fitur span { font-size: 14px; font-weight: 800; line-height: 1; }
.fitur b { justify-self: end; font-size: 14px; font-weight: 800; color: var(--gold); }
.fitur[aria-pressed="true"] { border-color: var(--hijau); background: linear-gradient(180deg, #0f8a4f, #063d27); }
.fitur:disabled { opacity: 0.45; cursor: default; }

/* Tengah */
.gm-tengah {
  grid-area: tengah;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 0;
  z-index: 2;
}
.readout {
  position: relative;
  min-width: 62%;
  padding: 2px 18px 3px;
  text-align: center;
  background: linear-gradient(90deg, transparent, rgba(20, 4, 31, 0.86) 18%, rgba(20, 4, 31, 0.86) 82%, transparent);
  font-family: var(--font-u);
}
.readout small { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.14em; color: var(--cream); }
.readout strong {
  display: block;
  min-height: 24px;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255, 150, 30, 0.8);
}

.bingkai {
  position: relative;
  padding: 7px;
  border-radius: 12px;
  background: linear-gradient(135deg, #fff0b0, #c88a18 22%, #fff0b0 44%, #8a5206 66%, #ffdc78 84%, #6a3a04);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.7), 0 0 26px rgba(255, 190, 70, 0.32);
}
.grid {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-template-columns: repeat(6, var(--cell));
  grid-template-rows: repeat(5, var(--cell));
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px) 0 0 / var(--cell) 100%,
    radial-gradient(ellipse at 50% 30%, rgba(92, 44, 140, 0.9), rgba(16, 4, 38, 0.97) 74%);
  box-shadow: inset 0 0 24px #000;
}
.cell { position: relative; }
.cell.hit::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 2px solid #fff0b0;
  border-radius: 8px;
  background: radial-gradient(circle, rgba(255, 214, 90, 0.34), transparent 72%);
  box-shadow: 0 0 10px #ffcc3d;
}

/* Sprite atlas 5×3, frame ditentukan kelas fN */
.sym {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  background: url("../assets/atlas.webp") 0 0 / 500% 300% no-repeat;
}
.grid .sym { will-change: transform; }
.f0 { background-position: 0 0; }
.f1 { background-position: 25% 0; }
.f2 { background-position: 50% 0; }
.f3 { background-position: 75% 0; }
.f4 { background-position: 100% 0; }
.f5 { background-position: 0 50%; }
.f6 { background-position: 25% 50%; }
.f7 { background-position: 50% 50%; }
.f8 { background-position: 75% 50%; }
.f9 { background-position: 100% 50%; }
.f10 { background-position: 0 100%; }
.f11 { background-position: 25% 100%; }
.f12 { background-position: 50% 100%; }
.f13 { background-position: 75% 100%; }
.f14 { background-position: 100% 100%; }

.sym b {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding-top: 8%;
  font: 800 calc(var(--cell) * 0.34) / 1 var(--font-u);
  color: #fff;
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.55);
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.8);
}

/* Dewa */
.gm-kanan {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
.dewa { position: absolute; top: 2px; right: 2px; width: 92px; animation: mengambang 4s ease-in-out infinite; }
.dewa img { display: block; width: 100%; height: auto; }
@keyframes mengambang {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.dewa::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(170, 240, 255, 0.95), transparent 68%);
  opacity: 0;
}
.dewa.strike::after { animation: kilat 0.42s ease-out; }
@keyframes kilat {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* Di potret, panel free spin mengambil baris tombol fitur yang memang tak terpakai */
.panggung.fs .gm-kiri { visibility: hidden; }
.fs-panel {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 124px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 3px 8px;
  border: 1px solid var(--gold);
  border-radius: 8px;
  background: rgba(20, 4, 31, 0.92);
  font-family: var(--font-u);
}
.fs-panel small { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; color: var(--cream); }
.fs-panel strong { margin-right: 10px; font-size: 22px; font-weight: 800; line-height: 1.1; color: var(--gold); }

.winlog {
  position: absolute;
  left: 10px;
  bottom: 172px;
  margin: 0;
  padding: 0;
  list-style: none;
  font: 700 13px/1.25 var(--font-u);
  text-shadow: 0 1px 3px #000;
}
.winlog li { display: flex; align-items: center; gap: 4px; }
.winlog li:nth-child(n + 2) { display: none; }
.winlog i { width: 20px; height: 20px; flex: none; }

/* Bar bawah */
.gm-bar {
  grid-area: bar;
  z-index: 3;
  padding: 4px 8px calc(6px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(20, 4, 31, 0.5), var(--ink) 38%);
}
.bar-data {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr 1.2fr;
  gap: 6px;
  font-family: var(--font-u);
  text-align: center;
}
.bar-item small { display: block; font-size: 10px; font-weight: 700; letter-spacing: 0.1em; color: #d9b8e8; }
.bar-item strong { display: block; font-size: 17px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
#gm-win { color: var(--gold); }

.bar-kontrol {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 2px;
}
.bulat {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid var(--gold2);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #57217a, #210835);
  color: #fff;
  font: 800 13px/1 var(--font-u);
  cursor: pointer;
}
.bulat.kecil { font-size: 12px; }
.bulat[aria-pressed="true"] { border-color: #ffe16a; background: radial-gradient(circle at 40% 30%, #ffb52e, #a9570a); }
.bulat:disabled { opacity: 0.45; cursor: default; }
.spin {
  position: relative;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 3px solid #fff0b0;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #ffe16a, #ff9a0a 52%, #b84d06);
  color: #fff;
  box-shadow: 0 0 0 3px #6a3a04, 0 0 20px rgba(255, 180, 50, 0.75), inset 0 -6px 10px rgba(120, 40, 0, 0.6);
  cursor: pointer;
}
.spin svg { stroke-width: 4; filter: drop-shadow(0 2px 1px rgba(90, 30, 0, 0.8)); }
.spin:active { transform: scale(0.94); }
.spin.main svg { opacity: 0.55; }
#spin-auto {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 800 22px/1 var(--font-u);
  text-shadow: 0 2px 2px rgba(90, 30, 0, 0.9);
}
#spin-auto[hidden] { display: none; }

#fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 8; /* di atas overlay menang, supaya hujan koin terlihat */
  visibility: hidden;
  pointer-events: none;
}

/* Overlay */
.ov {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
  background: radial-gradient(circle, rgba(60, 8, 90, 0.9), rgba(10, 2, 18, 0.95) 72%);
  cursor: pointer;
}
.ov:focus-visible { outline-offset: -6px; }
.ov small { font: 800 16px/1 var(--font-u); letter-spacing: 0.24em; color: var(--cream); }
.ov h2 {
  margin: 0;
  font: 900 clamp(34px, 10vw, 76px) / 1.05 var(--font-d);
  color: var(--gold);
  text-shadow: 0 3px 0 #6a3a04, 0 0 30px rgba(255, 170, 40, 0.8);
}
.ov p { margin: 0; font: 600 18px/1.3 var(--font-u); }
.ov em { font: 600 14px/1 var(--font-u); font-style: normal; color: #d9b8e8; }
.ov-win strong {
  font: 800 clamp(40px, 12vw, 88px) / 1 var(--font-u);
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 22px #ffb52e;
}

.splash { z-index: 9; cursor: default; background: rgba(10, 2, 18, 0.78); }
.splash-logo {
  font: 900 clamp(26px, 7vw, 44px) / 1 var(--font-d);
  color: var(--cream);
  text-shadow: 0 3px 0 #4d2800, 0 0 24px rgba(255, 170, 40, 0.8);
}
.splash-logo span { display: block; font-size: 1.7em; color: var(--gold); }
.splash-fitur {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 170px));
  gap: 10px;
  margin: 8px 0;
  padding: 0;
  list-style: none;
  font: 600 14px/1.2 var(--font-u);
}
.splash-fitur li { display: grid; justify-items: center; gap: 4px; }
.splash-fitur .sym { width: 64px; height: 64px; }

/* Lanskap: tiga kolom, tata letak desktop */
@media (min-width: 720px) and (orientation: landscape) {
  .panggung {
    --sisi-x: 500px;
    --sisi-y: 186px;
    grid-template-columns: 210px minmax(0, 1fr) 250px;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "top top top" "kiri tengah kanan" "bar bar bar";
  }
  .gm-logo { font-size: 18px; }
  .gm-logo span { font-size: 24px; }
  .gm-kiri {
    grid-template-columns: 1fr;
    align-content: center;
    gap: 12px;
    padding: 0 0 0 18px;
  }
  .fitur { padding: 10px 12px; grid-template-columns: 1fr; row-gap: 3px; text-align: center; }
  .fitur small { grid-column: 1; font-size: 12px; }
  .fitur span { font-size: 19px; }
  .fitur b { justify-self: center; font-size: 19px; }
  .gm-kanan {
    position: relative;
    inset: auto;
    grid-area: kanan;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-right: 10px;
  }
  .dewa { position: relative; top: auto; right: auto; width: min(230px, 42vh); }
  .panggung.fs .gm-kiri { visibility: visible; }
  .fs-panel { position: static; display: grid; justify-items: center; gap: 0; margin-top: 6px; min-width: 130px; }
  .fs-panel strong { margin-right: 0; font-size: 26px; }
  .winlog { position: static; margin-top: 6px; font-size: 16px; }
  .winlog li:nth-child(n + 2) { display: flex; }
  .winlog i { width: 26px; height: 26px; }
  .readout small { font-size: 14px; }
  .readout strong { font-size: 30px; min-height: 33px; }
  .gm-bar {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 24px;
    padding: 6px 22px 8px;
  }
  .bar-item small { font-size: 13px; }
  .bar-item strong { font-size: 25px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .panggung { --sisi-x: 400px; --sisi-y: 132px; grid-template-columns: 150px minmax(0, 1fr) 150px; }
  .readout { position: absolute; top: 2px; left: 50%; z-index: 4; min-width: 0; width: 40%; transform: translateX(-50%); }
  .readout small { font-size: 11px; }
  .readout strong { font-size: 20px; min-height: 22px; }
  .bar-item strong { font-size: 18px; }
  .spin { width: 56px; height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .dewa { animation: none; }
}
