:root {
  --bg: #08090b;
  --header: #0b0c0f;
  --surface: #111317;
  --raised: #181b20;
  --hover: #1d2027;
  --line: #22252c;
  --line-strong: #3d414b;
  --text: #ece8e1;
  --muted: #9c9b96;
  --faint: #6c6c68;
  --accent: #e4685c;
  --accent-hover: #f08a7f;
  --on-accent: #1a0e0c;
  --top: 56px;
  --gap: clamp(16px, 2vw, 24px);
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: dark;
}
* { box-sizing: border-box }
html { background: var(--bg) }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 15px/1.6 "IBM Plex Sans KR", system-ui, sans-serif; -webkit-font-smoothing: antialiased }
a { color: inherit; text-decoration: none }
a:focus-visible, button:focus-visible, iframe:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
p { color: var(--muted) }
kbd {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px;
  background: var(--raised); color: var(--text); font: 500 11px/1 "IBM Plex Sans KR", system-ui, sans-serif;
}

/* Header */
.top {
  position: sticky; top: 0; z-index: 3;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  /* Same left and right edges as the content below (which stops growing at 1600px). */
  height: var(--top); padding: 0 max(var(--gap), calc((100% - 1600px) / 2 + var(--gap)));
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--header) 86%, transparent);
  backdrop-filter: blur(10px);
  transition: margin-top .35s var(--ease), opacity .35s var(--ease);
}
.brand { flex: none; display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font: 700 19px/1 "Noto Serif KR", serif; letter-spacing: -.02em }
.brand svg { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round }
.now { min-width: 0; display: inline-flex; align-items: center; gap: 10px; margin: 0; color: var(--text); font: 500 14px/1 "Noto Serif KR", serif }
.now[hidden] { display: none }
.now .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); animation: live 2.4s ease-in-out infinite }
@keyframes live { 50% { box-shadow: 0 0 0 7px transparent } }
.platform { color: var(--faint); font-size: 12px; letter-spacing: .04em }

/* Stage first, the side column next to it */
.hub {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px;
  gap: var(--gap); align-items: start;
  max-width: 1600px; margin: 0 auto; padding: var(--gap);
  transition: padding .35s var(--ease);
}
.theatre {
  container-type: inline-size;
  position: relative; border-radius: 12px; overflow: hidden; background: #000;
  box-shadow: 0 0 0 1px var(--line), 0 40px 100px -40px #000;
  transition: border-radius .35s var(--ease);
}
.theatre iframe[hidden] { display: none }
.theatre iframe {
  display: block; width: 100%; border: 0; background: #000;
  height: min(calc(var(--aspect, .66667) * 100cqw + 52px), calc(100dvh - var(--top) - 2 * var(--gap)));
  min-height: 300px;
}

