:root {
  --paper: #e8dcc0;
  --ink: #1a1a1a;
  --red: #722f37;
  --wood: #3d2914;
  --mould: #4a5d3a;
  --panel: rgba(232, 220, 192, 0.92);
  --line: rgba(26, 26, 26, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--ink);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--paper);
  background:
    radial-gradient(circle at 20% 0%, rgba(114, 47, 55, 0.22), transparent 30rem),
    linear-gradient(180deg, #111, #211b15 42%, #0d0d0d);
  font-family: Georgia, "Times New Roman", serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid rgba(232, 220, 192, 0.35);
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.app {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.topbar,
.scene-head,
.top-actions,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  padding: 8px 0 14px;
}

.brand span,
.meta {
  margin: 0 0 4px;
  color: #c6b58e;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.02;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 6vw, 4.2rem);
}

h2 {
  font-size: clamp(1.35rem, 3vw, 2.3rem);
}

.level-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.level-nav button {
  display: grid;
  min-width: 0;
  padding: 10px;
  text-align: left;
  border-color: rgba(232, 220, 192, 0.24);
  background: rgba(26, 26, 26, 0.72);
}

.level-nav button.active {
  border-color: var(--red);
  box-shadow: inset 0 -3px 0 var(--red);
}

.level-nav span {
  color: #bba77f;
  font-size: 0.72rem;
}

.level-nav strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 16px;
  align-items: start;
}

.scene-wrap,
.panel {
  border: 1px solid rgba(232, 220, 192, 0.22);
  background: rgba(10, 10, 10, 0.56);
}

.scene-head {
  padding: 14px;
  border-bottom: 1px solid rgba(232, 220, 192, 0.16);
}

.hint-btn {
  min-width: 82px;
  border-color: var(--mould);
}

.scene {
  position: relative;
  width: min(100%, 860px);
  margin: 0 auto;
  background: #090909;
  touch-action: manipulation;
}

.scene img {
  display: block;
  width: 100%;
  height: auto;
}

.hotspot-layer {
  position: absolute;
  inset: 0;
}

.hotspot {
  position: absolute;
  border: 2px solid transparent;
  background: rgba(232, 220, 192, 0.01);
  color: transparent;
  padding: 0;
}

.hotspot::after {
  content: "";
  position: absolute;
  inset: max(0px, calc((44px - 100%) / -2));
}

.hotspot:focus-visible,
.hotspot:hover {
  border-color: rgba(232, 220, 192, 0.8);
  background: rgba(114, 47, 55, 0.18);
  outline: none;
}

.hotspot.collected {
  border-color: rgba(74, 93, 58, 0.85);
}

.panel {
  position: sticky;
  top: 12px;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.panel section {
  border-bottom: 1px solid rgba(232, 220, 192, 0.14);
  padding-bottom: 12px;
}

.panel section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.message,
.task-box {
  min-height: 96px;
  padding: 14px;
  color: #261a12;
  background: var(--panel);
  border: 1px solid var(--line);
  line-height: 1.45;
}

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

.memory {
  min-height: 44px;
  padding: 10px;
  border: 1px solid rgba(232, 220, 192, 0.22);
  background: rgba(232, 220, 192, 0.08);
  color: #baa987;
}

.memory.found {
  border-color: var(--mould);
  color: var(--paper);
  background: rgba(74, 93, 58, 0.28);
}

.choice-row,
.code-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.choice-row button,
.code-row button {
  flex: 1 1 120px;
}

.code-row input {
  flex: 999 1 150px;
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: #f0e5c9;
  color: var(--ink);
}

.modal {
  width: min(560px, calc(100% - 28px));
  border: 1px solid rgba(232, 220, 192, 0.45);
  padding: 0;
  color: var(--paper);
  background: #17120e;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.78);
}

.modal > div {
  padding: 22px;
}

.modal p {
  line-height: 1.5;
}

.ending.accept {
  border-color: #d4b25f;
}

.ending.repeat {
  border-color: var(--red);
}

@media (max-width: 920px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .app {
    padding: 10px;
  }

  .topbar {
    align-items: flex-start;
  }

  .top-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .level-nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
  }

  .level-nav button {
    flex: 0 0 132px;
    scroll-snap-align: start;
  }

  .scene-head {
    align-items: flex-start;
  }

  .inventory {
    grid-template-columns: 1fr;
  }
}
