:root {
  --bg: #0f1216; --panel: #171c23; --panel2: #1e252e; --line: #2a333f;
  --text: #e8edf3; --muted: #9aa7b4; --accent: #4c9aff; --accent2: #2d7cf0;
  --ok: #2ecc71; --err: #ff5b6e; --radius: 14px;
  --U:#f7f7f7; --R:#c41e3a; --F:#00a651; --D:#ffd500; --L:#ff6d00; --B:#0051ba;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 0 16px 40px; max-width: 560px; margin: 0 auto; line-height: 1.45;
}
header { padding: 18px 0 8px; }
header h1 { font-size: 20px; margin: 0; letter-spacing: .2px; }
header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 8px; margin: 14px 0; }
.tabs button {
  flex: 1; padding: 10px; border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); border-radius: 10px; font-size: 14px; font-weight: 600;
}
.tabs button.active { color: var(--text); border-color: var(--accent); background: var(--panel2); }

.screen { display: none; }
.screen.active { display: block; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 10px; }

/* NET input */
.net { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; }
.facebox { aspect-ratio: 1; }
.facebox.blank { visibility: hidden; }
.face { display: grid; grid-template-columns: repeat(3,1fr); grid-template-rows: repeat(3,1fr); gap: 3px; width: 100%; height: 100%; }
.face { background: #0b0b0c; padding: 3px; border-radius: 7px; }
.sticker { border-radius: 4px; position: relative; overflow: hidden; cursor: pointer;
  box-shadow: inset 0 1px 1px rgba(255,255,255,.45), inset 0 -2px 3px rgba(0,0,0,.25); }
.sticker::before { content: ""; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.45), rgba(255,255,255,0) 45%, rgba(0,0,0,.08)); }
.sticker.center { pointer-events: none; }
.sticker.center::after { content: ""; position: absolute; inset: 30%; border-radius: 50%; border: 2px solid rgba(0,0,0,.25); }
.facelabel { text-align: center; font-size: 11px; color: var(--muted); margin: 2px 0 4px; }

.palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 4px 0 6px; }
.swatch { height: 44px; border-radius: 10px; border: 2px solid transparent; position: relative; overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center; cursor: pointer;
  box-shadow: inset 0 1px 1px rgba(255,255,255,.5), inset 0 -3px 6px rgba(0,0,0,.25); }
.swatch::before { content: ""; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.5), rgba(255,255,255,0) 50%); }
.swatch span { position: relative; font-size: 10px; font-weight: 700; color: #111; background: rgba(255,255,255,.7);
  padding: 0 5px; border-radius: 6px; margin-bottom: 3px; }
.swatch.sel { border-color: var(--text); box-shadow: 0 0 0 3px var(--accent); transform: translateY(-2px); }