/* Title card: a night still from the game, falling snow, the title and one button. */
.marquee {
  position: relative; isolation: isolate;
  display: flex; align-items: flex-end;
  aspect-ratio: 3 / 2; max-height: calc(100dvh - var(--top) - 2 * var(--gap)); width: 100%;
  overflow: hidden; background: #05060a;
}
.marquee[hidden] { display: none }
.still { position: absolute; inset: 0; z-index: -2 }
.still img {
  position: absolute; inset: 0 0 0 auto; width: 84%; height: 100%; object-fit: cover; object-position: 50% 40%;
  image-rendering: pixelated; filter: saturate(.8) brightness(.85);
  animation: drift 40s ease-in-out infinite alternate;
}
@keyframes drift { from { transform: scale(1.02) } to { transform: scale(1.1) translate(-1.5%, -1%) } }
.still::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(90deg, #05060a 16%, rgba(5, 6, 10, .78) 40%, rgba(5, 6, 10, .05) 80%),
    linear-gradient(0deg, rgba(5, 6, 10, .95) 0%, transparent 45%),
    radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(0, 0, 0, .7) 100%);
}
/* a bright title picture (the SFC paper) is dimmed more so the text over it stays readable */
/* a title screen with its own big lettering sits further back behind the card */
.marquee.dim .still img { filter: saturate(.7) brightness(.4) blur(3px) }
.marquee.light .still img { filter: saturate(.8) brightness(.55) }
.marquee:not(:has(.still img)) { background: radial-gradient(120% 80% at 70% 0%, #1c2538, transparent 60%), radial-gradient(90% 70% at 10% 100%, #2a0f12, transparent 65%), linear-gradient(#0a0d14, #050608) }
.snow { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none }
@media (prefers-reduced-motion: reduce) { .still img { animation: none } }

.card { display: flex; flex-direction: column; gap: 10px; width: 100%; padding: clamp(24px, 6cqw, 72px) }
.card > * { animation: rise .9s var(--ease) both }
.card > :nth-child(2) { animation-delay: .08s } .card > :nth-child(3) { animation-delay: .14s }
.card > :nth-child(4) { animation-delay: .2s } .card > :nth-child(5) { animation-delay: .26s } .card > :nth-child(6) { animation-delay: .34s }
@keyframes rise { from { opacity: 0; translate: 0 12px } }
@media (prefers-reduced-motion: reduce) { .card > * { animation: none } }
.kicker { display: flex; gap: 10px; margin: 0; color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: .14em }
.kicker span + span::before { content: ""; display: inline-block; width: 3px; height: 3px; margin: 0 10px 0 0; vertical-align: middle; border-radius: 50%; background: var(--faint) }
/* Title in the spirit of the game's logo: thick red marker strokes with a white rim. */
.logo {
  --red: #d8261d;
  --rim: #f4f0ea;
  display: inline-grid; justify-items: end; justify-self: start; align-self: flex-start;
  margin: 6px 0 6px; line-height: 1;
  filter: drop-shadow(0 6px 24px rgba(0, 0, 0, .7));
}
.card [hidden] { display: none !important }
/* every logo gets the same visual area: width grows with the square root of its (trimmed)
   aspect ratio, capped by the card width and a common height */
.logo img { --ar: 2.5; display: block; height: auto;
  width: min(calc(clamp(250px, 46cqw, 540px) * pow(var(--ar) / 2.5, .36)), 86cqw, 640px, calc(min(30vh, 34cqw, 250px) * var(--ar))) }
.marquee.long .logo img { width: min(calc(clamp(220px, 38cqw, 440px) * pow(var(--ar) / 2.5, .36)), 86cqw, 560px, calc(min(24vh, 28cqw, 200px) * var(--ar))) }
.logo:not(.text) .jp, .logo:not(.text) .adv { display: none }
.logo.text img { display: none }
.logo .jp {
  justify-self: start;
  font: 400 clamp(40px, 8.2cqw, 100px)/1.05 var(--logo-font, "Yusei Magic"), "Noto Serif JP", serif;
  letter-spacing: .01em;
  color: var(--red);
  -webkit-text-stroke: clamp(5px, .7cqw, 9px) var(--rim);
  paint-order: stroke fill;
}
.logo .adv {
  margin: .02em -.05em 0 0;
  font: 400 clamp(16px, 2.6cqw, 32px)/1 Anton, "IBM Plex Sans KR", sans-serif;
  letter-spacing: .06em;
  color: var(--red);
  -webkit-text-stroke: clamp(3px, .45cqw, 6px) var(--rim);
  paint-order: stroke fill;
}
.marquee .ko { margin: 0; color: var(--text); font: 500 clamp(15px, 2cqw, 21px)/1.4 "Noto Serif KR", serif }
.marquee .ko .name { word-break: keep-all }
.subt { display: inline-block; word-break: keep-all }
.tail { white-space: nowrap }
.marquee .ko .tail::after { content: ""; display: inline-block; width: 48px; height: 1px; margin-left: 14px; vertical-align: .35em; background: var(--accent) }
.lede .para, .lede .line { display: block }
.lede .para + .para { margin-top: .6em }
.lede .warning { display: inline-block; margin-bottom: 4px; color: var(--text); font-weight: 600; letter-spacing: .02em }
.lede { margin: 6px 0 12px; max-width: 38em; word-break: keep-all; text-wrap: pretty; font-size: clamp(13px, 1.45cqw, 15px); line-height: 1.8; color: #bdbbb5 }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px }
.start {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 50px; padding: 0 28px 0 22px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-size: 16px; font-weight: 600;
  box-shadow: 0 10px 30px -10px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
}
.start:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 14px 36px -10px var(--accent) }
.start:active { transform: none }
.start svg { width: 18px; height: 18px; fill: currentColor }
.hint { color: var(--faint); font-size: 12px }
.facts { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 22px 0 0; padding: 18px 0 0; list-style: none; border-top: 1px solid rgba(255, 255, 255, .08); color: var(--muted); font-size: 12px }
.facts li { display: flex; flex-direction: column; gap: 2px }
.facts b { color: var(--text); font: 600 13px/1.2 "IBM Plex Sans KR", sans-serif; letter-spacing: .04em }

/* Side column: works, controls, links */
.side { display: flex; flex-direction: column; gap: 28px; position: sticky; top: calc(var(--top) + var(--gap)); transition: opacity .35s var(--ease) }
.label { display: flex; align-items: center; gap: 8px; margin: 0 0 10px 2px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .12em }
.label span { color: var(--faint); font-weight: 500 }
.library { display: flex; flex-direction: column; gap: 8px }
/* One card per work: a cover, title, platforms and status. A series card opens its editions below it. */
.entry {
  position: relative; display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 8px 12px 8px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  transition: border-color .15s ease, background .15s ease;
}
a.entry:hover, summary.entry:hover { background: var(--hover); border-color: var(--line-strong) }
div.entry { grid-template-columns: 84px minmax(0, 1fr); cursor: default }
/* works not playable yet still show their card on a press */
.entry.soon, .edition.soon { cursor: pointer }
.entry.soon[aria-current] .cover { filter: none }
.edition.soon[aria-current] { background: var(--raised) }
.start.soon { background: rgba(255,255,255,.08); color: var(--muted); box-shadow: none; cursor: default; pointer-events: auto }
.start.soon:hover { background: rgba(255,255,255,.08); transform: none; box-shadow: none }
.start.soon svg { display: none }
div.entry .cover, a.entry:not([aria-current]) .cover { filter: saturate(.75) }
.entry[aria-current] { border-color: color-mix(in srgb, var(--accent) 70%, transparent); background: var(--raised) }
.series { border-radius: 12px }
.series > summary { list-style: none; cursor: pointer; user-select: none }
.series > summary::-webkit-details-marker { display: none }
.series[open] > summary { background: var(--raised); border-color: var(--line-strong); border-radius: 12px 12px 0 0 }
.series:has(.work[aria-current]) > summary { border-color: color-mix(in srgb, var(--accent) 70%, transparent) }
.series:has(.work[aria-current]) > summary::before { content: ""; position: absolute; left: -1px; top: 18px; bottom: 18px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent) }
.chev { width: 16px; height: 16px; fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s var(--ease) }
.series[open] .chev { transform: rotate(90deg) }
.entry[aria-current]::before { content: ""; position: absolute; left: -1px; top: 18px; bottom: 18px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent) }

