:root {
  --ink: #f2f2f2;
  --paper: #0d0e11;
  --muted: #8b8e95;
  --line: rgba(255, 255, 255, 0.12);
  --night: #05070c;
}

* {
  box-sizing: border-box;
  margin: 0;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Apple SD Gothic Neo',
    'Malgun Gothic',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* 하늘 위 HUD — 색은 하늘 밝기에 맞춰 main 이 --hud 로 넘기고, 반대색 그림자로 중간 밝기에서도 읽히게 한다. */
.hud,
.hint,
.callout {
  color: var(--hud, #f2f2f2);
  text-shadow: 0 0 10px var(--halo, rgba(0, 0, 0, 0.5));
}

.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  padding: max(16px, env(safe-area-inset-top)) 16px 0;
  font-size: 14px;
  pointer-events: none;
}

.brand {
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 32px;
}

.clock {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 32px;
  font-variant-numeric: tabular-nums;
}

.hud-right {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.counter {
  display: flex;
  align-items: baseline;
  gap: 3px;
  padding: 0;
  border: 0;
  background: none;
  font-variant-numeric: tabular-nums;
  pointer-events: auto;
  cursor: pointer;
}

.counter b {
  font-size: 24px;
  font-weight: 900;
  line-height: 32px;
}

.counter-label {
  margin-left: 8px;
  padding: 2px 7px;
  border: 1px solid currentColor;
  font-size: 11px;
  font-weight: 700;
}

.counter.bump b {
  display: inline-block;
  animation: bump 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.gauge {
  width: 96px;
  height: 3px;
  background: color-mix(in srgb, var(--hud, #f2f2f2) 25%, transparent);
}

.gauge i {
  display: block;
  width: calc(var(--fill, 0) * 100%);
  height: 100%;
  background: var(--hud, #f2f2f2);
  transition: width 0.15s linear;
}

.gauge.active i {
  animation: pulse 0.4s ease-in-out infinite alternate;
}

.hint {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  font-size: 12px;
  text-align: center;
  opacity: 0.7;
  pointer-events: none;
}

.hint.fade {
  opacity: 0;
  transition: opacity 1s 8s;
}

.pointer {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  margin: -9px 0 0 -9px;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 16px solid var(--hud, #f2f2f2);
  pointer-events: none;
}

.callout {
  position: fixed;
  top: 26%;
  left: 0;
  right: 0;
  display: grid;
  justify-items: center;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
}

.callout b {
  font-size: clamp(28px, 6vw, 48px);
  font-weight: 900;
  letter-spacing: 0.06em;
}

.callout span {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.callout.show {
  animation: callout 1.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.toast {
  position: fixed;
  left: 16px;
  bottom: max(48px, calc(env(safe-area-inset-bottom) + 32px));
  display: flex;
  gap: 14px;
  align-items: center;
  max-width: min(380px, calc(100% - 32px));
  padding: 8px 18px 8px 8px;
  border: 1px solid var(--line);
  background: rgba(13, 14, 17, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  text-align: left;
  cursor: pointer;
}

.toast.in {
  animation: toast 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.toast img,
.flying {
  flex: none;
  width: 64px;
  height: 64px;
  object-fit: cover;
}

.flying {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 5;
  pointer-events: none;
}

.toast-text {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.toast-index {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.toast-title {
  overflow: hidden;
  font-size: 15px;
  font-weight: 900;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.toast-more {
  font-size: 12px;
  color: var(--muted);
}

kbd {
  margin-left: 6px;
  padding: 0 5px;
  border: 1px solid var(--line);
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.stick {
  position: fixed;
  top: 0;
  left: 0;
  width: 140px;
  height: 140px;
  margin: -70px 0 0 -70px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  pointer-events: none;
}

.knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}

/* 인트로 */
.intro {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  padding: 16px;
  text-align: center;
  background: radial-gradient(
    ellipse at 50% 50%,
    rgba(5, 7, 12, 0.7),
    rgba(5, 7, 12, 0.2) 70%
  );
}

.intro-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  font-size: 13px;
  font-weight: 700;
}

.intro-links a {
  color: var(--muted);
}

.intro-links a:hover {
  color: var(--ink);
}

a.btn {
  display: inline-block;
  text-decoration: none;
}

.intro-eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--muted);
}

.intro h1 {
  font-size: clamp(52px, 13vw, 136px);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 0.9;
}

.intro-lead {
  font-size: clamp(16px, 2.4vw, 20px);
  font-weight: 600;
  line-height: 1.6;
  word-break: keep-all;
}

.intro-guide {
  font-size: 14px;
  line-height: 1.8;
  color: var(--muted);
  word-break: keep-all;
}

.intro-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.btn {
  padding: 14px 30px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
}

.btn.ghost:hover:not(:disabled) {
  background: var(--ink);
  color: var(--paper);
}

/* 카드 공통 */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  background: rgba(5, 7, 12, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade 0.25s ease-out;
}

.case,
.collection,
.finale {
  background: var(--paper);
  border: 1px solid var(--line);
  outline: none;
  animation: rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.case-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
}

.close,
.back {
  padding: 6px 0;
  border: 0;
  background: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.desc {
  font-size: 15px;
  line-height: 1.8;
  color: rgba(242, 242, 242, 0.82);
  word-break: keep-all;
}

/* 작업 상세 — 왼쪽 목업, 오른쪽 정보 */
.case {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  max-width: 1320px;
  height: 100%;
  max-height: 840px;
  overflow: hidden;
}

.case-bar {
  grid-column: 1 / -1;
}

.viewer {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: radial-gradient(
    ellipse 60% 55% at 50% 48%,
    color-mix(in srgb, var(--accent) 38%, transparent),
    transparent 75%
  );
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 8px 64px;
  touch-action: pan-y;
  user-select: none;
}

.frames {
  position: relative;
  width: 100%;
  height: 100%;
}

.frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
}

.frame.under {
  z-index: 1;
  opacity: 1;
}

.frame.active {
  z-index: 2;
  opacity: 1;
  animation: fade 0.65s ease;
}

.stage.loading::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 64px;
  height: 2px;
  margin-left: -32px;
  background: var(--ink);
  animation: loading 0.9s ease-in-out infinite;
}

.arrow {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(13, 14, 17, 0.5);
  cursor: pointer;
  transition: border-color 0.2s;
}

.arrow:hover {
  border-color: var(--ink);
}

.arrow::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 9px;
  height: 9px;
  border-top: 2px solid var(--ink);
  border-right: 2px solid var(--ink);
}

.arrow-prev {
  left: 12px;
}

.arrow-prev::before {
  transform: translate(-30%, -50%) rotate(-135deg);
}

.arrow-next {
  right: 12px;
}

.arrow-next::before {
  transform: translate(-70%, -50%) rotate(45deg);
}

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  min-height: 52px;
  padding: 0 24px 16px;
}

.pager-count {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.pager-dots {
  display: flex;
  gap: 4px;
}

.pager-dot {
  width: 22px;
  height: 18px;
  padding: 0;
  border: 0;
  background: linear-gradient(var(--line), var(--line)) center / 100% 2px
    no-repeat;
  cursor: pointer;
}

.pager-dot.on {
  background-image: linear-gradient(var(--ink), var(--ink));
}

.info {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
  padding: 16px 32px 32px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
}

.info h2 {
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 900;
  line-height: 1.25;
  letter-spacing: -0.02em;
  word-break: keep-all;
}

.meta {
  display: grid;
  gap: 14px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.meta div {
  display: grid;
  grid-template-columns: 110px 1fr;
}

.meta dt {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.meta dd {
  margin: 0;
  font-size: 14px;
}

.work-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: auto;
}

.work-nav button {
  display: grid;
  gap: 4px;
  padding: 14px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  text-align: left;
  cursor: pointer;
}

.work-nav button:last-child {
  text-align: right;
}

.work-nav span {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.work-nav b {
  overflow: hidden;
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.work-nav button:hover b {
  text-decoration: underline;
}

/* 도감 */
.collection {
  width: 100%;
  max-width: 1120px;
  height: 100%;
  max-height: 880px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 40px;
}

.collection .case-bar {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--paper);
}

.collection-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 8px 32px 32px;
}

.collection-head h2 {
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 900;
  letter-spacing: -0.03em;
}

.year-group {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  padding: 24px 32px;
  border-top: 1px solid var(--line);
}

.year-group h3 {
  font-size: 20px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px 16px;
  padding: 0;
  list-style: none;
}

.tile {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.tile img {
  width: 100%;
  aspect-ratio: 1;
  margin-bottom: 6px;
  object-fit: cover;
  background: #1a1b1f;
  transition:
    filter 0.3s,
    transform 0.3s;
}

.tile.locked img {
  filter: grayscale(1) brightness(0.55);
}

.tile:hover img {
  filter: none;
  transform: translateY(-2px);
}

.tile-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  word-break: keep-all;
}

.tile-client {
  font-size: 12px;
  color: var(--muted);
}

/* 피날레 */
.finale {
  display: grid;
  justify-items: center;
  gap: 16px;
  width: 100%;
  max-width: 600px;
  padding: 48px 32px;
  text-align: center;
}

.finale h2 {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 900;
  word-break: keep-all;
}

.figures {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: 100%;
  margin: 8px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.figures div {
  display: grid;
  gap: 6px;
  padding: 18px 4px;
}

.figures div + div {
  border-left: 1px solid var(--line);
}

.figures dt {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.figures dd {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.mail {
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
}

.finale-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

@media (pointer: coarse) {
  kbd,
  .arrow {
    display: none;
  }
  .stage {
    padding: 8px 16px;
  }
}

@media (max-width: 520px) {
  .figures {
    grid-template-columns: repeat(2, 1fr);
  }
  .figures div:nth-child(3) {
    border-left: 0;
  }
  .figures div:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 860px) {
  .overlay {
    padding: 0;
  }
  .case,
  .collection {
    max-height: none;
    border: 0;
  }
  .case {
    display: block;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .stage {
    flex: none;
    aspect-ratio: 1918 / 1310;
    padding: 0 16px;
  }
  .info {
    overflow: visible;
    padding: 8px 20px 40px;
    border-left: 0;
  }
  .collection-head,
  .year-group {
    padding-left: 20px;
    padding-right: 20px;
  }
  .year-group {
    grid-template-columns: 1fr;
  }
  .tiles {
    grid-template-columns: repeat(2, 1fr);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
}

@keyframes bump {
  40% {
    transform: scale(1.5);
  }
}

@keyframes pulse {
  to {
    opacity: 0.4;
  }
}

@keyframes callout {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }
  15%,
  70% {
    opacity: 1;
    transform: none;
  }
  100% {
    opacity: 0;
    transform: translateY(-12px);
  }
}

@keyframes toast {
  from {
    opacity: 0;
    transform: translateX(-24px);
  }
}

@keyframes loading {
  0%,
  100% {
    transform: scaleX(0.2);
  }
  50% {
    transform: scaleX(1);
  }
}
