:root {
  --green: #0e4d3c;
  --green-2: #16705a;
  --gold: #d4a73f;
  --gold-soft: #f3e3b5;
  --ink: #1d2422;
  --muted: #5d6b66;
  --paper: #fffdf8;
  --glass: rgba(255, 253, 248, 0.88);
  --radius: 16px;
  --shadow: 0 10px 30px rgba(10, 30, 25, 0.22);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --arab: 'Amiri', 'Traditional Arabic', serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #e9dfcb; font-family: var(--font); color: var(--ink); }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font-family: inherit; }

/* ---------- layar & panel ---------- */
.screen { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(ellipse at center, rgba(14, 77, 60, 0.25), rgba(8, 30, 24, 0.55)); z-index: 20; }
.screen.show { display: flex; }
.panel { width: min(420px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--paper); border-radius: 22px;
  padding: 28px 26px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; border-top: 6px solid var(--gold); }
.panel.center { align-items: center; text-align: center; }
.panel h1 { margin: 4px 0 0; font-size: 26px; color: var(--green); letter-spacing: -0.02em; }
.panel h2 { margin: 0; font-size: 22px; color: var(--green); }
.lead { margin: 0; color: var(--muted); line-height: 1.5; }
.muted { color: var(--muted); margin: 0; }
.note { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.45; }
.error { color: #b42318; font-size: 14px; margin: 0; min-height: 1em; }
.error.ok { color: var(--green-2); }
.logo { width: 54px; height: 60px; background: #111; border-radius: 4px; position: relative; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25); }
.logo span { position: absolute; left: 0; right: 0; top: 16px; height: 7px; background: linear-gradient(90deg, #b8892f, #f0cf73, #b8892f); }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
input[type=email], input[type=password], input:not([type]) {
  font: inherit; font-weight: 500; padding: 12px 14px; border: 1.5px solid #d6d0c2; border-radius: 12px; background: #fff; outline: none; }
input:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(22, 112, 90, 0.15); }
form { display: flex; flex-direction: column; gap: 12px; }
.btn { font-weight: 700; font-size: 15px; border-radius: 12px; padding: 13px 16px; border: 0; cursor: pointer; display: inline-flex;
  justify-content: center; align-items: center; gap: 10px; transition: transform .08s, filter .15s; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.secondary { background: var(--gold-soft); color: #5a4310; }
.btn.ghost { background: transparent; color: var(--green); border: 1.5px solid #d6d0c2; }
.link { color: var(--green-2); font-size: 14px; text-align: center; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: #efe9dc; border-radius: 12px; padding: 4px; margin-bottom: 4px; }
.tabs button { border: 0; background: transparent; padding: 9px; border-radius: 9px; font-weight: 700; color: var(--muted); cursor: pointer; }
.tabs button.active { background: #fff; color: var(--green); box-shadow: 0 2px 6px rgba(0, 0, 0, .08); }
#auth-online { display: flex; flex-direction: column; gap: 12px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: #e0d9ca; }
.gender-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gender-choice { text-align: left; border: 2px solid #e0d9ca; background: #fff; border-radius: 14px; padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.gender-choice b { color: var(--green); font-size: 16px; }
.gender-choice small { color: var(--muted); line-height: 1.35; }
.gender-choice.active { border-color: var(--green-2); background: #eef7f3; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
.glass { background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: var(--radius); box-shadow: var(--shadow); }
#objective { position: absolute; left: 16px; top: 16px; width: min(330px, calc(100vw - 32px)); padding: 14px 16px; border-left: 5px solid var(--gold); }
.step-no { font-size: 12px; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: .06em; }
.step-title { font-size: 18px; font-weight: 800; color: var(--green); margin-top: 2px; }
.step-desc { font-size: 14px; color: var(--ink); margin-top: 4px; line-height: 1.4; }
.progress { height: 5px; background: #e6dfd0; border-radius: 9px; margin-top: 10px; overflow: hidden; }
.bar { height: 100%; background: linear-gradient(90deg, var(--green-2), var(--gold)); transition: width .6s; }
.steps { margin-top: 8px; font-size: 13px; }
.steps summary { cursor: pointer; color: var(--green-2); font-weight: 600; }
.steps ol { margin: 6px 0 0; padding-left: 20px; color: var(--muted); max-height: 40vh; overflow: auto; }
.steps li.done { color: var(--green-2); text-decoration: line-through; }
.steps li.now { color: var(--ink); font-weight: 700; }
#counter { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); padding: 10px 20px; font-weight: 800; font-size: 20px; color: var(--green); border: 2px solid var(--gold); }
#compass { position: absolute; left: 50%; top: 74px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none !important; }
#compass .arrow { width: 30px; height: 38px; background: var(--gold); clip-path: polygon(50% 0, 100% 100%, 50% 74%, 0 100%);
  transition: transform .1s linear; }
#compass { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35)); }
#compass .dist { background: rgba(14, 77, 60, .85); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
#topright { position: absolute; right: 16px; top: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
#minimap { width: 180px; height: 180px; border-radius: 18px; border: 4px solid var(--paper); box-shadow: var(--shadow); background: #ebe5d8; }
#topright .row { display: flex; gap: 8px; }
.icon-btn { border: 0; background: var(--paper); color: var(--green); font-weight: 800; border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); cursor: pointer; font-size: 15px; }
.icon-btn.on, .round.on { background: var(--green); color: #fff; }
#toasts { position: absolute; left: 50%; bottom: 210px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(560px, 92vw); pointer-events: none !important; }
.toast { background: rgba(14, 77, 60, .93); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow); text-align: center; animation: pop .25s ease-out; transition: opacity .5s; line-height: 1.4; }
.toast.warn { background: rgba(180, 35, 24, .95); }
.toast.out { opacity: 0; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
#banner { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(640px, 94vw); padding: 12px 18px; text-align: center; border-top: 4px solid var(--gold); }
#banner .b-title { margin-bottom: 6px; font-size: 12px; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: .06em; }
#banner .ar { font-family: var(--arab); font-size: 26px; line-height: 1.8; color: var(--ink); }
#banner .lat { font-style: italic; font-size: 14px; color: var(--green); }
#banner .arti { font-size: 13px; color: var(--muted); margin-top: 2px; }
#banner .b-note { margin-top: 6px; font-size: 13px; font-weight: 700; color: #8a5a00; }
#prompt { position: absolute; left: 50%; bottom: 170px; transform: translateX(-50%); background: var(--gold); color: #3b2a05; font-weight: 800; padding: 10px 18px; border-radius: 99px; display: flex; gap: 10px; align-items: center; box-shadow: var(--shadow); animation: pulse 1.4s infinite; pointer-events: none !important; }
#prompt kbd { background: #fff; border-radius: 6px; padding: 2px 8px; font-family: inherit; box-shadow: 0 2px 0 #b8892f; }
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.05); } }
#help { position: absolute; left: 16px; bottom: 16px; padding: 8px 12px; font-size: 12px; color: var(--muted); max-width: 46vw; }
.debug-only { display: none; }
body.debug .debug-only { display: inline; }

/* kontrol sentuh */
#joy-zone, #joy-base, #touch-buttons { display: none; }
body.touch #joy-zone { display: block; position: absolute; left: 0; bottom: 0; width: 45vw; height: 55vh; touch-action: none; }
body.touch #joy-base { display: block; position: absolute; width: 120px; height: 120px; border-radius: 50%; background: rgba(255, 255, 255, .25); border: 2px solid rgba(255, 255, 255, .6);
  left: 40px; bottom: 60px; top: auto; opacity: .55; pointer-events: none !important; }
body.touch #joy-base.on { opacity: 1; bottom: auto; }
#joy-knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255, 255, 255, .9); box-shadow: var(--shadow); }
body.touch #touch-buttons { display: grid; position: absolute; right: 16px; bottom: 20px; grid-template-columns: repeat(2, auto); gap: 10px; align-items: end; justify-items: center; }
.round { width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--paper); color: var(--green); font-weight: 800; font-size: 13px; box-shadow: var(--shadow); touch-action: manipulation; }
.round.small { width: 44px; height: 44px; font-size: 22px; }
.round.big { width: 92px; height: 92px; grid-column: span 2; background: #e7dcc1; color: #6b5a33; }
.round.big.ready { background: var(--gold); color: #3b2a05; animation: glow 1.2s infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 10px rgba(212, 167, 63, .35); } }
body.touch #help { display: none; }
body.touch #btn-auto-desk { display: none; }
body.touch #toasts { bottom: 250px; }
body.touch #prompt { bottom: 200px; }
body.touch #banner { bottom: auto; top: 196px; padding: 8px 12px; }
body.touch #banner .arti { font-size: 12px; line-height: 1.35; }
body.touch #banner .lat { font-size: 13px; }

/* ---------- modal & kartu ---------- */
.modal { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(8, 30, 24, .45); }
.card-inner { width: min(640px, 100%); max-height: calc(100vh - 32px); background: var(--paper); border-radius: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; border-top: 6px solid var(--gold); animation: pop .25s ease-out; }
.card-head { padding: 20px 24px 8px; }
.card-badge { font-size: 12px; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: .06em; }
.card-title { margin: 4px 0 0; font-size: 22px; color: var(--green); }
.card-body { padding: 4px 24px 12px; overflow: auto; line-height: 1.6; font-size: 15px; }
.card-body p { margin: 8px 0; }
.card-foot { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-top: 1px solid #ece5d6; background: #faf6ec; }
.card-foot .btn-next { margin-left: auto; }
.card-foot .icon-btn { box-shadow: none; border: 1.5px solid #e0d9ca; padding: 8px 12px; }
.dots { display: flex; gap: 6px; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: #ddd3bd; }
.dots span.on { background: var(--green-2); }
.doa { background: linear-gradient(180deg, #fbf5e6, #fffdf8); border: 1px solid #eadfc2; border-radius: 14px; padding: 14px 16px; margin: 12px 0; text-align: center; }
.doa-title { font-size: 12px; font-weight: 700; color: #8a6a1f; text-transform: uppercase; letter-spacing: .05em; }
.doa .ar { font-family: var(--arab); font-size: 28px; line-height: 2; direction: rtl; margin: 4px 0; color: #111; }
.doa .lat { font-style: italic; color: var(--green); font-weight: 500; }
.doa .arti { color: var(--muted); font-size: 14px; margin-top: 6px; }
.checks { padding-left: 0; list-style: none; margin: 8px 0; }
.checks li { padding: 6px 0 6px 28px; position: relative; border-bottom: 1px dashed #ece5d6; }
.checks li::before { content: '✓'; position: absolute; left: 4px; color: var(--green-2); font-weight: 800; }
.gender-note { background: #eef7f3; border-left: 4px solid var(--green-2); border-radius: 10px; padding: 10px 14px; margin: 12px 0; }
.gender-note p { margin: 4px 0 0; }
.tip { background: #fff6dc; border-radius: 10px; padding: 10px 14px; margin: 10px 0; font-size: 14px; }
.other-note { margin: 10px 0; font-size: 14px; color: var(--muted); }
.other-note summary { cursor: pointer; font-weight: 600; }
.toggle { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }
.toggle input { width: 18px; height: 18px; accent-color: var(--green); }
.certificate { text-align: center; align-items: center; background: linear-gradient(180deg, #fffdf8, #f8f0dc); border: 2px solid var(--gold); }
.certificate .big-name { font-size: 26px; font-weight: 800; color: var(--green); margin: 4px 0; }
.certificate .btn { width: 100%; }

#fade { position: fixed; inset: 0; background: #08201a; opacity: 0; pointer-events: none; transition: opacity .6s; z-index: 40; }
#fade.on { opacity: 1; }

@media (max-width: 640px) {
  #objective { width: calc(100vw - 32px - 120px); padding: 10px 12px; }
  .step-title { font-size: 15px; }
  .step-desc { font-size: 12.5px; }
  #minimap { width: 104px; height: 104px; }
  #counter { top: auto; bottom: 330px; font-size: 16px; }
  #compass { top: auto; bottom: 380px; }
  .doa .ar { font-size: 24px; }
  #banner .ar { font-size: 19px; line-height: 1.6; }
  #objective .steps { display: none; }
}
