/* =========================================================================
   GREENPATH — Eco-Green Design System
   Palet: hutan dalam, hijau segar, mint terang, putih hangat, abu grafit
   ========================================================================= */

:root {
  /* --- Warna --- */
  --forest-deep: #16352B;
  --forest: #1F5C45;
  --green-fresh: #2E8B57;
  --mint: #9FE2BF;
  --mint-soft: #E4F6EC;
  --paper: #F7F8F4;
  --graphite: #2A2E2B;
  --graphite-soft: #6B756F;
  --amber-warn: #D9A441;
  --line: #DCE5DD;

  /* --- Tipografi --- */
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Manrope', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-comic-title: 'Bangers', cursive;
  --font-comic-body: 'Comic Neue', cursive;

  /* --- Lainnya --- */
  --radius: 14px;
  --shadow-soft: 0 10px 30px -12px rgba(22, 53, 43, 0.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--graphite);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

/* =========================================================================
   SPLASH SCREEN
   ========================================================================= */

#splash-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 15%, rgba(159,226,191,0.18), transparent 55%),
    radial-gradient(circle at 85% 80%, rgba(46,139,87,0.25), transparent 50%),
    linear-gradient(160deg, var(--forest-deep), #0E2A21 70%);
  animation: fadeIn 0.4s ease both;
}
#splash-screen.hidden { display: none; }

#splash-card {
  max-width: 460px;
  width: 100%;
  text-align: center;
  color: var(--mint-soft);
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

#splash-badge {
  font-size: 2.4rem;
  margin-bottom: 6px;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,0.35));
}

.splash-eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mint);
  border: 1px solid rgba(159,226,191,0.35);
  border-radius: 999px;
  padding: 4px 12px;
  margin-bottom: 14px;
}

#splash-title {
  font-family: var(--font-display);
  font-size: 2.6rem;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}
#splash-title strong { color: var(--mint); }

#splash-tagline {
  font-size: 0.98rem;
  line-height: 1.6;
  color: rgba(228, 246, 236, 0.82);
  margin: 0 0 30px;
}

.splash-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 22px;
}

.btn-primary, .btn-secondary {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 999px;
  padding: 14px 28px;
  cursor: pointer;
  border: none;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary {
  color: var(--forest-deep);
  background: var(--mint);
  box-shadow: 0 10px 24px -10px rgba(159,226,191,0.5);
}
.btn-primary:hover { background: #fff; transform: translateY(-2px); }

.btn-secondary {
  color: var(--mint-soft);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(159,226,191,0.35);
}
.btn-secondary:hover { background: rgba(255,255,255,0.14); transform: translateY(-2px); }

#splash-sound-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.78rem;
  color: rgba(228, 246, 236, 0.7);
  cursor: pointer;
}
#splash-sound-toggle input { accent-color: var(--mint); width: 16px; height: 16px; }

#splash-net-note {
  margin: 16px 0 0;
  font-size: 0.7rem;
  line-height: 1.5;
  color: rgba(228, 246, 236, 0.6);
}

/* =========================================================================
   GUIDE / PETUNJUK PEMAKAIAN MODAL
   ========================================================================= */

#guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(22, 53, 43, 0.78);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.25s ease both;
}
#guide-overlay.hidden { display: none; }

#guide-card {
  position: relative;
  background: var(--paper);
  border-radius: 18px;
  max-width: 540px;
  width: 100%;
  max-height: 86vh;
  overflow-y: auto;
  padding: 34px 30px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.5);
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.guide-heading {
  font-family: var(--font-display);
  color: var(--forest-deep);
  font-size: 1.3rem;
  margin: 0 0 18px;
}

.guide-section { margin-bottom: 18px; }
.guide-section h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--forest);
  margin: 0 0 6px;
}
.guide-section p {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--graphite);
  margin: 0;
}

.guide-stat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.guide-stat-list li {
  font-size: 0.86rem;
  line-height: 1.5;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.guide-stat-list .g-icon { margin-right: 6px; }

#guide-card .btn-primary {
  width: 100%;
  margin-top: 6px;
  color: #fff;
  background: var(--forest);
}
#guide-card .btn-primary:hover { background: var(--green-fresh); }

#guide-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
}

/* =========================================================================
   ICON BUTTONS (help / audio toggle)
   ========================================================================= */

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(159,226,191,0.3);
  background: rgba(255,255,255,0.06);
  color: var(--mint-soft);
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease;
}
.icon-btn:hover { background: rgba(255,255,255,0.16); transform: translateY(-2px); }
.icon-btn.muted { opacity: 0.55; }

#guide-card .icon-btn {
  border-color: var(--line);
  background: var(--mint-soft);
  color: var(--forest-deep);
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* =========================================================================
   APP SHELL — sidebar status-bar di kiri + kolom konten di kanan
   ========================================================================= */

