:root {
  --wood-dark: #1d1410;
  --wood-mid: #2f2019;
  --wood-light: #473227;
  --parchment: #f6efe2;
  --parchment-deep: #eadcc4;
  --ink: #2a1d17;
  --ink-muted: #665043;
  --brass: #c79846;
  --brass-bright: #e5be73;
  --brass-dark: #7d581d;
  --ruby: #a2352c;
  --sage: #386a4c;
  --shadow-lg: 0 18px 48px rgba(10, 6, 4, 0.55);
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-ui: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--wood-dark);
  color: var(--ink);
  font-family: var(--font-ui);
  user-select: none;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

.hidden {
  display: none !important;
}

/* === PARCHMENT & BRASS SURFACES === */
.parchment-panel {
  background: radial-gradient(circle at 30% 20%, #fbf6ec 0%, var(--parchment) 55%, var(--parchment-deep) 100%);
  border: 2px solid var(--brass);
  box-shadow: var(--shadow-lg), inset 0 0 0 3px rgba(199, 152, 70, 0.22);
  border-radius: 16px;
}

.parchment-bar {
  background: linear-gradient(180deg, #35241c 0%, #241812 100%);
  color: var(--parchment);
  border-bottom: 1.5px solid rgba(199, 152, 70, 0.5);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* === BUTTONS === */
button {
  font-family: var(--font-ui);
  cursor: pointer;
  border: none;
  outline: none;
  transition: transform 0.14s ease, filter 0.14s ease, background 0.2s ease;
}

button:active {
  transform: scale(0.96);
}

.btn-brass {
  background: linear-gradient(180deg, var(--brass-bright) 0%, var(--brass) 55%, #a87a2d 100%);
  color: #21150d;
  font-weight: 800;
  font-size: 1rem;
  padding: 12px 24px;
  border-radius: 999px;
  border: 1.5px solid #f7dc9e;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.btn-brass:hover {
  filter: brightness(1.06);
}

.btn-ghost {
  background: rgba(42, 29, 23, 0.08);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1.5px solid rgba(125, 88, 29, 0.45);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(246, 239, 226, 0.1);
  color: var(--parchment);
  border: 1px solid rgba(199, 152, 70, 0.45);
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* === PORTRAIT MEDALLION === */
.portrait-medallion {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--brass);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3), inset 0 0 0 2px #fbf6ec;
  background: var(--parchment);
  flex-shrink: 0;
}

.portrait-medallion.large {
  width: 104px;
  height: 104px;
}

.portrait-medallion img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

/* === TITLE SCREEN === */
#screen-title {
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.title-backdrop {
  position: absolute;
  inset: 0;
  background: url('../assets/locations/loc01_essen_study.jpg') center/cover no-repeat;
  filter: blur(2px) brightness(0.68) saturate(1.08);
  transform: scale(1.04);
}

.title-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(29, 20, 16, 0.15) 0%, rgba(17, 11, 8, 0.82) 100%);
}

.title-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 520px;
  padding: 24px 22px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.title-crest {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass-dark);
  font-weight: 800;
}

.title-hero-row {
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
}

.title-headings h1 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4.5vw, 2.35rem);
  line-height: 1.08;
  color: var(--ink);
}

.subtitle {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-muted);
  font-weight: 600;
}

.title-blurb {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.5;
  color: var(--ink);
  background: rgba(199, 152, 70, 0.1);
  border-left: 3px solid var(--brass);
  padding: 10px 12px;
  border-radius: 0 8px 8px 0;
  text-align: left;
}

.lang-switch-pill {
  display: inline-flex;
  align-self: center;
  background: rgba(42, 29, 23, 0.09);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid rgba(125, 88, 29, 0.3);
  gap: 4px;
}

.lang-btn {
  background: transparent;
  color: var(--ink-muted);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 7px 14px;
  border-radius: 999px;
}

.lang-btn.active {
  background: var(--wood-mid);
  color: var(--brass-bright);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.title-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.primary-cta {
  flex: 1;
  max-width: 280px;
  font-size: 1.05rem;
}

/* === MAP / CHAPTERS SCREEN === */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  z-index: 5;
}

.brand-mini {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
  border: 2px solid var(--brass);
}

.bar-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--brass-bright);
  line-height: 1.1;
}

.bar-sub {
  font-size: 0.78rem;
  color: rgba(246, 239, 226, 0.78);
}

