:root {
  color-scheme: dark;
  --ink: #101923;
  --panel: #17232f;
  --panel-soft: #20303e;
  --line: #34424e;
  --snow: #f1f1ec;
  --mist: #a9b7c2;
  --amber: #e4c69a;
  --amber-dark: #292d34;
  --heading: Batang, "Nanum Myeongjo", "Times New Roman", serif;
  --text: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overflow: clip;
  min-width: 0;
  margin: 0;
  color: var(--snow);
  background: var(--ink);
  font: 400 0.95rem/1.65 var(--text);
  word-break: keep-all;
}

img {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:not(:disabled) {
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
}

a {
  color: inherit;
}

:where(a, button, select, input, textarea):focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 4px;
}

#scene-title[tabindex="-1"]:focus,
#entry-title[tabindex="-1"]:focus {
  outline: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.site-header {
  border-bottom: 1px solid #7f93a325;
  background: #121c27;
}

.header-inner,
.site-main,
.site-footer {
  width: min(1160px, calc(100% - 64px));
  margin-inline: auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 70px;
}

.brand,
.brand-copy {
  display: flex;
}

.brand {
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
}

.brand-icon {
  flex: none;
  width: 38px;
  height: 38px;
  object-fit: cover;
  border: 1px solid #9aafbd52;
  border-radius: 8px;
}

.brand-copy {
  flex-direction: column;
  line-height: 1.3;
}

.brand-name {
  font: 700 1.07rem/1.25 var(--heading);
  letter-spacing: -0.025em;
}