/* Editions: a tree line from under the cover through each edition. */
.editions {
  position: relative; margin: 0; padding: 6px 8px 8px 56px; list-style: none;
  border: 1px solid var(--line-strong); border-top: 0; border-radius: 0 0 12px 12px; background: var(--surface);
}
.editions::before { content: ""; position: absolute; left: 50px; top: 0; bottom: 26px; width: 1px; background: var(--line-strong) }
.editions li { position: relative }
.editions li::before { content: ""; position: absolute; left: -6px; top: 18px; width: 10px; height: 1px; background: var(--line-strong) }
.edition { display: flex; flex-direction: column; padding: 5px 10px; border-radius: 8px }
.edition .title { font-size: 14px; color: var(--muted) }
.edition .sub { font-size: 11px }
a.edition .title { color: var(--text) }
a.edition:hover { background: var(--hover) }
a.edition[aria-current] { background: var(--raised) }
.editions li:has(a.edition)::before { background: var(--accent) }
.edition .status { font-size: 11px; margin-top: 1px }

.cover {
  position: relative; display: grid; place-items: center;
  aspect-ratio: 3 / 2; border-radius: 7px; overflow: hidden;
  background: radial-gradient(90% 100% at 30% 15%, color-mix(in srgb, var(--tint, #1c2538) 100%, #fff 6%), #07080b);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated }
/* Package photos scale smoothly; only the game still keeps its pixels. */
.cover img[src$=".jpg"] { image-rendering: auto }
/* The package already carries its title. */
.cover:has(img[src$=".jpg"])::after, .cover:has(img[src$=".jpg"]) .cover-text { display: none }
.cover:has(img)::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(0, 0, 0, .75), transparent 70%) }
.cover-text { position: relative; z-index: 1; padding: 4px; font: 700 11px/1.25 "Noto Serif JP", serif; text-align: center; text-shadow: 0 1px 6px #000; color: #e4e0d8; word-break: keep-all }
.cover:has(img) .cover-text { align-self: end; font-size: 9px; letter-spacing: .04em }
.info { display: flex; flex-direction: column; min-width: 0 }
.title { font: 600 15px/1.35 "Noto Serif KR", serif; word-break: keep-all }
.sub { color: var(--faint); font-size: 12px }
.status { display: inline-flex; align-items: center; gap: 6px; margin-top: 3px; color: var(--muted); font-size: 12px }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong) }
.status.ready { color: var(--text) }
.status .ver { color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .02em }
.status.ready::before { background: var(--accent); box-shadow: 0 0 8px var(--accent) }
/* Part of the original runs (the sound so far): a hollow accent dot. */
.status.partial::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--accent) }

