:root {
  --bg: #FFF8F2;
  --ink: #5A3E45;
  --ink-soft: #8A6F75;
  --pink: #F9C5D5;
  --pink-deep: #F08FB0;
  --lav: #D7C6F2;
  --blue: #BFE0F5;
  --mint: #C8EFD9;
  --yellow: #FFF1B8;
  --card: #FFFFFF;
  --z0: #FFE9EF;
  --z1: #E3F1FA;
  --z2: #E6F6EC;
  --shadow: 0 6px 18px rgba(150, 90, 110, .16);
  --r: 18px;
}
body.spicy {
  --bg: #FBEAEE;
  --pink-deep: #D9577F;
  --z0: #F9D9E2;
  --z1: #EBD9EE;
  --z2: #F3DCE4;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  transition: background .5s;
  overflow-x: hidden;
}
h1, h2, h3, .logo, .btn, #dice { font-family: "Fredoka", "Nunito", sans-serif; }
[hidden] { display: none !important; }

.screen {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}

/* tombol */
.btn {
  display: block; width: 100%;
  border: 0; border-radius: 999px;
  padding: 12px 18px; margin: 8px 0;
  font-size: 1rem; font-weight: 600;
  background: var(--card); color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.big { background: var(--pink-deep); color: #fff; font-size: 1.1rem; padding: 14px 18px; }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--pink); }
.btn.small { width: auto; padding: 8px 12px; font-size: .85rem; margin: 0; }
.btn:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid var(--lav); outline-offset: 2px; }

.cat { width: 100%; height: 100%; display: block; }

/* login */
#login { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.logo { font-size: 3rem; margin: 0; color: var(--pink-deep); letter-spacing: .5px; }
.sub { color: var(--ink-soft); margin: 4px 0 24px; }
.ask { font-weight: 700; margin: 0 0 10px; }
.choose { display: flex; gap: 14px; margin-bottom: 18px; }
.who-btn {
  width: 130px; padding: 12px; border: 0; border-radius: var(--r);
  background: var(--card); box-shadow: var(--shadow); cursor: pointer;
  font: inherit; color: inherit; transition: transform .15s, box-shadow .15s;
}
.who-btn .cat { width: 84px; height: 84px; margin: 0 auto 6px; }
.who-btn.sel { box-shadow: 0 0 0 3px var(--pink-deep), var(--shadow); transform: translateY(-3px); }
#pin-form { width: 100%; max-width: 280px; }
#pin {
  width: 100%; text-align: center; font-size: 1.6rem; letter-spacing: 10px;
  padding: 12px; border-radius: var(--r); border: 2px solid var(--pink); background: var(--card); color: var(--ink);
  font-family: "Fredoka", sans-serif;
}
.err { min-height: 1.2em; color: #C2547A; font-size: .9rem; }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }

/* lobby */
#lobby { text-align: center; }
.lobby-cats { display: flex; align-items: center; justify-content: space-between; margin: 12px 0 18px; }
.who { width: 110px; opacity: .45; transition: opacity .3s; }
.who.on { opacity: 1; }
.who .cat { width: 80px; height: 80px; margin: 0 auto; }
.who b { display: block; }
.who small, .dots small { color: var(--ink-soft); font-size: .8rem; }
.dots { color: var(--pink-deep); font-size: 1.4rem; font-weight: 800; }
.dots small { display: block; font-size: .8rem; }
.count, .mode-box {
  background: var(--card); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 14px;
}
.count small { display: block; color: var(--ink-soft); }
.count b { display: block; font-family: "Fredoka", sans-serif; font-size: 1.5rem; color: var(--pink-deep); margin: 4px 0; }
.mode-box h3 { margin: 0 0 4px; }
.mode-box p { margin: 6px 0; font-size: .92rem; }
.consent { display: flex; gap: 8px; justify-content: center; margin: 8px 0; }
.consent span { background: var(--bg); padding: 6px 10px; border-radius: 999px; font-size: .85rem; }
.consent span.yes { background: #FAD0DC; }
.mode-now { color: var(--ink-soft); }

/* game */
#game { display: flex; flex-direction: column; padding-top: 10px; }
#hud { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 8px; }
.pl { flex: 1 1 0; display: flex; align-items: center; gap: 5px; padding: 4px 8px 4px 4px; border-radius: 999px; transition: background .3s; min-width: 0; }
.pl > div { min-width: 0; }
.pl .cat { width: 38px; height: 38px; flex: none; }
.pl b { display: block; font-size: .9rem; }
.pl small { display: block; font-size: .68rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl.turn { background: var(--card); box-shadow: 0 0 0 2px var(--pink-deep); }
.km { text-align: center; flex: none; width: 70px; line-height: 1.1; }
.km b { display: block; font-family: "Fredoka", sans-serif; color: var(--pink-deep); }
.km small { font-size: .65rem; color: var(--ink-soft); }

#board-wrap { width: 100%; }
#board {
  position: relative; width: 100%; aspect-ratio: 1;
  display: grid; grid-template: repeat(10, 1fr) / repeat(10, 1fr); gap: 2px;
  padding: 4px; border-radius: var(--r); background: var(--card); box-shadow: var(--shadow);
}
.tile {
  position: relative; border-radius: 7px; display: grid; place-items: center;
  font-size: clamp(10px, 3.4vw, 16px);
}
.tile.z0 { background: var(--z0); } .tile.z1 { background: var(--z1); } .tile.z2 { background: var(--z2); }
.tile.q-ngobrol { background: #F9C5D5; } .tile.q-rencana { background: #D7C6F2; } .tile.q-misi { background: #BFE0F5; }
.tile.q-tebak { background: #FFE79A; } .tile.q-jujur { background: #FFFFFF; box-shadow: inset 0 0 0 1.5px #EADFD6; }
.tile.q-hadiah { background: #B9EBCF; } .tile.q-spicy { background: #F7A8B8; }
.tile.t-landmark { background: #FFE3B8; }
.tile .num { position: absolute; top: 1px; left: 3px; font-size: clamp(7px, 1.9vw, 10px); font-weight: 800; color: var(--ink-soft); }
.tile .ic { line-height: 1; }
.links { position: absolute; inset: 4px; width: calc(100% - 8px); height: calc(100% - 8px); pointer-events: none; }
.token {
  position: absolute; width: 8.5%; aspect-ratio: 1; transform: translate(-50%, -62%);
  transition: left .18s ease, top .18s ease; z-index: 3; pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(90, 62, 69, .3));
}
.token.hop { animation: hop .19s infinite; }
.token.glide { transition: left .8s cubic-bezier(.5, 0, .3, 1), top .8s cubic-bezier(.5, 0, .3, 1); }
@keyframes hop { 50% { transform: translate(-50%, -85%); } }

#msg { min-height: 2.6em; margin: 8px 2px; font-size: .92rem; text-align: center; color: var(--ink); }
#controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.dice-box { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#dice {
  width: 78px; height: 78px; border-radius: 22px; border: 0; cursor: pointer;
  background: var(--card); box-shadow: var(--shadow), inset 0 -4px 0 var(--pink);
  font-size: 2.6rem; line-height: 1; color: var(--ink);
}
#dice:not(:disabled) { animation: pulse 1.4s infinite; }
#dice:disabled { opacity: .55; cursor: default; }
#dice.rolling { animation: roll .62s; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(240, 143, 176, .25), inset 0 -4px 0 var(--pink); } }
@keyframes roll { 30% { transform: rotate(-20deg) scale(1.1); } 70% { transform: rotate(18deg) scale(1.05); } }
#turn-label { font-size: .8rem; color: var(--ink-soft); text-align: center; max-width: 150px; }

/* kartu */
#sheet, #journal {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(90, 62, 69, .28); padding: 16px;
}
.card {
  position: relative; width: 100%; max-width: 448px; max-height: 88dvh; overflow-y: auto;
  background: var(--card); border-radius: 24px; padding: 18px 18px 14px;
  box-shadow: var(--shadow); border-top: 10px solid var(--cc);
}
.card.pop { animation: up .35s .55s both cubic-bezier(.3, 1.4, .5, 1); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.card h2 { margin: 0 34px 10px 0; font-size: 1.15rem; }
.card h2 small { display: block; font-family: "Nunito", sans-serif; font-weight: 600; font-size: .82rem; color: var(--ink-soft); margin-top: 4px; }
.card .q { font-size: 1.25rem; font-weight: 700; line-height: 1.4; margin: 8px 0 14px; padding: 14px; border-radius: 16px; background: var(--cc); }
.star { position: absolute; top: 18px; right: 14px; border: 0; background: none; font-size: 1.5rem; cursor: pointer; }
#star-box { display: flex; gap: 6px; margin-bottom: 8px; }
#star-box input { flex: 1; min-width: 0; padding: 10px; border-radius: 12px; border: 2px solid var(--yellow); font: inherit; color: var(--ink); }
#star-box .btn { width: auto; margin: 0; }
.nosave { font-size: .8rem; color: var(--ink-soft); margin: -6px 0 8px; }
.wait { text-align: center; color: var(--ink-soft); font-weight: 700; }
.picks { display: grid; gap: 8px; }
.pick {
  text-align: left; border: 0; border-radius: 14px; padding: 12px; background: var(--cc);
  font: 600 1rem "Nunito", sans-serif; color: var(--ink); cursor: pointer;
}
.pick span { margin-right: 6px; }

/* akhir */
#end { text-align: center; }
.hug { display: flex; justify-content: center; align-items: center; margin-top: 10px; }
.hug .cat { width: 110px; height: 110px; }
.hug .cat:first-child { transform: rotate(8deg) translateX(14px); }
.hug .cat:last-child { transform: rotate(-8deg) translateX(-14px); }
.heart { font-size: 2rem; z-index: 2; animation: beat 1s infinite; }
@keyframes beat { 50% { transform: scale(1.25); } }
#end h1 { margin: 6px 0 0; color: var(--pink-deep); font-size: 2.2rem; }
.letter {
  text-align: left; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 16px 18px; margin: 16px 0; line-height: 1.6; min-height: 120px;
  border-left: 4px solid var(--pink);
}
.letter p { margin: 0 0 10px; }
.caret { animation: blink .8s infinite; color: var(--pink-deep); }
@keyframes blink { 50% { opacity: 0; } }
.jr { text-align: left; }
.jr h3 { margin: 10px 0 6px; }
.je { background: var(--bg); border-radius: 12px; padding: 10px; margin-bottom: 6px; font-size: .9rem; }
.je em { display: block; margin-top: 4px; color: var(--pink-deep); }
.count-end { color: var(--ink-soft); }

/* efek */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; z-index: 20;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: .9rem;
  transition: .25s; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
.fx { position: fixed; bottom: -40px; z-index: 30; pointer-events: none; animation: float 2.4s ease-out forwards; }
@keyframes float { to { transform: translateY(-110vh) rotate(25deg); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
