:root {
  --gold: #f2d189;
  --gold-2: #d9ad58;
  --ink: #f7ebd4;
  --ink-dim: #ceb98d;
  --line: rgba(236, 200, 124, 0.28);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Noto Sans TC", "PingFang TC", sans-serif;
  color: var(--ink);
  background: radial-gradient(120% 120% at 50% -10%, #13242e, #050a0e 62%);
}

.shrine-page {
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 4px 8px calc(env(safe-area-inset-bottom) + 10px);
  display: grid;
  gap: 6px;
}

.shrine-topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px;
  background: linear-gradient(180deg, rgba(2, 12, 18, 0.78), rgba(2, 10, 15, 0.45));
  border: 1px solid rgba(236, 200, 124, 0.16);
  border-radius: 11px;
  padding: 5px 7px;
}
.topbar-back {
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 12px;
}
.topbar-title-wrap h1 {
  margin: 0;
  font-size: 14px;
  line-height: 1.05;
}
.topbar-title-wrap h1 span {
  font-size: 10px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.06em;
}
.topbar-title-wrap p {
  margin: 1px 0 0;
  font-size: 9px;
  color: var(--ink-dim);
}
.topbar-meta {
  display: grid;
  gap: 4px;
  justify-items: end;
}
.room-level-badge {
  border-radius: 999px;
  border: 1px solid rgba(240, 201, 127, 0.38);
  background: rgba(17, 36, 43, 0.75);
  color: #f8e6bc;
  font-size: 9px;
  padding: 2px 6px;
}
.server-status-badge {
  border: 1px solid var(--line);
  color: #d9f3e5;
  background: rgba(26, 67, 53, 0.5);
  border-radius: 999px;
  font-size: 9px;
  padding: 2px 6px;
}
.topbar-menu-btn {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid rgba(238, 201, 129, 0.34);
  background: rgba(13, 27, 35, 0.84);
  color: #f8dfaf;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 90px));
  gap: 6px;
  justify-content: end;
}
.mode-btn {
  border-radius: 999px;
  border: 1px solid rgba(237, 198, 117, 0.35);
  min-height: 26px;
  background: rgba(12, 27, 34, 0.78);
  color: var(--ink);
  font-size: 11px;
}
.mode-btn.is-active {
  background: linear-gradient(180deg, rgba(39, 77, 63, 0.88), rgba(17, 42, 35, 0.92));
  color: #ffefcb;
}

.shrine-scene {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--line);
  min-height: 72dvh;
  aspect-ratio: 390 / 610;
  box-shadow: 0 20px 42px rgba(0, 0, 0, 0.45);
}
.shrine-scene-root {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(75% 40% at 50% 16%, rgba(255, 210, 140, 0.2), rgba(0, 0, 0, 0) 72%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.35) 42%, rgba(0, 0, 0, 0.66)),
    url('/img/temple-quest/shrine/rpg/scene/sacred-room-main-altar-close-v1.png') center/cover no-repeat;
}
.scene-item {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
}
.scene-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.58));
}
.scene-item.scene-altar { z-index: 3; }
.scene-item.scene-object { z-index: 5; }
.scene-item.scene-object.is-selected {
  transform: translate(-50%, -52%) scale(1.06);
}
.scene-item.scene-object.is-selected img {
  filter: drop-shadow(0 12px 15px rgba(0, 0, 0, 0.62)) drop-shadow(0 0 10px rgba(252, 219, 143, 0.24));
}
.scene-item.scene-object::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4%;
  width: 82%;
  height: 24%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0) 72%);
  pointer-events: none;
  z-index: -1;
}
.scene-item.scene-candle-left,
.scene-item.scene-candle-right,
.scene-item.scene-garland { z-index: 6; }
.scene-hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  z-index: 7;
}
.scene-hotspot::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  border: 1px solid rgba(255, 242, 204, 0.8);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.22), 0 0 12px rgba(255, 224, 161, 0.52);
  opacity: 0;
  transition: opacity 120ms ease;
}
.shrine-page.is-edit-mode .scene-hotspot::before,
.scene-hotspot.is-selected::before {
  opacity: 1;
}
.scene-hotspot.is-replace-target::before {
  opacity: 1;
  border-color: rgba(145, 245, 196, 0.92);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2), 0 0 16px rgba(78, 208, 147, 0.75);
}
.scene-item.scene-object.is-replace-target img {
  filter: drop-shadow(0 12px 15px rgba(0, 0, 0, 0.62)) drop-shadow(0 0 14px rgba(122, 245, 191, 0.36));
}
.hotspot-hint {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 8;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  color: #ffe9bd;
  background: rgba(11, 30, 35, 0.78);
  border: 1px solid rgba(241, 209, 141, 0.36);
}