#app-shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

#app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* =========================================================================
   STATUS BAR (Dashboard) — sidebar vertikal
   ========================================================================= */

#status-bar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
  flex: 0 0 240px;
  width: 240px;
  background: linear-gradient(180deg, var(--forest-deep), var(--forest));
  color: var(--mint-soft);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  box-shadow: var(--shadow-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-mark { color: var(--mint); font-size: 0.7rem; }
.brand-text strong { color: var(--mint); }

.stats-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-chip {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(159,226,191,0.18);
  border-radius: 10px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s ease, border-color 0.25s ease;
}
.stat-chip:hover { transform: translateX(3px); border-color: var(--mint); }

.stat-icon { font-size: 1.1rem; line-height: 1; }

.stat-info { display: flex; flex-direction: column; min-width: 0; }
.stat-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  opacity: 0.7;
}
.stat-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
}

.stat-bar {
  grid-column: 1 / -1;
  height: 4px;
  background: rgba(255,255,255,0.12);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}
.stat-bar-fill {
  height: 100%;
  width: 50%;
  background: var(--mint);
  border-radius: 4px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1), background 0.4s ease;
}

/* Variasi warna fill saat nilai negatif/rendah */
.stat-bar-fill.warn { background: var(--amber-warn); }
.stat-bar-fill.danger { background: #C75450; }

/* =========================================================================
   MISSION TRACKER
   ========================================================================= */

#mission-tracker {
  max-width: 760px;
  margin: 22px auto 0;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--graphite-soft);
}

.mission-pill {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
}
.mission-pill.active {
  background: var(--forest);
  color: #fff;
  border-color: var(--forest);
}
.mission-divider { opacity: 0.4; }

/* =========================================================================
   STAGE & GAME CANVAS (Peta 2D Top-Down)
   ========================================================================= */

#game-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 16px 40px;
}

#game-canvas-container {
  position: relative;
  width: 100%;
  max-width: 800px;
  aspect-ratio: 800 / 480;
  margin: 0 auto;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  background: var(--mint-soft);
  animation: cardIn 0.45s ease both;
}

/* Phaser menyisipkan <canvas> di dalam container ini */
#game-canvas-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

#control-hint {
  margin: 12px auto 0;
  max-width: 800px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--graphite-soft);
}
#control-hint kbd {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  margin: 0 1px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--forest-deep);
}

/* =========================================================================
   DIALOG MODAL — GAYA KOMIK (narasi & pilihan, tampil di atas canvas)
   ========================================================================= */

#dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 18, 15, 0.72);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.25s ease both;
}
#dialog-overlay.hidden { display: none; }

/* Panel komik utama: kertas putih, garis tinta tebal, bayangan "flat" khas komik */
#story-card {
  position: relative;
  width: 100%;
  max-width: 760px;
  max-height: 88vh;
  overflow-y: auto;
  overflow-x: hidden;
  background:
    radial-gradient(circle, rgba(22,53,43,0.07) 1.1px, transparent 1.1px) 0 0 / 14px 14px,
    #fffdf7;
  border: 4px solid #15201b;
  border-radius: 6px;
  box-shadow: 9px 9px 0 rgba(0,0,0,0.85), 0 0 0 2px #fffdf7 inset;
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Panel gambar dengan bingkai tinta tebal + tekstur halftone di atasnya */
#image-container {
  position: relative;
  width: 100%;
  height: 280px;
  background: var(--mint-soft);
  overflow: hidden;
  border-bottom: 4px solid #15201b;
}
#story-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 8s ease;
  filter: saturate(1.12) contrast(1.05);
}
#image-container:hover #story-image { transform: scale(1.06); }

/* Tekstur titik halftone di atas gambar — ciri khas cetakan komik lama */
#image-container::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(21,32,27,0.55) 1px, transparent 1.4px);
  background-size: 5px 5px;
  mix-blend-mode: multiply;
  opacity: 0.16;
}

/* Caption dibuat seperti label komik miring di pojok panel */
#image-caption {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 2;
  max-width: 78%;
  padding: 6px 14px;
  font-family: var(--font-comic-body);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: #15201b;
  background: var(--mint);
  border: 2.5px solid #15201b;
  border-radius: 3px;
  transform: rotate(-1.6deg);
  box-shadow: 3px 3px 0 rgba(0,0,0,0.85);
}

#story-container { padding: 22px 26px 4px; position: relative; }

