:root {
  --ink: #241b18;
  --cream: #f3e1bd;
  --paper: #fff4dc;
  --red: #9f3729;
  --teal: #176f72;
  --cyan: #61e8f2;
  --gold: #d89b3c;
  --night: #101522;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  color: var(--cream);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: var(--night);
}
button, a { color: inherit; font: inherit; }
a { text-decoration: none; }
button { cursor: pointer; }

.lab-header {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  width: 100%;
  padding: 12px clamp(12px, 3vw, 40px);
  background: linear-gradient(rgba(12, 14, 24, .9), transparent);
  pointer-events: none;
}
.lab-header > * { pointer-events: auto; }
.lab-header-actions { display: flex; align-items: center; gap: 7px; }
.back-link, .mission-button {
  padding: 9px 13px;
  font-size: 11px;
  font-weight: 900;
  background: rgba(18, 39, 44, .82);
  border: 2px solid #a97045;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px #182324, 0 4px 0 #160e0b;
}
.back-link { display: flex; align-items: center; gap: 7px; }
.lab-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.45));
}
.mission-button strong { color: var(--cyan); }
.human-language-switch {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 0 7px;
  padding: 7px 10px;
  color: var(--cream);
  cursor: pointer;
  border: 2px solid #a97045;
  border-radius: 4px;
  background: rgba(18, 39, 44, .82);
  box-shadow: inset 0 0 0 1px #182324, 0 4px 0 #160e0b;
}
.human-language-switch span {
  grid-row: 1 / 3;
  max-width: 68px;
  font-size: 8px;
  font-weight: 900;
  line-height: 1.2;
  text-align: left;
}
.human-language-switch strong { color: var(--cyan); font-size: 10px; }
.human-language-switch small { font-size: 7px; opacity: .72; }
.human-language-switch:hover,
.human-language-switch:focus-visible { border-color: var(--cyan); background: rgba(23, 111, 114, .88); }
.lab-title { text-align: center; text-shadow: 0 2px 4px #000; }
.lab-title strong, .lab-title small { display: block; }
.lab-title strong { font-size: 14px; }
.lab-title small { margin-top: 2px; font-size: 7px; letter-spacing: .16em; }

.intro-screen, .exploration {
  position: fixed;
  inset: 0;
  overflow: hidden;
}
.intro-screen { z-index: 20; transition: opacity .8s ease, visibility .8s ease; }
.intro-screen.is-open { visibility: hidden; opacity: 0; pointer-events: none; }
.intro-screen > img, .room-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.intro-shade, .room-vignette {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(10,13,22,.86), rgba(10,13,22,.1) 65%), linear-gradient(0deg, rgba(10,13,22,.55), transparent 45%);
}
.intro-panel {
  position: absolute;
  top: 50%;
  left: clamp(20px, 8vw, 120px);
  width: min(580px, calc(100% - 40px));
  transform: translateY(-50%);
  text-shadow: 0 3px 14px #000;
}
.label {
  margin: 0 0 14px;
  color: #ffcf72;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
}
h1, h2 { margin: 0; line-height: 1.12; }
h1 { font-size: clamp(48px, 7vw, 96px); }
h2 { font-size: clamp(30px, 4vw, 52px); }
.intro-panel > p:nth-of-type(2) { max-width: 460px; margin: 22px 0 28px; font-weight: 700; line-height: 1.9; }

.machine-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 10px 18px;
  color: var(--cream);
  font-weight: 900;
  background: linear-gradient(#315e5e, #174a4c);
  border: 3px solid #af7142;
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px #1b2827, 0 7px 0 #201713;
}
.machine-button span, .status-light {
  width: 11px;
  height: 11px;
  background: var(--cyan);
  border: 2px solid #102e30;
  border-radius: 50%;
  box-shadow: 0 0 13px var(--cyan);
}

