/*
 * gaya.css — SELURUH CSS situs. Tidak ada CSS inline (dilarang CSP).
 * Font bawaan sistem saja.
 */

:root {
  --plum: #4a1f3d;
  --plum-muda: #7a3b5e;
  --krem: #fff4e3;
  --krem-tua: #f3dcc2;
  --pink: #ff9fbf;
  --pink-tua: #e5739b;
  --pink-muda: #ffd3e0;
  --huruf: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--plum);
  color: var(--plum);
  font-family: var(--huruf);
}

/* ---------------- GERBANG SANDI: ADVENTURE LANE ---------------- */
.halaman-gerbang {
  --pink-pita: #e39bbb;
  --pink-pucat: #f6d3e0;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: #0d0b0e;
  color: var(--plum);
  overflow-x: hidden;
}

/* latar gurun, tetap di tempat saat halaman digulir */
.halaman-gerbang::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #d9a86c url("/assets/img/gerbang-gurun.webp") center / cover no-repeat;
}

/* bingkai layar ala TV tabung: tepi hitam membulat, sudut gelap, garis pindai halus */
.layar-crt {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(20, 8, 20, 0.05) 0 1px, transparent 1px 3px);
}
.layar-crt::before {
  content: "";
  position: absolute;
  inset: clamp(6px, 1.1vw, 16px);
  border-radius: clamp(16px, 3vw, 40px) / clamp(14px, 2.6vw, 34px);
  box-shadow:
    0 0 0 60px #0d0b0e,
    inset 0 0 0 2px rgba(0, 0, 0, 0.55),
    inset 0 0 clamp(40px, 8vw, 120px) clamp(6px, 2vw, 30px) rgba(25, 10, 25, 0.5);
}

.panggung {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(18px, 3.2vh, 34px) 16px 0;
}

/* gulungan judul "Adventure Lane, Birthday Gift" */
.gulungan { width: min(420px, 92%); margin: 0 0 48px; flex: 0 0 auto; }
.gulungan img { display: block; width: 100%; height: auto; }