/* Judul ala "banner ledakan" komik: font Bangers, outline tinta, banner bersudut */
#story-title {
  position: relative;
  display: inline-block;
  font-family: var(--font-comic-title);
  font-size: 1.7rem;
  letter-spacing: 0.03em;
  line-height: 1.15;
  margin: 4px 0 16px;
  padding: 10px 22px;
  color: #fffdf7;
  background: var(--forest);
  clip-path: polygon(2% 18%, 9% 2%, 91% 2%, 98% 18%, 98% 82%, 91% 98%, 9% 98%, 2% 82%);
  text-shadow:
    2px 2px 0 #15201b,
    -1px -1px 0 #15201b,
    1px -1px 0 #15201b,
    -1px 1px 0 #15201b;
  transform: rotate(-0.8deg);
  box-shadow: 4px 4px 0 rgba(0,0,0,0.85);
}

#story-text {
  position: relative;
  font-family: var(--font-comic-body);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.55;
  color: #1f2b25;
  margin: 0;
  white-space: pre-line;
  background: #fff;
  border: 2.5px solid #15201b;
  border-radius: 4px;
  padding: 14px 16px;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.18);
}
/* Ekor balon teks komik (opsional, memberikan efek ucapan karakter) */
#story-text::before {
  content: "";
  position: absolute;
  bottom: -15px;
  left: 30px;
  border-width: 15px 15px 0 0;
  border-style: solid;
  border-color: var(--graphite) transparent;
  display: block;
  width: 0;
}
#story-text::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 32px;
  border-width: 12px 12px 0 0;
  border-style: solid;
  border-color: #fff transparent;
  display: block;
  width: 0;
}
/* =========================================================================
   OPTIONS / CHOICES — GAYA KOMIK ("tombol aksi" dengan efek tekan)
   ========================================================================= */

#options-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 26px 28px;
}

.choice-btn {
  position: relative;
  text-align: left;
  font-family: var(--font-comic-body);
  font-size: 1rem;
  font-weight: 700;
  color: #15201b;
  background: #fff;
  border: 2.5px solid #15201b;
  border-radius: 8px;
  padding: 13px 16px 13px 46px;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 4px 4px 0 #15201b;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.choice-btn::before {
  content: "▶";
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--green-fresh);
  font-weight: 700;
  font-size: 0.85rem;
}

.choice-btn:hover {
  background: var(--mint-soft);
}

/* Efek "ditekan" khas tombol komik: bergeser ke arah bayangan flat-nya */
.choice-btn:active,
.choice-btn.is-pressed {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 #15201b;
}

.choice-btn .choice-hint {
  display: block;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--graphite-soft);
}

/* Tombol ditandai sebagai pilihan "berisiko/dilema" — aksen merah komik */
.choice-btn.risky {
  border-color: #b3261e;
  box-shadow: 4px 4px 0 #b3261e;
}
.choice-btn.risky::before { content: "⚡"; color: #b3261e; }
.choice-btn.risky:hover { background: #fdebe9; }
.choice-btn.risky:active,
.choice-btn.risky.is-pressed {
  box-shadow: 0 0 0 #b3261e;
}

/* =========================================================================
   ENDING OVERLAY
   ========================================================================= */

#ending-overlay {
  position: fixed;
  inset: 0;
  background: rgba(22, 53, 43, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 180;
  backdrop-filter: blur(3px);
  animation: fadeIn 0.3s ease both;
}
#ending-overlay.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

#ending-card {
  background: var(--paper);
  border-radius: 18px;
  max-width: 480px;
  width: 100%;
  padding: 36px 32px;
  text-align: center;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.5);
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

#ending-badge { font-size: 2.6rem; margin-bottom: 8px; }

#ending-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--forest-deep);
  margin: 0 0 10px;
}

#ending-desc {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--graphite-soft);
  margin: 0 0 22px;
}

#ending-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 26px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}
#ending-stats div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}
#ending-stats strong { display: block; color: var(--forest); font-size: 1rem; }

#restart-btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
  background: var(--forest);
  border: none;
  border-radius: 999px;
  padding: 13px 32px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}
#restart-btn:hover { background: var(--green-fresh); transform: translateY(-2px); }
#restart-btn:active { transform: translateY(0); }

/* =========================================================================
   FOOTER
   ========================================================================= */

#game-footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--graphite-soft);
  padding: 0 0 26px;
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */

@media (max-width: 768px) {
  #app-shell { flex-direction: column; }

  #status-bar {
    position: sticky;
    top: 0;
    align-self: stretch;
    width: 100%;
    height: auto;
    max-height: none;
    overflow-y: visible;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    padding: 14px 16px;
  }

  .stats-grid {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1 1 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    order: 3;
    width: 100%;
  }

  .brand { order: 1; }
  .header-actions { order: 2; margin-left: auto; }

  #image-container { height: 200px; }
  #story-container, #options-container { padding-left: 18px; padding-right: 18px; }
  #story-title { font-size: 1.2rem; }
  #splash-title { font-size: 2.1rem; }
}

/* Hormati preferensi pengguna yang mengurangi motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
