:root {
  color-scheme: light;
  --bg: #261a1a;
  --paper: #fff4df;
  --paper-dark: #f2d7a4;
  --ink: #201617;
  --muted: #6e4e43;
  --accent: #b85336;
  --accent-dark: #783328;
  --gold: #e4ae4b;
  --green: #4f7456;
  --blue: #315f78;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
  --radius: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: ui-rounded, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(circle at top left, rgba(228, 174, 75, 0.28), transparent 32rem),
    linear-gradient(135deg, #3b2526 0%, #211718 52%, #563526 100%);
  color: var(--ink);
  padding: calc(14px + var(--safe-top)) 14px calc(14px + var(--safe-bottom));
}

button {
  font: inherit;
  color: inherit;
}

.start-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: calc(18px + var(--safe-top)) 16px calc(18px + var(--safe-bottom));
  background:
    linear-gradient(rgba(32, 22, 23, 0.58), rgba(32, 22, 23, 0.72)),
    url('assets/scene-rehearsal.webp') center center / cover no-repeat,
    #261a1a;
}

.start-screen.hidden {
  display: none;
}

.start-card {
  width: min(680px, 100%);
  padding: clamp(22px, 5vw, 42px);
  border: 1px solid rgba(255, 244, 223, 0.36);
  border-radius: 28px;
  color: var(--paper);
  background: rgba(32, 22, 23, 0.86);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(16px);
}

.start-card h1 {
  margin: 0;
  font-size: clamp(3rem, 10vw, 6.5rem);
  letter-spacing: -0.07em;
  line-height: 0.86;
}

.start-premise {
  max-width: 58ch;
  margin: 18px 0 0;
  color: #ffe8ba;
  font-size: clamp(1rem, 2.2vw, 1.16rem);
  line-height: 1.55;
}

.start-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.primary-button {
  padding: 12px 18px;
  background: var(--gold);
  color: #2b1b1a;
  font-weight: 950;
}

.start-new-button {
  background: rgba(255, 244, 223, 0.94);
}

.start-note {
  margin: 18px 0 0;
  color: rgba(255, 244, 223, 0.76);
  font-size: 0.9rem;
  line-height: 1.4;
}


.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 244, 223, 0.28);
  border-radius: var(--radius);
  color: var(--paper);
  background: rgba(32, 22, 23, 0.72);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.brand-block h1,
.panel-section h2,
.scene-header h2 {
  margin: 0;
}

.brand-block h1 {
  letter-spacing: -0.04em;
  line-height: 0.95;
  font-size: clamp(2rem, 5vw, 4rem);
}

.eyebrow {
  margin: 0 0 4px;
  color: #f4cd8a;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
}

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

.save-status {
  min-width: 110px;
  text-align: right;
  color: #f6dbad;
  font-size: 0.85rem;
}

.ghost-button,
.matrix-home-link,
.primary-button,
.scene-nav button,
.hotspot,
.inventory-item {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ghost-button,
.matrix-home-link {
  background: var(--paper);
  color: var(--accent-dark);
  padding: 10px 14px;
  font-weight: 900;
}

.matrix-home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 14px;
}

.stage-card,
.side-panel {
  border-radius: var(--radius);
  background: rgba(255, 244, 223, 0.96);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.scene-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 2px solid rgba(120, 51, 40, 0.12);
  background: linear-gradient(90deg, #fff7e8, #f5d9a7);
}

.scene-header h2 {
  font-size: clamp(1.35rem, 3vw, 2.1rem);
}

.scene-header p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.35;
}