.guide dl { display: grid; gap: 2px; margin: 0; padding: 6px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line) }
.guide dl div { display: grid; grid-template-columns: 64px 1fr; align-items: center; min-height: 34px }
.guide dt { display: flex; gap: 4px }
.guide dd { margin: 0; color: var(--muted); font-size: 13px }
.note { margin: 10px 2px 0; color: var(--faint); font-size: 12px; line-height: 1.6 }
@media (pointer: coarse) { .guide { display: none } }
.links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: -8px 2px 0 }
.links a { display: inline-flex; align-items: center; min-height: 32px; color: var(--muted); font-size: 12px; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 4px }
.links a:hover { color: var(--accent-hover); text-decoration-color: currentColor }

/* While playing the side column steps back a little; theatre mode removes it. */
body.playing .side { opacity: .6 }
/* While playing, the controls come first so the menu key is in view without scrolling. */
body.playing .guide { order: -1 }
body.playing .side:hover, body.playing .side:focus-within { opacity: 1 }
body.playing .platform { display: none }
body.theatre-mode { overflow: hidden }
body.theatre-mode .top { margin-top: calc(-1 * var(--top)); opacity: 0; pointer-events: none }
body.theatre-mode .hub { grid-template-columns: minmax(0, 1fr); max-width: none; padding: 0 }
body.theatre-mode .side { display: none }
body.theatre-mode .theatre { border-radius: 0; box-shadow: none }
body.theatre-mode .theatre iframe { height: 100dvh }

@media (max-width: 900px) {
  :root { --top: 52px }
  .now { font-size: 13px }
  .platform { display: none }
  .hub { grid-template-columns: minmax(0, 1fr); padding: 0 0 24px; gap: 24px }
  .theatre { border-radius: 0; box-shadow: none; border-bottom: 1px solid var(--line) }
  .marquee { aspect-ratio: auto; min-height: min(560px, calc(100dvh - var(--top) - 120px)) }
  .still img { width: 100%; object-position: 50% 40%; filter: saturate(.85) brightness(1) }
  .still::after { background: linear-gradient(0deg, rgba(5, 6, 10, .97) 15%, rgba(5, 6, 10, .55) 60%, rgba(5, 6, 10, .2) 100%) }
  .facts { gap: 8px 20px }
  .side { position: static; padding: 0 16px; opacity: 1 !important }
}
@media (pointer: coarse) {
  /* Touch play needs no buttons; when the player shows them (its pad button) the frame grows to hold them. */
  body.pad-on .theatre iframe { height: min(calc(var(--aspect, .66667) * 100cqw + 52px + 200px), calc(100dvh - var(--top))) }
  body.theatre-mode .theatre iframe { height: 100dvh }
}
/* Phone turned sideways while a game is open: the player takes the whole window, like a handheld.
   Turning back to portrait brings the hub back. */
@media (pointer: coarse) and (orientation: landscape) {
  body.playing { overflow: hidden }
  body.playing .theatre iframe { position: fixed; inset: 0; z-index: 50; width: 100vw; height: 100dvh; border-radius: 0 }
}

