/* Sayap Nusantara: pemandangan 3D memenuhi skrin, HUD gaya kokpit kaca terapung di atasnya. */
:root {
  --night: #0b1a2c;
  --panel: rgba(8, 20, 34, .62);
  --panel-solid: rgba(10, 24, 40, .94);
  --line: rgba(170, 220, 255, .22);
  --ink: #f2f7fb;
  --ink-2: #b6c8d6;
  --hud: #7cf3c8;
  --gold: #ffc65a;
  --gold-ink: #2b1c00;
  --blue: #6cc4ff;
  --danger: #ff7a6b;
  --display: "Chakra Petch", "Trebuchet MS", system-ui, sans-serif;
  --body: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gl: max(16px, env(safe-area-inset-left, 0px));
  --gr: max(16px, env(safe-area-inset-right, 0px));
  --gt: max(12px, env(safe-area-inset-top, 0px));
  --gb: max(14px, env(safe-area-inset-bottom, 0px));
  color-scheme: dark;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: var(--night); color: var(--ink); font: 16px/1.5 var(--body); -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#app { position: fixed; inset: 0; overflow: hidden; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
h1, h2 { font-family: var(--display); margin: 0; line-height: 1.05; text-wrap: balance; }
p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.eyebrow { font: 700 13px/1.2 var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin: 0; }
.eyebrow.danger { color: var(--danger); }

.btn { border: 0; border-radius: 12px; padding: 12px 20px; min-height: 48px; font-weight: 800; background: var(--gold); color: var(--gold-ink); }
.btn.alt { background: rgba(255, 255, 255, .06); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.col { display: grid; gap: 10px; margin-top: 18px; }

/* ---------- Overlay & kad ---------- */
.overlay { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: var(--gt) var(--gr) var(--gb) var(--gl); background: radial-gradient(120% 90% at 50% 40%, rgba(5, 14, 26, .35), rgba(5, 14, 26, .78)); overflow-y: auto; }
.overlay.soft { background: rgba(5, 10, 18, .45); }
.card { width: min(440px, 100%); background: var(--panel-solid); border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: 0 30px 80px rgba(0, 0, 0, .45); backdrop-filter: blur(10px); }
.card.wide { width: min(560px, 100%); }
.card h2 { font-size: 28px; margin: 6px 0 10px; }
.card p { color: var(--ink-2); }
.progress { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .12); overflow: hidden; margin-top: 14px; }
.progress i { display: block; height: 100%; width: 0; background: var(--hud); transition: width .2s; }

/* Menu utama: teks di kiri, langit 3D kelihatan di belakang */
#menu { place-items: center start; background: linear-gradient(90deg, rgba(5, 14, 26, .86) 0%, rgba(5, 14, 26, .55) 45%, rgba(5, 14, 26, 0) 75%); }
.menu-inner { width: min(560px, 100%); padding: 24px 0; }
.menu-inner h1 { font-size: clamp(44px, 9vw, 76px); letter-spacing: -.01em; margin: 8px 0 12px; text-shadow: 0 4px 30px rgba(0, 0, 0, .4); }
.lede { color: var(--ink-2); font-size: 17px; max-width: 46ch; margin-bottom: 22px; }
.back { display: inline-block; color: var(--ink-2); text-decoration: none; font-weight: 700; margin-bottom: 26px; padding: 8px 0; }
.chapters { display: grid; gap: 10px; margin-bottom: 16px; }
.chap { display: grid; grid-template-columns: 48px 1fr auto; gap: 14px; align-items: center; text-align: left; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: rgba(10, 24, 40, .72); min-height: 64px; }
.chap:hover:not(:disabled) { border-color: var(--gold); }
.chap:disabled { opacity: .5; cursor: not-allowed; }
.chap .num { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font: 700 22px var(--display); background: rgba(255, 198, 90, .14); color: var(--gold); }
.chap b { display: block; font-family: var(--display); font-size: 18px; line-height: 1.2; }
.chap small { color: var(--ink-2); font-size: 14px; line-height: 1.35; display: block; }
.chap .st { font-size: 15px; color: var(--gold); letter-spacing: 2px; white-space: nowrap; }

.stars { font-size: 38px; letter-spacing: 6px; color: var(--gold); margin: 6px 0 4px; }
.stars .off { color: rgba(255, 255, 255, .18); }
.stats { display: flex; gap: 28px; margin: 8px 0 12px; }
.stats dt { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2); }
.stats dd { margin: 0; font: 700 24px var(--display); }

