
:root {
  --c-primary: #c2410c;
  --c-accent: #3f6212;
  --c-bg: #f7f1e8;
  --c-fg: #1c1917;
  --card-w: 1080;
  --card-h: 1920;
  --paper: #fffdf8;
  --paper-deep: #efe6d8;
  --ink-soft: #44403c;
  --muted: #57534e;
  --line: #d6c7b2;
  --panel: #f7f1e8;
  --panel-ink: #1c1917;
  --warn: #9f1239;
  --ok: #3f6212;
  --chrome-h: 48px;
  --dock-h: 72px;
  --shadow: 0 10px 28px rgba(28, 25, 23, .14);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c-bg: #1c1917;
    --c-fg: #f7f1e8;
    --paper: #292524;
    --paper-deep: #1c1917;
    --ink-soft: #e7e5e4;
    --muted: #a8a29e;
    --line: #44403c;
    --shadow: 0 10px 28px rgba(0, 0, 0, .45);
  }
}
html[data-theme="dark"] {
  --c-bg: #1c1917;
  --c-fg: #f7f1e8;
  --paper: #292524;
  --paper-deep: #1c1917;
  --ink-soft: #e7e5e4;
  --muted: #a8a29e;
  --line: #44403c;
  --shadow: 0 10px 28px rgba(0, 0, 0, .45);
}
html[data-theme="light"] {
  --c-bg: #f7f1e8;
  --c-fg: #1c1917;
  --paper: #fffdf8;
  --paper-deep: #efe6d8;
  --ink-soft: #44403c;
  --muted: #57534e;
  --line: #d6c7b2;
  --shadow: 0 10px 28px rgba(28, 25, 23, .14);
}
html[data-ratio="9-16"] { --card-w: 1080; --card-h: 1920; }
html[data-ratio="1-1"] { --card-w: 1080; --card-h: 1080; }
html[data-ratio="4-5"] { --card-w: 1080; --card-h: 1350; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", serif, sans-serif;
  background:
    radial-gradient(ellipse at 8% 0%, rgba(194, 65, 12, .07), transparent 42%),
    radial-gradient(ellipse at 94% 10%, rgba(63, 98, 18, .06), transparent 40%),
    var(--c-bg);
  color: var(--c-fg);
  min-height: 100dvh;
  overflow: hidden;
}
button {
  font: inherit;
  color: inherit;
  background: var(--paper);
  border: 1px solid var(--line);
  cursor: pointer;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--c-primary);
  outline-offset: 2px;
}

.chrome {
  height: var(--chrome-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--c-bg) 88%, var(--paper));
}
.chrome h1 {
  margin: 0;
  font-family: "Noto Serif KR", "Noto Sans KR", serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.02em;
  white-space: nowrap;
}
.tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  background: var(--paper);
  overflow: hidden;
}
.seg button {
  border: 0;
  border-right: 1px solid var(--line);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--ink-soft);
  background: transparent;
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] {
  background: var(--c-primary);
  color: #fff7ed;
}
.counter {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 700;
  min-width: 3.2em;
  text-align: right;
  color: var(--c-primary);
}

.stage {
  height: calc(100dvh - var(--chrome-h) - var(--dock-h));
}
.deck {
  display: flex;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.deck::-webkit-scrollbar { display: none; }
.card {
  flex: 0 0 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}
.frame {
  position: relative;
  aspect-ratio: var(--card-w) / var(--card-h);
  height: min(92vh, calc(100dvh - var(--chrome-h) - var(--dock-h) - 16px));
  width: auto;
  max-width: calc(100vw - 16px);
  background: #efe6d8;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.photo {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(135deg, #f3eadc 0 10px, #efe2ce 10px 20px);
}
.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 72%;
  display: block;
}
.photo.fit-contain img { object-fit: contain; object-position: center 80%; background: #efe6d8; }
.photo.fit-top img { object-position: center 58%; }
.photo img.is-missing { opacity: 0; position: absolute; width: 0; height: 0; }
.photo.is-placeholder::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 40%, #f7f1e8, #e8d9c4);
  pointer-events: none;
}

