@font-face {
  font-family: 'Be Vietnam Pro';
  src: url('/fonts/BeVietnamPro-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Be Vietnam Pro';
  src: url('/fonts/BeVietnamPro-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-charcoal: #121212;
  --bg-ambient: radial-gradient(circle at 50% 34%, rgba(28, 66, 52, 0.28) 0%, rgba(18, 18, 18, 0.96) 62%, #121212 100%);
  --glass-bg: rgba(22, 22, 26, 0.56);
  --glass-bg-strong: rgba(18, 18, 22, 0.78);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-highlight: rgba(255, 255, 255, 0.08);
  --text-primary: #f5f5f2;
  --text-secondary: rgba(245, 245, 242, 0.74);
  --gold: #f4d078;
  --gold-soft: #d9a441;
  --emerald: #2a8f6a;
  --emerald-bright: #3cb88a;
  --shadow-glass: 0 20px 50px rgba(0, 0, 0, 0.55);
  --font-sans: 'Be Vietnam Pro', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-charcoal);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  user-select: none;
}

[hidden] {
  display: none !important;
}

.viewer-root {
  position: relative;
  width: 100%;
  height: 100dvh;
  background: var(--bg-ambient);
  overflow: hidden;
}

.scene-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.scene-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

.scene-canvas:active {
  cursor: grabbing;
}

/* Liquid Glass shared surface */
.glass-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass), inset 0 1px 0 var(--glass-highlight);
  backdrop-filter: blur(20px) saturate(145%);
  -webkit-backdrop-filter: blur(20px) saturate(145%);
}

/* Preview corner badge */
.preview-badge {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--glass-bg-strong);
  border: 1px solid rgba(244, 208, 120, 0.35);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  pointer-events: none;
}

.preview-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px rgba(244, 208, 120, 0.9);
}

/* Audio mute/unmute toggle */
.audio-toggle {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 30;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38), inset 0 1px 0 var(--glass-highlight);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  color: var(--text-primary);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.audio-toggle:hover {
  transform: scale(1.05);
  border-color: rgba(244, 208, 120, 0.45);
  color: var(--gold);
}