.opt { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.opt input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--gold); flex: none; }
.opt b { display: block; }
.opt small { color: var(--ink-2); }
#settings .btn { margin-top: 18px; width: 100%; }
.keys p { margin: 6px 0; color: var(--ink); }
kbd { display: inline-block; min-width: 28px; padding: 2px 7px; margin-right: 4px; border-radius: 6px; background: rgba(255, 255, 255, .1); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .35); font: 700 13px var(--display); text-align: center; color: var(--ink); }
.tip { margin-top: 10px !important; font-size: 15px; }
.tip b { color: var(--ink); }
#help .btn { margin-top: 18px; width: 100%; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; font-family: var(--display); color: var(--hud); text-shadow: 0 1px 6px rgba(0, 0, 0, .5); }
#hud button { pointer-events: auto; }
.objective { position: absolute; left: var(--gl); top: var(--gt); max-width: min(340px, 52vw); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; backdrop-filter: blur(6px); color: var(--ink); font-family: var(--body); }
.objective b { display: block; font: 700 17px/1.25 var(--display); }
.objective small { display: block; color: var(--ink-2); font-size: 13px; }
.objective .progress { margin-top: 8px; }

#compass { position: absolute; top: var(--gt); left: 50%; transform: translateX(-50%); width: 280px; height: 32px; }
.gauge { position: absolute; top: 50%; transform: translateY(-50%); min-width: 104px; padding: 8px 12px; border: 1px solid rgba(124, 243, 200, .35); border-radius: 10px; background: rgba(4, 16, 22, .35); text-align: center; }
.gauge.left { left: var(--gl); }
.gauge.right { right: var(--gr); }
.gauge small { display: block; font-size: 11px; letter-spacing: .14em; opacity: .8; }
.gauge b { display: block; font-size: 34px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.gauge span { font-size: 12px; opacity: .85; white-space: nowrap; }
.warn { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); font-size: 22px; font-weight: 700; letter-spacing: .12em; color: #ffd166; background: rgba(60, 20, 0, .45); padding: 6px 16px; border-radius: 8px; border: 1px solid rgba(255, 209, 102, .6); animation: blink 0.8s steps(2) infinite; }
.warn.red { color: var(--danger); border-color: rgba(255, 122, 107, .7); }
@keyframes blink { 50% { opacity: .35; } }
.throttle { position: absolute; left: 50%; bottom: var(--gb); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: rgba(4, 16, 22, .35); border-radius: 10px; border: 1px solid rgba(124, 243, 200, .25); }
.throttle small { font-size: 11px; letter-spacing: .14em; }
.throttle .bar { width: 140px; height: 8px; border-radius: 4px; background: rgba(124, 243, 200, .15); overflow: hidden; }
.throttle .bar i { display: block; height: 100%; width: 0; background: var(--hud); }
.throttle b { min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
#minimap { position: absolute; right: var(--gr); bottom: var(--gb); width: 150px; height: 150px; border-radius: 50%; border: 1.5px solid rgba(124, 243, 200, .45); box-shadow: 0 6px 24px rgba(0, 0, 0, .35); pointer-events: auto; cursor: zoom-in; }
#bigmap { z-index: 25; }
.mapcard { width: min(92vw, calc(100dvh - 120px)); max-width: 900px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 18px; padding: 12px; box-shadow: 0 30px 80px rgba(0, 0, 0, .45); }
.maphead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 2px 10px; font-family: var(--display); font-size: 18px; }
#mapCanvas { display: block; width: 100%; height: auto; aspect-ratio: 1; border-radius: 12px; cursor: zoom-out; touch-action: none; }
.maphint { margin: 8px 2px 0; font-size: 13px; color: var(--ink-2); text-align: center; }
.marker { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.marker i { position: absolute; left: -11px; top: -11px; width: 22px; height: 22px; border: 2.5px solid var(--gold); transform: rotate(45deg); border-radius: 3px; box-shadow: 0 0 12px rgba(255, 198, 90, .6); }
.marker.edge i { border-width: 0; width: 0; height: 0; left: -10px; top: -14px; transform: rotate(var(--a, 0deg)); border-left: 10px solid transparent; border-right: 10px solid transparent; border-bottom: 22px solid var(--gold); border-radius: 0; box-shadow: none; transform-origin: 10px 14px; }
.marker span { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); white-space: nowrap; font-size: 14px; font-weight: 700; color: var(--gold); }
.topbtns { position: absolute; right: var(--gr); top: var(--gt); display: flex; gap: 8px; }
.icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); backdrop-filter: blur(6px); padding: 0; }
.icon svg { width: 22px; height: 22px; }
.icon.muted #muteWave { opacity: .15; }

