:root {
  --bg: #1a0805;
  --bg2: #3a120a;
  --red: #8b1a10;
  --gold: #e8c66a;
  --gold-dark: #b08a2e;
  --text: #f6e7c1;
  --muted: #c9ae7a;
  --card: rgba(40, 12, 6, 0.85);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Serif", Georgia, serif;
  color: var(--text);
  background:
    radial-gradient(ellipse at 50% 20%, rgba(232, 198, 106, 0.18), transparent 60%),
    linear-gradient(180deg, var(--bg2), var(--bg));
  background-attachment: fixed;
}

h1, h2 { color: var(--gold); margin: 0 0 12px; }
h2 { font-size: 1.1rem; letter-spacing: 0.5px; }

.screen { display: none; }
.screen.active { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--gold-dark);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit;
  font-size: 1rem;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s, box-shadow 0.2s;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(180deg, #d6402b, var(--red));
  color: #fff4d6;
  border: 1px solid var(--gold-dark);
}
.btn.primary:hover:not(:disabled) { box-shadow: 0 0 14px rgba(232, 198, 106, 0.5); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--gold-dark); }
.btn.small { padding: 6px 12px; font-size: 0.85rem; }
.btn.big { font-size: 1.2rem; padding: 14px 32px; margin-top: 24px; }

input[type="text"] {
  font-family: inherit;
  font-size: 1rem;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--gold-dark);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  outline: none;
}
input[type="text"]:focus { border-color: var(--gold); }
input:disabled { opacity: 0.5; }

/* ---------- Login ---------- */
#login-screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}
.login-card { max-width: 420px; width: 100%; text-align: center; padding: 32px 24px; }
.lotus { font-size: 64px; }
.sub { color: var(--muted); margin-bottom: 24px; }
#login-form { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-bottom: 1px solid var(--gold-dark);
  background: rgba(0, 0, 0, 0.3);
}
.incense-count b { color: var(--gold); font-size: 1.2rem; }

/* ---------- Temple layout ---------- */
.temple {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px;
}
@media (max-width: 860px) {
  .temple { grid-template-columns: 1fr; }
}

.altar-area { display: flex; flex-direction: column; align-items: center; text-align: center; }

.buddha { position: relative; margin-bottom: 8px; }
.halo {
  position: absolute;
  left: 50%;
  top: 0;
  width: 280px;
  height: 280px;
  margin-left: -140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 215, 120, 0.5), transparent 70%);
  animation: glow 4s ease-in-out infinite;
}
.buddha-img {
  position: relative;
  display: block;
  height: 340px;
  width: auto;
  margin: 0 auto;
  filter: drop-shadow(0 0 18px rgba(255, 215, 120, 0.35));
}
.altar-title { position: relative; color: var(--gold); letter-spacing: 2px; font-weight: 700; }

