/* Acakin - gaya halaman. Token warna dan font ada di :root di bawah. */
/* Reset dasar (di versi standalone, bukan dari halaman pembungkus) */
html { color-scheme: light; }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* Layout: chunky "capsule toy" look. Header with logo + mode switch, then a two-column workspace (stage left: wheel or group boxes; inputs right). Stacks under 860px. */
:root {
  --bg: #EEF0FF;
  --paper: #FFFFFF;
  --paper-2: #F5F6FF;
  --ink: #15123A;
  --muted: #5A5880;
  --sh: #15123A;
  --rim: #15123A;
  --dot: rgba(21, 18, 58, .13);
  --dash: rgba(21, 18, 58, .2);
  --yellow: #FFD93D;
  --pink: #FF7AB6;
  --mint: #3FE0A0;
  --sky: #5CC8FF;
  --coral: #FF6F59;
  --violet: #9B8BFF;
  --on-bright: #15123A;
  --font-display: 'Unbounded', 'Arial Black', system-ui, sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'DM Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #100E26; --paper: #1A1741; --paper-2: #231F52; --ink: #F1EFFF; --muted: #A9A6D0;
    --sh: #5B47FF; --rim: #0B0920; --dot: rgba(241, 239, 255, .1); --dash: rgba(241, 239, 255, .18);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #100E26; --paper: #1A1741; --paper-2: #231F52; --ink: #F1EFFF; --muted: #A9A6D0;
  --sh: #5B47FF; --rim: #0B0920; --dot: rgba(241, 239, 255, .1); --dash: rgba(241, 239, 255, .18);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  background: var(--bg) radial-gradient(var(--dot) 1.3px, transparent 1.5px) 0 0 / 22px 22px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  padding-inline: 16px;
  padding-block: 22px 48px;
}
.app { max-width: 1180px; margin-inline: auto; display: flex; flex-direction: column; gap: 26px; }
h1, h2, h3, p { margin: 0; }

/* ---------- header ---------- */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 28px; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo { width: 54px; height: 54px; flex: none; transition: transform .25s cubic-bezier(.2, 1.5, .4, 1); filter: drop-shadow(3px 3px 0 var(--sh)); }
.brand:hover .logo { transform: rotate(14deg) scale(1.08); }
.brand h1 { font: 800 clamp(26px, 5vw, 38px) var(--font-display); letter-spacing: -0.04em; line-height: 1.05; }
.brand p { color: var(--muted); font-weight: 500; margin-top: 2px; }
.controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tabs { display: flex; gap: 5px; padding: 5px; background: var(--paper); border: 2.5px solid var(--ink); border-radius: 18px; box-shadow: 4px 4px 0 var(--sh); }
.tabs button {
  display: flex; align-items: center; gap: 8px; font: 600 13px var(--font-display); color: var(--ink);
  background: transparent; border: 2px solid transparent; border-radius: 12px; padding: 10px 16px; cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--yellow); color: var(--on-bright); border-color: var(--ink); }
.tabs svg { flex: none; }
.round-btn {
  width: 46px; height: 46px; display: grid; place-items: center; background: var(--paper); color: var(--ink);
  border: 2.5px solid var(--ink); border-radius: 16px; box-shadow: 3px 3px 0 var(--sh); cursor: pointer;
}
.round-btn:active { transform: translate(3px, 3px); box-shadow: none; }

/* ---------- shared pieces ---------- */
.workspace { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 26px; align-items: start; }
.card { background: var(--paper); border: 2.5px solid var(--ink); border-radius: 24px; box-shadow: 6px 6px 0 var(--sh); padding: 24px; min-width: 0; }
.stage { background-image: radial-gradient(var(--dot) 1.3px, transparent 1.5px); background-size: 18px 18px; }
.panel { display: flex; flex-direction: column; gap: 18px; }
.panel-head, .stage-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-head h2, .stage-bar h2 { font: 800 18px var(--font-display); letter-spacing: -0.02em; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > label { font-weight: 700; }
.hint { color: var(--muted); font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }

textarea, input[type="number"], .title-input {
  width: 100%; font: 500 15px var(--font-body); color: var(--ink);
  background: var(--paper-2); border: 2.5px solid var(--ink); border-radius: 14px; padding: 11px 14px;
}
textarea { resize: vertical; min-height: 170px; line-height: 1.6; }
textarea:read-only { opacity: .7; }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }

