/* 1rem = 1/100 lebar panggung 16:9, jadi semua ukuran ikut skala layar */
html { font-size: min(1vw, 1.7778vh); }

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #24133f url("img/bg.svg") center / cover no-repeat;
  font-family: "Montserrat", sans-serif;
  color: #4a3528;
  user-select: none;
}

.stage {
  position: relative;
  width: 100rem;
  height: 56.25rem;
  overflow: hidden;
  background: url("img/bg.svg") center / cover no-repeat;
  box-shadow: 0 0 4rem rgba(0, 0, 0, .5);
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3rem;
  padding: 3rem;
}

.screen.column { flex-direction: column; gap: 1.6rem; }
.hidden { display: none !important; }

h1 { margin: .2rem 0 .8rem; color: #c45036; font-size: 3.6rem; font-weight: 800; }
h2 { margin: 1.2rem 0 .8rem; font-size: 1.8rem; }
p { font-size: 1.4rem; line-height: 1.5; margin: 0 0 1rem; }

.eyebrow {
  margin: 0;
  color: #bd5a35;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: .2rem;
  text-transform: uppercase;
}

button {
  font: inherit;
  font-size: 1.4rem;
  font-weight: 600;
  padding: 1rem 2rem;
  border: 0;
  border-radius: 1rem;
  background: #e8794f;
  color: #fff;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}

button:hover:not(:disabled) { transform: translateY(-.2rem); box-shadow: 0 .6rem 1.2rem rgba(190, 75, 64, .35); }
button:focus-visible { outline: .3rem solid #2f6b3a; outline-offset: .2rem; }
.ghost { background: #fff; color: #c45036; box-shadow: inset 0 0 0 .2rem #e8794f; }

.menu-links { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* Tombol suara */
.sound-buttons { position: absolute; top: 1.2rem; right: 1.2rem; z-index: 40; display: flex; gap: .8rem; }
.round { width: 4.4rem; height: 4.4rem; padding: 0; border-radius: 50%; font-size: 1.9rem; background: rgba(255, 255, 255, .9); box-shadow: 0 .3rem .8rem rgba(0, 0, 0, .2); }
.round.off { opacity: .45; filter: grayscale(1); }

/* Menu */
#menu, #credits, #badges { background: rgba(36, 19, 63, .25); }
#badges h1 { color: #fff; text-shadow: 0 .3rem 0 #c45036, 0 .6rem 1.4rem rgba(0, 0, 0, .4); }

.story-card, .menu-right {
  padding: 2.6rem 3rem;
  border-radius: 2.2rem;
  background: rgba(255, 250, 235, .94);
  box-shadow: 0 1.2rem 3rem rgba(20, 8, 40, .4);
}

.story-card { width: 40rem; border: .3rem dashed #e8794f; }
.menu-right h2:first-child { margin-top: 0; }

.hero { width: 11rem; height: 11rem; margin: -1rem 0 .4rem; animation: bob 2.4s ease-in-out infinite; }
.hero svg, .face svg { width: 100%; height: 100%; }
.progress { font-weight: 800; color: #2f6b3a; }

.menu-right { width: 46rem; text-align: center; }

#caseList { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }

.case-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  min-height: 4.6rem;
  padding: .8rem 1.2rem;
  background: #f3ad45;
  color: #3d2a1e;
  text-align: left;
  font-size: 1.3rem;
}

.case-button .stars { color: #b0400f; letter-spacing: .1rem; white-space: nowrap; }
.case-button.selected { outline: .35rem solid #2f6b3a; }
.case-button:disabled { background: #cfc4bb; color: #6e625a; cursor: not-allowed; }

.mode-row { display: flex; gap: 1.2rem; justify-content: center; }
.mode-row button { min-width: 18rem; font-size: 1.7rem; }

/* Papan */
.grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: .5rem;
  width: 48rem;
  height: 48rem;
  padding: .6rem;
  border: .8rem solid rgba(255, 249, 229, .92);
  border-radius: 2.4rem;
  background: linear-gradient(rgba(74, 40, 112, .82), rgba(36, 19, 63, .9));
  box-shadow: 0 1.8rem 3.4rem rgba(85, 46, 74, .35);
  touch-action: none;
}

.cell {
  border: .2rem solid rgba(255, 255, 255, .14);
  border-radius: 1.4rem;
  background-size: 96%;
  background-repeat: no-repeat;
  background-position: center;
  cursor: pointer;
  filter: drop-shadow(0 .4rem .3rem rgba(0, 0, 0, .34));
  transition: transform .17s cubic-bezier(.4, 0, .2, 1), border-color .17s;
  will-change: transform;
}

.cell:hover { border-color: rgba(255, 247, 185, .8); }
.cell.selected { border-color: #fff36b; background-color: rgba(255, 243, 107, .25); transform: scale(1.08); }
.cell.hint { animation: hint 1s ease-in-out infinite; }
.cell.kaca { animation: glow 1.2s ease-in-out infinite; }

/* Rintangan */
.cell { position: relative; }
.cell.sticky1 {
  background-color: rgba(226, 160, 70, .75);
  border-color: #ffcf7a;
  box-shadow: inset 0 -.6rem 0 rgba(150, 85, 25, .45);
}
.cell.sticky2 {
  background-color: rgba(150, 82, 22, .9);
  border-color: #ffcf7a;
  border-style: dashed;
  box-shadow: inset 0 -.6rem 0 rgba(80, 40, 10, .6), inset 0 0 0 .35rem rgba(255, 207, 122, .5);
}
.cell.locked::after {
  content: "";
  position: absolute;
  inset: -4%;
  background: url("img/borgol.svg") center / 100% no-repeat;
  pointer-events: none;
}
.cell.sticky1, .cell.sticky2, .cell.locked { cursor: not-allowed; }
.cell.crate { background-size: 100%; cursor: not-allowed; border-color: transparent; }
.cell.crate:hover { border-color: transparent; }

.splat {
  width: 4.6rem;
  height: 4.6rem;
  border-radius: 45% 55% 50% 40%;
  background: radial-gradient(circle, #ffcf7a, #c27a2c 70%);
  animation: burst .5s ease-out forwards;
}

.grid.shake { animation: shake .35s; }
.grid.shake-big { animation: shake-big .65s cubic-bezier(.36, .07, .19, .97); }

.banner.top { top: 0; z-index: 6; }

/* Gelombang kejut baris/kolom */
.beam {
  z-index: 3;
  border-radius: 99rem;
  mix-blend-mode: screen;
  filter: blur(.15rem) drop-shadow(0 0 1.2rem #fff36b);
}
.beam.h {
  background: linear-gradient(90deg, transparent, #ffe066 12%, #fff 45%, #fff 55%, #ffe066 88%, transparent);
  animation: beam-h .5s cubic-bezier(.2, .8, .3, 1) forwards;
}
.beam.v {
  background: linear-gradient(180deg, transparent, #ffe066 12%, #fff 45%, #fff 55%, #ffe066 88%, transparent);
  animation: beam-v .5s cubic-bezier(.2, .8, .3, 1) forwards;
}

/* Cincin ledakan petunjuk: 1x1 → 3x3 → 5x5 ... */
.ring {
  z-index: 3;
  border: .6rem solid var(--c);
  border-radius: 1.4rem;
  box-shadow: 0 0 1.6rem var(--c), inset 0 0 1.6rem var(--c);
  animation: ring .45s cubic-bezier(.2, .8, .3, 1) forwards;
}

.spark {
  z-index: 4;
  width: .9rem;
  height: .9rem;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 .8rem var(--c);
  animation: spark .55s cubic-bezier(.2, .8, .3, 1) forwards;
}

.fx.flash {
  inset: 0;
  z-index: 5;
  border-radius: 1.6rem;
  background: radial-gradient(circle, #fff, rgba(255, 243, 107, .6) 60%, transparent);
  transform: none;
  animation: flash .6s ease-out forwards;
}

/* Efek */
.fx { position: absolute; pointer-events: none; transform: translate(-50%, -50%); }
.burst { width: 5rem; height: 5rem; border-radius: 50%; border: .6rem solid var(--c); animation: burst .45s ease-out forwards; }
.float { color: #fff; font-size: 2rem; font-weight: 800; text-shadow: 0 .2rem .4rem rgba(0, 0, 0, .6); animation: rise .9s ease-out forwards; }
.banner {
  left: 50%; top: 45%;
  padding: 1rem 2.6rem;
  border-radius: 99rem;
  background: #fff36b;
  color: #c45036;
  font-size: 3rem;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 .6rem 1.6rem rgba(0, 0, 0, .35);
  animation: pop .9s ease-out forwards;
}

/* Papan skor */
.scoreBoard {
  display: flex;
  flex-direction: column;
  gap: .9rem;
  width: 30rem;
  height: 48rem;
  padding: 1.8rem;
  border-radius: 2.4rem;
  background: linear-gradient(160deg, #fffae5, #ffefd1);
  box-shadow: 0 1.8rem 3.4rem rgba(85, 46, 74, .3);
}

.score-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  padding: 1rem 1.4rem;
  border-radius: 1.6rem;
  background: linear-gradient(135deg, #fffdf0, #ffe0ad);
}

.score-display span, .panel-label {
  color: #a0583e;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: .15rem;
  text-transform: uppercase;
}

.score-display strong { color: #bd4d3e; font-size: 3.8rem; line-height: 1; }
.score-display small { font-size: 1.3rem; font-weight: 600; }
.bar { width: 100%; height: 1rem; border-radius: 1rem; background: rgba(160, 88, 62, .2); overflow: hidden; }
#bar { height: 100%; width: 0; background: linear-gradient(90deg, #ff9a3c, #e8794f); transition: width .3s; }

.status-chip { align-self: center; padding: .6rem 1.6rem; border-radius: 99rem; background: #2f6b3a; color: #fff; font-size: 1.5rem; font-weight: 600; }
.status-chip.urgent { background: #c62828; animation: hint .6s infinite; }

.panel { padding: 1rem 1.2rem; border-radius: 1.4rem; background: rgba(255, 255, 255, .7); font-size: 1.3rem; line-height: 1.4; }
.panel-label { display: block; margin-bottom: .2rem; }
.stats { display: flex; justify-content: space-between; margin-top: .6rem; }
.stats b { font-size: 1.5rem; }
#caseName { color: #c45036; font-weight: 800; font-size: 1.4rem; line-height: 1.3; }
/* Reaksi langsung Detektif Gulali */
.reaction { flex: 1; display: flex; align-items: flex-end; gap: .6rem; min-height: 0; overflow: hidden; padding-top: 1.6rem; }
.det-avatar { flex: none; width: 9rem; height: 9rem; }
.det-avatar svg { width: 100%; height: 100%; }
.face-slot { width: 100%; height: 100%; }
.face-slot svg { width: 100%; height: 100%; }

.bubble {
  position: relative;
  flex: 1;
  align-self: center;
  padding: 1rem 1.2rem;
  border: .25rem solid #e8794f;
  border-radius: 1.4rem;
  background: #fff;
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.35;
  color: #4a3528;
}

.bubble::after {
  content: "";
  position: absolute;
  right: -1.2rem;
  bottom: 1.6rem;
  border: .9rem solid transparent;
  border-left-color: #e8794f;
}

.bubble.pop { animation: bubble .42s cubic-bezier(.34, 1.56, .64, 1); transform-origin: 100% 80%; }
.bubble.hot { border-color: #d81b60; background: #fff0f6; }
.bubble.hot::after { border-left-color: #d81b60; }

.swap-hint { display: flex; align-items: center; justify-content: center; gap: .6rem; margin-top: .5rem; }
.mini {
  width: 3.6rem;
  height: 3.6rem;
  border-radius: .9rem;
  background: #4a2870 center / 90% no-repeat;
  box-shadow: inset 0 0 0 .2rem #fff36b;
}
.swap-hint b { font-size: 2rem; color: #d81b60; }
.game-buttons button { width: 100%; background: linear-gradient(135deg, #ed7650, #d9514c); }

/* Lencana */
#badgeList { display: grid; grid-template-columns: repeat(5, 16rem); gap: 1.2rem; }
.badge { display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: 1.4rem 1rem; border-radius: 1.6rem; background: #fff; text-align: center; box-shadow: 0 .4rem 1rem rgba(104, 67, 45, .15); }
.badge b { font-size: 1.35rem; color: #c45036; }
.badge small { font-size: 1.15rem; line-height: 1.35; }
.badge-icon { font-size: 4rem; }
.badge.locked { opacity: .7; filter: grayscale(1); }

/* Kredit */
.credit-card { display: flex; gap: 3rem; align-items: center; max-width: 80rem; padding: 3rem 4rem; border-radius: 2.4rem; background: #fff; box-shadow: 0 1rem 3rem rgba(104, 67, 45, .2); }
.credit-card img { width: 18rem; height: 18rem; object-fit: cover; border-radius: 50%; border: .5rem solid #f3ad45; }
.credit-card ul { margin: 0 0 1.6rem; padding-left: 2rem; font-size: 1.3rem; line-height: 1.6; }
.credit-card p { margin-bottom: .6rem; }

/* Overlay: dialog & hasil */
.overlay { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(48, 30, 20, .6); }
#dialog { align-items: flex-end; padding-bottom: 3rem; background: rgba(48, 30, 20, .45); }

.dialog-card {
  display: flex;
  align-items: flex-end;
  gap: 2rem;
  width: 84rem;
  min-height: 17rem;
  padding: 2rem 2.6rem;
  border: .4rem solid #e8794f;
  border-radius: 2.4rem;
  background: #fff7d7;
  box-shadow: 0 1.2rem 3.2rem rgba(0, 0, 0, .35);
  cursor: pointer;
}

.face { flex: none; width: 16rem; height: 16rem; margin-top: -6rem; animation: bob 2s ease-in-out infinite; }
.narration .face { display: none; }
.narration .dialog-card, #dialog.narration .dialog-card { background: #3b2a3f; color: #fff7d7; border-color: #a77fb0; }
.dlg-body { flex: 1; display: flex; flex-direction: column; align-self: stretch; }
.dlg-name { margin: 0 0 .4rem; color: #c45036; font-size: 1.6rem; font-weight: 800; }
.narration .dlg-name { color: #ffb3d1; }
#dlgText { flex: 1; font-size: 1.7rem; line-height: 1.5; min-height: 7.5rem; }
#dlgNext { align-self: flex-end; }

.modal-card { width: 60rem; padding: 3rem 3.5rem; border-radius: 2.2rem; background: #fff7d7; text-align: center; box-shadow: 0 1.2rem 3.2rem rgba(0, 0, 0, .3); }
.modal-card h2 { color: #c45036; font-size: 2.8rem; margin: .4rem 0 .6rem; }
#resText { white-space: pre-line; text-align: left; display: inline-block; }
.modal-card .sub { font-weight: 600; color: #2f6b3a; font-size: 1.3rem; }
.big-stars { color: #f2a500; font-size: 4.6rem; letter-spacing: .6rem; line-height: 1.2; text-shadow: 0 .2rem 0 #b0400f; }
.big-stars:empty { display: none; }

#toast {
  position: absolute;
  left: 50%;
  top: 2rem;
  z-index: 50;
  transform: translateX(-50%);
  padding: 1rem 2.4rem;
  border-radius: 99rem;
  background: #2f6b3a;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 800;
  box-shadow: 0 .6rem 1.6rem rgba(0, 0, 0, .3);
  animation: drop .4s ease-out;
}

@keyframes bob { 50% { transform: translateY(-.8rem); } }
@keyframes hint { 50% { transform: scale(1.12); border-color: #fff36b; } }
@keyframes glow { 50% { filter: drop-shadow(0 0 1.2rem #fff36b); } }
@keyframes shake { 20%, 60% { transform: translateX(-.8rem); } 40%, 80% { transform: translateX(.8rem); } }
@keyframes burst { from { opacity: 1; transform: translate(-50%, -50%) scale(.3); } to { opacity: 0; transform: translate(-50%, -50%) scale(1.4); } }
@keyframes rise { to { opacity: 0; transform: translate(-50%, -250%); } }
@keyframes pop { 0% { transform: translate(-50%, -50%) scale(.3); } 20% { transform: translate(-50%, -50%) scale(1.1); } 80% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -80%) scale(1); } }
@keyframes beam-h {
  0% { transform: translate(-50%, -50%) scaleX(0) scaleY(1.4); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(-50%, -50%) scaleX(1) scaleY(.2); opacity: 0; }
}
@keyframes beam-v {
  0% { transform: translate(-50%, -50%) scaleY(0) scaleX(1.4); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(-50%, -50%) scaleY(1) scaleX(.2); opacity: 0; }
}
@keyframes ring {
  0% { transform: translate(-50%, -50%) scale(.7); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.08); opacity: 0; }
}
@keyframes spark {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0); opacity: 0; }
}
@keyframes flash { 0% { opacity: .9; } 100% { opacity: 0; } }
@keyframes shake-big {
  10%, 90% { transform: translate(-.3rem, .2rem); }
  20%, 80% { transform: translate(.8rem, -.4rem); }
  30%, 50%, 70% { transform: translate(-1.4rem, .6rem) rotate(-.6deg); }
  40%, 60% { transform: translate(1.4rem, -.6rem) rotate(.6deg); }
}
@keyframes jump { 30% { transform: translateY(-1.6rem) rotate(-6deg); } 60% { transform: translateY(0) rotate(4deg); } }
@keyframes bubble { from { transform: scale(.5) translateX(2rem); opacity: 0; } }
@keyframes drop { from { transform: translate(-50%, -150%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
