/* =============================================================
   Garbarata Simulator — gaya dasar
   ============================================================= */
:root {
  --navy: #0f1f4b;
  --navy-2: #182c63;
  --silver: #c9d1dc;
  --amber: #f2c200;
  --text: #eef2f8;
  --muted: #9fb0cc;
  --danger: #e5484d;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0b1530; color: var(--text); overflow: hidden; }
#app { position: fixed; inset: 0; }
#app canvas { display: block; width: 100%; height: 100%; }

/* ---------- layar pemuatan ---------- */
.loading {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(ellipse at 50% 40%, var(--navy-2), var(--navy) 60%, #070f26);
  transition: opacity .6s ease; z-index: 20;
}
.loading.done { opacity: 0; pointer-events: none; }
.loading-logo { width: 120px; height: auto; filter: drop-shadow(0 6px 24px rgba(0,0,0,.4)); }
.loading-title { letter-spacing: .32em; font-weight: 600; font-size: 15px; color: var(--silver); }
.loading-text { font-size: 13px; color: var(--muted); min-height: 1.2em; }

/* ---------- pemilih kualitas (sementara) ---------- */
.quality {
  position: fixed; right: 16px; bottom: 16px; display: flex; align-items: center; gap: 6px; z-index: 10;
  padding: 6px 8px; border-radius: 10px; background: rgba(10, 20, 48, .72); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.08); font-size: 12px;
}
.quality span { color: var(--muted); margin: 0 4px; }
.quality button {
  font: inherit; color: var(--text); background: transparent; border: 1px solid rgba(255,255,255,.15);
  border-radius: 6px; padding: 4px 10px; cursor: pointer;
}
.quality button.on { background: var(--silver); color: var(--navy); border-color: var(--silver); font-weight: 600; }
.quality button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---------- pesan ---------- */
.toast {
  position: fixed; left: 50%; top: 20px; transform: translateX(-50%); z-index: 30;
  padding: 10px 16px; border-radius: 10px; background: rgba(10, 20, 48, .9); border: 1px solid rgba(255,255,255,.12);
  font-size: 13px; max-width: calc(100vw - 32px);
}
.error {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; z-index: 40;
  padding: 24px; background: var(--navy); font-size: 16px; line-height: 1.6;
}
[hidden] { display: none !important; }

/* =============================================================
   Tahap 2–5: HUD, panel, menu, panduan, hasil, kuis
   ============================================================= */
:root {
  --glass: rgba(10, 18, 42, .78);
  --glass-2: rgba(16, 28, 62, .86);
  --line: rgba(255, 255, 255, .1);
  --ok: #35d07f;
  --warn: #f2c200;
  --info: #7fd8ff;
  --radius: 14px;
}
button { font: inherit; }
.btn {
  appearance: none; border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.06); color: var(--text);
  padding: 10px 16px; border-radius: 10px; cursor: pointer; font-size: 14px; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.3); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.btn.primary { background: linear-gradient(180deg, #f6cf33, #e2ad00); color: #10203f; border-color: transparent; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.kbd { display: inline-block; min-width: 1.6em; padding: 1px 6px; border-radius: 5px; border: 1px solid rgba(255,255,255,.25); border-bottom-width: 2px; font: 600 11px/1.5 ui-monospace, monospace; text-align: center; background: rgba(255,255,255,.06); }

/* ---------- lapisan layar penuh (menu, panduan, hasil, kuis) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 15; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(90deg, rgba(7,14,34,.88), rgba(7,14,34,.55) 55%, rgba(7,14,34,.2));
}
.overlay.dim { background: rgba(5,10,26,.72); backdrop-filter: blur(3px); }
.panel {
  background: var(--glass); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.45);
  backdrop-filter: blur(14px); max-height: calc(100vh - 48px); overflow: auto;
}
.panel h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: .01em; }
.panel h3 { margin: 18px 0 8px; font-size: 15px; color: var(--silver); text-transform: uppercase; letter-spacing: .12em; }
.panel p { color: #c8d2e3; line-height: 1.6; margin: 6px 0; }
.muted { color: var(--muted); }
.eyebrow { font-size: 11px; letter-spacing: .28em; text-transform: uppercase; color: var(--amber); font-weight: 700; }

/* ---------- menu ---------- */
.menu { width: min(460px, 100%); padding: 28px; margin-right: auto; margin-left: 4vw; }
.menu .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.menu .brand img { width: 46px; }
.menu .brand .t1 { font-weight: 800; font-size: 22px; letter-spacing: .04em; }
.menu .brand .t2 { font-size: 12px; color: var(--muted); letter-spacing: .2em; text-transform: uppercase; }
.field { display: grid; gap: 6px; margin: 14px 0; }
.field input { font: inherit; padding: 11px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,.16); background: rgba(0,0,0,.25); color: var(--text); }
.modes { display: grid; gap: 10px; margin: 16px 0; }
.mode {
  text-align: left; display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: center; padding: 14px; border-radius: 12px;
  border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04); color: var(--text); cursor: pointer;
}
.mode:hover { border-color: rgba(242,194,0,.6); background: rgba(242,194,0,.06); }
.mode .ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,.08); font-size: 20px; }
.mode b { display: block; font-size: 15px; }
.mode span { color: var(--muted); font-size: 12.5px; }
.menu-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 8; font-size: 13px; }
.hud > * { pointer-events: auto; }
.hud-card { background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(10px); }
.hud-steps { position: absolute; left: 16px; top: 16px; width: 270px; padding: 12px 14px; max-height: calc(100vh - 240px); overflow: auto; }
.hud-steps .phase { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.chip { font-size: 11px; font-weight: 700; letter-spacing: .14em; padding: 3px 8px; border-radius: 999px; background: rgba(242,194,0,.16); color: var(--amber); text-transform: uppercase; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.steps li { display: grid; grid-template-columns: 18px 1fr; gap: 6px; color: var(--muted); padding: 3px 4px; border-radius: 6px; }
.steps li.done { color: #8fe3b4; }
.steps li.cur { color: var(--text); background: rgba(255,255,255,.07); font-weight: 600; }
.steps li .m::before { content: '○'; }
.steps li.done .m::before { content: '✓'; }
.steps li.cur .m::before { content: '▶'; color: var(--amber); }
.hud-top { position: absolute; top: 16px; right: 16px; display: flex; gap: 8px; align-items: center; }
.hud-top .mode-badge { padding: 8px 12px; font-weight: 700; letter-spacing: .08em; }
.hud-top .timer { padding: 8px 12px; font: 600 14px ui-monospace, monospace; }
.iconbtn { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; color: var(--text); border: 1px solid var(--line); background: var(--glass); font-size: 16px; }
.iconbtn:hover { background: var(--glass-2); }
.hud-msg { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 6px; justify-items: center; max-width: min(560px, calc(100vw - 640px)); min-width: 280px; }
.msg { padding: 9px 14px; border-radius: 10px; background: rgba(140, 30, 20, .82); border: 1px solid rgba(255,120,100,.35); font-weight: 600; text-align: center; }
.msg.info { background: rgba(12, 60, 110, .82); border-color: rgba(127,216,255,.35); }
.coach { padding: 12px 16px; border-radius: 12px; background: rgba(10, 18, 42, .9); border: 1px solid rgba(242,194,0,.45); text-align: left; width: 100%; }
.coach .ct { font-weight: 800; color: var(--amber); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }
.coach .cx { margin-top: 4px; line-height: 1.5; }
.hud-tele { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.tele { padding: 8px 12px; min-width: 104px; }
.tele .k { font-size: 10.5px; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }
.tele .v { font: 700 20px ui-monospace, monospace; margin-top: 2px; }
.tele .v small { font-size: 11px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.tele.good .v { color: var(--ok); } .tele.warn .v { color: var(--warn); } .tele.bad .v { color: #ff6b5f; }
.hud-lamps { position: absolute; left: 16px; bottom: 16px; display: grid; grid-template-columns: repeat(3, auto); gap: 6px; padding: 10px; }
.lamp { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--muted); padding: 4px 8px; border-radius: 8px; background: rgba(255,255,255,.04); }
.lamp i { width: 9px; height: 9px; border-radius: 50%; background: #39424f; }
.lamp.on { color: var(--text); } .lamp.on i { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.lamp.red.on i { background: #ff4b3e; box-shadow: 0 0 10px #ff4b3e; } .lamp.amber.on i { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.pip { position: absolute; right: 16px; bottom: 16px; width: 340px; height: 212px; border-radius: 12px; border: 1px solid rgba(255,255,255,.25); box-shadow: 0 10px 30px rgba(0,0,0,.4); pointer-events: none; }
.pip span { position: absolute; left: 8px; top: 6px; font-size: 10.5px; letter-spacing: .14em; font-weight: 700; background: rgba(0,0,0,.45); padding: 2px 6px; border-radius: 6px; }
.precheck { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, 92vw); padding: 20px; }
.precheck li { list-style: none; display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.precheck li.cur { background: rgba(242,194,0,.1); }
.precheck li .bx { width: 20px; height: 20px; border-radius: 5px; border: 2px solid rgba(255,255,255,.35); display: grid; place-items: center; font-size: 13px; }
.precheck li.ok .bx { border-color: var(--ok); background: var(--ok); color: #082; }
.precheck ul { padding: 0; margin: 10px 0; }
.boardbar { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); width: 360px; padding: 10px 14px; }
.boardbar .bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; margin-top: 6px; }
.boardbar .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #7fd8ff, #35d07f); }
.keyhint { position: absolute; right: 16px; top: 64px; padding: 10px 12px; font-size: 12px; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; }

/* ---------- hasil ---------- */
.results { width: min(760px, 100%); padding: 28px; }
.score-head { display: flex; align-items: center; gap: 22px; }
.grade { width: 96px; height: 96px; border-radius: 22px; display: grid; place-items: center; font: 900 54px/1 system-ui; background: linear-gradient(160deg, #f6cf33, #c98f00); color: #10203f; }
.grade.X, .grade.D { background: linear-gradient(160deg, #ff6b5f, #a5221a); color: #fff; }
.total { font: 800 44px/1 ui-monospace, monospace; }
.parts { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13.5px; }
.parts td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
.parts td:last-child { text-align: right; font-family: ui-monospace, monospace; white-space: nowrap; }
.parts .barc { width: 34%; }
.parts .barc i { display: block; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #7fd8ff, #35d07f); }
.loglist { max-height: 160px; overflow: auto; font: 12px/1.6 ui-monospace, monospace; color: #b9c4d6; background: rgba(0,0,0,.2); padding: 8px 10px; border-radius: 10px; }
.loglist .error { color: #ff8b80; } .loglist .warn { color: var(--warn); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; justify-content: flex-end; }

/* ---------- panduan ---------- */
.guide { width: min(1080px, 100%); height: min(720px, calc(100vh - 48px)); display: grid; grid-template-rows: auto 1fr auto; padding: 0; overflow: hidden; }
.guide-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px 0; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { padding: 8px 12px; border-radius: 10px; color: var(--muted); cursor: pointer; border: 1px solid transparent; background: none; }
.tab.on { color: var(--text); background: rgba(255,255,255,.08); border-color: var(--line); }
.tab b { color: var(--amber); margin-right: 6px; }
.guide-body { overflow: auto; padding: 16px 22px; }
.guide-foot { display: flex; justify-content: space-between; align-items: center; padding: 14px 22px; border-top: 1px solid var(--line); }
.parts-grid { display: grid; grid-template-columns: 240px 1fr; gap: 18px; height: 100%; }
.part-list { display: grid; gap: 4px; align-content: start; }
.part-list button { text-align: left; padding: 9px 12px; border-radius: 9px; border: 1px solid transparent; background: rgba(255,255,255,.03); color: var(--text); cursor: pointer; }
.part-list button.on { border-color: rgba(242,194,0,.6); background: rgba(242,194,0,.08); }
.part-view { position: relative; border-radius: 14px; border: 1px solid var(--line); min-height: 360px; background: transparent; }
.part-desc { position: absolute; left: 12px; right: 12px; bottom: 12px; padding: 14px; border-radius: 12px; background: rgba(8,14,34,.86); border: 1px solid var(--line); }
.ctl-table { width: 100%; border-collapse: collapse; }
.ctl-table td, .ctl-table th { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.ctl-table th { font-size: 11px; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }
.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.rule { padding: 14px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.rule b { display: block; margin-bottom: 4px; } .rule .ri { font-size: 22px; }
.proc { counter-reset: s; display: grid; gap: 8px; padding: 0; }
.proc li { list-style: none; counter-increment: s; display: grid; grid-template-columns: 32px 1fr; gap: 10px; padding: 10px; border-radius: 10px; background: rgba(255,255,255,.03); }
.proc li::before { content: counter(s); width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: rgba(242,194,0,.15); color: var(--amber); font-weight: 800; }
.hotspot { position: fixed; z-index: 16; transform: translate(-50%, -50%); padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; cursor: pointer; background: rgba(242,194,0,.92); color: #10203f; border: none; box-shadow: 0 2px 10px rgba(0,0,0,.4); white-space: nowrap; }
.hotspot.on { background: #fff; }

/* ---------- kuis ---------- */
.quiz { width: min(820px, 100%); padding: 26px; }
.qitem { padding: 14px; border-radius: 12px; background: rgba(255,255,255,.03); border: 1px solid var(--line); margin: 10px 0; }
.qitem .qn { color: var(--amber); font-weight: 800; margin-right: 6px; }
.qopt { display: flex; gap: 10px; align-items: flex-start; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.qopt:hover { background: rgba(255,255,255,.05); }
.qitem.right { border-color: rgba(53,208,127,.5); } .qitem.wrong { border-color: rgba(255,107,95,.5); }
.qopt.correct { background: rgba(53,208,127,.12); } .qopt.picked.incorrect { background: rgba(255,107,95,.14); }
.why { margin-top: 6px; font-size: 13px; color: #b9c4d6; }
.settings { width: min(520px, 100%); padding: 26px; }
.setrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.seg { display: flex; gap: 4px; } .seg .btn.on { background: var(--silver); color: var(--navy); }
.credits { width: min(640px, 100%); padding: 26px; font-size: 13.5px; }
.ghost-label { position: fixed; z-index: 7; pointer-events: none; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(127,216,255,.85); color: #062033; transform: translate(-50%, -100%); }
@media (max-width: 900px) {
  .hud-steps { width: 210px; } .hud-msg { max-width: calc(100vw - 32px); top: 64px; }
  .pip { width: 220px; height: 138px; } .keyhint { display: none; }
  .tele { min-width: 76px; } .tele .v { font-size: 16px; }
}
/* panduan tab 1: panel sempit di kiri, tampilan 3D bebas di kanan */
.overlay.side { justify-content: flex-start; background: linear-gradient(90deg, rgba(7,14,34,.7), rgba(7,14,34,0) 45%); pointer-events: none; }
.overlay.side .panel { pointer-events: auto; }
.guide.narrow { width: min(430px, 100%); backdrop-filter: blur(8px); }
.guide.narrow .tabs { display: grid; grid-template-columns: 1fr 1fr; }
.guide.narrow .part-list { grid-template-columns: 1fr 1fr; margin-top: 12px; }
.part-desc2 { padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.05); border: 1px solid var(--line); }