.btn {
  font: 700 15px var(--font-body); padding: 12px 20px; border-radius: 14px; cursor: pointer;
  background: var(--paper); color: var(--ink); border: 2.5px solid var(--ink); box-shadow: 3px 3px 0 var(--sh);
  transition: transform .08s, box-shadow .08s;
}
.btn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--sh); }
.btn:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--sh); }
.btn.primary { background: var(--yellow); color: var(--on-bright); }
.btn.big { font-size: 17px; padding: 14px 26px; }
.btn.sm { font-size: 13px; padding: 8px 13px; border-radius: 11px; box-shadow: 2px 2px 0 var(--sh); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }

.pill {
  display: inline-flex; align-items: center; gap: 7px; font: 700 12px var(--font-body); padding: 5px 12px;
  border-radius: 999px; border: 2px solid var(--ink); background: var(--paper-2); color: var(--muted); font-variant-numeric: tabular-nums;
}
.pill i { width: 9px; height: 9px; border-radius: 50%; background: currentColor; border: 1.5px solid var(--on-bright); }
.pill.ok { background: var(--mint); color: var(--on-bright); }
.pill.warn { background: var(--yellow); color: var(--on-bright); }
.pill.bad { background: var(--coral); color: var(--on-bright); }
.pill.sky { background: var(--sky); color: var(--on-bright); }
.pill.count { color: var(--ink); }

.switch { display: flex; gap: 12px; align-items: center; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; flex: none; width: 48px; height: 28px; border: 2.5px solid var(--ink); border-radius: 999px; background: var(--paper-2); transition: background .15s; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: var(--ink); transition: transform .15s, background .15s; }
.switch input:checked + .track { background: var(--mint); }
.switch input:checked + .track::after { transform: translateX(20px); background: var(--on-bright); }
.switch input:focus-visible + .track { outline: 3px solid var(--violet); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .5; }

/* ---------- wheel ---------- */
.wheel-wrap { position: relative; width: min(100%, 520px); aspect-ratio: 1; margin: 34px auto 28px; }
.wheel-wrap canvas { display: block; width: 100%; height: 100%; filter: drop-shadow(6px 8px 0 var(--sh)); }
.pointer { position: absolute; top: -26px; left: 50%; width: 46px; height: 56px; margin-left: -23px; z-index: 3; transform-origin: 50% 16px; filter: drop-shadow(3px 3px 0 var(--sh)); }
.pointer svg { display: block; width: 100%; height: 100%; }
.pointer.flick { animation: flick .13s ease-out; }
.hub {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 3; width: 22%; aspect-ratio: 1;
  border-radius: 50%; background: var(--yellow); color: var(--on-bright); border: 3px solid var(--ink); cursor: pointer;
  font: 800 clamp(12px, 2.8vw, 17px) var(--font-display); letter-spacing: -0.02em; box-shadow: 3px 4px 0 var(--sh);
  transition: box-shadow .08s;
}
.hub:active:not(:disabled) { transform: translate(-46%, -46%); box-shadow: 0 0 0 var(--sh); }
.hub:disabled { opacity: .7; cursor: not-allowed; }
.stage-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