.scene-tools {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.objective-badge {
  align-self: flex-start;
  border-radius: 999px;
  padding: 8px 12px;
  background: #2b1b1a;
  color: #f8dc9a;
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.examine-button {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 0.82rem;
  border-color: rgba(228, 174, 75, 0.48);
}

.examine-button.active,
.examine-button[aria-pressed="true"] {
  background: #2b1b1a;
  color: #f8dc9a;
  border-color: rgba(248, 220, 154, 0.86);
}

.scene-canvas {
  position: relative;
  height: min(62vh, 560px);
  min-height: 420px;
  overflow: hidden;
  background: #dab26b;
  isolation: isolate;
}

.scene-canvas.examine-active {
  cursor: crosshair;
}

.scene-canvas.examine-active::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  box-shadow: inset 0 0 0 3px rgba(248, 220, 154, 0.18);
}

.scene-backdrop,
.hotspots-layer,
.scene-characters {
  position: absolute;
  inset: 0;
}

.scene-backdrop {
  z-index: 0;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.scene-characters {
  z-index: 1;
  pointer-events: none;
}

.hotspots-layer {
  z-index: 2;
}

.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  min-height: 40px;
  max-width: 190px;
  border: 2px solid rgba(255, 244, 223, 0.84);
  color: #fff8e8;
  background: rgba(32, 22, 23, 0.78);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  font-weight: 900;
  font-size: 0.9rem;
}

.hotspot:focus-visible,
.ghost-button:focus-visible,
.primary-button:focus-visible,
.scene-nav button:focus-visible,
.inventory-item:focus-visible {
  outline: 4px solid rgba(228, 174, 75, 0.82);
  outline-offset: 3px;
}


.hotspot-hidden {
  cursor: pointer;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: transparent;
  overflow: hidden;
  opacity: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.hotspot-hidden:focus-visible {
  opacity: 0;
  background: transparent;
  outline: none;
}

.dialog-log-pulse {
  animation: logPulse 560ms ease;
}

@keyframes logPulse {
  0% { box-shadow: inset 0 0 0 0 rgba(228, 174, 75, 0); }
  36% { box-shadow: inset 0 0 0 3px rgba(228, 174, 75, 0.34); }
  100% { box-shadow: inset 0 0 0 0 rgba(228, 174, 75, 0); }
}

.hotspot.collected,
.hotspot.locked {
  display: none;
}

.side-panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px - var(--safe-top) - var(--safe-bottom));
  max-height: calc(100vh - 120px - var(--safe-top) - var(--safe-bottom));
  min-height: 0;
  overflow: hidden;
}

.side-panel > .panel-section:not(.log-section) {
  flex: 0 0 auto;
  padding: 6px 12px;
}

.side-panel > .panel-section:not(.log-section) h2 {
  margin-bottom: 4px;
  font-size: 0.68rem;
  letter-spacing: 0.13em;
}

.side-panel > .panel-section:not(.log-section) .inventory-empty,
.side-panel > .panel-section:not(.log-section) .stories-count {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.12;
}

.side-panel > .panel-section:not(.log-section) .scene-nav {
  gap: 5px;
}

.side-panel > .panel-section:not(.log-section) .scene-nav button,
.side-panel > .panel-section:not(.log-section) .stories-button,
.side-panel > .panel-section:not(.log-section) .inventory-item {
  min-height: 26px;
  padding: 4px 8px;
  font-size: 0.72rem;
  border-radius: 999px;
}

.stories-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 10px;
  row-gap: 4px;
}

.stories-panel h2 {
  grid-column: 1 / -1;
}

.stories-panel .stories-button {
  justify-self: end;
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid rgba(120, 51, 40, 0.15);
}

.panel-section h2 {
  margin-bottom: 10px;
  font-size: 1rem;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.inventory-list,
.scene-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inventory-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.inventory-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 7px 10px 7px 8px;
  background: #2c1d1d;
  color: var(--paper);
  font-weight: 800;
}

.inventory-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  object-fit: contain;
}

.scene-nav button {
  padding: 10px 12px;
  background: #edd3a1;
  color: #38211e;
  font-weight: 900;
}

.scene-nav button.active {
  background: var(--accent-dark);
  color: var(--paper);
}

.stories-panel {
  display: grid;
  gap: 8px;
}