.sizepick { display: flex; gap: 8px; align-items: center; margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.sizepick .btn { flex: 1; padding: 9px 0; font-size: 15px; }
.sizepick .btn.on { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.viewbtns { display: flex; gap: 6px; justify-content: center; margin: 2px 0 12px; }
.viewbtns .btn { padding: 7px 12px; font-size: 13px; }
.ptitle { font-size: 15px; margin: 0 0 10px; }
.field { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; margin: 8px 0; }
.field select { flex: 0 0 58%; padding: 9px 10px; border-radius: 10px; background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); font-size: 14px; }

/* gaya badan: putih */
:root[data-body="putih"] .c3d-face { background: linear-gradient(145deg, #ffffff 0%, #e4e6ea 55%, #c4c8cf 100%); }
:root[data-body="putih"] .face { background: #e9ebee; }
/* gaya badan: stickerless — plastik berwarna penuh, celah tipis */
:root[data-body="stickerless"] .c3d-face { background: #1a1a1c; }
:root[data-body="stickerless"] .c3d-sticker { inset: 1px; border-radius: 7px; }
:root[data-body="stickerless"] .face { background: #1a1a1c; padding: 1px; gap: 1px; }

.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
button.btn { padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font-size: 14px; font-weight: 600; }
button.btn.primary { background: var(--accent2); border-color: var(--accent2); }
button.btn.primary:disabled { opacity: .5; }
button.btn.ghost { background: transparent; }

.msg { margin-top: 10px; font-size: 13px; padding: 10px; border-radius: 10px; display: none; }
.msg.err { display: block; background: rgba(255,91,110,.12); color: var(--err); border: 1px solid rgba(255,91,110,.3); }
.msg.ok { display: block; background: rgba(46,204,113,.12); color: var(--ok); border: 1px solid rgba(46,204,113,.3); }

/* 3D cube */
.c3d-wrap { display: flex; justify-content: center; padding: 8px 0 4px; }
.c3d-scene {
  width: 240px; height: 240px; perspective: 1000px; touch-action: none; position: relative;
  /* sorot lampu lembut di belakang cube */
  background: radial-gradient(circle at 50% 42%, rgba(120,150,190,.16), transparent 62%);
}
/* bayangan lantai */
.c3d-scene::after {
  content: ""; position: absolute; left: 50%; bottom: 4px; width: 150px; height: 26px; margin-left: -75px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.55), transparent 70%);
  filter: blur(4px); pointer-events: none;
}
.c3d-cube { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform .35s cubic-bezier(.2,.8,.2,1); }
.c3d-cubie, .c3d-pivot { position: absolute; top: 50%; left: 50%; transform-style: preserve-3d; }
.c3d-pivot { width: 0; height: 0; }
.c3d-cubie { margin-left: -23px; margin-top: -23px; }
/* badan plastik hitam, sudut membulat, sedikit kilap */
.c3d-face {
  position: absolute; top: 0; left: 0; border-radius: 7px; backface-visibility: hidden;
  background: linear-gradient(145deg, #2a2a2e 0%, #121214 55%, #050506 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05), inset 0 -2px 4px rgba(0,0,0,.6);
}
/* stiker: inset dari tepi, membulat, kilap seperti stiker vinyl/permukaan stickerless */
.c3d-sticker {
  position: absolute; inset: 3px; border-radius: 6px; overflow: hidden;
  box-shadow: inset 0 1px 1px rgba(255,255,255,.45), inset 0 -2px 3px rgba(0,0,0,.28), 0 0 1px rgba(0,0,0,.8);
}
.c3d-sticker::before { /* lapisan pantulan lingkungan (kaca/plastik licin), kekuatan ikut sudut lampu */
  content: ""; position: absolute; inset: 0; opacity: var(--s, .4);
  background:
    linear-gradient(160deg, rgba(255,255,255,.75) 0%, rgba(255,255,255,.18) 30%, rgba(255,255,255,0) 46%),
    linear-gradient(160deg, rgba(0,0,0,0) 60%, rgba(0,0,0,.18) 100%);
}
.c3d-sticker::after { /* titik kilau (specular) */
  content: ""; position: absolute; top: 8%; left: 10%; width: 40%; height: 20%; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255,255,255,.95), rgba(255,255,255,0) 70%);
  opacity: calc(var(--s, .4) * 1.1); transform: rotate(-18deg);
}
/* pencahayaan dinamis (dihitung di cube3d.js dari arah pandangan) */
.c3d-face { transition: filter .15s linear; }
.c3d-face[data-dir="U"] { filter: brightness(var(--b-U, 1)); --s: var(--s-U); }
.c3d-face[data-dir="D"] { filter: brightness(var(--b-D, .7)); --s: var(--s-D); }
.c3d-face[data-dir="F"] { filter: brightness(var(--b-F, .95)); --s: var(--s-F); }
.c3d-face[data-dir="B"] { filter: brightness(var(--b-B, .8)); --s: var(--s-B); }
.c3d-face[data-dir="R"] { filter: brightness(var(--b-R, .88)); --s: var(--s-R); }
.c3d-face[data-dir="L"] { filter: brightness(var(--b-L, .88)); --s: var(--s-L); }
/* sisi lapisan yang sedang berputar: matikan transisi filter agar tak berkedip */
.c3d-pivot .c3d-face { transition: none; }

/* guide */
.movebig { text-align: center; font-size: 15px; color: var(--muted); margin: 6px 0 2px; }
.movebig b { color: var(--text); font-size: 34px; font-weight: 800; letter-spacing: 1px; }
.movebig .inner { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 8px; font-size: 12px;
  background: rgba(76,154,255,.15); color: var(--accent); border: 1px solid rgba(76,154,255,.35); vertical-align: middle; }
.progress { text-align: center; color: var(--muted); font-size: 12px; }
.controls { display: flex; justify-content: center; gap: 8px; margin: 12px 0; }
.controls button { width: 54px; height: 44px; font-size: 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); }
.controls button.play { background: var(--accent2); border-color: var(--accent2); }
.speed { display: flex; gap: 8px; justify-content: center; align-items: center; color: var(--muted); font-size: 13px; }
.stages { margin-top: 8px; }
.stage { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; overflow: hidden; }
.stage h3 { margin: 0; font-size: 13px; padding: 9px 12px; background: var(--panel2); display: flex; justify-content: space-between; }
.stage .moves { display: flex; flex-wrap: wrap; gap: 5px; padding: 10px 12px; }
.mv { font-family: ui-monospace, monospace; font-size: 14px; padding: 4px 8px; border-radius: 7px; background: #0c1116; border: 1px solid var(--line); min-width: 30px; text-align: center; }
.mv.cur { background: var(--accent2); border-color: var(--accent2); color: #fff; font-weight: 700; }
.mv.past { opacity: .45; }
.empty-note { color: var(--muted); font-size: 13px; text-align: center; padding: 20px; }