.object-sheet {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 80px);
  transform: translateX(-50%);
  width: min(382px, calc(100vw - 24px));
  z-index: 30;
  border-radius: 12px;
  border: 1px solid rgba(240, 198, 120, 0.3);
  background: linear-gradient(180deg, rgba(10, 18, 26, 0.92), rgba(6, 13, 19, 0.95));
  padding: 8px;
  display: grid;
  gap: 6px;
  pointer-events: none;
}
.object-sheet[hidden] { display: none !important; }
.sheet-close-btn,
.object-sheet-card,
.object-sheet-actions,
.sheet-cancel-replace-btn {
  pointer-events: auto;
}
.sheet-close-btn {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid rgba(241, 210, 144, 0.4);
  background: rgba(17, 31, 40, 0.95);
  color: #fce8bf;
}
.object-sheet-card {
  display: grid;
  grid-template-columns: 66px 1fr;
  gap: 8px;
  align-items: start;
}
.object-sheet-card img {
  width: 66px;
  height: 66px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  object-fit: contain;
}
.object-sheet-copy h2 { margin: 0; font-size: 16px; }
.object-sheet-copy p {
  margin: 2px 0 0;
  font-size: 12px;
  color: #dcc79a;
}
.replace-target-badge {
  display: inline-flex;
  margin-top: 3px;
  width: fit-content;
  border: 1px solid rgba(242, 209, 137, 0.42);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  color: #ffe8bc;
  background: rgba(26, 56, 45, 0.7);
}
.replace-target-badge[hidden] { display: none !important; }
.object-sheet-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.object-sheet-actions button {
  min-height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(241, 209, 141, 0.35);
  background: rgba(17, 31, 40, 0.84);
  color: #ffefca;
  font-size: 12px;
}
.sheet-cancel-replace-btn {
  position: absolute;
  left: 8px;
  top: 8px;
  min-height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(237, 155, 137, 0.36);
  background: rgba(55, 23, 21, 0.84);
  color: #ffd3c8;
  font-size: 11px;
  padding: 0 10px;
}
.sheet-cancel-replace-btn[hidden] { display: none !important; }

.inventory-strip {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 6px);
  transform: translateX(-50%);
  width: min(430px, calc(100vw - 16px));
  z-index: 20;
  border-radius: 12px;
  border: 1px solid rgba(240, 198, 120, 0.25);
  background: rgba(4, 12, 17, 0.9);
  padding: 4px 6px 5px;
  display: grid;
  gap: 6px;
}
.inventory-toggle {
  width: 100%;
  min-height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(238, 201, 126, 0.24);
  background: linear-gradient(180deg, rgba(19, 43, 54, 0.74), rgba(10, 25, 34, 0.78));
  color: rgba(247, 232, 192, 0.9);
  font-size: 10px;
  letter-spacing: 0.02em;
  padding: 0 8px;
}
.inventory-body[hidden] { display: none !important; }
.inventory-body {
  max-height: 35dvh;
  overflow-y: auto;
}
.inventory-strip.is-collapsed {
  gap: 0;
  padding-bottom: 4px;
}
.inventory-cats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.inventory-cat {
  border-radius: 999px;
  border: 1px solid rgba(236, 199, 122, 0.26);
  min-height: 34px;
  background: rgba(17, 31, 40, 0.86);
  color: #e8d5ab;
  font-size: 12px;
}
.inventory-cat.is-active {
  background: linear-gradient(180deg, rgba(76, 111, 71, 0.95), rgba(35, 64, 40, 0.95));
  color: #ffefc7;
}
.inventory-row {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 78px;
  gap: 8px;
  overflow-x: auto;
}
.inventory-item {
  border: 1px solid rgba(237, 199, 122, 0.2);
  border-radius: 10px;
  background: rgba(8, 19, 27, 0.88);
  color: var(--ink);
  padding: 8px;
  display: grid;
  gap: 6px;
  min-height: 74px;
  align-content: start;
}
.inventory-item img { width: 100%; height: 34px; object-fit: contain; }
.inventory-item-name {
  font-size: 11px;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.inventory-item-meta { display: none; }
.inventory-item.is-selected {
  border-color: rgba(247, 225, 160, 0.92);
  box-shadow: 0 0 0 1px rgba(250, 222, 151, 0.5);
}
.inventory-status { margin: 0; font-size: 12px; color: #c6b082; }

.chat-placeholder {
  position: fixed;
  right: 8px;
  bottom: calc(env(safe-area-inset-bottom) + 40px);
  width: min(104px, 30vw);
  z-index: 40;
  border-radius: 999px;
  border: 1px solid rgba(238, 198, 118, 0.2);
  background: rgba(5, 13, 18, 0.82);
  overflow: hidden;
}
.shrine-page.has-object-sheet .chat-placeholder {
  bottom: calc(env(safe-area-inset-bottom) + 142px);
}
.chat-toggle {
  width: 100%;
  min-height: 24px;
  border: 0;
  background: rgba(8, 21, 30, 0.72);
  color: #f6e4bc;
  font-size: 10px;
}
.chat-body { padding: 10px; font-size: 13px; color: #ccb688; }

button:focus-visible,
.scene-hotspot:focus-visible,
.inventory-item:focus-visible,
.mode-btn:focus-visible,
.inventory-cat:focus-visible,
.chat-toggle:focus-visible,
.sheet-close-btn:focus-visible,
.topbar-back:focus-visible,
.topbar-menu-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

@media (max-width: 389px) {
  .topbar-title-wrap h1 { font-size: 13px; }
  .topbar-title-wrap h1 span { display: block; }
  .inventory-cats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .shrine-scene { min-height: 64dvh; }
  .chat-placeholder { width: 44vw; }
  .shrine-page.has-object-sheet .chat-placeholder {
    bottom: calc(env(safe-area-inset-bottom) + 136px);
  }
}