.stories-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 800;
}

.stories-button {
  justify-self: start;
}

.stories-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.log-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.log-header-row h2 {
  margin-bottom: 0;
}

.log-filter-label {
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(120, 51, 40, 0.1);
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 900;
}

.log-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.log-filter {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 999px;
  background: #f5dfb4;
  color: #3a2420;
  font-size: 0.82rem;
  font-weight: 900;
}

.log-filter.active {
  background: var(--accent-dark);
  color: var(--paper);
  box-shadow: 0 8px 18px rgba(120, 51, 40, 0.2);
}

.log-section {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 10px 12px 12px;
  overflow: hidden;
}

.dialog-log {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-right: 4px;
  line-height: 1.52;
}

.dialog-empty {
  margin: 0;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 250, 240, 0.72);
  color: var(--muted);
  font-weight: 800;
}

.dialog-entry {
  margin: 0 0 8px;
  padding: 9px 11px;
  border-radius: 14px;
  background: #fffaf0;
  border-left: 5px solid var(--gold);
  animation: logEntryIn 220ms ease both;
}

.dialog-entry-talk {
  border-left-color: #b85c38;
}

.dialog-entry-inventory {
  border-left-color: #4f6f52;
}

.dialog-entry-diary {
  border-left-color: var(--gold);
}

.dialog-entry strong {
  color: var(--accent-dark);
}

.trivia-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: calc(18px + var(--safe-top)) 16px calc(18px + var(--safe-bottom));
  background: rgba(32, 22, 23, 0.72);
  backdrop-filter: blur(10px);
}

.trivia-modal[hidden],
.stories-modal[hidden],
.final-modal[hidden] {
  display: none;
}

.stories-modal,
.final-modal {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: grid;
  place-items: center;
  padding: calc(18px + var(--safe-top)) 16px calc(18px + var(--safe-bottom));
  background: rgba(32, 22, 23, 0.72);
  backdrop-filter: blur(10px);
}

.stories-card,
.final-card {
  width: min(780px, 100%);
  max-height: min(84vh, 760px);
  overflow: auto;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid rgba(255, 244, 223, 0.36);
  border-radius: 28px;
  background: #fff4df;
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
}

.stories-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.stories-card h2 {
  margin: 0;
  color: var(--accent-dark);
  font-size: clamp(1.42rem, 3vw, 2.1rem);
}

.stories-list {
  display: grid;
  gap: 12px;
}

.story-entry {
  padding: 14px;
  border: 2px solid rgba(120, 51, 40, 0.16);
  border-radius: 18px;
  background: #fffaf0;
}

.story-entry h3 {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 1.08rem;
}

.story-entry p {
  margin: 0;
  line-height: 1.45;
}

.story-entry p + p {
  margin-top: 8px;
}

.story-question {
  color: var(--muted);
  font-weight: 850;
}

.stories-empty {
  margin: 0;
  padding: 14px;
  border-radius: 18px;
  background: #fffaf0;
  color: var(--muted);
  font-weight: 800;
}

.final-card {
  background:
    linear-gradient(rgba(255, 244, 223, 0.94), rgba(255, 244, 223, 0.98)),
    url('assets/scene-studio.webp') center center / cover no-repeat;
}

