* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body,
#app,
#canvas-container {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #120b07;
  font-family: 'Crimson Pro', Georgia, serif;
  user-select: none;
  -webkit-user-select: none;
}

#canvas-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.hidden {
  display: none !important;
}

/* Loading Screen */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 45%, #261810 0%, #110a06 75%);
  transition: opacity 0.45s ease;
}

.loading-box {
  text-align: center;
  padding: 28px 36px;
}

.loading-title {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #f0d084;
  margin-bottom: 8px;
}

.loading-sub {
  font-size: 19px;
  font-style: italic;
  color: #cbb48c;
  margin-bottom: 22px;
}

.loading-bar {
  width: 340px;
  height: 12px;
  margin: 0 auto;
  border-radius: 6px;
  background: #2b1b11;
  border: 1px solid #9c763f;
  overflow: hidden;
}

#loading-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #b8832f, #f2cf78);
  transition: width 0.2s ease;
}

/* HUD Layers */
.hud {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

/* Menu HUD at bottom of closed 3D book */
#menu-hud {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: clamp(18px, 3.2vh, 38px);
  gap: 12px;
}

.menu-actions {
  display: flex;
  gap: 18px;
  pointer-events: auto;
}

.menu-hint {
  font-size: clamp(14px, 1.5vw, 18px);
  color: #d6be93;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
  background: rgba(20, 12, 7, 0.55);
  padding: 5px 16px;
  border-radius: 999px;
  border: 1px solid rgba(201, 156, 74, 0.35);
}

/* Buttons */
.btn-gold,
.btn-leather,
.btn-parchment,
.btn-next {
  cursor: pointer;
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 700;
  border-radius: 8px;
  transition: transform 0.12s ease, filter 0.15s ease, background 0.15s ease;
}

.btn-gold {
  padding: 13px 28px;
  font-size: 16px;
  color: #1b0f07;
  background: linear-gradient(180deg, #e5b75a 0%, #b88430 100%);
  border: 2px solid #fae2a0;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
}

.btn-gold:hover {
  transform: translateY(-1px) scale(1.03);
  filter: brightness(1.08);
}

.btn-leather {
  padding: 13px 26px;
  font-size: 16px;
  color: #f3dba8;
  background: linear-gradient(180deg, #4b2b1a 0%, #2f190e 100%);
  border: 1.5px solid #c99c4a;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
}

.btn-leather:hover {
  transform: translateY(-1px) scale(1.03);
  background: linear-gradient(180deg, #5d3621 0%, #3a2013 100%);
}

/* Book Open HUD: 50% Left toolbar + 50% Right translucent overlays */
.left-toolbar {
  position: fixed;
  left: 4.5vw;
  bottom: 4.2vh;
  width: 42vw;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  pointer-events: auto;
}

.btn-parchment {
  flex: 1;
  padding: 7px 6px;
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: clamp(12.5px, 0.98vw, 15.5px);
  font-weight: 700;
  color: #3a2210;
  background: rgba(242, 226, 193, 0.9);
  border: 1.4px solid rgba(140, 96, 46, 0.85);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
  white-space: nowrap;
}

.btn-parchment.btn-nav {
  flex: 0.78;
}

.btn-parchment:disabled {
  opacity: 0.42;
  cursor: default;
  transform: none;
}

.btn-parchment:hover:not(:disabled) {
  background: rgba(250, 238, 212, 0.98);
  transform: translateY(-1px);
}

.right-overlay {
  position: fixed;
  left: 52.2vw;
  right: 4.5vw;
  top: 5.5vh;
  bottom: 5.5vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.translucent-pill {
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}

.header-pill {
  background: rgba(246, 234, 208, 0.78);
  border: 1.4px solid rgba(138, 93, 46, 0.78);
  padding: 7px 22px 6px;
  text-align: center;
}

.header-pill-title {
  font-family: 'Cinzel', Georgia, serif;
  font-size: clamp(11px, 0.95vw, 14px);
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #3a2210;
}

.chapter-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 5px;
}

.chapter-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid #7c5c34;
  background: transparent;
}

.chapter-dot.active {
  background: #8b2f1b;
  border-color: #8b2f1b;
  transform: scale(1.15);
}

.chapter-dot.solved {
  background: #c48f2e;
  border-color: #c48f2e;
}

.right-bottom-bar {
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  position: relative;
  padding: 0 8px;
}

.right-bottom-bar.anchor-left {
  justify-content: flex-start;
}

.feedback-pill {
  max-width: min(560px, 76%);
  padding: 9px 18px;
  text-align: center;
  font-size: clamp(14px, 1.15vw, 18px);
  font-weight: 600;
  line-height: 1.3;
  transition: transform 0.15s ease, background 0.2s ease;
}

.right-bottom-bar.anchor-left .feedback-pill {
  max-width: min(390px, 46%);
}

.feedback-pill.neutral {
  background: rgba(246, 234, 208, 0.8);
  border: 1.5px solid rgba(156, 118, 64, 0.85);
  color: #3a2414;
}

.feedback-pill.hint {
  background: rgba(247, 230, 183, 0.86);
  border: 1.6px solid rgba(184, 134, 43, 0.9);
  color: #4f3309;
}

.feedback-pill.miss {
  background: rgba(245, 218, 208, 0.86);
  border: 1.6px solid rgba(166, 75, 53, 0.9);
  color: #5c1f12;
}

.feedback-pill.solved {
  max-width: min(600px, 85%) !important;
  background: rgba(227, 237, 208, 0.9);
  border: 1.8px solid rgba(75, 120, 55, 0.92);
  color: #1f3816;
  pointer-events: auto;
}

.feedback-pill.shake {
  animation: fbShake 0.26s ease;
}

@keyframes fbShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(6px); }
  50% { transform: translateX(-6px); }
  75% { transform: translateX(4px); }
}

