@charset "UTF-8";

:root {
  color-scheme: dark;
  --paper: #101116;
  --ink: #eee5d4;
  --muted: #b7b1a5;
  --gold: #c8a66b;
  --rule: #b8945038;
  --header-height: 82px;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  font-synthesis: none;
  color: var(--ink);
  background: #07090d;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; min-height: 100svh; position: relative; isolation: isolate; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: linear-gradient(180deg, #05070b52 0%, #05070b4d 35%, #05070b9c 70%, #05070bea 100%), url("./assets/gothic-hall.webp") center top / cover no-repeat; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: wait; opacity: .58; }
button:focus-visible, a:focus-visible { outline: 2px solid #ffe2a8; outline-offset: 5px; }
.site-header { height: var(--header-height); max-width: 1240px; margin: auto; padding: 0 40px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 11px; color: #e2c18b; text-decoration: none; font-family: "Batang", "AppleMyungjo", Georgia, serif; font-size: 19px; font-weight: 400; letter-spacing: 1px; }
.brand svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 1.1; }
.text-button { background: transparent; border: 0; padding: 13px 0 13px 12px; font-size: 12px; color: #d0c4ae; }
.text-button span { margin-left: 10px; color: var(--gold); }
main { text-align: center; }
.game { min-height: calc(100svh - var(--header-height)); padding-bottom: 24px; }
.intro { padding-top: 13px; animation: arrive .8s ease-out both; }
.eyebrow { font: 9px/1.5 "Segoe UI", sans-serif; letter-spacing: 4px; font-weight: 500; color: var(--gold); }
.intro .eyebrow { margin: 0 0 13px; display: flex; align-items: center; justify-content: center; gap: 17px; }
.intro .eyebrow::before, .intro .eyebrow::after { content: ""; width: 40px; height: 1px; background: linear-gradient(90deg, transparent, #c8a66b9c); }
.intro .eyebrow::after { transform: rotate(180deg); }
h1 { margin: 0; font-family: "Batang", "AppleMyungjo", Georgia, serif; font-size: clamp(36px, 4.6vw, 58px); line-height: 1.25; letter-spacing: 5px; font-weight: 400; color: #f3e7d0; text-shadow: 0 3px 24px #000, 0 0 34px #d8b56b28; }
.intro-copy { font-size: 12px; color: #c8c1b5; margin: 15px 20px 0; line-height: 1.8; text-shadow: 0 2px 8px #000; }

/* Video and stills carry alpha, so the stone hall remains visible around the book. */
.book-stage { position: relative; width: min(800px, calc(100% - 32px)); height: auto; min-height: 0; aspect-ratio: 8 / 5; margin: 17px auto 0; isolation: isolate; }
.closed-book, .open-book, .book-video { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; border: 0; display: block; }
.open-book { z-index: 1; }
.book-still, .book-video { display: block; width: 100%; height: 100%; object-fit: contain; }
.closed-book { perspective: 1100px; }
.closed-book::after { content: ""; position: absolute; left: 29%; top: 94%; width: 42%; height: 5%; background: radial-gradient(ellipse, #000b, transparent 70%); filter: blur(7px); pointer-events: none; }
.lobby-book { position: absolute; left: 31%; top: 8%; width: 38%; height: 81%; perspective: 950px; }
.lobby-book::before { content: ""; position: absolute; inset: -12% -35%; pointer-events: none; background: radial-gradient(ellipse, #bbdfff24, #caa05d0a 48%, transparent 70%); opacity: .35; transition: opacity .35s; }
.lobby-book.is-awake::before { opacity: 1; }
.lobby-float, .lobby-volume { position: absolute; inset: 0; transform-style: preserve-3d; }
.is-lobby .lobby-float { animation: lobby-float 6s ease-in-out infinite; }
.is-lobby::after { animation: lobby-shadow 6s ease-in-out infinite; }
.lobby-volume { transform: rotateX(calc(5deg + var(--tilt-x, 0deg))) rotateY(calc(-16deg + var(--tilt-y, 0deg))) rotateZ(-2deg); transition: transform .24s ease-out; }
.lobby-volume::before { content: ""; position: absolute; inset: -1px; background: #38271f; border: 2px solid #a17a3e; border-radius: 5px; transform: translateZ(-14px); box-shadow: 4px 15px 35px #000a; }
.lobby-cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; border-radius: 4px; transform: translateZ(14px); backface-visibility: hidden; box-shadow: 0 0 2px #efcc85; }
.lobby-volume::after { content: ""; position: absolute; inset: 0; transform: translateZ(15px); border-radius: 4px; pointer-events: none; background: radial-gradient(ellipse at var(--shine-x, 50%) var(--shine-y, 35%), #d9eeff2e, transparent 60%); opacity: .3; transition: opacity .3s; }
.is-awake .lobby-volume::after { opacity: 1; }
.lobby-pages { position: absolute; right: 0; top: 4px; width: 28px; height: calc(100% - 8px); transform-origin: right center; transform: rotateY(90deg) translateX(14px); background: repeating-linear-gradient(0deg, #baa47c 0 1px, #e8d8b8 1px 3px); border: 1px solid #795b32; }
.lobby-spine { position: absolute; left: 0; top: 0; width: 28px; height: 100%; transform-origin: left center; transform: rotateY(90deg) translateX(-14px); background: repeating-linear-gradient(0deg, #37251c 0 19%, #997442 20%, #37251c 22%); border: 1px solid #9b763b; }
.lobby-bottom { position: absolute; bottom: 0; left: 3px; width: calc(100% - 6px); height: 28px; transform-origin: center bottom; transform: rotateX(90deg) translateY(14px); background: repeating-linear-gradient(0deg, #ad9672 0 1px, #e1cfad 1px 3px); border: 1px solid #795b32; }
.lobby-particles { position: absolute; inset: 0; z-index: 3; transform: translateZ(60px); pointer-events: none; }
.lobby-spark { position: absolute; width: var(--size); height: var(--size); border-radius: 50%; pointer-events: none; background: #fff7dc; color: var(--spark-color); box-shadow: 0 0 7px 2px currentColor, 0 0 17px currentColor; animation: lobby-spark var(--life) ease-out forwards; }
.lobby-spark.is-star::before, .lobby-spark.is-star::after { content: ""; position: absolute; left: 50%; top: 50%; width: 350%; height: 1px; background: linear-gradient(90deg, transparent, #fffbea, transparent); transform: translate(-50%, -50%); }
.lobby-spark.is-star::after { transform: translate(-50%, -50%) rotate(90deg); }
@keyframes lobby-float { 0%, 100% { transform: translateY(7px) rotateZ(-1.5deg); } 50% { transform: translateY(-9px) rotateZ(1.5deg); } }
@keyframes lobby-shadow { 0%, 100% { transform: scaleX(1); opacity: .65; } 50% { transform: scaleX(.8); opacity: .35; } }
@keyframes lobby-spark { 0% { opacity: 0; transform: translate3d(0, 6px, 0) scale(.2); } 18% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); } 100% { opacity: 0; transform: translate3d(var(--drift), var(--rise), 0) scale(.2) rotate(130deg); } }
.book-stage.is-opening .open-book > .book-still { visibility: hidden; }
.book-photo { position: absolute; left: 15%; top: 18%; width: 70%; height: 64%; margin: 0; display: flex; align-items: center; justify-content: center; isolation: isolate; animation: photo-reveal .16s ease-out both; }
.book-photo::before { content: ""; position: absolute; inset: -10% -8%; z-index: 0; pointer-events: none; background: radial-gradient(ellipse, #fffff5 12%, #fff4cce8 36%, #ffdb889e 55%, #b5e8ff66 69%, transparent 83%); filter: blur(20px); opacity: .96; }
.book-photo img { position: relative; z-index: 1; display: block; width: auto; height: 100%; max-width: 100%; aspect-ratio: 3 / 2; object-fit: contain; background: transparent;
  /* Feather the actual photo bounds into the unmasked halo; keep its center sharp. */
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='960' height='640' viewBox='0 0 960 640'%3E%3Cdefs%3E%3Cfilter id='soft'%3E%3CfeGaussianBlur stdDeviation='26'/%3E%3C/filter%3E%3C/defs%3E%3Crect x='34' y='28' width='892' height='584' rx='36' fill='white' filter='url(%23soft)'/%3E%3C/svg%3E");
  mask-size: 100% 100%;
}
.result-summary { margin: 10px 20px 0; text-shadow: 0 2px 14px #000; }
.result-summary > p:first-child { display: flex; gap: 10px; align-items: baseline; justify-content: center; font-size: 11px; color: #d2c5ac; margin: 0; }
.result-summary strong { font: 48px/1.1 Georgia, serif; color: #f6e5bd; text-shadow: 0 0 22px #e8bf6b50; }
.result-summary #photo-caption { font-size: 10px; color: var(--muted); margin: 6px 0 0; }
.game-controls { margin: 14px 20px 0; }
.status { color: var(--muted); font-size: 11px; line-height: 1.7; min-height: 20px; margin: 0 0 13px; text-shadow: 0 2px 8px #000; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 27px; min-height: 53px; min-width: 254px; padding: 14px 28px; border: 1px solid #b28e50; border-radius: 2px; background: linear-gradient(180deg, #403422ed, #201c17f2); color: #f4e7cb; font-size: 13px; font-weight: 500; letter-spacing: .8px; box-shadow: inset 0 0 0 3px #0b0c0e, 0 5px 24px #0008; transition: border-color .2s, box-shadow .2s, transform .2s; }
.primary-button:hover:not(:disabled) { border-color: #f5d79e; box-shadow: inset 0 0 0 3px #0b0c0e, 0 0 25px #dba55826; transform: translateY(-1px); }
.button-arrow { font-size: 18px; font-weight: 300; color: #d7b981; }
.game-controls .primary-button { background: linear-gradient(180deg, #f3d998, #c9974d); border-color: #f0d092; color: #201509; font-size: 15px; font-weight: 700; box-shadow: 0 5px 24px #0009, inset 0 0 0 2px #f5dea04d; }
.game-controls .button-arrow { color: inherit; }
.play-note { color: #b1aa9e; font-size: 9px; margin: 12px 0 0; line-height: 1.8; text-shadow: 0 2px 6px #000; }
.storage-warning { color: #e4bf8c; font-size: 11px; max-width: 400px; margin: 12px auto; line-height: 1.7; }
.reading-section { width: min(780px, calc(100% - 48px)); margin: 28px auto 0; padding-top: 20px; border-top: 1px solid var(--rule); text-align: left; }
.game + .reading-section { margin-top: 0; }
.reading-section h2, .document-page h2 { font: 400 23px/1.5 "Batang", "AppleMyungjo", Georgia, serif; color: #f0dfbd; margin: 0 0 8px; }
.reading-section p, .document-page p { color: var(--muted); font-size: 13px; line-height: 1.95; }
.document-page .eyebrow { font-size: 9px; color: var(--gold); }
.reading-section a, dialog a, .document-page a:not(.primary-button) { color: #e0c79e; text-underline-offset: 4px; }
.section-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 12px; }
.section-heading h2 { margin-bottom: 0; }
.section-heading > p { font-size: 11px; margin: 0; }
.scene-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.scene-gallery figure { margin: 0; min-width: 0; }
.scene-gallery figure > a { display: block; }
.scene-gallery img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: contain; transition: filter .2s; }
.scene-gallery a:hover img { filter: brightness(1.1); }
.scene-kind { display: block; margin-top: 10px; font-size: 10px; color: var(--gold); }
.scene-gallery h3 { margin: 4px 0 0; font-size: 14px; font-weight: 500; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 8px; }
.scene-gallery h3 span { color: #e0c79e; font: 18px Georgia, serif; white-space: nowrap; }
.scene-gallery p { font-size: 12px; margin: 4px 0 0; }
.document-page { width: min(740px, calc(100% - 48px)); margin: 55px auto 70px; text-align: left; }
.document-page h1 { font-size: clamp(27px, 5vw, 40px); letter-spacing: 1px; }
.document-page .document-date { font-size: 11px; margin: 20px 0 32px; }
.document-page section { margin-top: 38px; }
.document-page h2 { font-size: 23px; margin-bottom: 10px; }
.document-page .primary-button { color: var(--ink); text-decoration: none; margin-top: 30px; }
.site-footer { width: min(1152px, calc(100% - 80px)); margin: 27px auto 0; padding: 20px 0 23px; border-top: 1px solid var(--rule); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px; color: #b1a58f; font-size: 9px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 18px; }
.site-footer a { color: #d0c4ae; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; text-underline-offset: 4px; }
.site-footer > span:last-child { font: 8px "Segoe UI", sans-serif; letter-spacing: 1.6px; }
dialog { width: min(440px, calc(100% - 32px)); padding: 42px 32px 24px; color: var(--ink); border: 1px solid #b291586e; border-radius: 3px; background: linear-gradient(145deg, #1c1e22, #0e1117); text-align: center; box-shadow: inset 0 0 0 5px #0b0e1355, 0 20px 90px #000b; max-height: calc(100dvh - 32px); overflow-y: auto; }
dialog[open] { animation: arrive .2s both; }
dialog::backdrop { background: #020409c7; backdrop-filter: blur(6px); }
.dialog-close { position: absolute; right: 9px; top: 7px; border: 0; background: transparent; color: #d8c6a5; width: 42px; height: 42px; font-size: 26px; }
dialog .eyebrow { font-size: 9px; margin-top: 18px; }
dialog h2 { font-family: "Batang", "AppleMyungjo", Georgia, serif; font-size: 23px; font-weight: 400; letter-spacing: -1px; line-height: 1.5; color: #f0dfbd; }
dialog p:not(.eyebrow) { color: #c6beb0; font-size: 12px; line-height: 1.9; }
dialog .primary-button { width: 100%; min-width: 0; gap: 12px; margin-top: 12px; }
.about-list { text-align: left; font-size: 12px; line-height: 1.9; }
.about-list dt { font-weight: 700; color: #e0c79e; margin-top: 18px; }
.about-list dd { color: #bcb3a4; margin: 4px 0 0; }
.no-script { text-align: center; padding: 20px; }
@keyframes arrive { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: translateY(0); } }
@keyframes photo-reveal { from { opacity: 0; filter: brightness(1.45); } to { opacity: 1; filter: brightness(1); } }
@media (min-width: 601px) and (max-height: 950px) {
  :root { --header-height: 62px; }
  .intro { padding-top: 5px; }
  .intro .eyebrow { margin-bottom: 9px; }
  h1 { font-size: 43px; }
  .intro-copy { margin-top: 10px; font-size: 11px; }
  .book-stage { width: min(720px, calc(100% - 36px), max(192px, calc((100svh - 350px) * 1.6))); margin-top: 14px; }
  .game-controls { margin-top: 10px; }
  .status { margin-bottom: 10px; }
  .result-summary { margin-top: 5px; }
  .primary-button { min-height: 48px; }
}
@media (max-width: 600px) {
  :root { --header-height: 66px; }
  .site-header { padding: 0 23px; }
  .brand { font-size: 16px; gap: 8px; }
  .brand svg { width: 24px; height: 24px; }
  .text-button { font-size: 11px; }
  .intro { padding-top: 15px; }
  .intro .eyebrow { font-size: 8px; letter-spacing: 3px; gap: 12px; margin-bottom: 13px; }
  .intro .eyebrow::before, .intro .eyebrow::after { width: 22px; }
  h1 { font-size: 38px; letter-spacing: 3px; }
  .intro-copy { font-size: 10px; margin: 12px 20px 0; }
  .book-stage { width: min(calc(100% - 24px), max(192px, calc((100svh - 322px) * 1.6))); margin-top: 17px; }
  .result-summary strong { font-size: 42px; }
  .game-controls { margin-top: 16px; }
  .primary-button { min-height: 52px; min-width: 248px; }
  .reading-section h2 { font-size: 21px; }
  .scene-gallery { grid-template-columns: 1fr; }
  .scene-gallery figure { display: grid; grid-template-columns: 88px 1fr; gap: 12px; align-items: start; }
  .scene-kind { margin-top: 0; }
  .document-page { margin-top: 30px; }
  .site-footer { width: calc(100% - 46px); margin-top: 24px; font-size: 8px; }
  .site-footer > span:last-child { font-size: 7px; letter-spacing: .7px; }
  dialog { padding: 37px 24px 20px; }
}
@media (max-width: 350px) {
  h1 { font-size: 34px; }
  .intro-copy { font-size: 9px; margin-inline: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