.final-card h2 {
  margin: 0;
  color: var(--accent-dark);
  font-size: clamp(1.8rem, 4.6vw, 3.1rem);
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.final-summary {
  max-width: 58ch;
  margin: 12px 0 18px;
  color: var(--muted);
  line-height: 1.48;
  font-weight: 800;
}

.final-stories-summary {
  padding: 14px;
  border: 2px solid rgba(120, 51, 40, 0.16);
  border-radius: 20px;
  background: rgba(255, 250, 240, 0.88);
}

.final-stories-summary h3 {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: 1.05rem;
}

.final-stories-list {
  display: grid;
  gap: 10px;
  max-height: min(30vh, 250px);
  overflow: auto;
  padding-right: 4px;
}

.final-story-entry {
  padding: 12px;
  border-radius: 16px;
  background: #fff4df;
  border-left: 5px solid var(--gold);
}

.final-story-entry h3 {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 1rem;
}

.final-story-entry p {
  margin: 0;
  line-height: 1.42;
}

.final-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.trivia-card {
  width: min(680px, 100%);
  max-height: min(82vh, 700px);
  overflow: auto;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid rgba(255, 244, 223, 0.36);
  border-radius: 28px;
  background: #fff4df;
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
}

.trivia-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.trivia-counter {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 900;
}

.trivia-close {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 12px;
  border: 2px solid rgba(120, 51, 40, 0.24);
  border-radius: 999px;
  background: #fffaf0;
  color: var(--accent-dark);
  font-weight: 950;
}

.trivia-card h2 {
  margin: 8px 0 16px;
  color: var(--accent-dark);
  font-size: clamp(1.12rem, 2.8vw, 1.72rem);
  line-height: 1.18;
}

.trivia-answers {
  display: grid;
  gap: 10px;
}

.trivia-answer {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 2px solid rgba(120, 51, 40, 0.24);
  border-radius: 16px;
  background: #fffaf0;
  text-align: left;
  font-weight: 900;
}

.trivia-answer:focus-visible,
.trivia-continue:focus-visible,
.trivia-close:focus-visible,
.stories-button:focus-visible,
.final-actions button:focus-visible {
  outline: 4px solid rgba(228, 174, 75, 0.82);
  outline-offset: 3px;
}

.trivia-answer.correct {
  border-color: rgba(79, 116, 86, 0.72);
  background: rgba(79, 116, 86, 0.16);
}

.trivia-answer.wrong {
  border-color: rgba(184, 83, 54, 0.72);
  background: rgba(184, 83, 54, 0.14);
}

.trivia-answer:disabled {
  cursor: default;
}

.trivia-feedback {
  min-height: 1.35em;
  margin: 14px 0 0;
  font-weight: 950;
  color: var(--accent-dark);
}

.trivia-story {
  margin-top: 14px;
  padding: 14px 16px;
  border-left: 5px solid var(--gold);
  border-radius: 16px;
  background: #fffaf0;
  line-height: 1.5;
  font-size: 0.98rem;
}

.trivia-story h3 {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.trivia-story p {
  margin: 0;
}

.trivia-continue {
  margin-top: 16px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  z-index: 20;
  transform: translateX(-50%) translateY(20px);
  max-width: min(92vw, 620px);
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(32, 22, 23, 0.94);
  color: var(--paper);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  text-align: center;
  font-weight: 800;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Illustrated scene backgrounds. */
.scene-rehearsal {
  background: #8a5937 url('assets/scene-rehearsal.webp') center center / cover no-repeat;
}

.scene-poppy {
  background: #91583f url('assets/scene-poppy.webp') center center / cover no-repeat;
}

.scene-studio {
  background: #5b4b41 url('assets/scene-studio.webp') center center / cover no-repeat;
}

.scene-rehearsal .scene-prop,
.scene-poppy .scene-prop,
.scene-studio .scene-prop {
  display: none;
}

.scene-prop {
  position: absolute;
  border-radius: 16px;
  background: rgba(255, 244, 223, 0.72);
  border: 4px solid rgba(32, 22, 23, 0.32);
  box-shadow: 0 18px 38px rgba(0,0,0,0.16);
}

.prop-amp { left: 8%; bottom: 22%; width: 18%; height: 20%; background: #302427; }
.prop-drums { left: 39%; bottom: 20%; width: 22%; height: 18%; border-radius: 999px; background: #f0cf78; }
.prop-guitars { right: 10%; bottom: 22%; width: 18%; height: 35%; background: linear-gradient(90deg, #753c28 0 30%, #f1d18a 30% 60%, #7b3429 60%); }
.prop-shop { left: 7%; bottom: 20%; width: 36%; height: 42%; background: #f9df9c; }
.prop-records { right: 9%; bottom: 23%; width: 28%; height: 24%; background: repeating-radial-gradient(circle, #1f181a 0 10px, #f6dfaa 11px 15px); }
.prop-console { left: 24%; bottom: 19%; width: 42%; height: 24%; background: #425769; }
.prop-booth { right: 8%; bottom: 22%; width: 20%; height: 48%; background: rgba(255, 244, 223, 0.42); }

.character {
  position: absolute;
  bottom: 19%;
  width: 86px;
  height: 156px;
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 12px 14px rgba(0, 0, 0, 0.28));
}

.char-pablo {
  left: 19%;
  background-image: url('assets/characters/pablo-cartney.svg');
}

.char-johnny {
  left: 31%;
  background-image: url('assets/characters/johnny-lumen.svg');
}

.char-george {
  left: 44%;
  background-image: url('assets/characters/george-harrow.svg');
}

.char-ricky {
  left: 57%;
  background-image: url('assets/characters/ricky-starling.svg');
}


@keyframes sceneSoftReveal {
  from { opacity: 0.72; transform: scale(1.015); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes characterIdle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes logEntryIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes panelSoftIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.scene-backdrop {
  animation: sceneSoftReveal 420ms ease both;
}

.character {
  animation: characterIdle 3.6s ease-in-out infinite;
}

.char-johnny { animation-delay: 0.35s; }
.char-george { animation-delay: 0.7s; }
.char-ricky { animation-delay: 1.05s; }

.panel-section,
.stage-card {
  animation: panelSoftIn 260ms ease both;
}

.inventory-item {
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.inventory-item:active {
  transform: scale(0.98);
}



.scene-canvas::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 222, 143, 0.16), transparent 24%),
    radial-gradient(circle at 84% 72%, rgba(125, 52, 43, 0.12), transparent 28%),
    linear-gradient(90deg, rgba(255,255,255,0.025), rgba(0,0,0,0.035));
  mix-blend-mode: soft-light;
  animation: ambientLightDrift 7s ease-in-out infinite alternate;
}

.scene-canvas::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.12;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.16) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0,0,0,0.12) 0 1px, transparent 1px 5px);
  animation: filmTexture 1.4s steps(2, end) infinite;
}

.scene-canvas.examine-active::after {
  z-index: 3;
  opacity: 1;
  background-image: none;
  box-shadow: inset 0 0 0 3px rgba(248, 220, 154, 0.18), inset 0 0 42px rgba(248, 220, 154, 0.12);
  animation: examineBreath 1.8s ease-in-out infinite;
}

.tap-ripple {
  position: absolute;
  z-index: 4;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(248, 220, 154, 0.78);
  background: rgba(248, 220, 154, 0.16);
  pointer-events: none;
  animation: tapRipple 680ms ease-out forwards;
}

.dialog-entry {
  box-shadow: 0 8px 18px rgba(52, 29, 25, 0.07);
}

.dialog-entry::selection,
.trivia-card ::selection,
.story-entry ::selection {
  background: rgba(228, 174, 75, 0.35);
}

.stage-card {
  position: relative;
  overflow: hidden;
}

.stage-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, transparent 0 45%, rgba(255,255,255,0.10) 50%, transparent 55% 100%);
  transform: translateX(-130%);
  animation: panelGlint 7s ease-in-out infinite;
}

.trivia-card,
.stories-card,
.final-card {
  animation: modalPopIn 260ms cubic-bezier(.2,.8,.2,1) both;
}

.trivia-answer {
  transition: transform 150ms ease, border-color 150ms ease, background-color 150ms ease;
}

.trivia-answer:active {
  transform: scale(0.985);
}

@keyframes ambientLightDrift {
  from { opacity: 0.72; transform: translate3d(-0.4%, -0.2%, 0) scale(1.006); }
  to { opacity: 1; transform: translate3d(0.4%, 0.2%, 0) scale(1.012); }
}

@keyframes filmTexture {
  0% { transform: translate(0, 0); }
  100% { transform: translate(-1px, 1px); }
}

@keyframes examineBreath {
  0%, 100% { box-shadow: inset 0 0 0 3px rgba(248, 220, 154, 0.16), inset 0 0 34px rgba(248, 220, 154, 0.08); }
  50% { box-shadow: inset 0 0 0 3px rgba(248, 220, 154, 0.28), inset 0 0 54px rgba(248, 220, 154, 0.18); }
}

@keyframes tapRipple {
  from { opacity: 0.75; transform: translate(-50%, -50%) scale(0.45); }
  to { opacity: 0; transform: translate(-50%, -50%) scale(2.9); }
}

@keyframes panelGlint {
  0%, 62% { transform: translateX(-130%); }
  78%, 100% { transform: translateX(130%); }
}

@keyframes modalPopIn {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}


@media (min-width: 861px) and (orientation: landscape) {
  .side-panel > .panel-section:not(.log-section) {
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .panel-section h2 {
    font-size: 0.78rem;
  }

  .log-section {
    padding-top: 10px;
  }

  .dialog-log {
    min-height: 0;
  }
}

@media (orientation: landscape) and (max-height: 760px) and (min-width: 861px) {
  .side-panel {
    height: calc(100vh - 88px - var(--safe-top) - var(--safe-bottom));
    max-height: calc(100vh - 88px - var(--safe-top) - var(--safe-bottom));
  }

  .side-panel > .panel-section:not(.log-section) {
    padding: 6px 14px;
  }

  .side-panel > .panel-section:not(.log-section) h2 {
    margin-bottom: 4px;
    font-size: 0.72rem;
  }

  .side-panel > .panel-section:not(.log-section) .inventory-empty,
  .side-panel > .panel-section:not(.log-section) .stories-count {
    font-size: 0.76rem;
  }

  .side-panel > .panel-section:not(.log-section) .scene-nav button,
  .side-panel > .panel-section:not(.log-section) .stories-button,
  .side-panel > .panel-section:not(.log-section) .inventory-item {
    min-height: 28px;
    padding: 5px 9px;
    font-size: 0.76rem;
  }

  .log-filters {
    gap: 5px;
  }

  .log-filter {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 0.76rem;
  }

  .dialog-log {
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

@media (max-width: 860px) {
  body {
    padding-left: 10px;
    padding-right: 10px;
  }

  .topbar,
  .scene-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .save-status {
    text-align: left;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    height: auto;
    max-height: none;
    min-height: 0;
    overflow: visible;
  }

  .dialog-log {
    min-height: 260px;
    max-height: 54vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .scene-canvas {
    height: 58vh;
    min-height: 380px;
  }

  .objective-badge {
    white-space: normal;
  }
}

@media (orientation: landscape) and (max-height: 720px) {
  .trivia-modal {
    align-items: start;
    padding-top: calc(10px + var(--safe-top));
    padding-bottom: calc(10px + var(--safe-bottom));
  }

  .trivia-card,
  .stories-card,
  .final-card {
    width: min(760px, 100%);
    max-height: calc(100vh - 24px - var(--safe-top) - var(--safe-bottom));
    padding: 16px 20px;
  }

  .trivia-card h2 {
    font-size: clamp(1rem, 2.2vw, 1.34rem);
    line-height: 1.2;
    margin-bottom: 12px;
  }

  .trivia-answer {
    min-height: 42px;
    padding: 9px 12px;
  }

  .trivia-story {
    max-height: 24vh;
    overflow: auto;
    font-size: 0.92rem;
  }
}

@media (max-width: 520px) {
  .trivia-modal {
    padding-left: 10px;
    padding-right: 10px;
  }

  .trivia-card,
  .stories-card,
  .final-card {
    border-radius: 22px;
    padding: 16px;
  }

  .trivia-card-top,
  .stories-card-top {
    gap: 10px;
  }

  .trivia-close {
    min-height: 38px;
    padding: 7px 10px;
    font-size: 0.84rem;
  }

  .trivia-card h2 {
    font-size: 1.08rem;
    line-height: 1.22;
  }

  .trivia-answer {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 0.92rem;
  }

  .trivia-story {
    padding: 12px;
    font-size: 0.92rem;
  }

  .hotspot {
    font-size: 0.78rem;
    padding: 7px 9px;
    max-width: 150px;
  }

  .scene-canvas {
    min-height: 360px;
  }

  .character {
    transform: scale(0.84);
    transform-origin: bottom center;
  }
}



.scene-canvas::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 222, 143, 0.16), transparent 24%),
    radial-gradient(circle at 84% 72%, rgba(125, 52, 43, 0.12), transparent 28%),
    linear-gradient(90deg, rgba(255,255,255,0.025), rgba(0,0,0,0.035));
  mix-blend-mode: soft-light;
  animation: ambientLightDrift 7s ease-in-out infinite alternate;
}

.scene-canvas::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.12;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.16) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0,0,0,0.12) 0 1px, transparent 1px 5px);
  animation: filmTexture 1.4s steps(2, end) infinite;
}

.scene-canvas.examine-active::after {
  z-index: 3;
  opacity: 1;
  background-image: none;
  box-shadow: inset 0 0 0 3px rgba(248, 220, 154, 0.18), inset 0 0 42px rgba(248, 220, 154, 0.12);
  animation: examineBreath 1.8s ease-in-out infinite;
}

.tap-ripple {
  position: absolute;
  z-index: 4;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(248, 220, 154, 0.78);
  background: rgba(248, 220, 154, 0.16);
  pointer-events: none;
  animation: tapRipple 680ms ease-out forwards;
}

.dialog-entry {
  box-shadow: 0 8px 18px rgba(52, 29, 25, 0.07);
}

.dialog-entry::selection,
.trivia-card ::selection,
.story-entry ::selection {
  background: rgba(228, 174, 75, 0.35);
}

.stage-card {
  position: relative;
  overflow: hidden;
}

.stage-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, transparent 0 45%, rgba(255,255,255,0.10) 50%, transparent 55% 100%);
  transform: translateX(-130%);
  animation: panelGlint 7s ease-in-out infinite;
}

