:root {
  --bg: #0a0e1a;
  --card: rgba(255, 255, 255, 0.055);
  --card2: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.13);
  --fg: #e9edf7;
  --muted: #93a0bb;
  --gold: #ffd23f;
  --gold2: #ffa62b;
  --pink: #ff4d6d;
  --green: #37d67a;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--fg);
  background:
    radial-gradient(900px 600px at 15% -10%, #1d2a4d 0%, transparent 60%),
    radial-gradient(800px 500px at 90% 110%, #2a1633 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--gold); }

.wrap { max-width: 760px; margin: 0 auto; padding: 18px 16px 40px; }
.wrap.wide { max-width: 1040px; }

/* ---------------------------------------------------------------- tipografi */
h1 { font-size: 1.5rem; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 1rem; margin: 0 0 10px; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.mono { font-family: var(--mono); }
.center { text-align: center; }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ kartu */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  backdrop-filter: blur(6px);
}
.card h2 { display: flex; align-items: center; gap: 8px; }
.card .hint { color: var(--muted); font-size: 0.82rem; margin: -4px 0 12px; line-height: 1.45; }

/* ---------------------------------------------------------------- kontrol */
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%;
  font: inherit;
  color: var(--fg);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--gold); }
textarea { min-height: 130px; resize: vertical; line-height: 1.5; }
select { appearance: none; }

.btn {
  font: inherit;
  font-weight: 600;
  color: var(--fg);
  background: var(--card2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 16px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.06s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.25); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(160deg, var(--gold), var(--gold2)); color: #23180a; border-color: transparent; }
.btn.danger { color: #ffc2cd; border-color: rgba(255, 77, 109, 0.45); background: rgba(255, 77, 109, 0.14); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 11px; font-size: 0.85rem; border-radius: 8px; }
.btn.block { width: 100%; }

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 700px) {
  .grid2 { grid-template-columns: 1fr; }
  .grid4 { grid-template-columns: repeat(2, 1fr); }
}

.switch { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--gold); flex: none; }
.switch span { font-size: 0.92rem; }

/* -------------------------------------------------------------- indikator */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.75rem; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  background: var(--card2); border: 1px solid var(--line);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill.on .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.pill.off .dot { background: var(--pink); }

