:root {
  --paper: #fbfbf9;
  --ink: #1f2023;
  --graphite: #5d5f66;
  --hair: #dcdcd6;
  --ultramarine: #2336c8;
  --alarm: #b3261e;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--ink); font-family: var(--sans); -webkit-tap-highlight-color: transparent; }
#stage { position: fixed; inset: 0; touch-action: none; }
#stage canvas { display: block; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ultramarine); outline-offset: 2px; }

/* Wall text in the corner */
#hud { position: fixed; top: calc(var(--top) + 18px); left: 20px; pointer-events: none; color: #fff; text-shadow: 0 1px 12px rgba(0,0,0,.5); max-width: 40vw; }
#hud .museum { font-size: 13px; opacity: .85; }
#hud .show { font-family: var(--serif); font-size: 28px; line-height: 1.1; }
#hud .room { font-size: 14px; margin-top: 4px; opacity: .85; }

#menuBtn { position: fixed; top: calc(var(--top) + 14px); right: 16px; background: var(--paper); border: 0; padding: 10px 16px; border-radius: 999px; font-weight: 500; box-shadow: 0 2px 14px rgba(0,0,0,.25); }

/* Camera switcher, a small segmented control at the top */
#modes { position: fixed; top: calc(var(--top) + 14px); left: 50%; transform: translateX(-50%); background: rgba(251,251,249,.94); box-shadow: 0 2px 14px rgba(0,0,0,.2); }
#tourBtn { position: fixed; top: calc(var(--top) + 60px); left: 50%; transform: translateX(-50%); display: none; background: rgba(31,32,35,.8); color: #fff; border: 0; border-radius: 999px; padding: 7px 14px; font-size: 14px; }
body[data-mode="drone"] #tourBtn { display: block; }
@media (max-width: 720px) {
  #hud { max-width: 55vw; }
  #hud .show { font-size: 22px; }
  #modes { top: auto; bottom: calc(var(--bottom) + 230px); }
  #tourBtn { top: auto; bottom: calc(var(--bottom) + 276px); }
}

#crosshair { position: fixed; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: #fff; mix-blend-mode: difference; pointer-events: none; }

#actions { position: fixed; left: 50%; bottom: calc(var(--bottom) + 20px); transform: translateX(-50%); display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 92vw; }
#actions:empty { display: none; }
#actions button { background: rgba(251,251,249,.94); border: 0; border-radius: 6px; padding: 9px 14px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
#actions button.warn { color: var(--alarm); }
#actions .note { background: rgba(31,32,35,.8); color: #fff; border-radius: 6px; padding: 9px 14px; font-size: 14px; }
kbd { font-family: var(--sans); font-size: 12px; font-weight: 600; border: 1px solid var(--hair); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; background: #fff; }
.touch kbd { display: none; }

/* Touch controls */
#joy { position: fixed; left: 28px; bottom: calc(var(--bottom) + 90px); width: 120px; height: 120px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.55); display: none; touch-action: none; }
#joy .knob { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%; background: rgba(255,255,255,.75); pointer-events: none; }
.touch #joy { display: block; }
#riseFall { position: fixed; right: 20px; bottom: calc(var(--bottom) + 100px); display: none; flex-direction: column; gap: 10px; }
#riseFall button { width: 64px; height: 48px; border-radius: 10px; border: 0; background: rgba(251,251,249,.9); touch-action: none; }
.touch[data-mode="drone"] #riseFall { display: flex; }

.primary { background: var(--ultramarine); color: #fff; border: 0; border-radius: 6px; padding: 13px 22px; font-weight: 500; font-size: 16px; }
.primary:disabled { opacity: .45; cursor: default; }
.quiet { background: transparent; border: 1px solid var(--hair); border-radius: 6px; padding: 9px 14px; }
.quiet.warn { color: var(--alarm); }

/* Curator's drawer */
#panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 100vw); background: var(--paper); z-index: 10; display: flex; flex-direction: column; transform: translateX(105%); transition: transform .28s ease; padding-top: var(--top); padding-bottom: var(--bottom); box-shadow: -8px 0 40px rgba(0,0,0,.25); }
#panel.open { transform: none; }
@media (max-width: 640px) {
  #panel { top: auto; left: 0; width: 100%; height: 78vh; transform: translateY(105%); border-radius: 14px 14px 0 0; }
}
@media (prefers-reduced-motion: reduce) { #panel { transition: none; } }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 10px; }
.panel-head h2 { font-family: var(--serif); font-weight: 400; font-size: 30px; margin: 0; }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--hair); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; padding: 10px 7px 12px; color: var(--graphite); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tab { display: none; overflow-y: auto; padding: 18px 20px 28px; flex: 1; }
.tab.active { display: block; }
.field { margin-bottom: 18px; }
.field > label, .field > .lbl { display: block; font-size: 13px; color: var(--graphite); margin-bottom: 6px; }
input[type="text"], input[type="search"], input[type="number"] { width: 100%; border: 1px solid var(--hair); border-radius: 6px; padding: 10px 12px; background: #fff; }
input[type="range"] { width: 100%; accent-color: var(--ultramarine); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 18px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.chips button { background: #fff; border: 1px solid var(--hair); border-radius: 999px; padding: 5px 12px; font-size: 14px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; margin-top: 10px; }
.hint { font-size: 13px; color: var(--graphite); line-height: 1.5; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.work { background: none; border: 0; padding: 0; text-align: left; }
.work .thumb { aspect-ratio: 1; background: #ecece7; display: grid; place-items: center; overflow: hidden; margin-bottom: 7px; }
.work img { max-width: 100%; max-height: 100%; display: block; }
.work .t { font-family: var(--serif); font-style: italic; font-size: 17px; line-height: 1.15; }
.work .a { font-size: 13px; color: var(--graphite); margin-top: 3px; line-height: 1.35; }
.work:hover .t { text-decoration: underline; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); padding: 0; }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.swatches input[type="color"] { width: 36px; height: 36px; border: 1px solid var(--hair); border-radius: 50%; padding: 0; background: none; }
.seg { display: flex; border: 1px solid var(--hair); border-radius: 6px; overflow: hidden; }
.seg button { flex: 1; background: #fff; border: 0; padding: 9px 10px; font-size: 14px; border-right: 1px solid var(--hair); white-space: nowrap; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
#modes button { background: transparent; }
#modes button[aria-pressed="true"] { background: var(--ink); }
#uploadPreview { max-width: 100%; max-height: 200px; display: none; margin: 4px 0 14px; }
.val { font-variant-numeric: tabular-nums; color: var(--ink); float: right; }

#toast { position: fixed; left: 50%; top: calc(var(--top) + 110px); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 6px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; max-width: 90vw; }
#toast.show { opacity: 1; }

.list .item { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--hair); font-size: 14px; }
.list .item .quiet { padding: 5px 10px; font-size: 13px; }
input.warmth { accent-color: #d98b3a; }
.tabs button { white-space: nowrap; }
.sub { font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 28px 0 4px; }
.grid .span { grid-column: 1 / -1; margin: 10px 0 -4px; }

/* What a guard says when you walk up */
#bubble, .bubble { position: fixed; transform: translate(-50%, -100%); max-width: min(300px, 80vw); background: var(--paper); color: var(--ink); font-family: var(--serif); font-size: 19px; line-height: 1.25; padding: 12px 16px; border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25); pointer-events: none; opacity: 0; transition: opacity .25s; z-index: 5; }
#bubble::after, .bubble::after { content: ""; position: absolute; left: 50%; bottom: -8px; margin-left: -8px; border: 8px solid transparent; border-bottom: 0; border-top-color: var(--paper); }
#bubble.show, .bubble.show { opacity: 1; }

/* Opening menu: a rendered gallery at sunset behind, the menu on the left */
#intro { position: fixed; inset: 0; z-index: 20; color: #f6f3ec; background: #1a1714; overflow: hidden; }
#intro .intro-bg { position: absolute; inset: 0; background: url("assets/intro.jpg") center / cover no-repeat, #1a1714; }
#intro .intro-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(14,12,10,.9) 0%, rgba(14,12,10,.74) 42%, rgba(14,12,10,.08) 78%); }
#intro .screen { position: absolute; inset: 0; display: none; flex-direction: column; justify-content: center; padding: calc(var(--top) + 32px) 24px calc(var(--bottom) + 32px) clamp(24px, 7vw, 96px); max-width: 720px; overflow-y: auto; }
#intro .screen.active { display: flex; animation: rise .35s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { #intro .screen.active { animation: none; } }
#intro h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(54px, 10vw, 104px); line-height: .95; margin: 0 0 14px; }
#intro h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(38px, 6vw, 56px); line-height: 1; margin: 0 0 14px; }
#intro .lede { font-size: 18px; line-height: 1.5; color: rgba(246,243,236,.8); margin: 0 0 28px; max-width: 44ch; }
#intro .lede.small { font-size: 15px; margin-bottom: 22px; }
#intro .menu { display: flex; flex-direction: column; gap: 4px; max-width: 480px; }
#intro .menu button { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; background: transparent; color: inherit; border: 0; border-left: 2px solid rgba(246,243,236,.25); padding: 12px 16px; transition: border-color .15s, background .15s; }
#intro .menu button:hover, #intro .menu button:focus-visible { border-left-color: #f0c987; background: rgba(246,243,236,.06); }
#intro .menu .k { font-family: var(--serif); font-size: 30px; line-height: 1.05; }
#intro .menu .d { font-size: 14px; color: rgba(246,243,236,.7); }
#intro .keys { font-size: 13px; color: rgba(246,243,236,.6); margin-top: 28px; line-height: 2; }
#intro kbd { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.25); color: #f6f3ec; }
.touch #intro .keys { display: none; }
#intro .link { background: none; border: 0; color: #f0c987; text-decoration: underline; text-underline-offset: 3px; padding: 14px 0 0; align-self: flex-start; font-size: 15px; }
#intro .back { align-self: flex-start; background: none; border: 0; color: rgba(246,243,236,.7); padding: 0 0 18px; font-size: 14px; }
#intro .back::before { content: "← "; }
#intro .ghost { background: transparent; color: inherit; border: 1px solid rgba(246,243,236,.4); border-radius: 6px; padding: 12px 20px; font-size: 16px; }
#intro .q { margin-bottom: 20px; }
#intro .q .lbl { display: block; font-size: 14px; color: rgba(246,243,236,.75); margin-bottom: 8px; }
#intro .choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
#intro .choices.small { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
#intro .choices button { text-align: left; background: rgba(246,243,236,.07); color: inherit; border: 1px solid rgba(246,243,236,.18); border-radius: 8px; padding: 10px 12px; font-size: 14px; line-height: 1.3; }
#intro .choices button b { display: block; font-weight: 600; font-size: 15px; margin-bottom: 2px; }
#intro .choices button[aria-pressed="true"] { border-color: #f0c987; background: rgba(240,201,135,.16); }
#intro .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
#intro .cards button { text-align: left; background: rgba(246,243,236,.07); color: inherit; border: 1px solid rgba(246,243,236,.18); border-radius: 8px; padding: 14px; }
#intro .cards button:hover { border-color: #f0c987; }
#intro .cards .n { font-family: var(--serif); font-size: 24px; line-height: 1.05; }
#intro .cards .c { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: #f0c987; margin: 4px 0 6px; }
#intro .cards .b { font-size: 13px; line-height: 1.4; color: rgba(246,243,236,.75); }
#intro .search-row { display: flex; gap: 8px; max-width: 560px; }
#intro .search-row input { flex: 1; background: rgba(255,255,255,.95); color: var(--ink); }
.chips.dark button { background: rgba(246,243,236,.08); color: inherit; border-color: rgba(246,243,236,.25); }
#liveResult { margin-top: 18px; max-width: 560px; font-size: 15px; line-height: 1.5; color: rgba(246,243,236,.85); }
#liveResult .thumbs { display: flex; gap: 6px; margin: 12px 0 16px; overflow: hidden; }
#liveResult .thumbs img { height: 70px; border-radius: 3px; }
#intro .levels { display: flex; flex-direction: column; gap: 8px; max-width: 560px; }
#intro .levels button { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; text-align: left; background: rgba(246,243,236,.07); color: inherit; border: 1px solid rgba(246,243,236,.18); border-radius: 8px; padding: 12px 14px; }
#intro .levels button:disabled { opacity: .45; cursor: default; }
#intro .levels .num { font-family: var(--serif); font-size: 30px; text-align: center; }
#intro .levels .t { font-family: var(--serif); font-size: 21px; line-height: 1.1; }
#intro .levels .s { font-size: 13px; color: rgba(246,243,236,.7); }
#intro .levels .stars { color: #f0c987; letter-spacing: 2px; font-size: 16px; }
#intro .bar { width: min(360px, 80vw); height: 3px; background: rgba(246,243,236,.15); border-radius: 2px; overflow: hidden; }
#intro .bar i { display: block; height: 100%; width: 40%; background: #f0c987; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@media (max-width: 640px) {
  #intro .intro-bg::after { background: linear-gradient(180deg, rgba(14,12,10,.55) 0%, rgba(14,12,10,.9) 55%); }
  #intro .screen { justify-content: flex-end; }
  #intro .menu .k { font-size: 26px; }
}
.bubble { background: #2b2622; color: #f6f3ec; font-style: italic; }
.bubble::after { border-top-color: #2b2622; }

/* Story mode: the brief, the critic's progress, and the review */
#brief { position: fixed; left: 20px; top: calc(var(--top) + 118px); width: min(320px, 44vw); background: rgba(251,251,249,.95); border-radius: 10px; padding: 14px 16px; box-shadow: 0 4px 20px rgba(0,0,0,.2); font-size: 14px; }
#brief .lvl { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--graphite); }
#brief h3 { font-family: var(--serif); font-weight: 400; font-size: 24px; margin: 2px 0 6px; line-height: 1.1; }
#brief p { margin: 0 0 8px; line-height: 1.45; color: var(--graphite); }
#brief ul, #review .goals { list-style: none; padding: 0; margin: 0 0 12px; }
#brief li, #review .goals li { padding: 2px 0; color: var(--graphite); }
#brief li.ok, #review .goals li.ok { color: #2c6e3f; }
#brief .primary { width: 100%; padding: 10px; font-size: 15px; }
@media (max-width: 720px) { #brief { top: auto; bottom: calc(var(--bottom) + 280px); left: 12px; width: min(300px, 70vw); font-size: 13px; } #brief p { display: none; } }
#criticStatus { position: fixed; left: 50%; bottom: calc(var(--bottom) + 76px); transform: translateX(-50%); background: rgba(31,32,35,.85); color: #fff; padding: 8px 14px; border-radius: 999px; font-size: 14px; }
#review { position: fixed; inset: 0; background: rgba(10,9,8,.55); display: grid; place-items: center; z-index: 15; padding: 16px; }
#review .card { background: #fbf8f1; max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; border-radius: 4px; padding: 28px 30px; box-shadow: 0 20px 60px rgba(0,0,0,.4); font-family: var(--serif); font-size: 19px; line-height: 1.5; }
#review .paper { font-family: var(--sans); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--graphite); border-bottom: 1px solid var(--ink); padding-bottom: 8px; margin-bottom: 14px; }
#review h2 { font-weight: 400; font-size: 36px; line-height: 1.05; margin: 0 0 6px; }
#review .stars.big { color: #c08a2c; font-size: 26px; letter-spacing: 4px; }
#review .by { font-family: var(--sans); font-size: 13px; color: var(--graphite); margin-bottom: 12px; }
#review p { margin: 0 0 10px; }
#review .goals { font-family: var(--sans); font-size: 14px; margin-top: 14px; }
#review .score { font-family: var(--sans); font-size: 13px; color: var(--graphite); }
#review .unlock { font-family: var(--sans); font-size: 15px; font-weight: 600; color: #2c6e3f; }
#review .row { font-family: var(--sans); }

/* 2D editor */
#planner { position: fixed; inset: 0; z-index: 12; background: var(--paper); display: flex; flex-direction: column; padding: calc(var(--top) + 14px) 18px calc(var(--bottom) + 14px); }
#planner header { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
#planner header h2 { font-family: var(--serif); font-weight: 400; font-size: 32px; margin: 0; }
#planner header .hint { flex: 1; min-width: 240px; margin: 0; }
#planner .panes { flex: 1; display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; min-height: 0; }
#planCanvas { width: 100%; height: 100%; background: #fff; border: 1px solid var(--hair); border-radius: 8px; cursor: default; touch-action: none; }
#planner .wall { display: flex; flex-direction: column; min-height: 0; gap: 8px; }
#planner .wall-head, #planner .wall-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
#elevCanvas { flex: 1; min-height: 160px; width: 100%; background: #fff; border: 1px solid var(--hair); border-radius: 8px; touch-action: none; }
#planner .lbl { font-size: 13px; color: var(--graphite); }
#planStorage { display: flex; gap: 8px; overflow-x: auto; min-height: 76px; padding-bottom: 4px; }
#planStorage img { height: 70px; border-radius: 3px; cursor: grab; box-shadow: 0 1px 4px rgba(0,0,0,.2); user-select: none; touch-action: none; }
@media (max-width: 760px) { #planner .panes { grid-template-columns: 1fr; grid-template-rows: 1fr 1.2fr; } }
body.shot #hud, body.shot #modes, body.shot #menuBtn, body.shot #crosshair, body.shot #actions, body.shot #tourBtn, body.shot #joy, body.shot #riseFall, body.shot #toast, body.shot #brief, body.shot #bubble { display: none !important; }
@media (max-aspect-ratio: 4/5) { #intro .intro-bg { background-image: url("assets/intro-tall.jpg"); } }

/* Artists: a clickable hello, then a dialog card for the tour */
.bubble.artist { border: 0; pointer-events: auto; cursor: pointer; background: #f0c987; color: #2b2217; font-style: normal; }
.bubble.artist::after { border-top-color: #f0c987; }
.bubble.artist:not(.show) { pointer-events: none; }
#artistDialog { position: fixed; left: 50%; bottom: calc(var(--bottom) + 24px); transform: translateX(-50%); width: min(560px, calc(100vw - 32px)); background: #fbf8f1; border-radius: 12px; padding: 16px 20px 12px; box-shadow: 0 10px 40px rgba(0,0,0,.35); z-index: 8; }
#artistDialog .who { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: #9a6a2c; margin-bottom: 4px; }
#artistText p { font-family: var(--serif); font-size: 21px; line-height: 1.35; margin: 0 0 8px; }
#artistDialog .row { margin: 6px 0 0; }
body:has(#artistDialog:not([hidden])) #actions { display: none; }