.trivia-card,
.stories-card,
.final-card {
  animation: modalPopIn 260ms cubic-bezier(.2,.8,.2,1) both;
}

.trivia-answer {
  transition: transform 150ms ease, border-color 150ms ease, background-color 150ms ease;
}

.trivia-answer:active {
  transform: scale(0.985);
}

@keyframes ambientLightDrift {
  from { opacity: 0.72; transform: translate3d(-0.4%, -0.2%, 0) scale(1.006); }
  to { opacity: 1; transform: translate3d(0.4%, 0.2%, 0) scale(1.012); }
}

@keyframes filmTexture {
  0% { transform: translate(0, 0); }
  100% { transform: translate(-1px, 1px); }
}

@keyframes examineBreath {
  0%, 100% { box-shadow: inset 0 0 0 3px rgba(248, 220, 154, 0.16), inset 0 0 34px rgba(248, 220, 154, 0.08); }
  50% { box-shadow: inset 0 0 0 3px rgba(248, 220, 154, 0.28), inset 0 0 54px rgba(248, 220, 154, 0.18); }
}

@keyframes tapRipple {
  from { opacity: 0.75; transform: translate(-50%, -50%) scale(0.45); }
  to { opacity: 0; transform: translate(-50%, -50%) scale(2.9); }
}

@keyframes panelGlint {
  0%, 62% { transform: translateX(-130%); }
  78%, 100% { transform: translateX(130%); }
}

@keyframes modalPopIn {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