/* Kawalan sentuh */
#touch { position: absolute; inset: 0; pointer-events: none; }
.stick { position: absolute; left: calc(var(--gl) + 8px); bottom: calc(var(--gb) + 8px); width: 150px; height: 150px; border-radius: 50%; background: rgba(255, 255, 255, .06); border: 1.5px solid rgba(255, 255, 255, .22); pointer-events: auto; touch-action: none; }
.stick i { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; background: rgba(255, 255, 255, .22); border: 2px solid rgba(255, 255, 255, .5); }
.tright { position: absolute; right: calc(var(--gr) + 4px); bottom: calc(var(--gb) + 8px); display: flex; align-items: flex-end; gap: 10px; pointer-events: none; }
.tbtn { pointer-events: auto; min-width: 72px; min-height: 52px; border-radius: 14px; border: 1.5px solid rgba(255, 255, 255, .3); background: rgba(10, 24, 40, .6); font: 700 13px var(--display); letter-spacing: .08em; color: var(--ink); touch-action: none; }
.tbtn.on { background: rgba(255, 198, 90, .3); border-color: var(--gold); }
#btnDrop { background: rgba(255, 198, 90, .85); color: var(--gold-ink); border-color: var(--gold); }
.slider { position: relative; width: 64px; height: 170px; border-radius: 18px; background: rgba(255, 255, 255, .06); border: 1.5px solid rgba(255, 255, 255, .22); pointer-events: auto; touch-action: none; }
.slider i { position: absolute; left: 6px; right: 6px; height: 40px; bottom: 6px; border-radius: 12px; background: rgba(124, 243, 200, .45); border: 2px solid var(--hud); }
.slider small { position: absolute; left: 50%; top: -20px; transform: translateX(-50%); font-size: 10px; letter-spacing: .1em; color: var(--ink-2); }
body.touch #minimap { top: calc(var(--gt) + 56px); bottom: auto; width: 110px; height: 110px; }
body.touch .throttle { display: none; }
body.touch .gauge { top: auto; bottom: calc(var(--gb) + 190px); transform: none; min-width: 84px; padding: 6px 10px; }
body.touch .gauge b { font-size: 26px; }

/* Dialog radio */
#dialog { position: absolute; z-index: 15; left: 50%; bottom: calc(var(--gb) + 56px); transform: translateX(-50%); width: min(620px, calc(100% - 32px)); display: grid; grid-template-columns: 52px 1fr 14px; gap: 14px; align-items: start; padding: 14px 16px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 50px rgba(0, 0, 0, .4); cursor: pointer; animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }
.avatar { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font: 700 18px var(--display); color: #08131f; background: var(--gold); }
#dlgName { display: block; font-family: var(--display); font-size: 15px; letter-spacing: .04em; }
#dlgName small { font-family: var(--body); font-weight: 400; color: var(--ink-2); margin-left: 6px; }
#dlgText { color: var(--ink); font-size: 16px; line-height: 1.45; min-height: 2.9em; }
.dlg-next { color: var(--gold); align-self: end; animation: blink 1s steps(2) infinite; }
body.touch #dialog { top: calc(var(--gt) + 64px); bottom: auto; }

#flash { position: absolute; inset: 0; pointer-events: none; background: #fff; opacity: 0; z-index: 12; }

@media (max-width: 900px) {
  #compass { top: calc(var(--gt) + 84px); left: var(--gl); transform: none; width: 200px; height: 23px; }
}
@media (max-height: 480px) {
  #dialog { grid-template-columns: 40px 1fr 12px; padding: 10px 12px; gap: 10px; width: min(520px, calc(100% - 340px)); bottom: calc(var(--gb) + 46px); }
  .avatar { width: 40px; height: 40px; font-size: 15px; }
  #dlgText { font-size: 14px; min-height: 0; }
  body.touch #dialog { top: var(--gt); left: 50%; width: min(420px, calc(100% - 420px)); min-width: 260px; }
}
@media (max-width: 640px) {
  .objective { max-width: calc(100% - 180px); padding: 8px 12px; }
  .objective b { font-size: 15px; }
  .menu-inner h1 { font-size: 46px; }
  #menu { background: linear-gradient(180deg, rgba(5, 14, 26, .55), rgba(5, 14, 26, .88)); }
}
@media (prefers-reduced-motion: reduce) {
  .warn, .dlg-next { animation: none; }
  #dialog { animation: none; }
}

/* tinjauan kepulauan */
#tour { position: absolute; left: 0; right: 0; bottom: max(var(--gb), 24px); z-index: 18; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; font-family: var(--display); color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, .65); text-align: center; padding: 0 16px; }
#tour[hidden] { display: none; }
#tour .eyebrow { margin: 0; letter-spacing: .14em; text-transform: uppercase; font-size: 12px; opacity: .85; }
#tour h2 { margin: 0; font-size: clamp(26px, 6vw, 44px); }
#tour .tour-left { margin: 0 0 8px; font-size: 15px; opacity: .85; }
#tour button { pointer-events: auto; }

/* kemas kini terbaru */
#news .card { max-height: calc(100vh - 32px); overflow-y: auto; }
#news ul.news { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 9px; color: var(--ink-2); line-height: 1.45; }
#news ul.news b { color: var(--ink, #fff); }
#news .btn { margin-top: 18px; width: 100%; }