/* Legacy emulator page (play.html) */
main.game-pane { width: 100%; padding: 8px 10px }
.game-pane header { display: flex; justify-content: space-between; margin: 0 0 5px; padding: 0 0 5px; border-bottom: 1px solid var(--line) }
.game-pane h1 { margin: 0; font-size: 18px }
.game-pane p { font-size: 14px; margin: 6px 0 }
.screen { width: 100%; aspect-ratio: 3/2; background: #07070a }
#game { width: 100%; height: 100% }

/* The port page's own full screen where the browser has none (iPhone): the frame covers the window. */
body.filled { overflow: hidden }
body.filled .theatre iframe { position: fixed; inset: 0; z-index: 60; width: 100vw; height: 100dvh; border-radius: 0 }

/* The hub's front page: the pension, the weather of this visit, the song. Over the hub until entered. */
body.front-on { overflow: hidden }
.front {
  position: fixed; inset: 0; z-index: 100; overflow: hidden; isolation: isolate;
  display: grid; place-items: center; background: #04050a; color: var(--text);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
}
.front[hidden] { display: none }
/* nothing on the front page is picked up or selected by a drag (태우 2026-11-28) */
.front, .front * { user-select: none; -webkit-user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none }
.front.leaving { opacity: 0; transform: scale(1.03); pointer-events: none }
.front-picture {
  position: absolute; inset: 5% -3% -11%; width: 106%; height: 106%; object-fit: cover; object-position: 50% 15%; z-index: -3;
  -webkit-mask-image: linear-gradient(transparent, #000 9%); mask-image: linear-gradient(transparent, #000 9%);
  image-rendering: pixelated; opacity: 0; transition: opacity 1.6s ease, filter 30s linear;
  animation: front-drift 60s ease-in-out infinite alternate;
}
.front.ready .front-picture { opacity: 1 }
.front-picture.sharp { image-rendering: auto }
@keyframes front-drift { from { transform: scale(1) } to { transform: scale(1.08) translate(-1%, -1%) } }
.front-sky { position: absolute; inset: 0; z-index: -2; pointer-events: none; transition: background 30s linear }
.front-snow { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none }
/* Night, as the game shows it. */
.front[data-hour="night"] .front-picture { filter: saturate(.9) brightness(.85) }
.front[data-hour="night"] .front-sky { background: radial-gradient(120% 90% at 50% 40%, transparent 40%, rgba(0,0,0,.75)), linear-gradient(rgba(4,6,14,.55), rgba(4,5,10,.2) 40%, rgba(4,5,10,.85)) }
.front-title { position: relative; display: grid; justify-items: center; gap: 14px; padding: 24px; text-align: center; text-shadow: 0 2px 18px rgba(0,0,0,.8) }
.front-kicker { margin: 0; color: rgba(236,232,225,.7); font: 500 11px/1 "IBM Plex Sans KR", sans-serif; letter-spacing: .32em }
.front h1 { margin: 0; font: 700 clamp(44px, 9vw, 104px)/1.05 "Noto Serif KR", serif; letter-spacing: -.02em; color: #f4f0ea }
.front-lede { margin: 0; color: rgba(236,232,225,.85); font: 500 clamp(14px, 1.6vw, 17px)/1.8 "Noto Serif KR", serif; word-break: keep-all }
.front-lede span { display: inline-block }
.front-enter {
  margin-top: 14px; display: inline-flex; align-items: center; min-height: 48px; padding: 0 30px; border-radius: 999px;
  border: 1px solid rgba(244,240,234,.55); background: rgba(8,9,11,.35); backdrop-filter: blur(6px);
  color: #f4f0ea; font: 600 15px/1 "IBM Plex Sans KR", sans-serif; letter-spacing: .08em; text-shadow: none;
  transition: background .2s ease, border-color .2s ease;
}
.front-enter:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent) }
.front-sound {
  position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid rgba(244,240,234,.35); border-radius: 50%;
  background: rgba(8,9,11,.4); color: #f4f0ea; cursor: pointer; backdrop-filter: blur(6px);
}
.front-note { position: fixed; z-index: 101; right: 70px; bottom: max(24px, env(safe-area-inset-bottom)); max-width: min(70vw, 420px); margin: 0; padding: 8px 12px; border-radius: 8px; background: rgba(8,9,11,.75); color: #f4f0ea; font: 500 12px/1.5 "IBM Plex Sans KR", sans-serif; word-break: break-all }
/* the same button in the hub's top bar; hidden while a game plays (the game has its own sound) */
.top .hub-sound { position: static; flex: none; width: 36px; height: 36px; margin-left: auto; backdrop-filter: none }
body.playing .top .hub-sound { display: none }
.front-sound svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round }
.front-sound[aria-pressed="true"] .off { display: none }
@media (prefers-reduced-motion: reduce) { .front-picture { animation: none } }