.audio-toggle:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.audio-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Glassmorphic greeting overlay */
.greeting-card {
  position: fixed;
  top: max(68px, calc(env(safe-area-inset-top) + 52px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  width: min(460px, calc(100% - 32px));
  max-height: 28dvh;
  padding: 14px 20px 16px;
  border-radius: 20px;
  text-align: center;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(244, 208, 120, 0.35) transparent;
  pointer-events: auto;
  user-select: text;
}

.greeting-kicker {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(244, 208, 120, 0.78);
}

.greeting-recipient {
  margin: 0 0 6px;
  font-size: clamp(17px, 2.5vw, 22px);
  font-weight: 700;
  line-height: 1.28;
  color: var(--gold);
  word-break: break-word;
}

.greeting-message {
  margin: 0;
  font-size: clamp(13px, 1.8vw, 15px);
  font-weight: 400;
  line-height: 1.55;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Splash overlay */
.splash-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(12, 12, 14, 0.76);
  backdrop-filter: blur(22px) saturate(130%);
  -webkit-backdrop-filter: blur(22px) saturate(130%);
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.splash-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-card {
  width: min(380px, 100%);
  padding: 34px 26px 28px;
  border-radius: 26px;
  text-align: center;
  background: linear-gradient(155deg, rgba(32, 34, 38, 0.78), rgba(18, 18, 22, 0.84));
  border: 1px solid rgba(244, 208, 120, 0.24);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.splash-emblem {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle, rgba(244, 208, 120, 0.24), rgba(42, 143, 106, 0.16));
  border: 1px solid rgba(244, 208, 120, 0.35);
  color: var(--gold);
}

.splash-emblem svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

.splash-title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.splash-subtitle {
  margin: 0 0 22px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.splash-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 13px 20px;
  border-radius: 999px;
  border: 1px solid rgba(244, 208, 120, 0.45);
  background: linear-gradient(135deg, rgba(244, 208, 120, 0.24), rgba(42, 143, 106, 0.28));
  color: var(--gold);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.splash-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(244, 208, 120, 0.2);
}

.splash-button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Wish modal */
.wish-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 10, 12, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.wish-modal {
  width: min(400px, 100%);
  padding: 22px 22px 20px;
  border-radius: 22px;
  background: var(--glass-bg-strong);
  border: 1px solid rgba(244, 208, 120, 0.25);
  box-shadow: var(--shadow-glass), inset 0 1px 0 var(--glass-highlight);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  user-select: text;
}

.wish-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.wish-modal-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold);
  background: rgba(244, 208, 120, 0.14);
  border: 1px solid rgba(244, 208, 120, 0.26);
}

.wish-modal-close {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
}

.wish-modal-close:hover {
  color: var(--text-primary);
  border-color: rgba(244, 208, 120, 0.4);
}

.wish-modal-sender {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  word-break: break-word;
}

.wish-modal-message {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.wish-modal-actions {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.wish-modal-actions:empty {
  display: none;
}

.report-trigger {
  align-self: flex-end;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(245, 245, 242, 0.52);
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease;
}

.report-trigger:hover {
  color: #f39a9a;
  background: rgba(243, 154, 154, 0.08);
}

.report-confirm {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.report-confirm-title {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.report-confirm-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.report-cancel-btn,
.report-submit-btn {
  padding: 8px 13px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.report-cancel-btn {
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.report-submit-btn {
  border: 1px solid rgba(243, 128, 128, 0.45);
  background: rgba(196, 59, 69, 0.28);
  color: #ffb8b8;
}

.report-submit-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.report-done {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--emerald-bright);
  text-align: center;
}

/* Floating button to add a wish */
.wish-fab {
  position: fixed;
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 54px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 26;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(42, 143, 106, 0.36), rgba(24, 26, 30, 0.84));
  border: 1px solid rgba(244, 208, 120, 0.48);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.52), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
  color: var(--gold);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.wish-fab:hover {
  transform: translateX(-50%) translateY(-2px);
  border-color: var(--gold);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.6);
}

.wish-fab:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Bottom-sheet Add Wish Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 48;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 12px 0;
  background: rgba(10, 10, 12, 0.64);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.wish-drawer {
  width: min(460px, 100%);
  max-height: 90dvh;
  overflow-y: auto;
  padding: 20px 20px calc(22px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--glass-bg-strong);
  border-bottom: 0;
  user-select: text;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.drawer-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--gold);
}

.drawer-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.drawer-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drawer-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.drawer-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

.drawer-counter {
  font-size: 11.5px;
  color: rgba(245, 245, 242, 0.55);
}

.drawer-input,
.drawer-textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(14, 14, 17, 0.78);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.drawer-textarea {
  resize: vertical;
  min-height: 82px;
}

.drawer-input:focus,
.drawer-textarea:focus {
  border-color: rgba(244, 208, 120, 0.65);
  box-shadow: 0 0 0 3px rgba(244, 208, 120, 0.14);
}

.ornament-pills {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.ornament-pill {
  padding: 9px 6px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.ornament-pill.is-active {
  border-color: rgba(244, 208, 120, 0.65);
  background: linear-gradient(135deg, rgba(244, 208, 120, 0.2), rgba(42, 143, 106, 0.24));
  color: var(--gold);
}

.turnstile-box {
  min-height: 65px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.form-error {
  margin: 0;
  padding: 9px 12px;
  border-radius: 11px;
  background: rgba(196, 59, 69, 0.18);
  border: 1px solid rgba(243, 128, 128, 0.34);
  color: #ffb8b8;
  font-size: 12.5px;
  line-height: 1.45;
}

.drawer-submit {
  width: 100%;
  padding: 13px 20px;
  border-radius: 999px;
  border: 1px solid rgba(244, 208, 120, 0.5);
  background: linear-gradient(135deg, rgba(244, 208, 120, 0.24), rgba(42, 143, 106, 0.34));
  color: var(--gold);
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.drawer-submit:hover:not(:disabled) {
  transform: translateY(-1px);
}

.drawer-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Toast notification */
.viewer-toast {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(400px, calc(100% - 32px));
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid rgba(244, 208, 120, 0.38);
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
}

/* Footer pill CTA */
.cta-pill {
  position: fixed;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  background: var(--glass-bg-strong);
  border: 1px solid rgba(244, 208, 120, 0.34);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5), inset 0 1px 0 var(--glass-highlight);
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.cta-pill:hover {
  transform: translateX(-50%) translateY(-2px);
  border-color: rgba(244, 208, 120, 0.6);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.58);
}

.cta-pill:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* State / 404 / Loading / WebGL fallback screen */
.viewer-state {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-ambient);
}

.state-card {
  width: min(440px, 100%);
  padding: 32px 26px;
  border-radius: 26px;
  text-align: center;
}

.state-spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 2.5px solid rgba(244, 208, 120, 0.2);
  border-top-color: var(--gold);
  animation: thiep-spin 0.85s linear infinite;
}

@keyframes thiep-spin {
  to {
    transform: rotate(360deg);
  }
}

.state-title {
  margin: 0 0 10px;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
}

.state-desc {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.state-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid rgba(244, 208, 120, 0.45);
  background: linear-gradient(135deg, rgba(244, 208, 120, 0.22), rgba(42, 143, 106, 0.25));
  color: var(--gold);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.state-link:hover {
  transform: translateY(-1px);
  border-color: var(--gold);
}

@media (max-width: 767px) {
  .greeting-card {
    top: max(64px, calc(env(safe-area-inset-top) + 48px));
    padding: 12px 15px 14px;
    border-radius: 16px;
    max-height: 24dvh;
  }

  .cta-pill {
    font-size: 12.5px;
    padding: 10px 18px;
  }
}
