:root {
  --app-w: 100vw;
  --app-h: 100dvh;
  --amber: #ffb347;
  --amber-soft: rgba(255, 179, 71, 0.85);
  --ink-deep: #070b24;
  --glass-bg: rgba(10, 16, 40, 0.55);
  --glass-border: rgba(255, 179, 71, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--ink-deep);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  width: var(--app-w);
  height: var(--app-h);
  font-family: "Zen Maru Gothic", "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: #f4ede0;
}

#scene-canvas {
  position: fixed;
  inset: 0;
  width: var(--app-w);
  height: var(--app-h);
  display: block;
  touch-action: none;
}

/* ---------- Loading overlay ---------- */

#loading-overlay {
  position: fixed;
  inset: 0;
  width: var(--app-w);
  height: var(--app-h);
  background: var(--ink-deep);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition: opacity 1.2s ease;
}

.loading-emblem {
  font-family: "Zen Maru Gothic", sans-serif;
  font-weight: 700;
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  letter-spacing: 0.08em;
  color: var(--amber);
  text-shadow: 0 0 24px rgba(255, 179, 71, 0.55);
}

.loading-hint {
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  color: rgba(244, 237, 224, 0.55);
}

/* ---------- UI overlay ---------- */

#ui-overlay {
  position: fixed;
  inset: 0;
  width: var(--app-w);
  height: var(--app-h);
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(1.6rem, env(safe-area-inset-top)) 1.2rem max(1.4rem, env(safe-area-inset-bottom));
}

.ui-header {
  text-align: center;
  text-shadow: 0 2px 18px rgba(7, 11, 36, 0.8);
}

.ui-title {
  margin: 0;
  font-family: "Zen Maru Gothic", sans-serif;
  font-weight: 700;
  font-size: clamp(1.5rem, 6vw, 2rem);
  letter-spacing: 0.14em;
  color: var(--amber);
}

.ui-subtitle {
  margin: 0.35rem 0 0;
  font-size: clamp(0.68rem, 2.6vw, 0.78rem);
  letter-spacing: 0.1em;
  color: rgba(244, 237, 224, 0.62);
}

.ui-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.link-pills {
  pointer-events: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  max-width: 26rem;
}

.link-pill {
  pointer-events: auto;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--amber-soft);
  font-family: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.25s ease;
}

.link-pill:hover,
.link-pill:active {
  background: rgba(255, 179, 71, 0.16);
  transform: translateY(-1px);
}

/* ---------- Tap hint ---------- */

.tap-hint {
  margin: 0;
  padding: 0.3rem 0.75rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: rgba(244, 237, 224, 0.6);
  text-shadow: 0 2px 10px rgba(7, 11, 36, 0.8);
  transition: opacity 0.6s ease;
  opacity: 1;
}

.tap-hint.is-hidden {
  opacity: 0;
}

/* ---------- Speech bubble ---------- */

.speech-bubble {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-9999px, -9999px);
  max-width: 12rem;
  padding: 0.5rem 0.85rem;
  border-radius: 14px;
  background: var(--glass-bg);
  border: 1px solid var(--amber);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #f4ede0;
  font-family: "Zen Maru Gothic", sans-serif;
  font-size: 0.82rem;
  line-height: 1.4;
  text-align: center;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  z-index: 20;
}

.speech-bubble.is-visible {
  opacity: 1;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: var(--glass-bg) transparent transparent transparent;
}

/* ---------- Traveler's notebook panel ---------- */

.notebook-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  pointer-events: none;
  padding: 1rem 1.2rem max(1.3rem, env(safe-area-inset-bottom));
  background: var(--glass-bg);
  border-top: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-radius: 20px 20px 0 0;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.notebook-panel.is-open {
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0);
}

.notebook-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.notebook-panel__title {
  margin: 0;
  font-family: "Zen Maru Gothic", sans-serif;
  font-size: 0.92rem;
  letter-spacing: 0.08em;
  color: var(--amber);
}

.notebook-panel__close {
  padding: 0.2rem 0.5rem;
  background: none;
  border: none;
  color: rgba(244, 237, 224, 0.7);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.notebook-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.notebook-input {
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: rgba(7, 11, 36, 0.5);
  color: #f4ede0;
  font-family: "Zen Maru Gothic", sans-serif;
  font-size: 0.82rem;
}

.notebook-input::placeholder {
  color: rgba(244, 237, 224, 0.4);
}

.notebook-input:focus {
  outline: none;
  border-color: var(--amber);
}

.notebook-input--name {
  flex: 0 0 5rem;
}

.notebook-input--message {
  flex: 1 1 10rem;
}

.notebook-submit {
  flex: 0 0 auto;
  padding: 0.55rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--amber);
  background: rgba(255, 179, 71, 0.16);
  color: var(--amber-soft);
  font-family: "Zen Maru Gothic", sans-serif;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.25s ease;
}

.notebook-submit:hover,
.notebook-submit:active {
  background: rgba(255, 179, 71, 0.28);
}

.notebook-submit:disabled {
  opacity: 0.55;
  cursor: default;
}

.notebook-error {
  margin: 0.5rem 0 0;
  min-height: 1em;
  font-size: 0.72rem;
  color: var(--amber);
}
