:root {
  --ink: #27231d;
  --glass: rgba(255, 255, 255, 0.26);
  --glass-line: rgba(255, 255, 255, 0.5);
  --glass-active: rgba(255, 255, 255, 0.9);
  --active-ink: #27231d;
  --glow: rgba(255, 255, 255, 0.35);
  --ease: cubic-bezier(.22, .61, .36, 1);
}

body[data-mode="night"],
body[data-mode="dusk"] {
  --ink: #f3f0e6;
  --glass: rgba(16, 24, 46, 0.36);
  --glass-line: rgba(255, 255, 255, 0.16);
  --glass-active: rgba(240, 243, 255, 0.92);
  --glow: rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; }

html,
body { height: 100%; }

body {
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #cfe0f2;
  color: var(--ink);
  overflow: hidden;
  cursor: grab;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: color .9s var(--ease);
}

body.grabbing { cursor: grabbing; }

button { font: inherit; color: inherit; cursor: pointer; }

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Cheap "lens": a soft vignette and a whisper of film grain over the scene. */
.lens,
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.lens { background: radial-gradient(ellipse 80% 70% at 50% 45%, transparent 55%, rgba(10, 16, 12, .32) 100%); }

/* Grey noise baked into the tile itself (feColorMatrix), plain alpha: no per-frame blend/filter pass. */
.grain {
  opacity: .045;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.veil {
  position: fixed;
  inset: 0;
  background: #e8eee9;
  pointer-events: none;
  transition: opacity 1.4s var(--ease);
  z-index: 50;
}

body[data-mode="night"] .veil { background: #0b1226; }
body[data-mode="dusk"] .veil { background: #5a3f4e; }
body.ready .veil { opacity: 0; }

/* ---------- brand ---------- */
.brand {
  position: fixed;
  inset: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: clamp(22px, 4vh, 40px) 16px;
  pointer-events: none;
  z-index: 10;
}

.brand-row { display: flex; align-items: center; gap: 10px; }

.tagline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: clamp(.78rem, 1.05vw, .9rem);
  font-weight: 500;
  letter-spacing: .02em;
  opacity: .82;
  text-shadow: 0 1px 14px var(--glow);
}

/* A small "work in progress" light. */
.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f2b33d;
  box-shadow: 0 0 0 0 rgba(242, 179, 61, .55);
  animation: pulse 2.4s ease-out infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(242, 179, 61, .55); }
  70%, 100% { box-shadow: 0 0 0 7px rgba(242, 179, 61, 0); }
}

@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

.brand svg { width: 26px; height: 26px; color: #5f9e2c; }

.brand h1 {
  font-size: clamp(1.4rem, 2.6vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1;
  text-shadow: 0 2px 24px var(--glow);
}

.brand h1 span { font-weight: 400; }

/* ---------- dock ---------- */
.seg,
.sound {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  transition: background .9s, border-color .9s, color .9s;
}

.dock {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
}

.seg { display: flex; padding: 3px; border-radius: 999px; }

.seg button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 7px 14px 7px 11px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  transition: background .35s var(--ease), color .35s var(--ease);
}

.seg button[aria-checked="true"] { background: var(--glass-active); color: var(--active-ink); box-shadow: 0 2px 10px rgba(0, 0, 0, .08); }

.seg svg,
.sound svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sound {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink);
}

.sound:hover { background: var(--glass-active); color: var(--active-ink); }
.sound .on,
.sound[aria-pressed="true"] .off { display: none; }
.sound[aria-pressed="true"] .on { display: block; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* ---------- fallbacks ---------- */
body.no-webgl {
  background:
    radial-gradient(ellipse 70% 30% at 50% 100%, #5d8f2c 0 60%, transparent 61%),
    linear-gradient(#3b78d6, #cfe0f2 70%, #7aa53a 70%, #3f6d1f);
}

/* ---------- tombol aplikasi (di bawah judul) ---------- */
.apps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 760px;
  margin-top: 10px;
  pointer-events: auto;
}

.app {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px 8px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: 0 4px 18px rgba(0, 0, 0, .08);
  cursor: pointer;
  transition: background .35s var(--ease), color .35s var(--ease), transform .35s var(--ease), border-color .9s;
}

.app svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app:hover,
.app:focus-visible { background: var(--glass-active); color: var(--active-ink); transform: translateY(-1px); }

@media (max-width: 520px) {
  .apps { display: grid; grid-template-columns: 1fr 1fr; width: 100%; max-width: 340px; gap: 7px; }
  .app { justify-content: center; padding: 9px 10px; font-size: 12.5px; }
}

/* ---------- portal: pintu kecil ke HalloMin (kanan atas) ---------- */
.portal {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 11;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px 7px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .01em;
  color: var(--ink);
  text-decoration: none;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: 0 4px 18px rgba(0, 0, 0, .08);
  overflow: hidden;
  isolation: isolate;
  opacity: .8;
  cursor: pointer;
  transition: background .35s var(--ease), color .35s var(--ease), opacity .35s var(--ease), transform .35s var(--ease), border-color .9s;
}

.portal svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.portal .arrow { width: 11px; height: 11px; opacity: .65; transition: transform .35s var(--ease), opacity .35s var(--ease); }

/* kilau tipis yang sesekali lewat — menarik mata tanpa mengganggu pemandangan */
.portal::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .5) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: sheen 7s var(--ease) 3s infinite;
}

@keyframes sheen {
  0%, 72% { transform: translateX(-120%); }
  100% { transform: translateX(120%); }
}

.portal:hover,
.portal:focus-visible { opacity: 1; background: var(--glass-active); color: var(--active-ink); transform: translateY(-1px); }
.portal:hover .arrow,
.portal:focus-visible .arrow { opacity: 1; transform: translate(2px, -2px); }

@media (prefers-reduced-motion: reduce) { .portal::after { animation: none; } }

/* layar HP: cukup ikon bulat agar tidak menabrak judul di tengah */
@media (max-width: 520px) {
  .portal { padding: 9px; }
  .portal span,
  .portal .arrow { display: none; }
}