.badge {
  display: inline-block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em;
  padding: 3px 8px; border-radius: 6px; text-transform: uppercase;
}
.badge.force { background: rgba(255, 77, 109, 0.2); color: #ff8ea3; }
.badge.queue { background: rgba(94, 160, 255, 0.2); color: #8fc0ff; }
.badge.weight { background: rgba(255, 210, 63, 0.18); color: var(--gold); }
.badge.random { background: rgba(255, 255, 255, 0.09); color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(120%);
  background: #1b2440; border: 1px solid var(--line); color: var(--fg);
  padding: 11px 18px; border-radius: 999px; font-size: 0.9rem; font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); z-index: 60;
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1); max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.bad { border-color: rgba(255, 77, 109, 0.5); }

/* ------------------------------------------------------------------- roda */
.stage {
  position: relative;
  width: min(84vmin, 720px);
  max-width: 100%;
  max-height: 100%;          /* menyusut sendiri kalau tinggi kolom terbatas */
  aspect-ratio: 1;
  margin: 0 auto;
  touch-action: manipulation;
}
.stage canvas {
  width: 100%; height: 100%; display: block; border-radius: 50%;
  will-change: transform;
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.06), 0 0 0 12px rgba(0, 0, 0, 0.35),
              0 24px 60px rgba(0, 0, 0, 0.55);
}
.pointer {
  position: absolute; top: -1.4%; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; z-index: 3;
  border-left: 1.9vmin solid transparent;
  border-right: 1.9vmin solid transparent;
  border-top: 4.6vmin solid var(--gold);
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6));
}
.hub {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 2; width: 23%; height: 23%; border-radius: 50%;
  border: none; cursor: pointer;
  background: linear-gradient(160deg, #fff3cf, var(--gold) 45%, var(--gold2));
  color: #2a1c05; font-family: var(--font); font-weight: 800;
  font-size: clamp(0.8rem, 3.1vmin, 1.7rem); letter-spacing: 0.02em;
  box-shadow: 0 0 0 5px rgba(0, 0, 0, 0.4), 0 8px 22px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s, filter 0.15s;
}
.hub:hover:not(:disabled) { filter: brightness(1.08); }
.hub:active:not(:disabled) { transform: translate(-50%, -50%) scale(0.95); }
.hub:disabled { filter: grayscale(0.55) brightness(0.8); cursor: default; }

.emptyhint {
  /* di bawah pusat, supaya tidak tertutup hub PUTAR */
  position: absolute; inset: 0; display: grid; place-items: end center; z-index: 1;
  color: rgba(255, 255, 255, 0.72); font-weight: 600; text-align: center;
  padding: 0 14% 16%; line-height: 1.5; pointer-events: none;
}

/* -------------------------------------------------- halaman serba-satu */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  height: 100dvh;
  padding: 14px 18px;
  align-items: stretch;
  overflow: hidden;
}
.wheelcol { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.headtools { position: absolute; top: 0; right: 0; z-index: 4; display: flex; gap: 6px; align-items: center; }
.apphead { text-align: center; padding: 0 96px 2px; flex: none; }

/* Nama undian = judul sekaligus kotak input.
   Selector dibuat sebentuk dengan aturan umum input (specificity 0,2,1) supaya
   background & border bawaan input benar-benar tertimpa — dengan selector kelas
   biasa (0,1,0) aturan umum yang menang dan kotak hitamnya tetap muncul. */
input[type="text"].titleinput,
input[type="text"].titleinput:hover,
input[type="text"].titleinput:focus,
input[type="text"].titleinput:active {
  width: 100%;
  background: none;
  background-color: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  outline: none;
  padding: 0 4px;
  margin: 0;
  text-align: center;
  font-family: "Palatino Linotype", Palatino, P052, "URW Palladio L", "Book Antiqua", Georgia, serif;
  font-size: clamp(2.02rem, 5.85vmin, 3.73rem);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: 0.005em;
  color: var(--fg);
  caret-color: var(--gold);
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
  -webkit-appearance: none;
  appearance: none;
}

/* Hint bergaya terminal: monospace sempit-tinggi bertangkai tipis (Ubuntu Mono
   adalah font terminal bawaan Ubuntu). Tajam — TANPA blur, karena tepi huruf
   yang tidak pernah fokus melelahkan mata.
   Ukuran 0.8em relatif judul, jadi ikut menyesuaikan kalau judul disetel ulang.
   text-shadow: none perlu, kalau tidak bayangan gelap dari input ikut terwarisi
   dan membuat hurufnya tampak kotor. */
input[type="text"].titleinput::placeholder {
  font-family: "Share Tech Mono", "Ubuntu Mono", "JetBrains Mono", "Fira Code",
               "Ubuntu Condensed", "DejaVu Sans Mono", "Liberation Mono", var(--mono);
  color: var(--gold);
  opacity: 0.55;
  text-shadow: none;
  font-size: 0.8em;
  font-weight: 400;
  letter-spacing: 0.12em;
}

.subline { margin-top: 4px; min-height: 1.2em; }
.stagewrap { flex: 1; display: grid; place-items: center; min-height: 0; padding: 4px 0; }

.panel { display: flex; flex-direction: column; min-height: 0; gap: 12px; }
.panel .card { margin-bottom: 0; }
.optscard { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.optsbox { flex: 1; min-height: 120px; margin-top: 10px; resize: none; font-size: 0.95rem; line-height: 1.7; }
.savestate { min-height: 1.2em; margin-top: 6px; text-align: right; flex: none; }

body.projector .panel { display: none; }
body.projector .app { grid-template-columns: 1fr; }

@media (max-width: 940px) {
  .app { grid-template-columns: 1fr; height: auto; min-height: 100dvh; overflow: visible; gap: 14px; padding: 12px 14px 20px; }
  .apphead { padding: 2px 92px 4px; }
  .panel { min-height: 44vh; }
  .optsbox { min-height: 200px; }
}
@media (max-width: 560px) {
  .apphead { padding: 36px 6px 4px; }
}

/* ------------------------------------------------------- kartu pemenang */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(6, 9, 18, 0.78); backdrop-filter: blur(10px);
  opacity: 0; pointer-events: none; transition: opacity 0.28s;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.winner {
  text-align: center; padding: 28px 26px; max-width: min(90vw, 620px);
  transform: scale(0.9); transition: transform 0.32s cubic-bezier(0.2, 1.3, 0.4, 1);
}
.overlay.show .winner { transform: scale(1); }
.winner .cap {
  color: var(--gold); font-weight: 700; letter-spacing: 0.22em;
  font-size: 0.8rem; text-transform: uppercase;
}
.overlay.show .winner .cap { animation: capPulse 1.4s ease-in-out infinite; }
.winner .name {
  font-size: clamp(2rem, 9vmin, 5rem); font-weight: 800; line-height: 1.1;
  margin: 12px 0 22px; letter-spacing: -0.02em; overflow-wrap: anywhere;
  text-shadow: 0 6px 30px rgba(255, 210, 63, 0.28);
  will-change: transform;
}
/* Denyut nama pemenang — transform & text-shadow, jadi ditangani compositor
   dan tetap hidup selama dialog terbuka. */
.overlay.show .winner .name { animation: winnerPulse 1.7s ease-in-out infinite alternate; }
@keyframes winnerPulse {
  from { transform: scale(1);     text-shadow: 0 6px 30px rgba(255, 210, 63, 0.28); }
  to   { transform: scale(1.045); text-shadow: 0 10px 52px rgba(255, 210, 63, 0.62),
                                               0 0 16px rgba(255, 210, 63, 0.4); }
}
@keyframes capPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ------------------------------------------------------------- daftar nama */
.list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
.list li {
  display: flex; align-items: center; gap: 10px;
  background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 8px 8px 12px;
}
.list li .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list li .idx { color: var(--muted); font-size: 0.75rem; min-width: 1.6em; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; font-size: 0.9rem; }

/* ------------------------------------------------------------ remote HP */
.roomcode { font-family: var(--mono); font-weight: 700; letter-spacing: 0.08em; color: var(--gold); font-size: 0.95rem; }
.spinbig {
  width: 100%; padding: 22px; font-size: 1.35rem; font-weight: 800; letter-spacing: 0.04em;
  border: none; border-radius: 18px; cursor: pointer; color: #23180a;
  background: linear-gradient(160deg, #ffe27a, var(--gold) 40%, var(--gold2));
  box-shadow: 0 10px 28px rgba(255, 166, 43, 0.25);
  transition: transform 0.08s, filter 0.15s;
}
.spinbig:active:not(:disabled) { transform: translateY(2px); }
.spinbig:disabled { filter: grayscale(0.6) brightness(0.7); cursor: default; box-shadow: none; }

/* --------------------------------------------------------------- tabel */
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; }
.scroll-x { overflow-x: auto; }

/* ------------------------------------------------ panel atur pemenang */
.rigpick { display: flex; flex-wrap: wrap; gap: 6px; }
.rigpick .btn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------------ misc */
.keybox {
  background: rgba(0, 0, 0, 0.35); border: 1px dashed var(--gold);
  border-radius: 10px; padding: 12px; font-family: var(--mono);
  font-size: 1.05rem; letter-spacing: 0.06em; word-break: break-all; color: var(--gold);
}
.fxcanvas { position: fixed; inset: 0; pointer-events: none; z-index: 55; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
