:root {
  --ink: #1f2430;
  --paper: #fffaf0;
  --accent: #ff6b4a;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #cfe8f7;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Plaque with its button underneath. Anchored to the bottom, so the plaque grows upward. */
.card-stack {
  position: fixed;
  left: 50%;
  bottom: max(16px, var(--safe-b));
  transform: translateX(-50%);
  width: min(420px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}
/* on touch screens, sit above the driving buttons */
body.touch .card-stack { bottom: calc(110px + var(--safe-b)); }

/* Museum-style wall plaque for the nearest exhibit */
.card {
  --plaque: #f8f4ea;
  --plaque-line: #cdbf9f;
  --serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Times New Roman', serif;
  position: relative;
  width: 100%;
  max-height: 40vh;
  overflow: auto;
  padding: 20px 26px 16px;
  font-family: var(--serif);
  color: #2a2620;
  background: var(--plaque);
  border-radius: 3px;
  /* thin engraved border inside the edge, like a printed label */
  box-shadow:
    0 10px 26px rgba(0, 0, 0, .28),
    inset 0 0 0 6px var(--plaque),
    inset 0 0 0 7px var(--plaque-line);
  pointer-events: none;
  animation: pop .25s ease-out;
}
.card[hidden] { display: none; }
/* little mounting screws */
.card::before, .card::after {
  content: '';
  position: absolute;
  top: 11px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #b9ae95);
}
.card::before { left: 12px; }
.card::after { right: 12px; }
.card-kind {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: .64rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #8a7a55;
  font-weight: 600;
}
.card h2 { margin: 6px 0 0; font-size: 1.4rem; line-height: 1.2; font-weight: 700; }
.card-artist { margin-top: 3px; font-size: 1rem; font-style: italic; color: #5a5242; }
#card-desc {
  margin: 12px 0 0;
  padding-top: 11px;
  border-top: 1px solid var(--plaque-line);
  font-size: .93rem;
  line-height: 1.5;
}
.card-artist:empty, #card-desc:empty { display: none; }

/* Floats to the right of the plaque, vertically centred on it. */
.card-actions {
  position: absolute;
  left: calc(100% + 16px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
/* No room beside the plaque on narrow or touch screens: put them underneath. */
@media (max-width: 760px) {
  .card-actions { position: static; transform: none; }
}
body.touch .card-actions { position: static; transform: none; }
.card-actions[hidden] { display: none; }
.card-more {
  padding: 9px 26px;
  font: inherit;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: .03em;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 3px 0 #c24a2e;
  cursor: pointer;
  pointer-events: auto; /* the card itself ignores clicks so driving isn't blocked */
  transition: transform .08s, box-shadow .08s;
}
.card-more:active { transform: translateY(3px); box-shadow: 0 0 0 #c24a2e; }
.card-prompt {
  padding: 3px 11px;
  border-radius: 999px;
  background: rgba(31, 36, 48, .72);
  color: #fff;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: .72rem;
}
.card-prompt kbd { margin-left: 3px; color: #23262b; animation: keypress 1.8s infinite; }
body[data-device='touch'] .card-prompt { display: none; }

/* The Space key presses down now and then */
@keyframes keypress {
  0%, 55%, 100% { transform: translateY(0); border-bottom-width: 3px; }
  65%, 80% { transform: translateY(2px); border-bottom-width: 1px; }
}
@media (prefers-reduced-motion: reduce) {
  .card-prompt kbd { animation: none; }
}

/* Shown on the desktop window while a headset session is running */
.vr-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #14181f;
}
.vr-overlay[hidden] { display: none; }

/* Floating QR code, bottom-left (switched on in the settings) */
.qr-panel {
  position: fixed;
  z-index: 5;
  left: max(16px, env(safe-area-inset-left, 0px));
  bottom: max(16px, var(--safe-b));
  width: 172px;
  padding: 8px 8px 10px;
  text-align: center;
  color: var(--ink);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
  pointer-events: none;
}
.qr-panel[hidden] { display: none; }
.qr-code svg { display: block; width: 100%; height: auto; }
.qr-caption { margin-top: 6px; font: 600 .74rem/1.25 system-ui, sans-serif; }
/* on touch screens, sit above the driving buttons */
body.touch .qr-panel { bottom: calc(110px + var(--safe-b)); }

/* Floating language flag, bottom-right */
.lang-flag {
  position: fixed;
  z-index: 5;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(16px, var(--safe-b));
  width: 46px;
  height: 46px;
  padding: 0;
  font: 700 .8rem system-ui, sans-serif;
  color: var(--ink);
  background: #fff center / cover no-repeat;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
  cursor: pointer;
  transition: transform .12s;
}
.lang-flag:hover { transform: scale(1.1); }
.lang-flag:active { transform: scale(.94); }
.lang-flag[hidden] { display: none; }
/* on touch screens, sit above the driving buttons */
body.touch .lang-flag { bottom: calc(196px + var(--safe-b)); }

/* Pointer moved by the gamepad's left stick while the settings menu is open */
.pad-cursor {
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 26'%3E%3Cpath d='M3 2l17 11-8 1.5 4.5 8.5-3.5 2-4.5-8.5L3 21z' fill='%23fff' stroke='%2323262b' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .4));
}
.pad-cursor[hidden] { display: none; }
.pad-hover { outline: 3px solid #4aa3ff; outline-offset: 2px; }

/* Settings */
.gear {
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  width: 42px;
  height: 42px;
  font-size: 22px;
  line-height: 1;
  color: #fff;
  background: rgba(31, 36, 48, .55);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.gear:hover { background: rgba(31, 36, 48, .75); }
/* The menu is taller than a small window: the whole overlay scrolls, the box stays centred when it fits. */
#settings { overflow-y: auto; }
.settings-box { width: min(460px, 100%); max-height: none; margin: auto; padding: 22px 24px; }
.settings-box .modal-close { top: 12px; right: 12px; }
.settings-box h2 { margin: 0 0 4px; font-size: 1.4rem; }
.settings-box h3 { margin: 18px 0 8px; font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: #8a7a55; }
.settings-box p { margin: 6px 0; line-height: 1.4; }
.muted { opacity: .75; }
.small { font-size: .82rem; }
.seg { display: flex; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; }
.seg button {
  flex: 1;
  padding: 8px 12px;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.seg button.active { color: #fff; background: var(--ink); }
.primary {
  margin-top: 8px;
  padding: 10px 28px;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
.primary:disabled { background: #b9b9b9; cursor: default; }
#settings-resume { display: block; margin: 22px auto 0; }

/* "Look Closer" modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(20, 24, 32, .75);
}
.modal[hidden] { display: none; }
.modal-box {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 14px;
  background: var(--paper);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .4);
}
.modal-close {
  position: absolute;
  top: -14px;
  right: -14px;
  z-index: 1;
  width: 40px;
  height: 40px;
  font-size: 26px;
  line-height: 1;
  color: #fff;
  background: var(--ink);
  border: 2px solid var(--paper);
  border-radius: 50%;
  cursor: pointer;
}
.modal-body { display: grid; place-items: center; min-height: 0; }
.modal-body img, .modal-body video {
  max-width: min(92vw, 1100px);
  max-height: calc(100vh - 140px);
  max-height: calc(100dvh - 140px);
  border-radius: 8px;
  background: #000;
}
.crop {
  position: relative;
  overflow: hidden;
  aspect-ratio: var(--aspect);
  width: min(92vw, 1100px, calc((100vh - 140px) * var(--aspect)));
  width: min(92vw, 1100px, calc((100dvh - 140px) * var(--aspect)));
  border-radius: 8px;
  background: #000;
  cursor: pointer;
}
.viewer {
  position: relative;
  width: min(92vw, 900px);
  height: min(70vh, 640px);
  border-radius: 8px;
  background: radial-gradient(circle at 50% 40%, #fff, #e6e0d2);
}
.viewer canvas { display: block; width: 100%; height: 100%; border-radius: 8px; }
.viewer-msg { position: absolute; inset: 0; display: grid; place-items: center; opacity: .7; }
.modal-caption { margin-top: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.modal-meta { flex: 1 1 auto; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; min-width: 0; }
.modal-meta span { opacity: .7; }
.modal-download {
  margin-left: auto; /* sticks to the right of the row */
  padding: 7px 16px;
  font-size: .85rem;
  font-weight: 700;
  color: #fff;
  background: var(--ink);
  border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
}
.modal-download:hover { background: #3a4150; }
.modal-download[hidden] { display: none; }

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

/* Touch controls */
#touch[hidden] { display: none; }
.pad {
  position: fixed;
  bottom: calc(18px + var(--safe-b));
  display: flex;
  gap: 14px;
  touch-action: none;
}
.pad-left  { left: max(18px, env(safe-area-inset-left, 0px)); }
.pad-right { right: max(18px, env(safe-area-inset-right, 0px)); }
.pad-right { flex-direction: column; } /* forward on top, reverse below */
.pad button {
  width: 76px;
  height: 76px;
  border: 0;
  border-radius: 50%;
  font-size: 28px;
  color: #fff;
  background: rgba(31, 36, 48, .55);
  backdrop-filter: blur(4px);
  touch-action: none;
}
.pad button.down { background: var(--accent); transform: scale(.94); }

/* Intro overlay */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(207, 232, 247, .92);
  transition: opacity .4s;
}
.overlay.gone { opacity: 0; pointer-events: none; }
.intro-stack { width: min(480px, 100%); display: flex; flex-direction: column; align-items: center; gap: 16px; }
.intro-stack .overlay-box { width: 100%; }
/* Control guides: key on the left, what it does on the right, one row each */
.ctl-list {
  display: inline-grid;
  grid-template-columns: max-content max-content;
  gap: 8px 16px;
  align-items: center;
  text-align: left;
}
.ctl-keys { display: flex; flex-wrap: nowrap; gap: 4px; justify-content: flex-end; }
.ctl-keys kbd { margin: 0; }
.ctl-keys .pad-btn { margin: 0; }
.touch-key {
  display: inline-grid;
  place-items: center;
  width: 2em;
  height: 2em;
  font-size: .9em;
  color: #fff;
  background: rgba(31, 36, 48, .75);
  border-radius: 50%;
}
.ctl-heading { margin: 12px 0 6px; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #8a7a55; }
.ctl-heading:first-child { margin-top: 0; }
#settings-controls .ctl-list { font-size: .88rem; }

/* Controls reminder under the welcome card, shown if the player lingers on the welcome screen */
.intro-controls {
  padding: 12px 18px;
  text-align: center;
  font-size: .95rem;
  background: rgba(255, 250, 240, .88);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12);
  opacity: 0;
  visibility: hidden;
  transition: opacity .8s, visibility .8s;
}
.intro-controls.show { opacity: 1; visibility: visible; }
.overlay-box {
  width: min(480px, 100%);
  text-align: center;
  background: var(--paper);
  padding: 28px 24px;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .2);
}
.overlay-box h1 { margin: 0 0 8px; font-size: 2rem; }
.overlay-box p { margin: 8px 0; line-height: 1.45; }
.drive-hint {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  text-align: center;
  font-size: .95rem;
  background: var(--paper);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
  pointer-events: none;
  transition: opacity .5s;
}
.drive-hint[hidden] { display: none; }
.drive-hint.fade { opacity: 0; }
body.touch .drive-hint { bottom: calc(110px + var(--safe-b)); }
kbd {
  display: inline-block;
  min-width: 1.6em;
  margin: 0 2px;
  padding: 1px 6px;
  border: 1px solid #bbb;
  border-bottom-width: 3px;
  border-radius: 5px;
  background: #fff;
  font-size: .85em;
}
#start {
  margin-top: 14px;
  padding: 12px 36px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
#start:disabled { background: #b9b9b9; cursor: default; }
#progress { height: 6px; margin-top: 16px; background: #eee; border-radius: 3px; overflow: hidden; }
#progress-bar { width: 0; height: 100%; background: var(--accent); transition: width .2s; }

/* Show the right hint for the device */
/* Round / pill badges that stand in for gamepad buttons */
.pad-btn {
  display: inline-block;
  min-width: 1.7em;
  height: 1.7em;
  padding: 0 .5em;
  margin: 0 .15em;
  line-height: 1.7em;
  text-align: center;
  font: 700 .8em system-ui, sans-serif;
  font-style: normal;
  color: #23262b;
  background: #e8e6df;
  border-radius: 999px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .25);
  vertical-align: middle;
}
/* Face buttons are round and coloured like the Xbox ones; on a Nintendo pad they are dark with white letters. */
.pad-a, .pad-y { padding: 0; }
.pad-a { background: #3fbf4a; color: #fff; }
.pad-y { background: #f2c230; color: #23262b; }
body[data-pad='nintendo'] .pad-a, body[data-pad='nintendo'] .pad-y { background: #2b2c30; color: #fff; }

/* Shown in the middle of the screen when the player has been idle for a while */
.move-guide {
  position: fixed;
  z-index: 4;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100% - 32px));
  padding: 22px 26px;
  text-align: center;
  color: #fff;
  background: rgba(20, 24, 32, .78);
  border-radius: 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity .6s, visibility .6s;
}
.move-guide.show { opacity: 1; visibility: visible; }
.move-guide.single { padding: 16px 24px; }
.move-guide.single .guide-title { display: none; }
.guide-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 12px; }
.guide-text { font-size: 1.05rem; }
.guide-text kbd { padding: 4px 11px; font-size: 1rem; color: #23262b; animation: keypress 1.8s infinite; }
.guide-text .pad-btn { font-size: .95rem; }
.guide-text .ctl-list { gap: 10px 18px; }
@media (prefers-reduced-motion: reduce) { .guide-text kbd { animation: none; } }