.exploration { z-index: 1; }
.room-vignette {
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 45%, rgba(8,10,18,.52));
}
.hotspot {
  position: absolute;
  z-index: 4;
  width: 46px;
  height: 46px;
  padding: 0;
  background: radial-gradient(circle, rgba(255,244,210,.72) 0 8%, rgba(255,226,164,.18) 28%, transparent 68%);
  border: 1px solid rgba(255, 235, 190, .45);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(255, 220, 157, .42), 0 0 44px rgba(97, 232, 242, .16);
  animation: hotspot 2.8s ease-in-out infinite;
}
.hotspot span {
  display: block;
  width: 5px;
  height: 5px;
  margin: auto;
  background: rgba(255, 250, 220, .85);
  border-radius: 50%;
  box-shadow: 0 0 8px #fff5cc;
}
.hotspot.is-found {
  border-color: rgba(255, 235, 190, .28);
  box-shadow: 0 0 14px rgba(255, 220, 157, .18);
  animation: none;
  opacity: .38;
}
.hotspot-one { left: 29%; bottom: 17%; }
.hotspot-two { right: 22%; top: 33%; }
.hotspot-three { right: 31%; bottom: 22%; }
.hotspot-four { left: 36%; bottom: 31%; }
.hotspot-five { right: 7%; top: 41%; }

.room-message {
  position: absolute;
  z-index: 5;
  left: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(420px, calc(100% - 48px));
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(13, 30, 36, .85);
  border: 1px solid #a97045;
}
.room-message p { margin: 0; }
.inventory {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(190px, .42fr) minmax(360px, .88fr);
  width: min(900px, calc(100% - 40px));
  height: min(600px, calc(100% - 80px));
  margin: auto;
  overflow: hidden;
  color: var(--ink);
  background: #dec899;
  border: 7px solid #563828;
  border-radius: 18px 12px 12px 18px;
  box-shadow: inset 0 0 0 3px #a87a4e, 0 30px 90px rgba(0,0,0,.72);
  visibility: hidden;
  opacity: 0;
  transform: perspective(1000px) rotateY(-12deg) scale(.9);
  transition: opacity .3s ease, transform .4s ease, visibility .3s ease;
}
.inventory.is-open {
  visibility: visible;
  opacity: 1;
  transform: perspective(1000px) rotateY(0) scale(1);
}
.book-close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 4;
  width: 38px;
  height: 38px;
  color: var(--cream);
  font-size: 22px;
  background: #683c2d;
  border: 2px solid #c18a58;
  border-radius: 50%;
}
.book-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 30px;
  color: #f4dfae;
  text-align: center;
  background:
    radial-gradient(circle at 50% 35%, rgba(255,217,133,.18), transparent 28%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.02) 0 2px, transparent 2px 7px),
    #28585a;
  border-right: 8px double #563828;
  box-shadow: inset -12px 0 22px rgba(0,0,0,.25);
}
.book-cover span, .book-cover small {
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .16em;
}
.book-cover strong {
  margin: 22px 0;
  padding: 24px 10px;
  font-size: clamp(27px, 4vw, 46px);
  line-height: 1.25;
  border-block: 1px solid rgba(244,223,174,.55);
}
.book-page {
  overflow: auto;
  padding: 34px;
  background:
    linear-gradient(rgba(146,105,73,.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(146,105,73,.08) 1px, transparent 1px),
    #fff2cf;
  background-size: 26px 26px;
}
.book-heading { margin-bottom: 24px; }
.book-heading span, .book-heading strong { display: block; }
.book-heading span { color: var(--red); font-size: 8px; font-weight: 900; letter-spacing: .16em; }
.book-heading strong { margin-top: 5px; font-size: 22px; }
.fragment-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px 16px;
}
.fragment-list figure { margin: 0; text-align: center; }
.fragment-list figure div {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 12px;
  background: rgba(180, 146, 103, .12);
  border: 2px dashed rgba(116, 81, 55, .35);
  border-radius: 48% 52% 44% 56%;
}
.fragment-list img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: .08;
  filter: grayscale(1);
  transform: scale(.72) rotate(-5deg);
}
.fragment-list figure:nth-child(even) img { transform: scale(.72) rotate(5deg); }
.fragment-list figcaption {
  margin-top: 7px;
  color: rgba(36,27,24,.45);
  font-size: 9px;
  font-weight: 900;
}
.fragment-list figure.is-found div {
  background: transparent;
  border-color: transparent;
}
.fragment-list figure.is-found img {
  opacity: 1;
  filter: none;
  animation: sticker-in .55s cubic-bezier(.2,.9,.2,1.25) forwards;
}
.fragment-list figure.is-found figcaption { color: var(--ink); }
.book-note { margin: 28px 0 0; font-size: 8px; font-weight: 700; }

