/* HantuDompet — tema rumah hantu (SPEC §5) */
:root {
  --bg: #14101f;
  --bg2: #1d1533;
  --card: #241b3d;
  --edge: #3a2c5f;
  --ghost: #8affd1;
  --pumpkin: #ffb347;
  --blood: #ff6b81;
  --ink: #efeaff;
  --muted: #9d92c4;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
}
#app { max-width: 560px; margin: 0 auto; padding: 0 16px 96px; }
h1, h2, h3 { margin: 0.4em 0; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; color: var(--ghost); }
.muted { color: var(--muted); font-size: 0.9rem; }
.small { font-size: 0.8rem; }
.hidden { display: none !important; }
.big-number { font-size: 2rem; font-weight: 800; margin: 0.2em 0; color: var(--ghost); }

/* Header */
.haunted-header { position: relative; text-align: center; padding-top: 8px; overflow: hidden; }
.moon { font-size: 2.2rem; text-align: right; padding-right: 12px; filter: drop-shadow(0 0 12px #fff8c9); }
.house-silhouette { width: 100%; height: 60px; display: block; margin-top: -8px; }
.title { font-family: "Creepster", "Inter", cursive; font-size: 3rem; letter-spacing: 2px; color: var(--ghost); margin: 0; text-shadow: 0 0 18px rgba(138, 255, 209, 0.35); }
.subtitle { color: var(--muted); margin-top: 0; }

/* Screens */
.screen { display: none; }
.screen.active { display: block; animation: fadein 200ms ease-in; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* Ghost mascot */
.ghost-wrap { text-align: center; margin: 8px 0 4px; }
.ghost { display: inline-block; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.ghost-body {
  width: 92px; height: 104px; margin: 0 auto; background: var(--ink);
  border-radius: 46px 46px 0 0; position: relative;
  box-shadow: 0 0 24px rgba(239, 234, 255, 0.25);
}
.ghost-body::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -14px; height: 18px;
  background: var(--ink);
  clip-path: polygon(0 0, 12% 100%, 25% 0, 38% 100%, 50% 0, 62% 100%, 75% 0, 88% 100%, 100% 0);
}
.ghost-face { position: absolute; top: 30px; left: 0; right: 0; display: flex; justify-content: center; gap: 14px; }
.eye { width: 12px; height: 16px; background: #14101f; border-radius: 50%; display: inline-block; }
.mouth { position: absolute; top: 30px; left: 50%; transform: translateX(-50%); width: 22px; height: 12px; border: 3px solid #14101f; border-top: none; border-radius: 0 0 22px 22px; }
.mouth.worried { border-radius: 22px 22px 0 0; border-bottom: none; border-top: 3px solid #14101f; height: 10px; top: 34px; }
.mouth.pale { width: 10px; height: 10px; border-radius: 50%; border: 3px solid #14101f; top: 32px; }
.ghost.pale .ghost-body { background: #cfc8e8; }
.ghost-line { color: var(--muted); font-style: italic; margin: 6px 0 12px; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--edge); border-radius: 16px;
  padding: 16px; margin: 12px 0;
}
.banner {
  border-radius: 12px; padding: 12px 14px; margin: 12px 0; font-weight: 600;
  background: #3a2c10; border: 1px solid var(--pumpkin); color: #ffe1b0;
}
.banner.danger { background: #3d1520; border-color: var(--blood); color: #ffd3da; animation: shake 400ms ease-in-out; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* Candle budget */
.candle-wrap { margin-top: 12px; }
.candle {
  width: 34px; height: 90px; margin: 0 auto 8px; border: 2px solid var(--edge);
  border-radius: 6px 6px 4px 4px; position: relative; overflow: hidden; background: #120d22;
  display: flex; align-items: flex-end;
}
.candle-fill { width: 100%; background: var(--ghost); transition: height 300ms ease; }
.candle-fill.warn { background: var(--pumpkin); }
.candle-fill.crit { background: var(--blood); }
.candle-flame { position: absolute; top: -2px; left: 50%; transform: translateX(-50%); font-size: 1rem; }

/* Streak */
.streak-number { font-size: 1.4rem; font-weight: 800; color: var(--ghost); margin: 0.2em 0; }
.streak-candles { display: flex; gap: 8px; justify-content: center; margin: 10px 0; font-size: 1.6rem; }
.streak-candles .lit { filter: drop-shadow(0 0 6px var(--pumpkin)); }
.streak-candles .unlit { opacity: 0.3; filter: grayscale(1); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 8px 0; }
.badge { background: #3a2c5f; border: 1px solid var(--ghost); color: var(--ghost); border-radius: 999px; padding: 4px 10px; font-size: 0.8rem; }

/* Buttons */
.btn {
  background: var(--card); color: var(--ink); border: 1px solid var(--edge);
  border-radius: 12px; padding: 12px 16px; font-size: 1rem; cursor: pointer; font-family: inherit;
}
.btn.primary { background: var(--ghost); color: #10231a; border-color: var(--ghost); font-weight: 800; }
.btn.big { width: 100%; padding: 16px; font-size: 1.15rem; margin: 12px 0; }
.btn.ghost-btn { width: 100%; margin-top: 8px; }
.btn.danger { background: transparent; border-color: var(--blood); color: var(--blood); width: 100%; margin-top: 8px; }
.btn:active { transform: scale(0.98); }
.row { display: flex; gap: 10px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.hint { text-align: center; color: var(--muted); font-size: 0.85rem; }

/* Forms */
label { display: block; margin: 12px 0 4px; font-weight: 600; }
input[type="text"], input[type="number"] {
  width: 100%; padding: 12px; margin-top: 6px; border-radius: 10px;
  border: 1px solid var(--edge); background: #120d22; color: var(--ink); font-size: 1.1rem; font-family: inherit;
}
input:focus { outline: 2px solid var(--ghost); }
.error { color: var(--blood); font-weight: 600; }
.file-btn { cursor: pointer; }

/* Keypad + chips */
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.keypad button {
  padding: 14px; font-size: 1.3rem; border-radius: 12px; border: 1px solid var(--edge);
  background: #1d1533; color: var(--ink); cursor: pointer; font-family: inherit;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip {
  border: 1px solid var(--edge); background: #1d1533; color: var(--ink);
  border-radius: 999px; padding: 8px 12px; cursor: pointer; font-size: 0.95rem; font-family: inherit;
}
.chip.selected { background: var(--ghost); color: #10231a; border-color: var(--ghost); font-weight: 700; }
.chip.guess { border-color: var(--pumpkin); }

/* History */
.history-day { margin: 14px 0; }
.history-day h3 { color: var(--pumpkin); font-size: 0.95rem; }
.history-item {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  background: var(--card); border: 1px solid var(--edge); border-radius: 12px; padding: 10px 12px; margin: 6px 0;
}
.history-item .amount { font-weight: 800; white-space: nowrap; }
.history-item .cat { color: var(--ghost); font-size: 0.85rem; cursor: pointer; text-decoration: underline dotted; }
.history-item .note { color: var(--muted); font-size: 0.85rem; }
.history-item .del { background: none; border: none; color: var(--blood); cursor: pointer; font-size: 1.1rem; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }

/* Summary chart */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 110px; margin-top: 12px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; background: var(--ghost); border-radius: 6px 6px 0 0; min-height: 2px; }
.bar-col span { font-size: 0.7rem; color: var(--muted); }
.rules-list { list-style: none; padding: 0; }
.rules-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--edge); }
.rules-list button { background: none; border: none; color: var(--blood); cursor: pointer; }

/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(10, 6, 20, 0.85); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-card {
  background: var(--bg2); border: 1px solid var(--edge); border-radius: 20px 20px 0 0;
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; padding: 20px 16px 28px;
}

/* Bottom nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px; display: flex; justify-content: space-around;
  background: #1a1230; border-top: 1px solid var(--edge); padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 40;
}
.nav-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; font-size: 1.2rem; gap: 2px; font-family: inherit;
}
.nav-btn span { font-size: 0.65rem; }
.nav-btn.active { color: var(--ghost); }
.nav-add {
  background: var(--ghost); color: #10231a; border-radius: 50%; width: 52px; height: 52px;
  font-size: 1.8rem; font-weight: 800; margin-top: -24px; border: 3px solid #1a1230;
  display: flex; align-items: center; justify-content: center;
}

/* Fog */
.fog {
  position: fixed; bottom: 0; left: 0; right: 0; height: 90px; pointer-events: none; z-index: 30;
  background: linear-gradient(180deg, transparent, rgba(157, 146, 196, 0.12));
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
