:root {
  --bg-1: #f5ecd8;
  --bg-2: #dce8dd;
  --panel: rgba(255, 250, 243, 0.96);
  --panel-border: #7d6a58;
  --text: #1f2528;
  --muted: #555f63;
  --accent: #d79d41;
  --accent-2: #4f95a8;
  --good: #2d8a58;
  --bad: #ab3d3d;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: "Trebuchet MS", "Verdana", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 12%, rgba(255, 245, 226, 0.92) 0%, rgba(255, 245, 226, 0) 32%),
    radial-gradient(circle at 84% 18%, rgba(178, 213, 223, 0.4) 0%, rgba(178, 213, 223, 0) 28%),
    linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 100%);
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: linear-gradient(180deg, #efe4d2 0%, #d6e4dc 100%);
}

#hud {
  pointer-events: none;
  position: absolute;
  inset: 0;
  padding: 10px;
  z-index: 8;
}

#objective {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 920px;
  text-align: center;
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.94), rgba(245, 237, 223, 0.94));
  border: 2px solid rgba(125, 106, 88, 0.45);
  color: #243132;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  letter-spacing: 0.2px;
  box-shadow: 0 10px 18px rgba(58, 48, 38, 0.12);
}

#status-line {
  position: absolute;
  left: 10px;
  bottom: 76px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#status-line span {
  background: rgba(255, 250, 243, 0.93);
  border: 2px solid rgba(79, 149, 168, 0.38);
  color: #2d4247;
  border-radius: 9px;
  padding: 6px 10px;
  font-size: 0.86rem;
  font-weight: 700;
  box-shadow: 0 8px 12px rgba(24, 39, 43, 0.08);
}

#interaction-prompt {
  position: absolute;
  left: 50%;
  bottom: 76px;
  transform: translateX(-50%);
  background: rgba(31, 42, 44, 0.92);
  color: #f7f9fa;
  border: 2px solid rgba(215, 157, 65, 0.82);
  border-radius: 9px;
  padding: 8px 12px;
  font-weight: 700;
  box-shadow: 0 12px 18px rgba(0, 0, 0, 0.18);
}

#quick-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(29, 38, 40, 0.92), rgba(18, 24, 25, 0.94));
  border-top: 3px solid rgba(215, 157, 65, 0.7);
  padding: 10px 12px;
  box-shadow: 0 -12px 24px rgba(0, 0, 0, 0.12);
}

#quick-actions span {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f2f6f7;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.82rem;
  letter-spacing: 0.3px;
}

#touch-controls {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 56px;
  z-index: 11;
  display: none;
  justify-content: space-between;
  gap: 8px;
}

.touch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(52px, 66px));
  gap: 7px;
}

#touch-controls button {
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(29, 44, 46, 0.86);
  color: #ffffff;
  border-radius: 10px;
  font-size: 0.72rem;
  letter-spacing: 0.2px;
  font-weight: 700;
  padding: 10px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(14, 18, 20, 0.68);
  z-index: 20;
}

.overlay.visible {
  display: flex;
}

.overlay-panel {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(14, 18, 20, 0.58);
  z-index: 19;
}

.hidden {
  display: none !important;
}

.panel {
  width: min(940px, 96vw);
  max-height: min(88vh, 780px);
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(255, 253, 249, 0.98), rgba(247, 239, 227, 0.96));
  border: 2px solid var(--panel-border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 26px 48px rgba(0, 0, 0, 0.24);
}

.intro-panel {
  width: min(760px, 96vw);
}

h1,
h2,
h3 {
  margin-top: 0;
  color: #1f3637;
}

p {
  line-height: 1.44;
}

ul {
  margin: 10px 0;
  padding-left: 20px;
  color: var(--muted);
}

.controls-list {
  display: grid;
  gap: 4px;
  margin: 12px 0 16px;
  color: #2a5357;
}

button {
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 120ms ease, filter 120ms ease, background 120ms ease;
}

.primary {
  background: linear-gradient(180deg, #ffd98f, #f5b449);
  color: #332101;
  border-color: rgba(120, 78, 5, 0.42);
}

.secondary {
  background: rgba(83, 181, 216, 0.18);
  color: #1d454f;
  border-color: rgba(83, 181, 216, 0.48);
}

.icon-btn {
  float: right;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.08);
  color: #132122;
  border-color: rgba(0, 0, 0, 0.18);
  padding: 0;
}

#modal-body {
  display: grid;
  gap: 10px;
}

.artwork-card {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 14px;
  border: 1px solid rgba(82, 60, 39, 0.18);
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(248, 241, 231, 0.72));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.artwork-media {
  position: relative;
  cursor: zoom-in;
}

.artwork-image,
.artwork-fallback {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.14);
}

.artwork-fallback {
  display: grid;
  place-items: center;
  text-align: center;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.zoom-chip {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(23, 31, 33, 0.82);
  color: #f6fafb;
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.2);
}

.loupe-icon {
  position: relative;
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.loupe-icon::after {
  content: "";
  position: absolute;
  right: -4px;
  bottom: -5px;
  width: 2px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  transform: rotate(-42deg);
  transform-origin: top center;
}

.meta {
  display: grid;
  gap: 6px;
  color: #2f3d3f;
}

.clue-box {
  border-left: 4px solid rgba(246, 185, 78, 0.85);
  border-radius: 8px;
  background: rgba(246, 185, 78, 0.12);
  color: #4a3510;
  padding: 9px 11px;
}

.options-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-btn {
  background: rgba(79, 149, 168, 0.14);
  color: #1d454f;
  border-color: rgba(79, 149, 168, 0.45);
}

.choice-btn:hover,
.primary:hover,
.secondary:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.text-input {
  width: min(460px, 90vw);
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  padding: 10px;
}

.success {
  color: var(--good);
  font-weight: 700;
}

.error {
  color: var(--bad);
  font-weight: 700;
}

#notebook-content {
  display: grid;
  gap: 10px;
}

.notebook-room {
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.66);
}

.fragment {
  display: inline-block;
  margin-top: 7px;
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid rgba(45, 138, 88, 0.45);
  background: rgba(45, 138, 88, 0.14);
  color: #1e5a3c;
  font-weight: 700;
}

.external-link {
  color: #0e4f73;
}

.modal-hint {
  color: #536466;
  font-size: 0.9rem;
  font-weight: 700;
}

.zoom-overlay {
  z-index: 21;
  background: rgba(10, 14, 18, 0.78);
}

.zoom-panel {
  width: min(1100px, 96vw);
  max-height: min(92vh, 900px);
}

.zoom-media-wrap {
  display: grid;
  place-items: center;
  min-height: 360px;
}

.zoom-image,
.zoom-media-wrap .artwork-fallback {
  width: 100%;
  max-height: min(74vh, 760px);
  aspect-ratio: auto;
  object-fit: contain;
  border-radius: 12px;
  background: rgba(20, 24, 29, 0.82);
}

.zoom-media-wrap .artwork-fallback {
  min-height: 420px;
}

@media (max-width: 860px) {
  .artwork-card {
    grid-template-columns: 1fr;
  }

  #objective {
    font-size: 0.9rem;
  }

  #status-line span {
    font-size: 0.78rem;
  }

  #quick-actions {
    gap: 7px;
    padding: 8px;
  }

  #quick-actions span {
    font-size: 0.75rem;
  }

  .zoom-chip {
    left: 10px;
    right: 10px;
    justify-content: center;
  }
}

@media (hover: none) and (pointer: coarse) {
  #touch-controls {
    display: flex;
  }

  #status-line {
    bottom: 162px;
  }

  #interaction-prompt {
    bottom: 162px;
  }
}