.winner {
  position: relative; margin-top: 34px; background: var(--yellow); color: var(--on-bright); border: 2.5px solid var(--ink);
  border-radius: 20px; box-shadow: 5px 5px 0 var(--sh); padding: 26px 20px 20px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.sticker {
  position: absolute; top: -15px; left: 18px; transform: rotate(-4deg); background: var(--pink); color: var(--on-bright);
  border: 2.5px solid var(--ink); border-radius: 10px; padding: 3px 12px; font: 800 11px var(--font-display); letter-spacing: .06em; text-transform: uppercase;
}
.winner-name { font: 800 clamp(24px, 6vw, 38px) var(--font-display); letter-spacing: -0.03em; line-height: 1.15; overflow-wrap: anywhere; text-wrap: balance; }
.winner-name.pop { animation: pop .5s cubic-bezier(.2, 1.5, .4, 1); }
.winner-note { font-weight: 600; font-size: 13px; }
.winner .btn { margin-top: 4px; }

.history { border-top: 2.5px dashed var(--dash); padding-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.history h3 { font: 800 14px var(--font-display); }
.history ol { margin: 0; padding: 0; list-style-position: inside; display: flex; flex-wrap: wrap; gap: 8px; max-height: 190px; overflow-y: auto; }
.history li { background: var(--paper-2); border: 2px solid var(--ink); border-radius: 999px; padding: 3px 12px; font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }

/* ---------- stepper ---------- */
.stepper { display: flex; gap: 10px; align-items: stretch; }
.stepper button {
  flex: none; width: 54px; font: 800 24px var(--font-display); color: var(--ink); background: var(--paper);
  border: 2.5px solid var(--ink); border-radius: 14px; box-shadow: 3px 3px 0 var(--sh); cursor: pointer;
}
.stepper button:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: none; }
.stepper button:disabled, .stepper input:disabled { opacity: .5; cursor: not-allowed; }
.stepper input { text-align: center; font: 800 26px var(--font-display); -moz-appearance: textfield; appearance: textfield; padding-block: 8px; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.status { min-height: 1.4em; color: var(--muted); font-size: 13px; font-weight: 600; }
.status.error { color: var(--coral); }

/* ---------- group boxes ---------- */
.groups-stage { min-height: 380px; display: flex; flex-direction: column; gap: 18px; }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 235px), 1fr)); gap: 18px; align-items: start; }
.group { background: var(--paper); border: 2.5px solid var(--ink); border-radius: 20px; box-shadow: 4px 4px 0 var(--sh); overflow: hidden; min-width: 0; transition: transform .2s, box-shadow .2s; }
.group.active { transform: translateY(-4px); box-shadow: 6px 9px 0 var(--sh); }
.group-head { display: flex; align-items: center; gap: 8px; padding: 11px 11px 11px 15px; background: var(--gc); color: var(--on-bright); border-bottom: 2.5px solid var(--ink); }
.group-title { flex: 1; min-width: 0; font: 800 14px var(--font-display); letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-input { flex: 1; min-width: 0; padding: 6px 9px; font: 800 14px var(--font-display); background: #fff; color: var(--on-bright); border-color: var(--on-bright); border-radius: 10px; }
.badge { flex: none; background: var(--on-bright); color: #fff; font: 700 12px var(--font-body); padding: 3px 10px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.icon-btn { flex: none; width: 34px; height: 34px; display: grid; place-items: center; color: var(--on-bright); background: rgba(255, 255, 255, .6); border: 2.5px solid var(--on-bright); border-radius: 11px; cursor: pointer; }
.icon-btn:active { transform: scale(.92); }
.members { list-style: none; margin: 0; padding: 0; }
.member, .placeholder { display: flex; align-items: center; gap: 11px; min-height: 50px; padding: 7px 14px; border-bottom: 2px dashed var(--dash); }
.member:last-child, .placeholder:last-child { border-bottom: 0; }
.avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--gc); color: var(--on-bright); border: 2px solid var(--ink); font: 800 12px var(--font-display); }
.name { min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member.scrambling { background: color-mix(in srgb, var(--gc) 30%, var(--paper)); }
.member.scrambling .name { font-family: var(--font-mono); font-weight: 500; letter-spacing: .1em; }
.member.settled { animation: settle .35s cubic-bezier(.2, 1.4, .4, 1); }
.placeholder { color: var(--muted); font-weight: 600; font-size: 14px; }

/* ---------- overlay ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(10, 8, 32, .6); backdrop-filter: blur(3px); animation: fade .15s ease; }
.dialog {
  position: relative; width: min(100%, 470px); max-height: 100%; overflow-y: auto; background: var(--paper); border: 2.5px solid var(--ink);
  border-radius: 26px; box-shadow: 8px 8px 0 var(--sh); padding: 28px; display: flex; flex-direction: column; gap: 14px;
  animation: dlg .3s cubic-bezier(.2, 1.4, .4, 1);
}
.dlg-badge { width: 56px; height: 56px; display: grid; place-items: center; background: var(--yellow); color: var(--on-bright); border: 2.5px solid var(--ink); border-radius: 17px; box-shadow: 3px 3px 0 var(--sh); transform: rotate(-7deg); font: 800 28px var(--font-display); }
.dialog h2 { font: 800 21px var(--font-display); letter-spacing: -0.03em; line-height: 1.2; padding-right: 40px; text-wrap: balance; }
.dialog p { color: var(--muted); font-weight: 500; }
.dlg-sizes { display: flex; flex-wrap: wrap; gap: 8px; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.dlg-close { position: absolute; top: 16px; right: 16px; width: 38px; height: 38px; border-radius: 12px; box-shadow: 2px 2px 0 var(--sh); }

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

@keyframes flick { 0% { transform: rotate(-18deg); } 100% { transform: rotate(0); } }
@keyframes pop { from { transform: scale(.6) rotate(-4deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes settle { from { transform: scale(.94); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dlg { from { transform: translateY(18px) scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .pointer.flick, .winner-name.pop, .member.settled, .overlay, .dialog { animation: none; }
  .group, .logo { transition: none; }
}
@media (max-width: 860px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .controls { width: 100%; }
  .tabs { flex: 1; }
  .tabs button { flex: 1; justify-content: center; }
}
@media (max-width: 520px) {
  .card { padding: 16px; border-radius: 20px; }
  .brand p { display: none; }
  .tabs button { padding: 10px 10px; }
  .dialog { padding: 22px; }
}