.btn-next {
  margin-top: 10px;
  padding: 8px 22px;
  font-size: 13.5px;
  color: #f8f3e3;
  background: #2f5722;
  border: 1.5px solid #dbe8b8;
  border-radius: 999px;
  pointer-events: auto;
}

.btn-next:hover {
  background: #3b6b2c;
  transform: scale(1.03);
}

.skip-btn {
  position: absolute;
  right: 8px;
  bottom: 0;
  flex: none;
  padding: 7px 14px;
  pointer-events: auto;
}

/* Brass Magnifying Glass Cursor */
#magnifier-cursor {
  position: fixed;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2.5px solid #f2c96b;
  box-shadow: 0 0 0 1.5px rgba(59, 34, 16, 0.7), inset 0 0 12px rgba(255, 232, 168, 0.22);
  pointer-events: none;
  z-index: 45;
  transform: translate(-50%, -50%);
}

#magnifier-cursor::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #f2c96b;
  transform: translate(-50%, -50%);
}

#magnifier-cursor::after {
  content: '';
  position: absolute;
  width: 5px;
  height: 18px;
  background: linear-gradient(180deg, #b88635, #69401a);
  border-radius: 3px;
  right: -6px;
  bottom: -11px;
  transform: rotate(-45deg);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 6, 3, 0.78);
  backdrop-filter: blur(4px);
}

.parchment-modal {
  width: min(640px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  padding: 30px 34px;
  border-radius: 12px;
  background:
    linear-gradient(rgba(245, 232, 204, 0.9), rgba(239, 223, 189, 0.92)),
    url('assets/images/general/parchment_page.jpg') center/cover;
  border: 3px solid #7c542b;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75), inset 0 0 0 1px rgba(184, 143, 84, 0.8);
  text-align: center;
  color: #341e11;
}

.parchment-modal h2 {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 24px;
  margin-bottom: 18px;
  color: #3b2213;
}

.chapters-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.chapter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-radius: 8px;
  background: rgba(235, 220, 185, 0.88);
  border: 1.5px solid #c0a070;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.chapter-row:hover {
  background: rgba(230, 210, 168, 0.98);
  border-color: #8c5925;
}

.chapter-row-title {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 16px;
  font-weight: 700;
  color: #341e11;
}

.chapter-row-loc {
  font-size: 15px;
  font-style: italic;
  color: #6e4e32;
}

.chapter-row-badge {
  font-size: 16px;
  font-weight: 700;
  color: #7a3520;
}

.chapter-row-badge.solved {
  color: #8f5d10;
}

.btn-text-close {
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 15px;
  font-weight: 700;
  color: #6e3a20;
  padding: 6px 14px;
}

.btn-text-close:hover {
  color: #3d1c0c;
}

/* Ending Card */
.ending-card {
  width: min(820px, 92vw);
}

.ending-eyebrow {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 13px;
  letter-spacing: 2.5px;
  color: #8a5d2e;
  margin-bottom: 8px;
}

.ending-story {
  font-size: 19px;
  line-height: 1.45;
  color: #342216;
  margin-bottom: 18px;
}

.ending-relics {
  background: rgba(234, 217, 180, 0.82);
  border: 1.5px solid #b89156;
  border-radius: 8px;
  padding: 12px 20px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ending-relic-row {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
}

.ending-relic-name {
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 700;
  color: #3d2211;
}

.ending-relic-loc {
  font-style: italic;
  color: #6e5032;
}

.ending-stats {
  font-size: 18px;
  font-weight: 700;
  color: #7a351c;
  margin-bottom: 20px;
}

.ending-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