.bar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-switch-compact {
  display: inline-flex;
  background: rgba(246, 239, 226, 0.08);
  padding: 3px;
  border-radius: 999px;
  border: 1px solid rgba(199, 152, 70, 0.35);
}

.lang-switch-compact .lang-btn {
  padding: 4px 10px;
  font-size: 0.75rem;
  color: rgba(246, 239, 226, 0.72);
}

.lang-switch-compact .lang-btn.active {
  background: var(--brass);
  color: var(--wood-dark);
}

.map-viewport {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  background:
    radial-gradient(circle at 20% 10%, rgba(199, 152, 70, 0.12), transparent 50%),
    linear-gradient(180deg, #251a14 0%, #1a110d 100%);
}

.journey-banner {
  max-width: 1100px;
  margin: 0 auto 14px;
  background: rgba(246, 239, 226, 0.07);
  border: 1px solid rgba(199, 152, 70, 0.3);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--parchment);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brass) 0%, var(--brass-bright) 100%);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.chapters-grid {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
  padding-bottom: 24px;
}

.chapter-card {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: var(--parchment);
  border: 2px solid var(--brass);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
}

.chapter-card.locked {
  opacity: 0.62;
  filter: grayscale(0.55);
  cursor: not-allowed;
  border-color: rgba(199, 152, 70, 0.35);
}

.chapter-card.current {
  box-shadow: 0 0 0 2px var(--brass-bright), 0 12px 28px rgba(199, 152, 70, 0.35);
}

.chapter-thumb {
  position: relative;
  height: 132px;
  background-size: cover;
  background-position: center;
}

.chapter-num-pill {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(29, 20, 16, 0.84);
  color: var(--brass-bright);
  border: 1px solid var(--brass);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
}

.chapter-status-pill {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(29, 20, 16, 0.84);
  color: #fff;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
}

.chapter-status-pill.done {
  background: var(--sage);
}

.chapter-info {
  padding: 10px 12px 12px;
  color: var(--ink);
}

.chapter-city {
  font-family: var(--font-display);
  font-size: 1.22rem;
  font-weight: 700;
  line-height: 1.1;
}

.chapter-place {
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* === STORY PROLOGUE SCREEN === */
#screen-story {
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.story-backdrop {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: blur(4px) brightness(0.42);
  transform: scale(1.05);
}

.story-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 600px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 92dvh;
  overflow-y: auto;
}

.story-header {
  border-bottom: 1px solid rgba(125, 88, 29, 0.3);
  padding-bottom: 10px;
}

.chapter-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass-dark);
}

.story-header h2 {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2rem);
  color: var(--ink);
}

.story-body {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.story-portraits {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.speaker-tag {
  margin: 0 0 6px;
  font-weight: 800;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ruby);
}

.story-narrative {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.18rem;
  line-height: 1.48;
  color: var(--ink);
}

.story-objective {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--sage);
  background: rgba(56, 106, 76, 0.1);
  padding: 8px 10px;
  border-radius: 8px;
}

.story-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 6px;
}

/* === GAMEPLAY SCREEN === */
.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  gap: 8px;
  z-index: 10;
}

.hud-left, .hud-center, .hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-location {
  display: flex;
  flex-direction: column;
}

.hud-kicker {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brass-bright);
  font-weight: 700;
}

.hud-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.05;
}

