:root {
  --ink: #21142f;
  --night: #090c24;
  --night-2: #151137;
  --paper: #f4dfac;
  --paper-light: #fff6d8;
  --gold: #f8c35a;
  --mint: #69d6b4;
  --coral: #f37c70;
  --muted: #c7b9dd;
  --edge: rgba(248, 195, 90, .38);
  --shadow: 0 18px 55px rgba(0, 0, 0, .46);
  --radius: 20px;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body {
  margin: 0;
  color: #fff7df;
  background:
    radial-gradient(circle at 20% 5%, rgba(72, 48, 120, .48), transparent 34%),
    linear-gradient(145deg, #070a1d 0%, #141034 55%, #080a20 100%);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  overflow: hidden;
}
button { font: inherit; }
button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.game-shell {
  width: min(1600px, 100%);
  height: 100dvh;
  min-height: 620px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: 78px minmax(0, 1fr);
  background: var(--night);
  box-shadow: 0 0 80px rgba(0,0,0,.62);
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(300px, 1.15fr) minmax(320px, .9fr) auto;
  align-items: center;
  gap: 22px;
  padding: 9px 22px;
  border-bottom: 1px solid var(--edge);
  background: rgba(7, 10, 28, .98);
  z-index: 20;
}
.brand h1 {
  margin: 0;
  color: var(--paper-light);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(31px, 2.7vw, 43px);
  line-height: .92;
  letter-spacing: -.035em;
  text-shadow: 0 3px 0 #4d2e58;
}
.brand p { margin: 5px 0 0; color: var(--gold); font-size: 13px; font-weight: 800; letter-spacing: .02em; }

.progress-wrap { min-width: 0; }
.progress-label { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 7px; font-weight: 900; font-size: 14px; }
.progress-label span:last-child { color: var(--muted); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-track { height: 10px; border-radius: 99px; background: #292345; overflow: hidden; box-shadow: inset 0 1px 3px #000; }
.progress-fill { width: 0; height: 100%; background: linear-gradient(90deg, var(--mint), var(--gold)); border-radius: inherit; transition: width .55s ease; }

.toolbar { display: flex; align-items: center; gap: 9px; }
.keys { display: flex; gap: 7px; margin-right: 7px; }
.key-slot {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--edge); border-radius: 11px; background: #12142f;
  filter: grayscale(1); opacity: .5; transition: .3s ease; font-size: 19px;
}
.key-slot.found { filter: none; opacity: 1; color: var(--gold); background: #332440; box-shadow: 0 0 18px rgba(248,195,90,.3); }
.tool-btn {
  width: 40px; height: 40px; border: 1px solid var(--edge); border-radius: 50%;
  color: #fff; background: #252244; cursor: pointer; transition: .18s ease; font-size: 17px;
}
.tool-btn:hover { transform: translateY(-2px); background: #39305f; }

.main-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(355px, 28vw, 425px);
  overflow: hidden;
}
.scene-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #070a1d;
  cursor: crosshair;
}
.scene-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center;
  user-select: none; -webkit-user-drag: none;
  transition: object-position .5s ease;
}
.scene-vignette {
  position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 90px 20px rgba(4,5,19,.38);
  background: linear-gradient(90deg, rgba(4,5,19,.07), transparent 16%, transparent 84%, rgba(4,5,19,.08));
}
.room-title {
  position: absolute; left: 20px; top: 18px; z-index: 3;
  max-width: min(520px, calc(100% - 40px));
  padding: 11px 15px 12px;
  border: 1px solid var(--edge); border-radius: 14px;
  background: rgba(10, 9, 28, .82); backdrop-filter: blur(8px); box-shadow: var(--shadow);
}
.room-kicker { margin-bottom: 3px; color: var(--gold); font-size: 10px; font-weight: 900; letter-spacing: .14em; }
.room-title strong { display: block; font: 900 20px Georgia, serif; color: var(--paper-light); }
.room-title span { display: block; margin-top: 4px; font-size: 13.5px; line-height: 1.3; color: #ded4ee; }

.hotspot {
  position: absolute; z-index: 5;
  transform: translate(-50%, -50%);
  border: 0; border-radius: 12px;
  color: transparent; background: transparent; opacity: .01;
  cursor: crosshair;
}
.hotspot:focus-visible { opacity: 1; outline: 3px solid white; background: rgba(105,214,180,.17); }
.hotspot.done { opacity: 1; pointer-events: none; background: rgba(105,214,180,.04); }
.hotspot.done::before, .hotspot.done::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-color: var(--mint); border-style: solid;
  filter: drop-shadow(0 1px 2px #000);
}
.hotspot.done::before { left: 0; top: 0; border-width: 3px 0 0 3px; }
.hotspot.done::after { right: 0; bottom: 0; border-width: 0 3px 3px 0; }
.hotspot.done span {
  position: absolute; right: -5px; top: -10px; display: grid; width: 25px; height: 25px; place-items: center;
  border-radius: 50%; color: #10221d; background: var(--mint); font-size: 14px; font-weight: 900; box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.hotspot.locked { opacity: .01; cursor: not-allowed; pointer-events: none; }

.journal {
  position: relative;
  min-height: 0;
  padding: 18px 18px 15px;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    repeating-linear-gradient(0deg, rgba(104,73,39,.025) 0 2px, transparent 2px 5px),
    linear-gradient(100deg, #e8c983, #fff1c7 13%, #f2d99f 100%);
  border-left: 7px solid #513044;
  box-shadow: inset 14px 0 24px rgba(80,45,35,.18);
}
.journal::before { content: ""; position: absolute; inset: 7px; border: 1px solid rgba(91,54,36,.25); pointer-events: none; }
.journal h2 { position: relative; margin: 0 0 4px; text-align: center; font: 900 29px/1 Georgia, serif; color: #4a245b; }
.journal-sub { position: relative; margin: 0 auto 8px; max-width: 330px; text-align: center; font-size: 13px; line-height: 1.3; font-weight: 800; color: #78576b; }
.journal-status {
  position: relative;
  display: flex; justify-content: center; gap: 18px;
  margin: 0 0 11px;
  color: #68495b; font-size: 12px; font-weight: 800;
}
.journal-status b { color: #4a245b; }
.journal-list { position: relative; display: grid; gap: 9px; }
.clue-row {
  display: grid; grid-template-columns: 38px 1fr 24px; gap: 10px; align-items: center;
  min-height: 78px; padding: 10px 11px;
  border: 1px solid rgba(94,58,39,.24); border-radius: 13px;
  background: rgba(255,247,217,.55);
}
.clue-row.active { border-color: #9a6c34; background: rgba(255,250,228,.9); box-shadow: 0 5px 14px rgba(72,38,31,.1); }
.clue-row.done { border-color: #4c8f76; background: rgba(171,226,193,.45); }
.clue-icon {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 50%; background: rgba(75,38,87,.09); color: #4a245b;
  font-size: 19px; font-weight: 900; text-align: center;
}
.done .clue-icon { background: rgba(52,126,101,.12); }
.clue-copy strong { display: block; font-size: 15.5px; line-height: 1.26; }
.clue-copy span { display: block; margin-top: 4px; color: #715858; font-size: 12.5px; line-height: 1.28; }
.clue-check { width: 22px; height: 22px; display: grid; place-items: center; border: 2px solid #a78358; border-radius: 50%; font-size: 12px; color: white; }
.done .clue-check { background: #438b72; border-color: #438b72; }

.hint-box { position: relative; margin-top: 11px; padding: 11px 10px 0; border-top: 1px dashed #a58155; }
.hint-box button { border: 0; padding: 0; color: #4a245b; background: none; cursor: pointer; font-weight: 900; font-size: 14px; }
.hint-text { margin: 7px 0 0; color: #654b4d; font-size: 12.5px; line-height: 1.35; }
.next-btn, .primary-btn {
  position: relative; width: 100%; margin-top: auto; padding: 13px 18px;
  border: 1px solid #256f68; border-radius: 12px;
  color: white; background: linear-gradient(#248a80, #176159); box-shadow: 0 5px 0 #104941;
  cursor: pointer; font-weight: 900; font-size: 15px; letter-spacing: .01em;
}
.next-btn { margin-top: 12px; }
.next-btn:hover, .primary-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.next-btn:disabled { opacity: .5; filter: grayscale(1); cursor: not-allowed; box-shadow: none; transform: none; }

.modal-layer, .start-layer, .ending-layer {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px;
  background: rgba(4, 5, 20, .78); backdrop-filter: blur(7px);
}
.start-layer, .ending-layer { background: rgba(4, 5, 20, .68); }
.modal-card, .start-card, .ending-card {
  width: min(660px, 100%); max-height: calc(100dvh - 28px); overflow: auto;
  padding: 28px 30px; color: var(--ink); border: 2px solid #d8a94d; border-radius: var(--radius);
  background:
    linear-gradient(rgba(255,246,216,.95), rgba(241,216,159,.97)),
    url("assets/haunted-hall.png") center/cover;
  box-shadow: 0 22px 80px rgba(0,0,0,.7), inset 0 0 0 7px rgba(121,75,46,.08);
}
.start-card { text-align: center; }
.start-card h2, .ending-card h2 { margin: 0; color: #472053; font: 900 clamp(42px, 6vw, 68px)/.86 Georgia, serif; }
.start-card .lead, .ending-card .lead { margin: 13px auto; max-width: 500px; font-size: 19px; line-height: 1.3; font-weight: 900; }
.mission { margin: 16px 0; padding: 14px 16px; border: 1px dashed #a36f43; border-radius: 14px; background: rgba(255,250,231,.64); text-align: left; }
.mission p { margin: 6px 0; line-height: 1.38; font-size: 15px; }
.mission strong { color: #4a245b; }
.small-note { color: #745c56; font-size: 12.5px !important; }

.challenge-type { margin: 0 0 6px; color: #6a3a78; font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: .09em; }
.modal-card h3 { margin: 0 40px 7px 0; font: 900 28px/1.15 Georgia, serif; color: #351c42; }
.question { margin: 12px 0 17px; font-size: 20px; line-height: 1.42; font-weight: 900; }
.close-btn { float: right; width: 38px; height: 38px; border: 0; border-radius: 50%; color: #5a3d46; background: rgba(91,61,49,.1); cursor: pointer; font-size: 17px; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.answer {
  width: 100%; min-height: 58px; padding: 11px 13px; text-align: left;
  border: 1px solid #ba9060; border-radius: 11px;
  color: #2f2135; background: rgba(255,250,229,.76); cursor: pointer;
  font-weight: 800; font-size: 15px; line-height: 1.3; transition: .15s ease;
}
.answer span { color: #684173; font-weight: 900; }
.answer:hover { transform: translateY(-2px); border-color: #674272; background: white; }
.answer.correct { color: #144f43; border-color: #39816d; background: #bfe5ce; }
.answer.wrong { color: #7a2727; border-color: #bd5b56; background: #f4c4b9; animation: shake .28s ease; }
@keyframes shake { 33% { transform: translateX(-5px); } 66% { transform: translateX(5px); } }
.feedback { min-height: 48px; margin-top: 13px; padding: 10px 12px; border-radius: 10px; color: #654f52; background: rgba(103,65,74,.08); font-size: 14px; line-height: 1.36; }
.feedback.good { color: #17584a; background: rgba(78,155,125,.16); }
.feedback.bad { color: #7d302c; background: rgba(194,91,82,.14); }
.modal-card .primary-btn { margin-top: 12px; }

.toast {
  position: fixed; z-index: 95; left: 50%; top: 92px; transform: translateX(-50%);
  padding: 11px 17px; border: 1px solid rgba(255,255,255,.45); border-radius: 99px;
  background: #2c7b68; box-shadow: var(--shadow); font-weight: 900; animation: toast-in .35s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -12px); } }
.spark { position: fixed; z-index: 100; pointer-events: none; animation: fly 900ms ease-out forwards; font-size: 22px; }
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) rotate(220deg) scale(.3); opacity: 0; } }
[hidden] { display: none !important; }

@media (max-width: 1200px) {
  .game-shell { grid-template-rows: 72px minmax(0, 1fr); }
  .topbar { grid-template-columns: minmax(280px, 1fr) minmax(250px, .8fr) auto; gap: 14px; padding: 8px 15px; }
  .brand h1 { font-size: 33px; }
  .main-grid { grid-template-columns: minmax(0, 1fr) 360px; }
  .journal { padding: 14px 14px 12px; }
  .journal h2 { font-size: 26px; }
  .journal-sub { font-size: 12px; margin-bottom: 6px; }
  .journal-status { margin-bottom: 8px; }
  .journal-list { gap: 7px; }
  .clue-row { min-height: 72px; padding: 8px 9px; grid-template-columns: 34px 1fr 22px; }
  .clue-icon { width: 31px; height: 31px; font-size: 17px; }
  .clue-copy strong { font-size: 14.5px; }
  .clue-copy span { font-size: 11.5px; }
  .hint-box { margin-top: 8px; padding-top: 8px; }
  .next-btn { margin-top: 8px; padding: 11px 14px; }
}

@media (max-height: 720px) and (min-width: 901px) {
  .game-shell { min-height: 0; grid-template-rows: 66px minmax(0, 1fr); }
  .topbar { padding-top: 6px; padding-bottom: 6px; }
  .brand h1 { font-size: 30px; }
  .brand p { font-size: 11px; margin-top: 3px; }
  .key-slot { width: 34px; height: 34px; }
  .tool-btn { width: 36px; height: 36px; }
  .room-title { top: 14px; left: 15px; padding: 8px 12px; }
  .room-title strong { font-size: 18px; }
  .room-title span { font-size: 12px; }
  .journal { padding-top: 11px; }
  .journal h2 { font-size: 24px; }
  .journal-sub { display: none; }
  .journal-status { margin: 5px 0 7px; }
  .clue-row { min-height: 66px; }
  .clue-copy span { font-size: 11px; }
  .hint-text { font-size: 11.5px; }
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .game-shell { height: auto; min-height: 100vh; grid-template-rows: auto 1fr; overflow: visible; }
  .topbar { grid-template-columns: 1fr auto; min-height: 76px; }
  .progress-wrap { grid-column: 1 / -1; grid-row: 2; padding-bottom: 4px; }
  .main-grid { grid-template-columns: 1fr; overflow: visible; }
  .scene-wrap { min-height: 560px; }
  .journal { overflow: visible; border-left: 0; border-top: 7px solid #513044; }
  .answers { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Website launcher + Fullscreen mode ---------- */
.site-launcher {
  width: min(620px, 100%);
  min-height: 230px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 42% 58%;
  overflow: hidden;
  color: #fff7df;
  border: 1px solid rgba(248,195,90,.42);
  border-radius: 18px;
  background: #0b0d27;
  box-shadow: 0 16px 42px rgba(0,0,0,.35);
}
.launcher-art {
  min-height: 230px;
  background:
    linear-gradient(90deg, rgba(7,9,28,.04), rgba(7,9,28,.55)),
    url("assets/haunted-hall.png") 42% center / cover no-repeat;
}
.launcher-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: 20px 22px 18px 18px;
  background:
    radial-gradient(circle at 100% 0, rgba(93,58,133,.34), transparent 40%),
    linear-gradient(145deg, #111333, #080a20);
}
.launcher-kicker {
  margin-bottom: 5px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .16em;
}
.site-launcher h1 {
  margin: 0;
  color: var(--paper-light);
  font: 900 31px/.95 Georgia, "Times New Roman", serif;
  letter-spacing: -.03em;
  text-shadow: 0 3px 0 #4d2e58;
}
.site-launcher p {
  margin: 10px 0 12px;
  color: #ded4ee;
  font-size: 14px;
  line-height: 1.34;
  font-weight: 700;
}
.launch-btn {
  width: 100%;
  min-height: 48px;
  border: 1px solid #2c8d80;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(#299b8f, #17665d);
  box-shadow: 0 5px 0 #0e4943;
  cursor: pointer;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: .025em;
}
.launch-btn span { margin-left: 5px; font-size: 20px; }
.launch-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.launch-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #0e4943; }
.site-launcher .launcher-note {
  margin: 9px 0 0;
  color: #a99cbd;
  font-size: 11.5px;
  font-weight: 700;
}
.new-tab-btn {
  align-self: flex-start;
  margin-top: 8px;
  padding: 0;
  border: 0;
  color: var(--gold);
  background: transparent;
  cursor: pointer;
  font-weight: 900;
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

body:not(.fullscreen-active) {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 10px;
  overflow: auto;
}
body:not(.fullscreen-active) #app,
body:not(.fullscreen-active) .fullscreen-exit { display: none !important; }

body.fullscreen-active {
  padding: 0;
  overflow: hidden;
  background: #07091e;
}
body.fullscreen-active .site-launcher { display: none; }
body.fullscreen-active #app { display: block; width: 100%; height: 100%; }
body.fullscreen-active .game-shell { width: min(1600px, 100%); height: 100dvh; }

.fullscreen-exit {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid rgba(248,195,90,.5);
  border-radius: 12px;
  color: #fff7df;
  background: rgba(12,13,38,.88);
  box-shadow: 0 7px 20px rgba(0,0,0,.35);
  backdrop-filter: blur(7px);
  cursor: pointer;
  font-weight: 900;
  font-size: 13px;
}
.fullscreen-exit:hover { background: #29254d; transform: translateY(-1px); }

:fullscreen body,
:-webkit-full-screen body { width: 100%; height: 100%; }

@media (max-width: 520px) {
  .site-launcher { grid-template-columns: 34% 66%; min-height: 210px; }
  .launcher-art { min-height: 210px; }
  .launcher-copy { padding: 15px 15px 14px; }
  .site-launcher h1 { font-size: 25px; }
  .site-launcher p { font-size: 12.5px; }
  .launch-btn { min-height: 44px; font-size: 14px; }
}
