:root {
  --bg: #1a2226;
  --fog: #6d7f86;
  --ink: #e8ece8;
  --muted: #a8b4b0;
  --accent: #c4a574;
  --accent-dim: #8a7350;
  --panel: rgba(18, 24, 28, 0.88);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Source Sans 3", system-ui, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at center, transparent 42%, rgba(8, 12, 14, 0.55) 100%),
    linear-gradient(to bottom, rgba(8, 12, 14, 0.25), transparent 18%, transparent 72%, rgba(8, 12, 14, 0.5));
  z-index: 2;
}

#fade {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: #0a0e10;
  opacity: 0;
  z-index: 8;
  transition: opacity 0.45s ease;
}

#fade.on {
  opacity: 1;
}

#topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(0.75rem + var(--safe-top)) 1rem 0.5rem;
  pointer-events: none;
}

#topbar .back {
  pointer-events: auto;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
}

#topbar .place {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.55);
}

.hint {
  position: absolute;
  top: calc(3.2rem + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  margin: 0;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: rgba(12, 16, 18, 0.55);
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.6s ease;
  pointer-events: none;
}

.hint.fade {
  opacity: 0;
}

#hotspot-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  width: auto;
  height: auto;
  margin: 0;
  transform: translate(-50%, -50%);
  border: none;
  padding: 0.35rem;
  background: transparent;
  pointer-events: auto;
  cursor: pointer;
  touch-action: manipulation;
  z-index: 1;
}

.hotspot-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(232, 236, 232, 0.95);
  background: rgba(196, 165, 116, 0.35);
  box-shadow: 0 0 0 0 rgba(196, 165, 116, 0.5);
  animation: pulse 2.2s ease-out infinite;
}

.hotspot.move .hotspot-dot {
  border-radius: 4px;
  transform: rotate(45deg);
  width: 18px;
  height: 18px;
}

.hotspot.examine .hotspot-dot {
  border-style: dashed;
}

.hotspot-label {
  max-width: 7.5rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: rgba(12, 16, 18, 0.72);
  color: #e8ece8;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(196, 165, 116, 0.5); }
  70% { box-shadow: 0 0 0 12px rgba(196, 165, 116, 0); }
  100% { box-shadow: 0 0 0 0 rgba(196, 165, 116, 0); }
}

.exits {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
  pointer-events: auto;
  max-height: 5.5rem;
  overflow: auto;
}

.exit-chip {
  appearance: none;
  border: 1px solid rgba(196, 165, 116, 0.45);
  background: rgba(18, 24, 28, 0.82);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  backdrop-filter: blur(6px);
}

.exit-chip:active {
  background: rgba(196, 165, 116, 0.28);
}

.looks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  pointer-events: auto;
}

.look-chip {
  appearance: none;
  border: 1px dashed rgba(126, 200, 180, 0.55);
  background: rgba(18, 36, 32, 0.85);
  color: #d8ece4;
  border-radius: 999px;
  padding: 0.5rem 0.85rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.hotspot.talk .hotspot-dot {
  border-radius: 50%;
  background: rgba(106, 186, 88, 0.45);
  border-color: rgba(200, 240, 180, 0.95);
}

.look-chip.talk-chip {
  border-style: solid;
  border-color: rgba(106, 186, 88, 0.55);
  background: rgba(24, 48, 32, 0.9);
}

.panel {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
  padding-bottom: calc(1rem + var(--safe-bottom));
  background: rgba(6, 8, 10, 0.35);
}

.panel[hidden] {
  display: none;
}

.panel-inner {
  width: min(28rem, 100%);
  padding: 1.25rem 1.35rem 1.1rem;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid rgba(168, 180, 176, 0.18);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
}

.panel-inner h2 {
  margin: 0 0 0.45rem;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.55rem;
  font-weight: 600;
  color: var(--accent);
}

.panel-inner p {
  margin: 0 0 1rem;
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-line;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.panel-actions:empty {
  display: none;
  margin: 0;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.7rem 1.1rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  touch-action: manipulation;
}

.btn.primary {
  background: var(--accent);
  color: #1a1610;
  width: 100%;
}

.btn.ghost {
  width: 100%;
  background: transparent;
  color: var(--muted);
  border-color: rgba(168, 180, 176, 0.28);
}

.btn.action {
  background: rgba(196, 165, 116, 0.18);
  color: var(--ink);
  border-color: rgba(196, 165, 116, 0.4);
  flex: 1;
  min-width: 8rem;
}

.npc-chat {
  margin: 0 0 0.75rem;
}

.npc-chat[hidden] {
  display: none !important;
}

.npc-log {
  max-height: 10rem;
  overflow: auto;
  margin: 0 0 0.55rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  background: rgba(8, 14, 12, 0.55);
  border: 1px solid rgba(126, 200, 180, 0.2);
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.npc-log .npc-kora {
  color: #b8e0c8;
  margin-bottom: 0.45rem;
}

.npc-log .npc-you {
  color: #e8d8b8;
  margin-bottom: 0.45rem;
}

.npc-form {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.npc-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(168, 180, 176, 0.28);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: rgba(12, 18, 16, 0.7);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
}

.npc-form input:focus {
  outline: 1px solid rgba(106, 186, 88, 0.55);
}

.npc-send {
  flex: 0 0 auto;
  min-width: 4.5rem;
  width: auto;
}

.npc-meta {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  min-height: 1em;
}

#dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  padding: 0.75rem 1rem calc(0.85rem + var(--safe-bottom));
  background: linear-gradient(transparent, rgba(8, 12, 14, 0.75));
  pointer-events: none;
}

.inventory {
  display: flex;
  gap: 0.5rem;
  min-height: 2.5rem;
  margin-bottom: 0.35rem;
  pointer-events: auto;
}

.inv-slot {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 8px;
  border: 1px solid rgba(196, 165, 116, 0.45);
  background: rgba(18, 24, 28, 0.75);
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  color: var(--accent);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.25);
}

.status {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 1.1em;
}

.title-screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: end center;
  padding: 1.5rem;
  padding-bottom: calc(2rem + var(--safe-bottom));
  background: linear-gradient(to top, rgba(10, 14, 16, 0.82) 0%, rgba(10, 14, 16, 0.35) 45%, rgba(10, 14, 16, 0.15) 100%);
  transition: opacity 0.7s ease, visibility 0.7s;
}

.title-screen.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.title-inner {
  width: min(24rem, 100%);
  text-align: left;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.title-inner h1 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(3.2rem, 14vw, 4.5rem);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-shadow: 0 4px 28px rgba(0, 0, 0, 0.45);
}

.tagline {
  margin: 0.85rem 0 1.35rem;
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--muted);
  max-width: 22rem;
}

@media (min-width: 720px) {
  .hint {
    font-size: 0.85rem;
  }

  .panel {
    align-items: center;
  }
}
