:root, :host {
  color-scheme: dark;
  --ink: #eae6d8;
  --quiet: #b7b5a3;
  --night: #171812;
  --line: #b2ab8f41;
  --display: 'Baskerville', 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
  --ui: system-ui, sans-serif;
  font-family: var(--ui);
  color: var(--ink);
  background: var(--night);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 2px solid #e0ba75; outline-offset: 4px; }
button:disabled { opacity: .5; cursor: wait; }
svg { display: block; }

#gallery {
  position: fixed; inset: 0; width: 100%; height: 100%;
  display: block; outline: none; touch-action: none; cursor: grab;
}
#gallery:active { cursor: grabbing; }
#gallery.viewable { cursor: zoom-in; }
.entrance {
  position: fixed; inset: 0; overflow: auto;
  display: grid; grid-template-rows: auto 1fr auto;
  padding: 0 clamp(24px, 5.4vw, 92px);
  background: radial-gradient(ellipse at 80% 40%, #27271b, transparent 72%), var(--night);
}
.entrance-top, .entrance-bottom {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--quiet);
  min-height: 76px;
}
.entrance-top { border-bottom: 1px solid var(--line); }
.entrance-bottom { border-top: 1px solid var(--line); }
.entrance-main {
  position: relative; display: grid; grid-template-columns: 1fr 1.36fr; align-items: center;
  padding-block: 38px; min-height: 0;
}
.cover {
  grid-column: 2; grid-row: 1; margin: 0; overflow: hidden;
  background: #24231d; border: 1px solid #8f876640;
  height: min(62vh, 670px); min-height: 300px; position: relative;
}
.cover img { width: 100%; height: 100%; object-fit: cover; object-position: 55% center; display: block; }
.cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, #1819124a, transparent 45%); pointer-events: none; }
.invitation { grid-column: 1 / 3; grid-row: 1; z-index: 1; align-self: center; justify-self: start; }
h1 {
  font: 400 clamp(58px, 11.1vw, 174px)/.92 var(--display);
  letter-spacing: -.057em; margin: 0 0 clamp(28px, 4.3vw, 65px) -.045em;
  text-shadow: 0 2px 48px #11110e80;
}
.enter {
  border: 1px solid #efdcc1; padding: 13px 16px 13px 17px; min-height: 52px;
  min-width: 194px; display: inline-flex; align-items: center; justify-content: space-between; gap: 25px;
  background: #eee5d1; color: #191a13; font-size: 13px; font-weight: 600; transition: background .2s;
}
.enter:hover:not(:disabled) { background: #fff4d7; }
.enter span { font-size: 18px; font-weight: 400; }
#load-note { font-size: 12px; color: #e8dfc0; margin: 13px 0 0; min-height: 1.5em; }
.desktop-help { display: flex; align-items: center; gap: clamp(16px, 3vw, 44px); }
.desktop-help span { white-space: nowrap; }
.desktop-help kbd:last-of-type { margin-right: 6px; }
.touch-help { display: none; }
kbd { font: inherit; display: inline-grid; place-items: center; border: 1px solid currentColor; min-width: 18px; height: 18px; }
.text-button { background: none; color: var(--quiet); border: 0; padding: 7px 0; text-underline-offset: 4px; text-decoration: underline; font-size: 12px; }
.entrance-top .text-button { text-transform: none; letter-spacing: 0; min-height: 44px; }

#hud { pointer-events: none; position: fixed; inset: 0; }
.hud, .game-bottom { position: absolute; inset: 0 0 auto; display: flex; justify-content: space-between; align-items: flex-start; }
.hud {
  padding: max(21px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 35px max(24px, env(safe-area-inset-left));
  background: linear-gradient(#191a12a6, transparent);
}
.signature { display: grid; gap: 3px; text-shadow: 0 1px 6px #000b; }
.signature span:first-child { font: 29px/.95 var(--display); letter-spacing: .02em; }
.signature span:last-child { color: #f2eddd; font-size: 10px; letter-spacing: .18em; text-transform: uppercase; }
.hud-actions { display: flex; gap: 8px; }
.pill, .inspect {
  border: 1px solid #ded4b959; color: #f4ede0; border-radius: 99px; background: #191a13da;
  display: inline-flex; align-items: center; gap: 7px; justify-content: center; min-height: 38px;
  padding: 7px 13px; font-size: 12px; pointer-events: auto;
}
.pill:hover, .pill[aria-expanded="true"], .inspect:hover { background: #3b3b2e; border-color: #ded4b9a6; }
.pill svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5; }
.muted-wave, #sound-button[aria-pressed="false"] .sound-wave { display: none; }
#sound-button[aria-pressed="false"] .muted-wave { display: initial; }
.game-bottom {
  inset: auto 0 0; align-items: flex-end; gap: 16px;
  padding: 35px 24px max(22px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, #171812a3);
  text-shadow: 0 1px 5px #000;
}
.room-label { text-transform: uppercase; letter-spacing: .15em; font-size: 11px; }
.control-hint { color: #f0eadb; text-align: right; font-size: 11px; }
.crosshair {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 5px; height: 5px; border: 1px solid #fffdf4; border-radius: 50%; box-shadow: 0 0 4px #000b;
}
.crosshair.on-art { width: 11px; height: 11px; background-color: #1115; }
.inspect { position: absolute; top: calc(50% + 24px); left: 50%; transform: translateX(-50%); white-space: nowrap; }
.inspect kbd { min-width: 20px; height: 20px; border-radius: 4px; }
.room-map {
  pointer-events: auto; position: absolute; right: max(24px, env(safe-area-inset-right)); top: 70px;
  width: min(330px, calc(100vw - 48px)); padding: 16px; background: #191a14f2; border: 1px solid var(--line);
  box-shadow: 0 14px 52px #0005;
}
#floor-plan { width: 100%; }
.map-room { fill: #333529; }
.map-room.active { fill: #66694e; }
.map-wall { stroke: #b8b298; stroke-width: .065; stroke-linecap: square; }
.map-dot { fill: #fce6a7; stroke: #191a14; stroke-width: .045; }
.map-direction { fill: #fce6a7; }
.map-label { font: .46px var(--ui); text-anchor: middle; fill: var(--ink); pointer-events: none; }
.room-links { border-top: 1px solid var(--line); margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr; padding-top: 10px; gap: 3px; }
.room-links button { border: 0; padding: 8px; text-align: left; background: transparent; font-size: 12px; color: var(--ink); }
.room-links button:hover, .room-links button[aria-current="location"] { background: #393b2d; }
.joystick { display: none; }

#artwork {
  position: fixed; width: 100%; height: 100%; max-width: none; max-height: none;
  inset: 0; margin: 0; padding: clamp(12px, 3vw, 42px); border: 0;
  background: #171812f7; color: var(--ink);
}
#artwork[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 14px; }
#artwork::backdrop { background: #141510b8; }
.artwork-top { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.artwork-top h2 { font: 400 clamp(25px, 3vw, 44px)/1 var(--display); margin: 0; }
.artwork-stage { width: 100%; height: 100%; min-height: 0; display: grid; place-items: center; overflow: auto; position: relative; }
.artwork-stage img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; box-shadow: 0 4px 30px #090a05; }
.artwork-quality { position: absolute; bottom: 8px; left: 8px; padding: 6px 10px; background: #191a13e8; color: #f4ede0; font-size: 12px; pointer-events: none; }
.artwork-quality:empty { display: none; }
.artwork-stage.zoomed { display: block; }
.artwork-stage.zoomed img { width: auto; min-width: 100%; max-width: none; max-height: none; cursor: grab; user-select: none; }
.artwork-stage.zoomed img:active { cursor: grabbing; }
.artwork-bottom { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 9px; border-top: 1px solid var(--line); padding-top: 12px; }
#artwork-count { color: var(--quiet); min-width: 54px; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; }

@media (max-width: 670px) {
  .entrance-top, .entrance-bottom { min-height: 62px; }
  .entrance-main { align-content: center; grid-template-columns: 1fr; grid-template-rows: auto auto; gap: 22px; padding-block: 22px; }
  .invitation { grid-column: 1; grid-row: 1; }
  .cover { grid-column: 1; grid-row: 2; height: min(40vh, 380px); min-height: 180px; }
  h1 { font-size: clamp(47px, 12.4vw, 84px); margin-bottom: 21px; }
  .entrance-bottom { flex-wrap: wrap; }
  .desktop-help { flex-wrap: wrap; gap: 7px 15px; padding-block: 10px; }
  .hud { padding-inline: 13px; }
  .game-bottom { padding-inline: 13px; }
  .hud-actions { gap: 5px; }
  .pill { padding-inline: 10px; }
}
@media (pointer: coarse) {
  .desktop-help { display: none; }
  .touch-help { display: block; }
  .inspect kbd { display: none; }
  .pill, .inspect { min-height: 44px; }
  .joystick {
    display: grid; place-items: center; position: absolute; bottom: max(54px, env(safe-area-inset-bottom)); left: 19px;
    width: 103px; height: 103px; border: 1px solid #e7e0c579; border-radius: 50%; background: #12130f5e;
    pointer-events: auto; touch-action: none;
  }
  .joystick i { display: block; width: 37px; height: 37px; border: 1px solid #eee8d7aa; border-radius: 50%; background: #dad2b868; }
}
@media (max-width: 360px) {
  .signature span:first-child { font-size: 23px; }
  #map-button span, #sound-button span { display: none; }
  #map-button, #sound-button { min-width: 40px; }
}