.safe {
  position: absolute;
  inset: 0;
  transform: none;
  width: 100%;
  aspect-ratio: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 6px;
  padding: 5% 6% 18%;
  z-index: 2;
  pointer-events: none;
}
.safe > * { pointer-events: auto; }
.safe::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 32%;
  background: linear-gradient(180deg, rgba(247,241,232,.97) 0%, rgba(247,241,232,.78) 70%, rgba(247,241,232,0) 100%);
  z-index: -1;
  pointer-events: none;
}
.kicker {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--c-primary);
  background: var(--panel);
  border: 1px solid #e7d4c0;
  padding: 3px 8px;
}
.badge {
  align-self: flex-start;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .02em;
  color: #7c2d12;
  background: #ffedd5;
  border: 1px solid #fdba74;
  padding: 3px 8px;
}
h2 {
  margin: 0;
  font-family: "Noto Serif KR", "Noto Sans KR", serif;
  font-size: clamp(22px, 5.6vw, 36px);
  line-height: 1.18;
  letter-spacing: -.03em;
  color: var(--panel-ink);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  padding: 6px 10px;
  width: fit-content;
  max-width: 100%;
}
.sub {
  margin: 0;
  font-size: clamp(15px, 3.4vw, 20px);
  font-weight: 700;
  color: var(--panel-ink);
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  padding: 4px 10px;
  width: fit-content;
  max-width: 100%;
}
.panel {
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  color: var(--panel-ink);
  padding: 7px 10px;
  border: 1px solid #e7d4c0;
}
.panel ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
}
.check li::before { content: "☐ "; color: var(--c-accent); }
.pitfall, .ok {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 10px;
  width: fit-content;
  max-width: 100%;
}
.pitfall { color: #fff; background: var(--warn); }
.ok { color: #fff7ed; background: var(--c-accent); }
.bridge {
  position: absolute;
  left: 6%;
  bottom: 5%;
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--panel-ink);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  padding: 4px 10px;
  width: fit-content;
  max-width: 88%;
}
.bridge::before { content: "→ "; color: var(--c-primary); font-weight: 900; }

.flow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.flow b {
  display: block;
  text-align: center;
  font-size: 13px;
  font-weight: 900;
  padding: 10px 4px;
  background: var(--panel);
  border: 1px dashed var(--c-primary);
  color: var(--panel-ink);
}
.flow b small {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--c-primary);
  letter-spacing: .06em;
}

.trap {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-weight: 700;
  background: var(--panel);
  color: var(--panel-ink);
}
.trap th {
  text-align: left;
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--c-primary);
  padding: 6px 8px;
  border-bottom: 1px solid #e7d4c0;
}
.trap td {
  padding: 7px 8px;
  border-bottom: 1px solid #efe2ce;
  vertical-align: top;
}
.trap td:last-child { color: var(--c-accent); }

.thumbs {
  display: flex;
  gap: 8px;
}
.thumbs img, .thumb {
  width: 72px;
  height: 48px;
  object-fit: cover;
  border: 1px solid #e7d4c0;
  background: #efe6d8;
  display: block;
}
.side {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 28%;
  max-width: 140px;
  border: 2px solid #fffdf8;
  box-shadow: 0 4px 12px rgba(28,25,23,.2);
  z-index: 3;
  background: #efe6d8;
}
.side img {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}
.cta {
  display: inline-block;
  text-decoration: none;
  font-weight: 900;
  font-size: 16px;
  color: #fff7ed;
  background: var(--c-primary);
  padding: 10px 18px;
  width: fit-content;
  border: 1px solid #9a3412;
}

.dock {
  height: var(--dock-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 10px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--c-bg) 90%, var(--paper));
}
.nav-btn {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
}
.nav-btn.prev { justify-self: start; }
.nav-btn.next { justify-self: end; }
.dots {
  display: flex;
  gap: 6px;
  align-items: center;
}
.dots button {
  width: 8px;
  height: 8px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--c-primary);
  background: transparent;
}
.dots button[aria-current="true"] {
  background: var(--c-primary);
  width: 18px;
  border-radius: 99px;
}
.credit {
  grid-column: 1 / -1;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}
.credit a { color: var(--c-primary); }

@media (max-width: 640px) {
  :root { --chrome-h: 78px; --dock-h: 86px; }
  .chrome { flex-wrap: wrap; height: auto; min-height: var(--chrome-h); padding: 8px 10px; }
  .chrome h1 { font-size: 15px; }
  h2 { font-size: clamp(24px, 8vw, 34px); }
}
@media (prefers-reduced-motion: reduce) {
  .deck { scroll-behavior: auto; }
}
