/* Kurir Alpha: token warna & kaca disalin dari ../style.css supaya tampilannya serumpun. */
:root {
  --ink: #173d42;
  --ink-2: #4f6c70;
  --ink-3: #7d9497;
  --paper: rgba(255, 250, 241, 0.93);
  --paper-solid: #fffaf1;
  --line: rgba(23, 61, 66, 0.12);
  --teal: #0f5c63;
  --teal-2: #13797f;
  --sun: #f08a3c;
  --sun-soft: #fde6d2;
  --red: #d6453d;
  --shadow: 0 10px 30px rgba(9, 38, 48, 0.18), 0 2px 6px rgba(9, 38, 48, 0.08);
  --r: 18px;
  --gut: 16px;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #3b9dc6; overscroll-behavior: none; }
body { -webkit-font-smoothing: antialiased; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#map { position: fixed; inset: 0; display: block; touch-action: none; }

.glass {
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.kicker { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--sun); }
kbd { font: inherit; font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: rgba(15, 92, 99, 0.09); border: 1px solid rgba(15, 92, 99, 0.12); }
.btn {
  border: 0; border-radius: 999px; padding: 11px 18px; font-weight: 800; font-size: 14px; background: var(--teal); color: #fff;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
}
.btn.big { font-size: 16px; padding: 12px 28px; min-height: 48px; background: var(--sun); color: var(--ink); box-shadow: 0 6px 16px rgba(240, 138, 60, 0.35); }
.btn.ghost { background: rgba(15, 92, 99, 0.08); color: var(--ink); }
.btn:hover { filter: brightness(1.06); }
.btn:focus-visible, .icon-btn:focus-visible, .link:focus-visible { outline: 3px solid var(--teal-2); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.avatar {
  --h: 180;
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: hsl(var(--h) 55% 46%); color: #fff; font-weight: 800; font-size: 14px; letter-spacing: 0.02em;
}

/* ---------- HUD atas ---------- */
.g-top {
  position: fixed; top: calc(var(--gut) + env(safe-area-inset-top)); left: var(--gut); right: var(--gut);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none;
}
.g-top > * { pointer-events: auto; }
/* stats boleh menyempit (terpotong) tapi tidak pernah mendorong tombol jeda keluar layar */
.stats { display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 999px; min-width: 0; overflow: hidden; }
.st { position: relative; display: flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.st svg { width: 18px; height: 18px; color: var(--teal); flex: none; }
.st b { font-weight: 800; font-size: 18px; letter-spacing: -0.01em; line-height: 1; }
.st .lbl { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.st + .st { border-left: 1px solid var(--line); border-radius: 0; }
.st-time b { min-width: 42px; }
.st-time.low { color: var(--red); animation: pulse 0.9s ease-in-out infinite; }
.st-time.low svg { color: var(--red); }
.st-combo { color: var(--ink-2); }
.st-combo.on { background: var(--sun); color: var(--ink); border-radius: 999px; border-left-color: transparent; }
.st-combo.on .lbl { color: var(--ink); }
.st.bump b { animation: bump 0.35s ease-out; }
/* di dalam .g-top (bukan di dalam .stats yang overflow: hidden) */
.plus {
  position: absolute; left: 8px; top: calc(100% + 8px); font-style: normal; font-size: 12px; font-weight: 800; color: #fff; white-space: nowrap;
  background: var(--teal); padding: 3px 9px; border-radius: 999px; opacity: 0; pointer-events: none;
}
.plus.show { animation: plus 1.1s ease-out; }
@keyframes pulse { 50% { opacity: 0.55; } }
@keyframes bump { 40% { transform: scale(1.25); } }
@keyframes plus { 0% { opacity: 0; transform: translateY(-6px); } 15% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(4px); } }

.g-btns { display: flex; gap: 8px; flex: none; }
.icon-btn { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; padding: 0; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .mute { display: none; }
.icon-btn.off .on { display: none; }
.icon-btn.off .mute { display: block; }

/* ---------- kartu paket ---------- */
.pkg {
  position: fixed; left: var(--gut); bottom: calc(var(--gut) + env(safe-area-inset-bottom)); width: 330px; max-width: calc(100vw - 2 * var(--gut));
  border-radius: var(--r); padding: 14px 14px 12px; pointer-events: none;
}
.pkg.pop { animation: rise 0.3s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.pkg-head { display: flex; align-items: center; gap: 11px; }
.pkg-who { flex: 1; min-width: 0; }
.pkg-handle { font-weight: 800; font-size: 17px; letter-spacing: -0.01em; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pkg-name { font-size: 12.5px; color: var(--ink-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pkg-dist { text-align: right; flex: none; }
.pkg-dist b { display: block; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--teal); }
.pkg-dist span { font-size: 11px; color: var(--ink-3); font-weight: 600; }
.pkg-addr { display: flex; align-items: center; gap: 6px; margin-top: 10px; padding: 8px 10px; border-radius: 12px; background: var(--sun-soft); font-weight: 700; font-size: 13.5px; }
.pkg-addr svg { width: 16px; height: 16px; color: var(--sun); flex: none; }
.pkg-addr span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pkg-foot { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.pkg-bar { flex: 1; height: 5px; border-radius: 99px; background: rgba(23, 61, 66, 0.1); overflow: hidden; }
.pkg-bar i { display: block; height: 100%; width: 100%; background: var(--teal-2); border-radius: inherit; transition: width 0.15s linear; }
.pkg-bar-l { flex: none; font-size: 11.5px; color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }

/* tanpa paket aktif (warga sangat sedikit) */
.note {
  position: fixed; left: var(--gut); bottom: calc(var(--gut) + env(safe-area-inset-bottom)); width: 330px; max-width: calc(100vw - 2 * var(--gut));
  border-radius: var(--r); padding: 12px 14px; font-weight: 700; font-size: 14px; pointer-events: none;
}

/* ---------- peta mini ---------- */
.mini { position: fixed; right: var(--gut); bottom: calc(var(--gut) + env(safe-area-inset-bottom)); width: 216px; height: 118px; border-radius: 16px; padding: 4px; pointer-events: none; }
.mini canvas { display: block; width: 100%; height: 100%; }

/* ---------- petunjuk awal ---------- */
.hint {
  position: fixed; left: 50%; top: 50%; translate: -50% 60px; padding: 9px 16px; border-radius: 999px; max-width: calc(100vw - 32px);
  font-weight: 700; font-size: 14px; text-align: center; width: max-content; pointer-events: none; animation: rise 0.3s ease-out;
}

/* ---------- D-pad (layar sentuh) ---------- */
.pad { display: none; }
body.touch .pad {
  display: flex; position: fixed; left: var(--gut); right: var(--gut); bottom: calc(var(--gut) + env(safe-area-inset-bottom));
  justify-content: space-between; align-items: flex-end; pointer-events: none;
}
.pad > * { pointer-events: auto; }
.dpad { display: grid; grid-template-columns: repeat(2, 60px); gap: 8px; }
.dpad button, .brake {
  width: 60px; height: 60px; border-radius: 18px; border: 1px solid rgba(255, 255, 255, 0.8); display: grid; place-items: center;
  background: var(--paper); box-shadow: var(--shadow); color: var(--teal); touch-action: none;
}
.dpad button svg { width: 26px; height: 26px; stroke-width: 2.4; }
.dpad [data-dir='up'] svg { transform: rotate(-26.57deg); }
.dpad [data-dir='right'] svg { transform: rotate(26.57deg); }
.dpad [data-dir='down'] svg { transform: rotate(153.43deg); }
.dpad [data-dir='left'] svg { transform: rotate(-153.43deg); }
.dpad button.on, .brake.on { background: var(--teal); color: #fff; transform: scale(0.96); }
.brake { width: 72px; height: 72px; border-radius: 50%; font-weight: 800; font-size: 15px; color: var(--red); }
.brake.on { background: var(--red); }
.touch-only { display: none; }
body.touch .touch-only { display: list-item; }
body.touch .kbd-only { display: none; }
/* layar sentuh: diagram tanpa huruf W/A/S/D, panah diputar searah jalan (sama dengan D-pad) */
body.touch .diagram .k-tx { display: none; }
body.touch .diagram .k-ar { transform-box: fill-box; transform-origin: center; }
body.touch .diagram .k-v { transform: translateX(15px) rotate(63.43deg); }
body.touch .diagram .k-h { transform: translateX(15px) rotate(26.57deg); }

/* ---------- notifikasi ---------- */
.toasts { position: fixed; top: 84px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(380px, calc(100vw - 2 * var(--gut))); pointer-events: none; z-index: 20; }
.toast { display: flex; align-items: center; gap: 12px; padding: 9px 12px 9px 12px; border-radius: 16px; font-size: 14px; animation: rise 0.25s ease-out; }
.toast .ic { width: 32px; height: 32px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; flex: none; }
.toast .ic svg { width: 18px; height: 18px; }
.toast .tx { flex: 1; line-height: 1.35; word-break: break-word; }
.toast .tx small { display: block; color: var(--ink-2); font-size: 12px; }
.toast.out { opacity: 0; transform: translateY(-6px); transition: 0.3s; }

/* ---------- layar ---------- */
.screen {
  position: fixed; inset: 0; z-index: 10; display: grid; padding: var(--gut);
  background: radial-gradient(ellipse at center, rgba(9, 38, 48, 0.12), rgba(9, 38, 48, 0.42)); overflow: auto; touch-action: pan-y;
}
.sheet { position: relative; margin: auto; width: 100%; max-width: 520px; border-radius: 24px; padding: 24px; background: var(--paper-solid); animation: rise 0.25s ease-out; }
.sheet.small { max-width: 400px; text-align: center; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 46px; height: 46px; flex: none; }
.sheet h1 { margin: 2px 0 0; font-size: 28px; line-height: 1.05; letter-spacing: -0.02em; }
.sheet h2 { margin: 4px 0 0; font-size: 24px; letter-spacing: -0.02em; }
.lead { color: var(--ink-2); line-height: 1.5; margin: 12px 0 0; font-size: 14.5px; }
.howto { margin: 14px 0 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 8px; }
.howto li { counter-increment: s; display: flex; gap: 10px; align-items: flex-start; line-height: 1.45; font-size: 14px; }
.warn-mark { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--red); color: #fff; font-size: 12px; vertical-align: 1px; }
.howto li::before { content: counter(s); flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--teal); color: #fff; font-weight: 800; font-size: 12px; display: grid; place-items: center; margin-top: -1px; }
.controls { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding: 12px; border-radius: 16px; background: rgba(15, 92, 99, 0.06); }
.diagram { width: 190px; flex: none; height: auto; stroke: none; }
.keys { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); line-height: 1.4; }
.keys li { list-style: none; }
.best { margin-top: 14px; font-size: 14px; color: var(--ink-2); }
.best b { color: var(--ink); font-weight: 800; }
.row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; align-items: center; }
.sheet.small .row { justify-content: center; }
.link { display: inline-block; margin-top: 14px; color: var(--teal); font-weight: 700; font-size: 14px; text-decoration: none; padding: 6px 4px; }
.link:hover { text-decoration: underline; }
.score-big { margin-top: 16px; padding: 16px; border-radius: 18px; background: var(--sun-soft); display: grid; justify-items: center; gap: 2px; }
.score-big span { font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.score-big b { font-size: 46px; line-height: 1; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.record { margin-top: 6px; font-style: normal; font-weight: 800; font-size: 13px; color: var(--ink); background: var(--sun); padding: 4px 12px; border-radius: 999px; animation: bump 0.6s ease-out 0.2s; }
.end-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 0; }
.end-stats div { padding: 8px 4px; border-radius: 12px; background: rgba(15, 92, 99, 0.06); }
.end-stats dt { font-size: 11px; color: var(--ink-2); font-weight: 600; }
.end-stats dd { margin: 2px 0 0; font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; }
.share-msg { margin: 10px 0 0; min-height: 1em; font-size: 13px; font-weight: 600; color: var(--teal); }
.share-msg:empty { display: none; }
.share-out textarea {
  display: block; width: 100%; margin-top: 8px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: #fff;
  font: inherit; font-size: 13px; color: var(--ink); resize: none; -webkit-user-select: text; user-select: text;
}

/* HUD disembunyikan di layar mulai */
body[data-phase='start'] .stats, body[data-phase='start'] .pkg, body[data-phase='start'] .pad, body[data-phase='start'] .mini { visibility: hidden; }
body[data-phase='end'] .pad, body[data-phase='start'] #btn-pause, body[data-phase='end'] #btn-pause { visibility: hidden; }

/* ---------- layar kecil ---------- */
@media (max-width: 720px) {
  :root { --gut: 10px; }
  .stats { gap: 0; padding: 4px; }
  .g-top { gap: 8px; }
  .st { padding: 6px 5px; gap: 3px; }
  .st b { font-size: 15px; }
  .st svg { width: 15px; height: 15px; }
  .st .lbl { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .st-time b { min-width: 34px; }
  .st-combo:not(.on) { display: none; } /* x1 tidak perlu makan tempat */
  .note { top: calc(68px + env(safe-area-inset-top)); bottom: auto; left: var(--gut); right: var(--gut); width: auto; font-size: 13px; padding: 10px 12px; }
  .icon-btn { width: 44px; height: 44px; }
  .pkg { top: calc(68px + env(safe-area-inset-top)); bottom: auto; left: var(--gut); right: var(--gut); width: auto; padding: 10px 12px; }
  .pkg .kicker { display: none; }
  .pkg-handle { font-size: 15px; }
  .avatar { width: 34px; height: 34px; font-size: 12px; }
  .pkg-addr { margin-top: 7px; padding: 6px 9px; font-size: 12.5px; }
  .pkg-foot { margin-top: 7px; }
  .pkg-bar-l { font-size: 11px; }
  .mini { width: 132px; height: 74px; border-radius: 12px; padding: 3px; }
  body.touch .mini { bottom: calc(var(--gut) + 84px + env(safe-area-inset-bottom)); }
  .toasts { top: auto; bottom: calc(180px + env(safe-area-inset-bottom)); }
  body:not(.touch) .toasts { bottom: 110px; }
  .hint { font-size: 13px; translate: -50% 50px; border-radius: 16px; }
  .sheet { padding: 18px; border-radius: 20px; }
  .sheet h1 { font-size: 24px; }
  .controls { flex-direction: column; align-items: stretch; gap: 8px; }
  .diagram { width: 170px; align-self: center; }
  .end-stats { grid-template-columns: repeat(2, 1fr); }
  .score-big b { font-size: 40px; }
}
@media (max-width: 360px) {
  .st { padding: 6px 4px; }
  .st svg { width: 14px; height: 14px; }
  .dpad { grid-template-columns: repeat(2, 54px); }
  .dpad button { width: 54px; height: 54px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