@keyframes glow {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

.altar {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 36px;
  /* Chừa khoảng trống phía trên để hương cắm vào không che tượng */
  margin-top: 90px;
  padding: 0 30px 12px;
  border-bottom: 12px solid var(--red);
  border-radius: 4px;
}

/* Nến */
.candle {
  position: relative;
  width: 18px;
  height: 70px;
  background: linear-gradient(90deg, #c4281a, #e44b33, #c4281a);
  border-radius: 3px;
}
.flame {
  position: absolute;
  left: 50%;
  top: -22px;
  width: 12px;
  height: 22px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at 50% 70%, #fff6b0, #ffb02e 50%, transparent 72%);
  border-radius: 50% 50% 40% 40%;
  animation: flicker 0.25s infinite alternate;
}
@keyframes flicker {
  from { transform: translateX(-50%) scale(1, 1); }
  to { transform: translateX(-50%) scale(0.9, 1.1); }
}

/* Bát hương */
.burner { position: relative; width: 200px; }
.bowl { display: block; width: 200px; height: 90px; position: relative; z-index: 2; }
.sticks {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 74px;
  height: 90px;
  display: flex;
  justify-content: center;
  gap: 14px;
  z-index: 1;
}
.stick {
  position: relative;
  width: 4px;
  height: 90px;
  background: linear-gradient(180deg, #7a3b16 0%, #7a3b16 70%, #c0392b 70%);
  transform: rotate(var(--tilt));
  transform-origin: bottom center;
  animation: rise 0.8s ease-out;
}
@keyframes rise {
  from { transform: translateY(40px) rotate(var(--tilt)); opacity: 0; }
  to { transform: rotate(var(--tilt)); opacity: 1; }
}
.ember {
  position: absolute;
  top: -3px;
  left: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff5a1f;
  box-shadow: 0 0 8px 3px rgba(255, 110, 40, 0.8);
  animation: ember 1.2s ease-in-out infinite alternate;
}
@keyframes ember { from { opacity: 0.6; } to { opacity: 1; } }

.smoke {
  position: absolute;
  top: -10px;
  left: -6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(220, 220, 220, 0.35);
  filter: blur(4px);
  animation: smoke 3.5s linear infinite;
}
.smoke.s2 { animation-delay: 1.75s; }
@keyframes smoke {
  0% { transform: translate(0, 0) scale(0.6); opacity: 0.7; }
  50% { transform: translate(8px, -40px) scale(1.4); opacity: 0.35; }
  100% { transform: translate(-6px, -80px) scale(2); opacity: 0; }
}

.hint { color: var(--muted); max-width: 420px; }

/* ---------- Side ---------- */
.side { display: flex; flex-direction: column; gap: 18px; }

.fortune-empty, .wish-empty { color: var(--muted); font-style: italic; }
.f-cat { font-weight: 700; color: var(--gold); font-size: 1.05rem; }
.f-level {
  display: inline-block;
  margin: 8px 0;
  padding: 2px 12px;
  border-radius: 999px;
  background: var(--red);
  border: 1px solid var(--gold-dark);
  font-weight: 700;
}
.f-poem { font-style: italic; color: var(--gold); margin: 6px 0 10px; font-size: 1.05rem; }
.f-meaning { line-height: 1.55; }

.wish-list {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.wish {
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  border-left: 3px solid var(--gold);
}
.wish-text { word-break: break-word; }
.wish-time { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }
.wish-form { display: flex; gap: 8px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10;
}
.modal-card { max-width: 420px; width: 100%; text-align: center; }
.modal-card .btn { margin-top: 16px; }
.hidden { display: none !important; }

.tube { font-size: 72px; animation: shake 0.3s infinite; display: inline-block; }
@keyframes shake {
  0%, 100% { transform: rotate(-12deg); }
  50% { transform: rotate(12deg); }
}

/* ---------- Chén cơm ---------- */
.rice-bowl {
  position: absolute;
  right: -120px;
  bottom: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  font-family: inherit;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px dashed var(--gold);
  border-radius: 12px;
  cursor: pointer;
  animation: bob 2s ease-in-out infinite;
}
.rice-bowl:hover { box-shadow: 0 0 16px rgba(232, 198, 106, 0.6); }
.rice-icon { position: relative; font-size: 44px; line-height: 1; }
.rice-label { font-size: 0.75rem; color: var(--gold); line-height: 1.3; }
.rice-bowl .steam {
  position: absolute;
  top: 0;
  left: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(240, 240, 240, 0.4);
  filter: blur(3px);
  animation: steam 2.4s linear infinite;
}
.rice-bowl .steam.s2 { left: 38%; animation-delay: 1.2s; }
@keyframes steam {
  0% { transform: translateY(8px) scale(0.6); opacity: 0.7; }
  100% { transform: translateY(-30px) scale(1.8); opacity: 0; }
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@media (max-width: 560px) {
  .rice-bowl { right: -8px; bottom: 30px; }
}

/* ---------- Hỏi Gear ---------- */
.gear-ask { margin-top: 18px; }
.gear-ask p { margin: 0 0 4px; }
.gear-ask b { color: var(--gold); }
.gear-ask .row { display: flex; gap: 10px; justify-content: center; }

/* ---------- Quảng cáo giả ---------- */
.ad-card { position: relative; max-width: 380px; width: 100%; text-align: center; }
.ad-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: #f6e7c1;
  color: #3a120a;
  font-weight: 700;
}
.ad-banner {
  margin-top: 18px;
  padding: 24px 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f7d77d, #d9822b);
  color: #3a120a;
}
.ad-logo { font-size: 56px; }
.ad-title { font-size: 1.5rem; font-weight: 700; }
.ad-slogan { font-style: italic; margin: 6px 0 12px; }
.ad-promo {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: #8b1a10;
  color: #fff4d6;
  font-weight: 700;
}
.ad-note { font-size: 0.75rem; color: var(--muted); }
.ad-card .btn { margin-top: 8px; }
.gear-ask .gear-gift { font-size: 0.85rem; color: var(--muted); margin-bottom: 10px; }

/* ---------- Các bước ước nguyện ---------- */
.step-label { font-size: 0.85rem; color: var(--muted); margin: 12px 0 6px; }
.step-label:first-of-type { margin-top: 0; }
.step-label b { color: var(--gold); }
.categories { display: flex; gap: 8px; flex-wrap: wrap; }
.cat-btn {
  flex: 1 1 0;
  min-width: 96px;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 8px 6px;
  border-radius: 10px;
  border: 1px solid var(--gold-dark);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  cursor: pointer;
}
.cat-btn:hover:not(:disabled) { border-color: var(--gold); }
.cat-btn.selected {
  background: linear-gradient(180deg, #d6402b, var(--red));
  border-color: var(--gold);
  color: #fff4d6;
  box-shadow: 0 0 10px rgba(232, 198, 106, 0.4);
}
.cat-btn:disabled { opacity: 0.45; cursor: not-allowed; }
textarea#wish-input {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--gold-dark);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  outline: none;
  resize: vertical;
}
textarea#wish-input:focus { border-color: var(--gold); }
textarea#wish-input:disabled { opacity: 0.5; }

/* ---------- Ẩn khung thẻ khi chưa có quẻ ---------- */
.temple.solo { grid-template-columns: 1fr; }

/* ---------- Bồ đoàn ---------- */
.cushion {
  position: relative;
  margin-top: 28px;
  width: 220px;
  height: 92px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.cushion-top {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 0;
  height: 70px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #f0c75e 0 7px, transparent 8px),
    repeating-radial-gradient(circle at 50% 50%, #a8261a 0 10px, #8b1a10 10px 12px);
  border: 3px solid var(--gold-dark);
  box-shadow: 0 10px 0 #5e120a, 0 14px 20px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s, box-shadow 0.2s;
}
.cushion-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -14px;
  color: var(--gold);
  font-size: 0.95rem;
  font-weight: 700;
}
.cushion:hover:not(:disabled) .cushion-top {
  transform: translateY(-3px);
  box-shadow: 0 13px 0 #5e120a, 0 0 24px rgba(232, 198, 106, 0.6);
}
.cushion:not(:disabled) .cushion-top { animation: invite 2.4s ease-in-out infinite; }
.cushion:disabled { cursor: not-allowed; opacity: 0.5; }
@keyframes invite {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
}
.hint { margin-top: 26px; }

/* ---------- Popup khấn nguyện ---------- */
.pray-card { position: relative; }
.modal-x {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
}
.modal-x:hover { color: var(--gold); }
.pray-card h2 { margin-top: 6px; }
.pray-card .cat-btn { font-size: 1rem; padding: 14px 6px; line-height: 1.6; }
.pray-card textarea { margin-bottom: 12px; }
.row { display: flex; gap: 10px; justify-content: center; }
.pray-card .row .btn { margin-top: 0; }
.msg-text { font-size: 1.1rem; line-height: 1.6; margin-bottom: 4px; }
.msg-big { font-size: 2.6rem; font-weight: 700; color: var(--gold); }
#lang-modal .modal-card h2 { margin-bottom: 16px; }
#lang-modal .cat-btn { font-size: 1rem; padding: 14px 6px; line-height: 1.6; }
.lang-options { margin-top: 8px; }
.lang-options .cat-btn { font-size: 1rem; padding: 14px 6px; line-height: 1.6; }