dialog {
  color: var(--cream);
  background: linear-gradient(145deg, #1b3539, #151926);
  border: 4px solid #7f5438;
  border-radius: 14px;
  box-shadow: inset 0 0 0 2px #172021, 0 24px 80px rgba(0,0,0,.65);
}
dialog::backdrop { background: rgba(7,8,15,.76); backdrop-filter: blur(5px); }
.discovery {
  width: min(520px, calc(100% - 28px));
  padding: 42px;
  text-align: center;
}
.dialog-close {
  position: absolute;
  top: 10px;
  right: 12px;
  color: var(--cream);
  font-size: 24px;
  background: transparent;
  border: 0;
}
.discovery img {
  width: 180px;
  height: 180px;
  margin: 0 auto 20px;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0,0,0,.35));
}
.discovery p:not(.label), .complete-dialog p { line-height: 1.9; }
.maintenance-link {
  display: none;
  margin: 20px auto 0;
  padding: 8px 0;
  color: #ffcf72;
  font-size: 11px;
  font-weight: 900;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #ffcf72;
}
.maintenance-link.is-visible { display: block; }
.complete-dialog {
  width: min(660px, calc(100% - 28px));
  padding: 40px;
  text-align: center;
}
.complete-dialog img { width: 190px; margin: 0 auto -15px; }
.complete-dialog div { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; margin-top: 25px; }
.contact-link { align-self: center; padding-bottom: 5px; font-size: 12px; font-weight: 900; border-bottom: 1px solid var(--cream); }

