* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; font-family: "Segoe UI", system-ui, sans-serif; }
body { background: #ffeef2; touch-action: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

:root {
  --pink: #e5527c;
  --pink-d: #d13d6b;
  --ink: #7a4a5d;
  --muted: #c49aa8;
  --card: #fffdf8;
  --sat: env(safe-area-inset-top);
  --sab: env(safe-area-inset-bottom);
  --sal: env(safe-area-inset-left);
  --sar: env(safe-area-inset-right);
}

/* ---- screens ---- */
.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #ffd6e0, #ffeccc 55%, #d4f5e9); z-index: 20;
  padding: calc(12px + var(--sat)) calc(12px + var(--sar)) calc(12px + var(--sab)) calc(12px + var(--sal));
}
.card {
  background: var(--card); border-radius: 28px; padding: 30px 30px; width: min(430px, 94vw);
  box-shadow: 0 20px 60px rgba(230, 90, 130, .25), 0 0 0 6px #ffe1ea;
  display: flex; flex-direction: column; gap: 14px; text-align: center;
  max-height: 92vh; overflow-y: auto;
}
h1 { font-size: 2.4rem; color: var(--pink); }
h2 { color: var(--pink); font-size: 1.3rem; }
.sub { color: #b0788c; }
.hint { color: var(--muted); font-size: .85rem; line-height: 1.4; }
button {
  font-family: inherit; font-size: 1rem; border: none; border-radius: 16px; padding: 12px 18px;
  background: #ffd9e4; color: var(--pink-d); font-weight: 700; cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .15s;
}
button:active { transform: scale(.96); }
button.big { background: linear-gradient(135deg, #ff7ba2, #ff9d6c); color: #fff; font-size: 1.1rem; padding: 15px; }
input {
  font-family: inherit; font-size: 1.05rem; padding: 12px 16px; border-radius: 16px;
  border: 3px solid #ffd9e4; outline: none; text-align: center; background: #fff; color: var(--ink);
  min-width: 0;
}
input:focus { border-color: #ff7ba2; }
#join-code { text-transform: uppercase; letter-spacing: .3em; font-weight: 800; width: 140px; }
.row { display: flex; gap: 10px; justify-content: center; }
.code-big {
  font-size: 2.4rem; font-weight: 900; letter-spacing: .3em; color: var(--pink);
  background: #fff0f5; border-radius: 18px; padding: 14px 8px; border: 3px dashed #ffb2c9;
}
.ic { width: 1.15em; height: 1.15em; vertical-align: -0.2em; display: inline-block; }
.ic.gold { color: #f5b91e; }
.pill .ic { margin-right: 4px; }
.vopt { display: block; width: 100%; margin: 6px 0; font-size: 1.05rem; padding: 16px; }

/* ================= CHARACTER CREATOR ================= */
.char-wrap {
  width: min(920px, 100%); height: 100%; display: flex; gap: 12px; align-items: stretch;
}
.char-stage {
  position: relative; flex: 1 1 42%; min-width: 0;
  background: linear-gradient(180deg, #fff6fa, #ffe7f0);
  border-radius: 26px; overflow: hidden; box-shadow: inset 0 0 0 5px #ffe1ea;
}
#char-preview { width: 100%; height: 100%; display: block; touch-action: none; }
.stage-top { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 8px; align-items: center; }
.ghost-btn { background: rgba(255,255,255,.85); width: 40px; height: 40px; padding: 0; border-radius: 14px; }
.code-chip {
  background: rgba(255,255,255,.9); border-radius: 999px; padding: 7px 14px;
  font-size: .8rem; color: var(--ink); font-weight: 700;
}
.code-chip b { color: var(--pink); letter-spacing: .15em; }
.turn-hint {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  font-size: .7rem; color: var(--muted); background: rgba(255,255,255,.75);
  padding: 4px 12px; border-radius: 999px; pointer-events: none;
}
.char-panel {
  flex: 1 1 58%; min-width: 0; background: var(--card); border-radius: 26px;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 16px 44px rgba(230, 90, 130, .22);
}
.panel-head { display: flex; gap: 8px; }
.panel-head input { flex: 1; text-align: left; padding: 11px 14px; font-size: .95rem; }
.seg { display: flex; background: #ffeef4; border-radius: 14px; padding: 3px; gap: 3px; }
.seg button { padding: 8px 12px; font-size: .85rem; border-radius: 11px; background: transparent; color: var(--muted); }
.seg button.on { background: #fff; color: var(--pink-d); box-shadow: 0 2px 8px rgba(229,82,124,.2); }
.ctabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.ctabs::-webkit-scrollbar { display: none; }
.ctab {
  flex: 0 0 auto; font-size: .8rem; padding: 8px 14px; background: #fff2f6; color: var(--muted);
}
.ctab.on { background: linear-gradient(135deg, #ff7ba2, #ff9d6c); color: #fff; }
.cbody { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 2px; }
.opt-sec > label {
  font-size: .7rem; font-weight: 800; color: var(--muted); text-transform: uppercase;
  letter-spacing: .06em; display: block; margin-bottom: 6px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: .82rem; padding: 9px 13px; background: #fff2f6; color: #a05070; border-radius: 13px;
}
.chip.on { background: #ffd9e4; box-shadow: 0 0 0 2.5px var(--pink-d); }
.chip.lock { opacity: .5; }
.chip small { display: block; font-size: .62rem; color: #1d9e5f; font-weight: 800; }
.sw-row { display: flex; flex-wrap: wrap; gap: 7px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; padding: 0; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.swatch.on { box-shadow: 0 0 0 3px var(--pink-d); }

@media (max-width: 780px), (orientation: portrait) {
  .char-wrap { flex-direction: column; gap: 8px; }
  .char-stage { flex: 0 0 34vh; }
  .char-panel { flex: 1 1 auto; min-height: 0; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .char-wrap { flex-direction: row; }
  .char-stage { flex: 0 0 32%; }
  .char-panel { padding: 10px; gap: 7px; }
  .chip { padding: 7px 11px; font-size: .76rem; }
  .swatch { width: 30px; height: 30px; }
  #btn-ready { padding: 11px; font-size: 1rem; }
}

/* ================= HUD ================= */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
.hud-top {
  position: absolute; top: calc(8px + var(--sat)); left: calc(10px + var(--sal)); right: calc(10px + var(--sar));
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
}
.hud-left, .hud-right { display: flex; gap: 6px; flex-wrap: wrap; }
.hud-right { justify-content: flex-end; }
.pill {
  background: rgba(255, 253, 248, .93); border-radius: 999px; padding: 7px 14px; font-weight: 700;
  color: #a05070; box-shadow: 0 3px 10px rgba(0, 0, 0, .12); font-size: .88rem; white-space: nowrap;
}
.pill.sm { font-size: .78rem; padding: 6px 11px; }
.pill.money { background: #eafff2; color: #1d9e5f; }
.pill.money.partner { background: #fff7ea; color: #c98a1d; font-size: .72rem; }

#event-banner {
  position: absolute; top: calc(52px + var(--sat)); left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, #ff7043, #ffb020); color: #fff; font-weight: 800;
  padding: 7px 18px; border-radius: 999px; font-size: .85rem; display: flex; gap: 10px; align-items: center;
  box-shadow: 0 6px 18px rgba(255, 112, 67, .45); animation: pop .25s ease;
}
#event-banner span { font-size: .75rem; opacity: .9; }
#event-banner.danger { background: linear-gradient(135deg, #ff4d4d, #ff7043); animation: pulse .8s infinite; }
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.06); } }
#combo-badge {
  position: absolute; top: calc(90px + var(--sat)); left: 50%; transform: translateX(-50%);
  background: #ffd76c; color: #7a5a10; font-weight: 800; padding: 5px 14px; border-radius: 999px;
  font-size: .78rem; box-shadow: 0 4px 12px rgba(245, 185, 30, .5);
}

.hud-side {
  position: absolute; top: calc(96px + var(--sat)); right: calc(10px + var(--sar));
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.hbtn {
  width: 54px; height: 54px; padding: 0; border-radius: 18px; display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  box-shadow: 0 5px 14px rgba(0, 0, 0, .16); background: rgba(255, 253, 248, .95); color: var(--pink-d);
}
.hbtn .ic { width: 26px; height: 26px; }
.hbtn small { font-size: .5rem; font-weight: 800; letter-spacing: .02em; }
#btn-open.opened { background: #d7f7e6; color: #1d9e5f; }
#btn-open.closed { background: #ffe0e0; color: #d64545; }
.hbtn.active { box-shadow: 0 0 0 3px #f5b91e, 0 5px 14px rgba(0,0,0,.16); background: #fff6de; }

/* petunjuk arah pasangan */
#partner-arrow {
  position: absolute; width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255, 214, 108, .95); color: #7a5a10; display: flex; align-items: center; justify-content: center;
  font-weight: 900; box-shadow: 0 4px 14px rgba(0,0,0,.25); pointer-events: none; font-size: 1.4rem;
}
#partner-arrow::after {
  content: attr(data-nama); position: absolute; bottom: -18px; font-size: .6rem;
  background: rgba(60,30,45,.8); color: #fff; padding: 2px 7px; border-radius: 999px; white-space: nowrap;
}

#task-arrow {
  position: absolute; width: 44px; height: 44px; border-radius: 50%;
  background: var(--tc, #3ecf8e); color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 900; box-shadow: 0 4px 14px rgba(0,0,0,.28); pointer-events: none; font-size: 1.3rem;
  border: 3px solid rgba(255,255,255,.9);
}
#task-arrow::after {
  content: attr(data-tx); position: absolute; bottom: -18px; font-size: .6rem; font-weight: 800;
  background: rgba(60,30,45,.85); color: #fff; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}

/* konfirmasi taruh barang (mode decor) */
#place-bar {
  position: absolute; bottom: calc(16px + var(--sab)); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 6;
  background: rgba(255, 253, 248, .96); padding: 10px 14px; border-radius: 20px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .28); max-width: 92vw;
}
#place-bar-tx { font-size: .78rem; font-weight: 700; color: var(--ink); text-align: center; }
.pb-row { display: flex; gap: 10px; }
.pb {
  display: flex; align-items: center; gap: 7px; font-weight: 800; font-size: .9rem;
  padding: 12px 20px; border-radius: 16px; min-height: 50px; color: #fff;
  -webkit-tap-highlight-color: transparent;
}
.pb .ic { width: 20px; height: 20px; }
.pb.ok { background: linear-gradient(135deg, #3ecf8e, #63dfa6); box-shadow: 0 4px 14px rgba(62, 207, 142, .45); }
.pb.ok.off { background: #c9c4cc; box-shadow: none; }
.pb.no { background: rgba(122, 74, 93, .82); }

/* aksi kontekstual */
#actions {
  position: absolute; right: calc(14px + var(--sar)); bottom: calc(20px + var(--sab));
  display: flex; flex-direction: column-reverse; gap: 10px; align-items: flex-end;
}
.abtn {
  min-width: 76px; height: 76px; border-radius: 50%; font-weight: 800;
  background: linear-gradient(135deg, #ff7ba2, #ff9d6c); color: #fff;
  box-shadow: 0 6px 18px rgba(229, 82, 124, .45); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; padding: 6px; animation: pop .18s ease;
  border: 3px solid rgba(255, 255, 255, .55); transition: transform .1s ease;
  -webkit-tap-highlight-color: transparent;
}
.abtn .ic { width: 28px; height: 28px; }
.abtn .tx { font-size: .62rem; letter-spacing: .01em; }
/* aksi utama: paling besar, paling dekat jempol, bertuliskan penuh */
.abtn.main {
  min-width: 116px; height: 116px; border-width: 4px;
  box-shadow: 0 8px 26px rgba(229, 82, 124, .55), 0 0 0 8px rgba(255, 255, 255, .12);
}
.abtn.main .ic { width: 42px; height: 42px; }
.abtn.main .tx { font-size: .82rem; }
.abtn.tap { transform: scale(.9); }
.abtn.hot { background: linear-gradient(135deg, #ff4d4d, #ff8a3d); animation: pulse2 .6s infinite; }
.abtn.perfect { background: linear-gradient(135deg, #3ecf8e, #7ee8b0); }
@keyframes pulse2 { 50% { transform: scale(1.07); } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

#btn-emote {
  position: absolute; left: calc(24px + var(--sal)); bottom: calc(168px + var(--sab));
  width: 50px; height: 50px; border-radius: 50%; padding: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(255, 253, 248, .95); color: var(--pink-d); box-shadow: 0 4px 12px rgba(0,0,0,.18);
}
#btn-emote .ic { width: 25px; height: 25px; }
#emote-wheel {
  position: absolute; left: calc(16px + var(--sal)); bottom: calc(226px + var(--sab));
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; max-width: 230px;
}
#emote-wheel button { font-size: .78rem; padding: 9px 11px; background: rgba(255,253,248,.96); }

#joy-base {
  position: absolute; left: calc(20px + var(--sal)); bottom: calc(24px + var(--sab));
  width: 124px; height: 124px; border-radius: 50%;
  background: rgba(255, 255, 255, .26); border: 3px solid rgba(255, 255, 255, .62); touch-action: none;
}
#joy-knob {
  position: absolute; left: 40px; top: 40px; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255, 123, 162, .92); box-shadow: 0 4px 10px rgba(0, 0, 0, .2);
}
#prompt {
  position: absolute; bottom: calc(14px + var(--sab)); left: 50%; transform: translateX(-50%);
  background: rgba(60, 30, 45, .85); color: #fff; padding: 7px 16px; border-radius: 999px; font-weight: 700; font-size: .8rem;
}
#prompt b { color: #ffd76c; }
#place-hint {
  position: absolute; top: calc(56px + var(--sat)); left: 50%; transform: translateX(-50%);
  background: rgba(60, 30, 45, .85); color: #ffd76c; padding: 8px 16px; border-radius: 999px; font-size: .8rem;
  max-width: 84vw; text-align: center;
}
.hud-col {
  position: absolute; top: calc(58px + var(--sat)); left: calc(10px + var(--sal));
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(330px, 64vw); pointer-events: none;
}
#toasts { display: flex; flex-direction: column; gap: 6px; }

/* ---- daftar tugas ---- */
#tasklist { display: flex; flex-direction: column; gap: 4px; }
.trow {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 253, 248, .93); border-left: 6px solid var(--tc, #d9c7d0);
  padding: 6px 10px; border-radius: 12px; font-size: .78rem; font-weight: 700; color: var(--ink);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .14);
}
.trow .ic { width: 17px; height: 17px; color: var(--tc, #8a7480); flex: none; }
.trow span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow b { font-size: .68rem; color: var(--muted); font-weight: 800; flex: none; }
.trow.on {
  background: linear-gradient(135deg, rgba(255, 255, 255, .98), rgba(255, 246, 250, .98));
  font-size: .84rem; padding: 8px 11px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .2), 0 0 0 2px var(--tc, #ffd76c) inset;
}
.trow.on .ic { width: 20px; height: 20px; }
.trow.done { border-left-color: #3ecf8e; color: var(--muted); font-weight: 600; }
/* Notifikasi pojok sengaja mungil & cepat hilang — info utama sudah tampil
   di atas kepala karakter. */
.toast {
  background: rgba(255, 253, 248, .82); border-left: 4px solid #ff7ba2; padding: 4px 9px;
  border-radius: 9px; font-size: .66rem; line-height: 1.25; color: var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
  animation: slidein .2s ease; opacity: .92;
  transition: opacity .45s ease, transform .45s ease;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.toast.out { opacity: 0; transform: translateX(-14px); }
.toast.good { border-color: #3ecf8e; }
.toast.bad { border-color: #ff5a5a; opacity: 1; }
.toast.warn { border-color: #ffb020; }
@keyframes slidein { from { transform: translateX(-20px); opacity: 0; } }

/* ================= modals ================= */
.modal {
  position: fixed; inset: 0; background: rgba(90, 40, 60, .45); z-index: 30;
  display: flex; align-items: center; justify-content: center; padding: 14px;
}
.mcard {
  background: var(--card); border-radius: 24px; width: min(560px, 96vw); max-height: 86vh;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 70px rgba(0, 0, 0, .35);
}
.mhead { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px 6px; }
.x { background: #ffe4ec; width: 40px; height: 40px; border-radius: 50%; padding: 0; }
.tabs { display: flex; gap: 6px; padding: 6px 14px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; font-size: .82rem; padding: 8px 13px; background: #fff2f6; color: var(--muted); }
.tab.on { background: #ffd9e4; color: var(--pink-d); box-shadow: 0 0 0 2px #ff7ba2; }
#shop-list, #staff-list { overflow-y: auto; padding: 10px 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.shop-head { font-size: .72rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }
.item { display: flex; align-items: center; gap: 11px; background: #fff4f8; border-radius: 16px; padding: 10px 13px; text-align: left; }
.item .ico { color: #d1698c; display: flex; }
.ic.big { width: 28px; height: 28px; }
.item .inf { flex: 1; min-width: 0; }
.item .inf b { color: #a05070; display: block; font-size: .92rem; }
.item .inf small { color: var(--muted); font-size: .74rem; }
.item .prc { font-weight: 800; color: #1d9e5f; font-size: .85rem; white-space: nowrap; }
.item button { font-size: .8rem; padding: 9px 13px; }
.item.owned { opacity: .6; }
.item.col { flex-direction: column; align-items: stretch; gap: 8px; }
.item.col .chiprow { display: flex; gap: 6px; flex-wrap: wrap; }
.sheet-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 8px 16px 20px; }
.sbtn {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px;
  background: #fff4f8; font-size: .8rem; color: #a05070;
}
.sbtn .ic { width: 28px; height: 28px; color: var(--pink-d); }
.sbtn.active { background: #fff6de; box-shadow: 0 0 0 2.5px #f5b91e; }

#conn {
  position: fixed; top: 0; left: 0; right: 0; background: #ff5a5a; color: #fff; text-align: center;
  padding: calc(6px + var(--sat)) 6px 6px; z-index: 50; font-weight: 700; font-size: .85rem;
}

/* ---- rotate hint ---- */
#rotate-hint {
  position: fixed; inset: 0; z-index: 60; background: rgba(45, 18, 32, .88);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.rotate-card {
  background: var(--card); border-radius: 24px; padding: 26px 22px; text-align: center;
  width: min(360px, 92vw); box-shadow: 0 18px 50px rgba(0,0,0,.35); color: #a05070;
}
.rotate-card .rotate-phone {
  width: 44px; height: 70px; border: 4px solid var(--pink); border-radius: 10px; margin: 0 auto 14px;
  animation: tilt 1.4s ease-in-out infinite;
}
.rotate-card b { display: block; font-size: 1.1rem; margin-bottom: 8px; color: var(--pink-d); }
.rotate-card p { margin: 0 0 16px; color: var(--muted); font-size: .9rem; line-height: 1.4; }
@keyframes tilt { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(78deg); } }
html.fs-active, html.fs-active body { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; touch-action: none; }

@media (orientation: landscape) and (max-height: 520px) {
  .hud-top { top: calc(6px + var(--sat)); }
  .pill { padding: 5px 11px; font-size: .78rem; }
  .pill.sm { font-size: .7rem; }
  .hud-side { top: calc(74px + var(--sat)); gap: 6px; }
  .hbtn { width: 46px; height: 46px; border-radius: 14px; }
  .hbtn .ic { width: 22px; height: 22px; }
  #actions { bottom: calc(12px + var(--sab)); gap: 8px; }
  .abtn { min-width: 60px; height: 60px; }
  .abtn .ic { width: 24px; height: 24px; }
  .abtn.main { min-width: 92px; height: 92px; }
  .abtn.main .ic { width: 34px; height: 34px; }
  .abtn.main .tx { font-size: .72rem; }
  #joy-base { width: 104px; height: 104px; bottom: calc(12px + var(--sab)); }
  #joy-knob { left: 30px; top: 30px; width: 40px; height: 40px; }
  #btn-emote { bottom: calc(126px + var(--sab)); width: 44px; height: 44px; }
  #emote-wheel { bottom: calc(176px + var(--sab)); }
  .hud-col { top: calc(44px + var(--sat)); max-width: 46vw; }
  .trow { font-size: .7rem; padding: 4px 8px; }
  .trow.on { font-size: .76rem; padding: 6px 9px; }
  .toast { font-size: .6rem; padding: 3px 7px; }
  #event-banner { top: calc(40px + var(--sat)); font-size: .78rem; padding: 5px 14px; }
  #combo-badge { top: calc(70px + var(--sat)); }
}