.timer-pill, .found-pill {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(199, 152, 70, 0.5);
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.timer-pill.warning {
  background: rgba(162, 53, 44, 0.85);
  border-color: #ff9c94;
  animation: pulse-warn 0.9s infinite;
}

@keyframes pulse-warn {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.btn-hint {
  background: linear-gradient(180deg, #f3d285 0%, #c79846 100%);
  color: #241710;
  font-weight: 800;
  font-size: 0.88rem;
  padding: 6px 11px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid #fff0c2;
}

.btn-hint:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

/* === SCENE STAGE (PAN & ZOOM) === */
.scene-stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: #120c09;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scene-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 1200px;
  aspect-ratio: 16 / 9;
  transform-origin: center center;
  will-change: transform;
  box-shadow: 0 12px 42px rgba(0, 0, 0, 0.75);
}

.scene-bg {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  pointer-events: none;
}

.scene-items-layer, .scene-fx-layer {
  position: absolute;
  inset: 0;
}

.scene-fx-layer {
  pointer-events: none;
}

.hidden-prop {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: transform 0.25s ease, opacity 0.35s ease;
  background: transparent;
  border-radius: 14px;
  padding: 6px; /* generous mobile hit area */
}

.hidden-prop.found {
  pointer-events: none;
  opacity: 0;
}

.hidden-prop.hint-glow {
  border: 3px solid #ffe89e;
  background: rgba(255, 224, 130, 0.14);
  box-shadow: 0 0 18px rgba(255, 184, 48, 0.9), inset 0 0 12px rgba(255, 232, 158, 0.45);
  border-radius: 9999px;
  animation: hint-beacon 1.1s ease-in-out infinite;
  z-index: 6;
}

@keyframes hint-beacon {
  0%, 100% {
    transform: translate(-50%, -50%) scale(0.96);
    opacity: 0.85;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 1;
  }
}

.fx-ring {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid var(--brass-bright);
  transform: translate(-50%, -50%) scale(0.4);
  opacity: 1;
  animation: ring-pop 0.55s ease-out forwards;
}

.fx-ring.miss {
  width: 32px;
  height: 32px;
  border-color: rgba(220, 88, 72, 0.85);
}

@keyframes ring-pop {
  to {
    transform: translate(-50%, -50%) scale(1.65);
    opacity: 0;
  }
}

.fx-label {
  position: absolute;
  transform: translate(-50%, -100%);
  background: rgba(29, 20, 16, 0.9);
  color: var(--brass-bright);
  border: 1px solid var(--brass);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  animation: float-up 0.95s ease-out forwards;
}

@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, -60%); }
  20% { opacity: 1; transform: translate(-50%, -110%); }
  100% { opacity: 0; transform: translate(-50%, -180%); }
}

.scene-toast {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(29, 20, 16, 0.9);
  color: var(--parchment);
  border: 1px solid var(--brass);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  z-index: 12;
  pointer-events: none;
}

/* === BOTTOM ITEMS TRAY === */
.items-tray {
  border-top: 1.5px solid rgba(199, 152, 70, 0.5);
  border-bottom: none;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  z-index: 10;
}

.tray-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.72rem;
  color: rgba(246, 239, 226, 0.75);
  font-weight: 700;
}

.items-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  max-height: 120px;
  overflow-y: auto;
}

.item-chip {
  background: rgba(246, 239, 226, 0.09);
  border: 1px solid rgba(199, 152, 70, 0.35);
  color: var(--parchment);
  border-radius: 8px;
  padding: 4px 5px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  transition: all 0.25s ease;
}

.item-chip.found {
  background: rgba(56, 106, 76, 0.35);
  border-color: rgba(114, 194, 145, 0.55);
  color: rgba(246, 239, 226, 0.48);
  text-decoration: line-through;
}

/* === RESULT MODAL === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 9, 6, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 30;
}

.result-card {
  width: 100%;
  max-width: 440px;
  padding: 22px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.result-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.8rem;
}

.result-subtitle {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-muted);
}

.result-stars {
  font-size: 1.9rem;
  color: var(--brass);
  letter-spacing: 6px;
  text-shadow: 0 2px 6px rgba(125, 88, 29, 0.3);
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  margin: 4px 0 8px;
}

.stat-box {
  background: rgba(42, 29, 23, 0.07);
  border: 1px solid rgba(125, 88, 29, 0.25);
  border-radius: 10px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--ink-muted);
  font-weight: 700;
}

.stat-val {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
}

.result-actions {
  display: flex;
  width: 100%;
  gap: 10px;
}

.result-actions button {
  flex: 1;
}

/* === MOBILE RESPONSIVE TUNING === */
@media (max-width: 680px) {
  .title-hero-row {
    flex-direction: column;
    text-align: center;
  }
  .story-body {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .items-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: 158px;
  }
  .item-chip {
    font-size: 0.68rem;
    min-height: 28px;
    padding: 3px 4px;
  }
  .game-hud {
    padding: 6px 8px;
    gap: 4px;
  }
  .hud-left, .hud-center, .hud-right {
    gap: 4px;
  }
  .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }
  .btn-hint {
    padding: 5px 8px;
    font-size: 0.8rem;
  }
  .hud-kicker {
    white-space: nowrap;
  }
  .hud-title {
    font-size: 0.88rem;
  }
  .timer-pill, .found-pill {
    padding: 4px 7px;
    font-size: 0.78rem;
  }
}