.brand-sub {
  margin-top: 3px;
  color: var(--mist);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.header-actions,
.cover-actions,
.modal-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.progress-pill {
  color: var(--mist);
  white-space: nowrap;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  min-height: 40px;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  text-decoration: none;
  white-space: nowrap;
  color: var(--snow);
  background: var(--panel);
  transition: background-color 170ms ease, border-color 170ms ease, color 170ms ease;
}

.button:not(:disabled):hover {
  border-color: #91a8b9;
  background: var(--panel-soft);
}

.button-primary {
  border-color: var(--amber);
  color: #27201b;
  background: var(--amber);
  font-weight: 700;
}

.button-primary:not(:disabled):hover {
  border-color: #f3ddb8;
  background: #f3ddb8;
}

.button-quiet {
  background: transparent;
}

.text-button {
  min-height: 36px;
  padding-inline: 0;
  border: 0;
  border-radius: 4px;
  color: var(--mist);
  background: none;
  font-size: 0.87rem;
}

.text-button:hover {
  color: var(--snow);
}

.site-main {
  padding-block: 28px 38px;
}

body:has(#cover:not([hidden])) {
  display: flex;
  flex-direction: column;
}

.site-main:has(> #cover:not([hidden])) {
  display: flex;
  flex-direction: column;
  min-block-size: 0;
}

.cover {
  isolation: isolate;
  position: relative;
  display: grid;
  align-items: center;
  overflow: hidden;
  block-size: clamp(438px, 50vw, 572px);
  min-block-size: 0;
  border: 1px solid #8595a34d;
  border-radius: 8px;
  background: #142330;
}

.cover-image,
.cover-shade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.cover-image {
  z-index: -2;
  object-fit: cover;
  object-position: 63% center;
}

.cover-shade {
  z-index: -1;
  background:
    linear-gradient(90deg, #0c1521ed, #0e1a27d9 28%, #0e192575 54%, #0b15241c 100%),
    linear-gradient(0deg, #10192389, transparent 40%);
}

.cover-copy {
  width: min(610px, 64%);
  padding: clamp(34px, 5.5vw, 70px);
}

.eyebrow {
  color: var(--amber);
  font-size: 0.77rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.cover .eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cover .eyebrow::before {
  width: 22px;
  height: 1px;
  background: currentColor;
  content: "";
}

.cover h1 {
  margin-block: 18px 21px;
  font-family: var(--heading);
  font-size: clamp(2.8rem, 5.65vw, 4.85rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.06em;
  text-shadow: 0 2px 18px #101923ae;
}

.cover-subtitle {
  color: #eadfcf;
  font-family: var(--heading);
  font-size: clamp(.85rem, 1.6vw, 1.03rem);
  line-height: 1.5;
  text-shadow: 0 1px 9px #101923cf;
  word-break: keep-all;
}

.cover-actions {
  margin-top: 30px;
}

.cover-actions .button {
  min-height: 45px;
  padding-inline: 1rem;
}

.timeline {
  margin-top: 45px;
  scroll-margin-top: 22px;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  column-gap: 20px;
  row-gap: 5px;
  margin-bottom: 16px;
}

.section-header .eyebrow {
  flex-basis: 100%;
}

.section-header h2 {
  font: 700 1.75rem/1.3 var(--heading);
  letter-spacing: -0.04em;
}

.section-description {
  color: var(--mist);
  font-size: 0.86rem;
}

.day-list {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.day-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 0;
  min-height: 88px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  text-align: left;
  color: var(--snow);
  background: #17232f8c;
  transition: border-color 170ms ease, background-color 170ms ease;
}

.day-tile:hover {
  border-color: #8aa4b9;
  background: var(--panel-soft);
}

.day-tile.is-current,
.day-tile[aria-current="date"],
.day-tile[aria-current="true"] {
  border-color: var(--amber);
  background: #262e37;
}

.day-date {
  color: #d2e1ea;
  font: 700 1.18rem/1.3 var(--heading);
  font-variant-numeric: tabular-nums;
}

.day-title {
  font-size: 0.83rem;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.day-label {
  color: var(--mist);
  font-size: 0.7rem;
}

.day-tile.is-lit .day-date,
.day-tile.is-lit .day-label {
  color: var(--amber);
}

.day-tile.is-lit::after {
  position: absolute;
  top: 13px;
  right: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  content: "";
}

.experience {
  scroll-margin-top: 18px;
}

.experience-head,
.day-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.experience-head {
  margin-bottom: 10px;
}

.scene-counter {
  color: var(--mist);
  white-space: nowrap;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.scene-frame {
  isolation: isolate;
  position: relative;
  overflow: hidden;
  background: transparent;
}

.scene-art {
  position: relative;
  overflow: hidden;
  border: 1px solid #8396a54b;
  border-radius: 6px;
  background: #0c141e;
}

.scene-image {
  width: 100%;
  height: clamp(245px, 47vw, min(570px, calc(100svh - 390px)));
  object-fit: contain;
  object-position: center;
}

.scene-shade {
  position: absolute;
  z-index: 1;
  inset: 0 0 auto;
  height: 53px;
  pointer-events: none;
  background: linear-gradient(#10192360, transparent);
}

.scene-location {
  position: absolute;
  z-index: 2;
  inset: 13px auto auto 13px;
  max-width: calc(100% - 30px);
  padding: 0.23rem 0.54rem;
  border: 1px solid #c9d5dd44;
  border-radius: 3px;
  color: var(--snow);
  background: #111d27e8;
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

.scene-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 18px;
  min-width: 0;
  padding: 22px clamp(1px, 1vw, 14px) 18px;
  border-bottom: 1px solid #8396a535;
  background: transparent;
}

.scene-frame:has(.scene-art[hidden], .scene-image[hidden]) .scene-content {
  min-height: clamp(265px, 36vw, 435px);
  align-items: center;
  padding: clamp(24px, 6vw, 64px);
  border: 1px solid #8396a541;
  border-radius: 6px;
  background: linear-gradient(128deg, #16212c, #1e303e 80%);
}

.scene-reading {
  flex: 1;
  min-width: 0;
}

.scene-companion {
  flex: 0 0 96px;
  min-width: 0;
  color: var(--mist);
  text-align: center;
  font-size: 0.76rem;
}

.scene-meta {
  color: var(--amber);
  font-size: 0.76rem;
  letter-spacing: 0.055em;
  font-variant-numeric: tabular-nums;
}

.scene-content h2 {
  margin-top: 3px;
  font: 700 clamp(1.45rem, 2.7vw, 2.24rem)/1.28 var(--heading);
  letter-spacing: -0.06em;
}

.scene-caption {
  max-width: 72ch;
  margin-top: 8px;
  color: #dce3e7;
}

.scene-origin {
  margin-top: 7px;
  color: var(--mist);
  font-size: 0.73rem;
}

.scene-steps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

.scene-step {
  display: grid;
  width: 24px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 3px;
  color: var(--mist);
  background: transparent;
  font-size: 0;
}

.scene-step::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid #8597a6;
  background: transparent;
  content: "";
}

.scene-step:hover::before {
  background: #84a2b7;
}

.scene-step.is-current::before,
.scene-step.is-active::before,
.scene-step[aria-current="step"]::before,
.scene-step[aria-current="true"]::before,
.scene-step[aria-pressed="true"]::before {
  border-color: var(--amber);
  background: var(--amber);
}

.day-footer {
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 9px 2px 0;
  border-top: 1px solid #8396a535;
  background: transparent;
}

.day-completion {
  color: var(--mist);
  font-size: 0.85rem;
}

.day-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-inline-start: auto;
}

.day-actions .button {
  min-height: 34px;
  padding: 0.35rem 0.5rem;
  border-color: transparent;
  color: var(--mist);
  font-size: 0.81rem;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding-block: 15px 24px;
  border-top: 1px solid #8396a535;
  color: var(--mist);
  font-size: 0.8rem;
}

.modal {
  width: min(760px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  padding: clamp(18px, 3vw, 29px);
  border: 1px solid #7190a46e;
  border-radius: 8px;
  color: var(--snow);
  background: var(--panel);
  box-shadow: 0 28px 72px #02070dcc;
  overscroll-behavior: contain;
}

.modal::backdrop {
  background: #050c16cd;
  backdrop-filter: blur(5px);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-head h2 {
  font: 700 1.65rem/1.3 var(--heading);
}

.dialog-close {
  display: inline-grid;
  flex: none;
  width: 39px;
  height: 39px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--ink);
}

.dialog-close:hover {
  border-color: #8aa4b9;
}

.cast-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  max-height: 165px;
  margin-top: 12px;
  padding: 3px;
  overflow-y: auto;
  scrollbar-color: #657e94 var(--ink);
}

.cast-tile,
.expression-options button {
  min-height: 38px;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  text-align: center;
  color: var(--snow);
  background: var(--ink);
  font-size: 0.82rem;
}

.cast-tile:hover,
.expression-options button:hover {
  border-color: #8aa4b9;
}

.cast-tile[aria-pressed="true"],
.cast-tile.is-current,
.cast-tile.is-active,
.expression-options button[aria-pressed="true"],
.expression-options button.is-active {
  border-color: var(--amber);
  color: var(--amber);
  background: var(--amber-dark);
}

.cast-detail {
  display: grid;
  grid-template-columns: minmax(0, 0.72fr) minmax(0, 1fr);
  gap: 10px;
}

.portrait-card {
  display: grid;
  align-content: center;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: radial-gradient(ellipse at 50% 45%, #2c4559, #152737 69%);
}

.portrait-card > img {
  width: 100%;
  height: 270px;
  object-fit: contain;
}

.cast-expression {
  padding: 10px;
  text-align: center;
}

.cast-expression h3 {
  font-size: 0.9rem;
}

.portrait-frame {
  width: min(100%, 190px);
  margin-inline: auto;
  aspect-ratio: 1;
  background-size: 300% 200%;
  background-repeat: no-repeat;
}

.expression-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 11px;
}

.card-preview img {
  width: 100%;
  max-height: 62vh;
  margin-inline: auto;
  border-radius: 8px;
  background: var(--ink);
  object-fit: contain;
}

.card-note-label {
  display: block;
  margin: 15px 0 5px;
  color: var(--mist);
  font-size: 0.82rem;
}

.card-note {
  width: 100%;
  min-height: 40px;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--snow);
  background: var(--ink);
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 15px;
}

@media (max-width: 850px) {
  .header-inner,
  .site-main,
  .site-footer {
    width: calc(100% - 40px);
  }

  .cover-copy {
    width: min(570px, 75%);
  }

  .day-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .header-inner,
  .site-main,
  .site-footer {
    width: calc(100% - 26px);
  }

  .header-inner {
    min-height: 64px;
    gap: 10px;
  }

  .brand {
    gap: 8px;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
  }

  .brand-name {
    font-size: 0.87rem;
  }

  .brand-sub,
  .progress-pill {
    font-size: 0.7rem;
  }

  .header-actions {
    justify-content: flex-end;
    gap: 5px 8px;
  }

  .header-actions .button {
    min-height: 34px;
    padding: 0.25rem 0.55rem;
    font-size: 0.75rem;
  }

  .site-main {
    padding-block: 17px 34px;
  }

  .cover {
    align-items: end;
    block-size: 500px;
    border-radius: 6px;
  }

  .cover-image {
    object-position: 68% top;
  }

  .cover-shade {
    background: linear-gradient(0deg, #07111df5 4%, #091623e0 29%, #0a182b34 76%, #0613200d);
  }

  .cover-copy {
    width: 100%;
    padding: 25px 20px 29px;
  }

  .cover h1 {
    margin-block: 9px 12px;
  }

  .cover-actions {
    margin-top: 18px;
  }

  .timeline {
    margin-top: 30px;
  }

  .day-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .day-tile {
    min-height: 94px;
    padding: 9px;
  }

  .day-tile.is-lit::after {
    top: 9px;
    right: 8px;
  }

  .scene-image {
    height: clamp(168px, 56vw, 315px);
  }

  .scene-location {
    inset-block-start: 10px;
    inset-inline-start: 10px;
    padding: 0.18rem 0.4rem;
    font-size: 0.69rem;
  }

  .scene-content {
    gap: 7px;
    padding: 15px 2px 16px;
    font-size: 0.86rem;
  }

  .scene-companion {
    flex-basis: 66px;
  }

  .scene-steps {
    order: 3;
    width: 100%;
  }

  .cast-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .portrait-card > img {
    height: 185px;
  }

  .expression-options button {
    min-height: 30px;
    padding: 0.22rem 0.3rem;
    font-size: 0.72rem;
  }
}

@media (max-width: 350px) {
  .header-inner {
    flex-wrap: wrap;
    padding-block: 10px;
  }

  .day-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