.maintenance-room {
  position: fixed;
  inset: 0;
  z-index: 50;
  visibility: hidden;
  overflow: hidden;
  background: var(--night);
  opacity: 0;
  transition: opacity .45s ease, visibility .45s ease;
}
.maintenance-room.is-active { visibility: visible; opacity: 1; }
.maintenance-room > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.maintenance-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(9,12,22,.78), transparent 48%),
    linear-gradient(0deg, rgba(9,12,22,.48), transparent 42%);
}
.maintenance-room header {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px clamp(12px, 3vw, 40px);
  background: linear-gradient(rgba(12,14,24,.88), transparent);
}
.maintenance-room header button,
.maintenance-room header p {
  margin: 0;
  padding: 9px 13px;
  color: var(--cream);
  font-size: 10px;
  font-weight: 900;
  background: rgba(18,39,44,.82);
  border: 2px solid #a97045;
  border-radius: 4px;
}
.maintenance-room header div { text-align: center; }
.maintenance-room header strong,
.maintenance-room header small { display: block; }
.maintenance-room header small { margin-top: 2px; font-size: 7px; letter-spacing: .14em; }
.maintenance-room header p strong { display: inline; color: var(--cyan); }
.maintenance-guide {
  position: absolute;
  top: 22%;
  left: clamp(18px, 6vw, 90px);
  z-index: 3;
  width: min(450px, calc(100% - 36px));
  text-shadow: 0 3px 13px #000;
}
.maintenance-guide p:last-child {
  max-width: 380px;
  font-weight: 700;
  line-height: 1.9;
}
.repair-point {
  position: absolute;
  z-index: 5;
  width: 48px;
  height: 48px;
  padding: 0;
  background: radial-gradient(circle, rgba(255,244,210,.7) 0 8%, rgba(255,226,164,.16) 28%, transparent 68%);
  border: 1px solid rgba(255,235,190,.45);
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(255,220,157,.42), 0 0 50px rgba(97,232,242,.15);
  animation: hotspot 2.8s ease-in-out infinite;
}
.repair-point span { display: block; width: 5px; height: 5px; margin: auto; background: #fff5cc; border-radius: 50%; }
.repair-point.is-repaired {
  background: rgba(97,232,242,.16);
  border-color: var(--cyan);
  box-shadow: 0 0 24px rgba(97,232,242,.42);
  animation: none;
  opacity: .65;
}
.repair-antenna { left: 56%; top: 16%; }
.repair-tube { left: 56%; top: 49%; }
.repair-bolt { right: 16%; bottom: 22%; }
.maintenance-log {
  position: absolute;
  left: 24px;
  bottom: 24px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(13,30,36,.86);
  border: 1px solid #a97045;
}
.maintenance-log p { margin: 0; font-size: 11px; font-weight: 700; }
.maintenance-complete {
  position: absolute;
  right: 4%;
  bottom: 7%;
  z-index: 6;
  max-width: 360px;
  padding: 22px;
  color: var(--cream);
  background: rgba(14,35,39,.93);
  border: 2px solid var(--cyan);
  box-shadow: 0 0 38px rgba(97,232,242,.3);
  opacity: 0;
  transform: translateY(25px);
  transition: opacity .35s ease, transform .35s ease;
  pointer-events: none;
}
.maintenance-complete.is-visible { opacity: 1; transform: translateY(0); }
.maintenance-complete strong, .maintenance-complete span { display: block; }
.maintenance-complete strong { font-size: 20px; }
.maintenance-complete span { margin-top: 8px; font-size: 11px; line-height: 1.7; }

@keyframes hotspot {
  50% {
    opacity: .58;
    transform: scale(1.22);
    box-shadow: 0 0 25px rgba(255, 220, 157, .32), 0 0 55px rgba(97, 232, 242, .1);
  }
}
@keyframes sticker-in {
  0% { opacity: 0; transform: scale(1.7) rotate(14deg); }
  65% { opacity: 1; transform: scale(.9) rotate(-4deg); }
  100% { opacity: 1; transform: scale(1) rotate(-5deg); }
}

@media (max-width: 640px) {
  .lab-title { display: none; }
  .back-link, .mission-button { font-size: 9px; }
  .lab-logo { width: 24px !important; height: 24px !important; }
  .lab-header-actions { margin-left: auto; }
  .human-language-switch { padding: 6px 8px; }
  .human-language-switch span { display: none; }
  .human-language-switch strong,
  .human-language-switch small { grid-column: 1; }
  .intro-screen > img, .room-image { object-position: center; }
  .intro-panel { left: 18px; }
  h1 { font-size: 46px; }
  .hotspot { width: 42px; height: 42px; }
  .hotspot-one { left: 20%; bottom: 25%; }
  .hotspot-two { right: 12%; top: 31%; }
  .hotspot-three { right: 28%; bottom: 25%; }
  .hotspot-four { left: 42%; bottom: 34%; }
  .hotspot-five { right: 6%; top: 44%; }
  .room-message { display: none; }
  .inventory {
    grid-template-columns: 1fr;
    width: calc(100% - 20px);
    height: calc(100% - 90px);
    border-width: 5px;
  }
  .book-cover { display: none; }
  .book-page { padding: 30px 18px; }
  .fragment-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .discovery, .complete-dialog { padding: 32px 20px; }
  .maintenance-room header div { display: none; }
  .maintenance-guide { top: 17%; }
  .maintenance-guide h2 { font-size: 36px; }
  .maintenance-room > img { object-position: 60% center; }
  .repair-antenna { left: 55%; top: 20%; }
  .repair-tube { left: 50%; top: 49%; }
  .repair-bolt { right: 12%; bottom: 24%; }
  .maintenance-log { display: none; }
  .maintenance-complete { right: 14px; bottom: 14px; left: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}