/* kartu kertas: garis plum, pita merah muda, garis plum; kertas bernoda di sudut */
.kartu-gerbang {
  position: relative;
  z-index: 2;
  width: min(360px, calc(100% - 24px));
  margin-top: auto; /* ruang lebih di langit; kartu dan peti tetap menempel ke bawah */
  padding: 40px 26px 24px;
  text-align: center;
  border: 3px solid var(--plum);
  background:
    radial-gradient(ellipse at 0 0, rgba(170, 112, 60, 0.32), transparent 22%),
    radial-gradient(ellipse at 100% 0, rgba(170, 112, 60, 0.32), transparent 22%),
    radial-gradient(ellipse at 0 100%, rgba(170, 112, 60, 0.34), transparent 24%),
    radial-gradient(ellipse at 100% 100%, rgba(170, 112, 60, 0.34), transparent 24%),
    radial-gradient(ellipse at 50% 42%, #fcf3e2 0%, #f7e6cb 62%, #eed5b0 100%);
  box-shadow:
    inset 0 0 0 3px var(--pink-pucat),
    inset 0 0 22px rgba(150, 95, 50, 0.35),
    0 0 0 6px var(--pink-pita),
    0 0 0 9px var(--plum),
    12px 14px 0 9px rgba(80, 36, 64, 0.38);
}

.ikon-hati {
  width: 66px;
  height: 66px;
  margin: -76px auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 38% 32%, #f3b6cd, #e393b6 70%);
  border: 4px solid var(--plum);
  border-radius: 50%;
}
.ikon-hati svg { image-rendering: pixelated; }

.kartu-gerbang h1 { margin: 6px 0 12px; font-size: 1.45rem; color: var(--plum); }

.sapaan { margin: 0 0 22px; line-height: 1.6; color: var(--plum-muda); }

.form-sandi { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.form-sandi label { font-weight: bold; font-size: 0.95rem; }

.form-sandi input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-size: 1.05rem;
  color: var(--plum);
  background: rgba(255, 251, 246, 0.94);
  border: 3px solid var(--plum);
  border-radius: 0;
  box-shadow: inset 0 3px 0 rgba(74, 31, 61, 0.08);
  outline: none;
}
.form-sandi input[type="password"]:focus { border-color: #b4507f; box-shadow: 0 0 0 3px #ffd3e0; }

/* tombol Buka: merah muda mengilap dengan kilau berkelip */
.tombol-buka {
  position: relative;
  overflow: hidden;
  margin-top: 16px;
  padding: 13px 14px;
  font: inherit;
  font-size: 1.12rem;
  font-weight: bold;
  color: var(--plum);
  cursor: pointer;
  border: 3px solid var(--plum);
  border-radius: 0;
  background: linear-gradient(180deg, #f6c3d6 0%, #eaa4c0 38%, #e297b6 62%, #d688aa 100%);
  box-shadow:
    inset 0 -4px 0 #bd6f97,
    inset 0 3px 0 rgba(255, 255, 255, 0.5),
    0 0 16px 3px rgba(255, 226, 238, 0.85);
}
.tombol-buka span { position: relative; z-index: 1; }
.tombol-buka::before,
.tombol-buka::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-repeat: no-repeat;
}
.tombol-buka::before {
  background-image:
    radial-gradient(circle at 9% 30%, #fff 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 21% 70%, #fff 0 1px, transparent 2px),
    radial-gradient(circle at 33% 22%, #fff 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 44% 78%, #fff 0 1px, transparent 2px),
    radial-gradient(circle at 61% 26%, #fff 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 70% 64%, #fff 0 2px, transparent 3px),
    radial-gradient(circle at 82% 34%, #fff 0 1px, transparent 2px),
    radial-gradient(circle at 92% 72%, #fff 0 1.5px, transparent 2.5px);
  animation: kelip 2.2s ease-in-out infinite;
}
.tombol-buka::after {
  background-image:
    radial-gradient(ellipse 18px 22px at 0 50%, rgba(255, 255, 255, 0.95), transparent 70%),
    radial-gradient(ellipse 18px 22px at 100% 50%, rgba(255, 255, 255, 0.95), transparent 70%),
    radial-gradient(circle at 15% 58%, #fff 0 1px, transparent 2px),
    radial-gradient(circle at 27% 38%, #fff 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 54% 20%, #fff 0 1px, transparent 2px),
    radial-gradient(circle at 66% 82%, #fff 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 77% 18%, #fff 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 88% 52%, #fff 0 1px, transparent 2px),
    linear-gradient(180deg, transparent 30%, rgba(255, 255, 255, 0.28) 46%, transparent 62%);
  animation: kelip 2.2s ease-in-out -1.1s infinite;
}
@keyframes kelip {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}
.tombol-buka:hover, .tombol-buka:focus-visible { filter: brightness(1.06); outline: none; box-shadow: inset 0 -4px 0 #bd6f97, inset 0 3px 0 rgba(255, 255, 255, 0.5), 0 0 0 3px #fff1f6, 0 0 20px 6px rgba(255, 226, 238, 0.95); }
.tombol-buka:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 #bd6f97, 0 0 10px 2px rgba(255, 226, 238, 0.8); }

.galat {
  margin: 0 0 16px;
  padding: 10px 12px;
  font-size: 0.92rem;
  line-height: 1.45;
  color: #7d1d3a;
  background: #ffe1ea;
  border: 3px solid #c8476f;
}

.petunjuk {
  margin: 22px 0 0;
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--plum-muda);
}

/* peti kayu di bawah kartu, terpotong tepi bawah layar seperti pada konsep */
.peti {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  width: min(336px, calc(100% - 40px));
  height: clamp(76px, 17vh, 136px); /* selalu lebih pendek dari gambar peti: peti terpotong tepi bawah layar */
  margin-top: 6px;
  overflow: hidden;
}
.peti img { display: block; width: 100%; height: auto; }

/* layar tegak (HP): geser latar sedikit agar tebing kiri ikut terlihat */
@media (max-aspect-ratio: 4/5) {
  .halaman-gerbang::before { background-position: 40% center; }
}

@media (max-width: 480px) {
  .panggung { padding-left: 12px; padding-right: 12px; }
  .gulungan { margin-bottom: 44px; }
  .kartu-gerbang { padding: 38px 18px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .tombol-buka::before, .tombol-buka::after { animation: none; opacity: 0.8; }
}

/* tombol formulir keluar (formulirnya disembunyikan; dikirim oleh game.js) */
.form-keluar button {
  font: inherit;
  font-weight: bold;
  cursor: pointer;
  color: var(--plum);
  border: 3px solid var(--plum);
  border-radius: 0;
}

/* ---------------- HALAMAN PERMAINAN ---------------- */
.halaman-permainan {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

#bingkai {
  /* rasio 16:9 terjaga, mengikuti lebar atau tinggi layar mana yang lebih sempit */
  width: min(100vw, calc(100vh * 16 / 9));
  width: min(100vw, calc(100dvh * 16 / 9));
  aspect-ratio: 16 / 9;
}

#layar {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  background: var(--krem);
}

/* Formulir keluar tidak ditampilkan; tombol Keluar ada di Buku Perjalanan (game.js mengirim formulir ini). */
.form-keluar { display: none; }

.tanpa-js {
  color: var(--krem);
  text-align: center;
  padding: 24px;
}

/* ---------------- KARTU HARAPAN (sebelum meniup lilin) ---------------- */
.layar-harapan {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  background: radial-gradient(ellipse at 50% 40%, rgba(74, 31, 61, 0.35), rgba(30, 10, 25, 0.78));
}
.layar-harapan[hidden] { display: none; }

.kartu-harapan {
  position: relative;
  width: min(460px, 100%);
  margin: auto;
  padding: 44px 26px 22px;
  text-align: center;
  color: var(--plum);
  border: 3px solid var(--plum);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 211, 224, 0.75), transparent 28%),
    radial-gradient(circle at 92% 94%, rgba(255, 211, 224, 0.7), transparent 30%),
    linear-gradient(180deg, #fffaf2 0%, #fff1e0 100%);
  box-shadow:
    inset 0 0 0 3px #ffe6ee,
    0 0 0 6px var(--pink),
    0 0 0 9px var(--plum),
    10px 12px 0 9px rgba(30, 10, 25, 0.45);
  animation: harapanMuncul 0.35s ease-out;
}
@keyframes harapanMuncul {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.lencana-lilin {
  position: absolute;
  top: -40px;
  left: 50%;
  width: 70px;
  height: 70px;
  margin-left: -35px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 4px solid var(--plum);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #ffe3ec, var(--pink) 75%);
}
.lencana-lilin svg { image-rendering: pixelated; }
.lencana-lilin .api { transform-origin: 8px 7px; animation: apiLilin 1.1s ease-in-out infinite alternate; }
@keyframes apiLilin {
  from { transform: scale(1, 1) translateY(0); }
  to { transform: scale(0.9, 1.08) translateY(-0.4px); }
}

.judul-harapan { margin: 8px 0 8px; font-size: 1.35rem; color: var(--plum); }
.ajakan-harapan { margin: 0 0 18px; font-size: 0.92rem; line-height: 1.55; color: var(--plum-muda); }

.isian-harapan { position: relative; margin: 0 0 14px; text-align: left; }
.isian-harapan label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 0 0 6px;
  font-weight: bold;
  font-size: 0.95rem;
  line-height: 1.35;
}
.isian-harapan .nomor {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #fff;
  background: var(--pink-tua);
  border: 2px solid var(--plum);
}
.isian-harapan textarea {
  display: block;
  width: 100%;
  min-height: 78px;
  max-height: 180px;
  padding: 10px 12px 18px;
  resize: vertical;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--plum);
  background: rgba(255, 255, 255, 0.85);
  border: 3px solid var(--plum);
  border-radius: 0;
  box-shadow: inset 0 3px 0 rgba(74, 31, 61, 0.07);
  outline: none;
}
.isian-harapan textarea::placeholder { color: #b08aa0; font-style: italic; }
.isian-harapan textarea:focus { border-color: var(--pink-tua); box-shadow: 0 0 0 3px var(--pink-muda); }
.isian-harapan .hitung {
  position: absolute;
  right: 8px;
  bottom: 5px;
  font-size: 0.7rem;
  color: #b08aa0;
  pointer-events: none;
}

.catatan-harapan { margin: 4px 0 14px; font-size: 0.8rem; line-height: 1.45; color: var(--plum-muda); }
.catatan-harapan span { color: var(--pink-tua); }

.galat-harapan {
  margin: 0 0 12px;
  padding: 8px 10px;
  font-size: 0.85rem;
  color: #7d1d3a;
  background: #ffe1ea;
  border: 2px solid #c8476f;
}

.aksi-harapan { display: flex; gap: 12px; }
.aksi-harapan button {
  font: inherit;
  font-weight: bold;
  cursor: pointer;
  color: var(--plum);
  border: 3px solid var(--plum);
  border-radius: 0;
}
.tombol-nanti {
  flex: 0 0 auto;
  padding: 11px 14px;
  font-size: 0.9rem;
  background: var(--krem);
  box-shadow: inset 0 -3px 0 var(--krem-tua);
}
.tombol-simpan {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
  padding: 11px 14px;
  font-size: 1rem;
  background: linear-gradient(180deg, #ffc4d6 0%, var(--pink) 55%, #f48cb0 100%);
  box-shadow: inset 0 -4px 0 var(--pink-tua), inset 0 3px 0 rgba(255, 255, 255, 0.55), 0 0 14px 2px rgba(255, 220, 232, 0.8);
}
.tombol-simpan span { position: relative; z-index: 1; }
.tombol-simpan::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-repeat: no-repeat;
  background-image:
    radial-gradient(circle at 10% 30%, #fff 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 28% 72%, #fff 0 1px, transparent 2px),
    radial-gradient(circle at 52% 22%, #fff 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 74% 70%, #fff 0 1px, transparent 2px),
    radial-gradient(circle at 90% 32%, #fff 0 1.5px, transparent 2.5px);
  animation: kelip 2.2s ease-in-out infinite;
}
.aksi-harapan button:hover, .aksi-harapan button:focus-visible { filter: brightness(1.05); outline: 3px solid var(--pink-muda); outline-offset: 2px; }
.aksi-harapan button:active { transform: translateY(2px); }
.aksi-harapan button[disabled] { cursor: wait; filter: saturate(0.6); }

/* setelah tersimpan: isi kartu diganti ucapan singkat */
.kartu-harapan.sudah > :not(.terkirim-harapan):not(.lencana-lilin) { visibility: hidden; }
.terkirim-harapan {
  position: absolute;
  inset: 40px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: harapanMuncul 0.35s ease-out;
}
.terkirim-harapan[hidden] { display: none; }
.terkirim-harapan::before {
  content: "♥";
  margin-bottom: 10px;
  font-size: 3.4rem;
  line-height: 1;
  color: var(--pink-tua);
  text-shadow: 3px 3px 0 var(--plum);
  animation: detakHati 0.9s ease-in-out infinite alternate;
}
@keyframes detakHati { from { transform: scale(1); } to { transform: scale(1.12); } }
.terkirim-harapan p { margin: 0 0 8px; color: var(--plum-muda); }
.terkirim-harapan .terkirim-judul { font-size: 1.4rem; font-weight: bold; color: var(--plum); }
.terkirim-harapan .terkirim-judul span { color: var(--pink-tua); }

@media (max-width: 480px), (max-height: 560px) {
  .kartu-harapan { padding: 40px 16px 16px; }
  .judul-harapan { font-size: 1.15rem; }
  .ajakan-harapan { margin-bottom: 12px; font-size: 0.85rem; }
  .isian-harapan textarea { min-height: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  .kartu-harapan, .terkirim-harapan, .terkirim-harapan::before, .lencana-lilin .api, .tombol-simpan::before { animation: none; }
}
