:root {
  --paper: #FBF8F2;
  --paper-2: #F3EDE2;
  --ink: #1E1C1A;
  --muted: #6B655D;
  --line: rgba(30, 28, 26, 0.16);
  --seal: #C23B22;
  --seal-bg: #F6E3DD;
  --danger: #A32D2D;
  --surface: #FFFFFF;
  --sans: "Noto Sans KR", "Apple SD Gothic Neo", system-ui, sans-serif;
  --serif: "Noto Serif KR", Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1B1A18;
    --paper-2: #24221F;
    --ink: #F1EDE5;
    --muted: #B0A99E;
    --line: rgba(241, 237, 229, 0.16);
    --seal: #E0644B;
    --seal-bg: #3A1D16;
    --danger: #F09595;
    --surface: #24221F;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); }
body { line-height: 1.6; -webkit-font-smoothing: antialiased; }
main { max-width: 480px; margin: 0 auto; padding: 20px 16px 32px; min-height: 100dvh; display: flex; flex-direction: column; }

.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.brand-wrap { display: flex; align-items: center; gap: 12px; }
.seal { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 6px; background: var(--seal); color: #FBF8F2; font-family: var(--serif); font-size: 22px; transform: rotate(-5deg); box-shadow: inset 0 0 0 2px var(--seal), inset 0 0 0 4px #FBF8F2; }
.brand { font-family: var(--serif); font-weight: 500; font-size: 24px; margin: 0; letter-spacing: -0.3px; line-height: 1.2; }
.tagline { margin: 0; color: var(--muted); font-size: 13px; }

.screen { display: flex; flex-direction: column; gap: 16px; }
.screen[hidden] { display: none; }
.intro { font-family: var(--serif); font-size: 19px; line-height: 1.55; margin: 0; }
.modes { display: grid; gap: 10px; }
.mode { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); cursor: pointer; }
.mode input { grid-row: span 2; accent-color: var(--seal); width: 18px; height: 18px; }
.mode:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.mode-title { font-weight: 500; }
.mode-sub { color: var(--muted); font-size: 14px; }
.count-pick { display: grid; gap: 8px; font-size: 15px; }
.count-pick[hidden] { display: none; }
.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span { display: block; text-align: center; padding: 12px 0; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); font-weight: 500; }
.chip input:checked + span { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip input:focus-visible + span { outline: 2px solid var(--seal); outline-offset: 2px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row[hidden] { display: none; }
select, #nickname { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; }
.checks { display: grid; gap: 8px; font-size: 15px; }
.checks label, .check-line { display: flex; gap: 10px; align-items: flex-start; }
.checks input, .check-line input { margin-top: 5px; accent-color: var(--seal); }
.photo-opt { border: 1px dashed var(--line); border-radius: 4px; padding: 12px 14px; }
.photo-opt .note { margin: 4px 0 0 26px; }
.field { display: grid; gap: 6px; font-size: 15px; }
.error { color: var(--danger); font-size: 13px; margin: 0; min-height: 1em; }

button { font: inherit; font-weight: 500; color: var(--ink); background: transparent; border: 1px solid var(--ink); border-radius: 4px; padding: 13px 16px; cursor: pointer; }
button.primary { background: var(--ink); color: var(--paper); }
button.ghost { border-color: transparent; }
button.small { padding: 6px 10px; font-size: 14px; }
button:active { transform: scale(0.98); }
.center-btn { align-self: center; }
.note { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.center { text-align: center; }
.eyebrow { color: var(--muted); margin: 0; letter-spacing: 0.04em; }

.viewfinder { position: relative; aspect-ratio: 3 / 4; border-radius: 4px; overflow: hidden; background: #000; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cue { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 16px 26px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.72) 35%); color: #fff; font-size: 24px; font-weight: 500; text-align: center; pointer-events: none; }
.cue[hidden] { display: none; }
.cue-eye { display: none; width: 64px; height: 30px; border: 3px solid #fff; border-radius: 50% / 50%; position: relative; }
.cue-eye::after { content: ''; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px; border-radius: 50%; background: #fff; }
.cue.blink .cue-eye { display: block; animation: cue-blink 1.6s ease-in-out infinite; }
.cue.blink { font-size: 28px; }
@keyframes cue-blink { 0%, 40%, 100% { transform: scaleY(1); } 50%, 60% { transform: scaleY(0.08); } }
@media (prefers-reduced-motion: reduce) { .cue.blink .cue-eye { animation: none; } }
.oval { position: absolute; inset: 10% 18% 14%; border: 2px dashed rgba(255, 255, 255, 0.85); border-radius: 50%; pointer-events: none; }
.status { text-align: center; font-weight: 500; margin: 0; min-height: 1.6em; }
.progress { height: 4px; background: var(--line); overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--seal); transition: width 0.15s; }

/* reveal */
.reveal { position: relative; aspect-ratio: 3 / 4; border-radius: 4px; overflow: hidden; background: #111; }
.reveal canvas { width: 100%; height: 100%; display: block; }
.reveal-title { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 18px 22px; text-align: center; color: #FBF8F2; background: linear-gradient(transparent, rgba(20, 18, 16, 0.85) 40%); opacity: 0; transform: translateY(12px); transition: opacity 0.5s, transform 0.5s; }
.reveal-title.show { opacity: 1; transform: none; }
.reveal-title .t-main { font-family: var(--serif); font-size: 32px; line-height: 1.2; display: block; }
.reveal-title .t-sub { font-size: 14px; color: #F0B8A8; display: block; margin-top: 4px; }
.reveal-title .stamp { display: inline-grid; place-items: center; width: 54px; height: 54px; border-radius: 6px; background: var(--seal); color: #FBF8F2; font-family: var(--serif); font-size: 30px; margin-bottom: 10px; transform: rotate(-6deg) scale(2.2); opacity: 0; }
.reveal-title.show .stamp { animation: stamp 0.45s 0.15s cubic-bezier(0.3, 1.6, 0.5, 1) forwards; }
@keyframes stamp { to { transform: rotate(-6deg) scale(1); opacity: 1; } }

/* footer links + legal pages */
.legal-links { margin-top: 6px; font-size: 13px; }
.legal-links a, .legal a { color: inherit; }
.legal { gap: 0; }
.legal h1 { font-family: var(--serif); font-weight: 500; font-size: 28px; margin: 18px 0 4px; }
.legal h2 { font-size: 17px; font-weight: 500; margin: 22px 0 6px; }
.legal p, .legal li { line-height: 1.7; font-size: 15px; }
.legal ul { padding-left: 20px; }
.legal hr { border: 0; border-top: 1px solid var(--line); margin: 36px 0 12px; }

/* detailed reading */
.detail { border-top: 1px solid var(--line); padding-top: 18px; }
.detail > h2 { font-family: var(--serif); font-weight: 500; font-size: 22px; margin: 0 0 12px; }
.detail .tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; }
.detail .tabs[hidden] { display: none; }
.detail .tabs button { padding: 8px 14px; font-size: 14px; border-color: var(--line); white-space: nowrap; }
.detail .tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.detail .d-title { font-family: var(--serif); font-size: 20px; margin: 0 0 4px; }
.detail .d-mod { color: var(--muted); font-size: 13px; margin: 0 0 6px; }
.detail h3 { font-size: 15px; font-weight: 500; margin: 18px 0 6px; color: var(--seal); }
.detail p, .detail li { font-size: 15px; line-height: 1.7; margin: 0; }
.detail .d-line { font-family: var(--serif); font-size: 17px; }
.detail ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

/* flip card */
.flip { perspective: 1600px; cursor: pointer; outline: none; }
.flip-inner { position: relative; aspect-ratio: 4 / 5; transition: transform 0.7s cubic-bezier(0.4, 0.2, 0.2, 1); transform-style: preserve-3d; }
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 4px; overflow: hidden; box-shadow: 0 10px 30px rgba(30, 28, 26, 0.18); }
.face img { width: 100%; height: 100%; display: block; }
.back { transform: rotateY(180deg); background: #FBF8F2; color: #1E1C1A; padding: 22px 20px; overflow-y: auto; border: 1px solid #1E1C1A; outline: 1px solid #1E1C1A; outline-offset: -6px; }
.back h2 { font-family: var(--serif); font-weight: 500; font-size: 20px; margin: 0 0 2px; }
.back .ko-sub { color: #C23B22; font-size: 13px; margin: 0 0 12px; }
.back h3 { font-size: 15px; font-weight: 500; margin: 14px 0 2px; }
.back p { margin: 0; font-size: 14px; line-height: 1.6; }
.back .basis { color: #6B655D; font-size: 12px; margin-top: 2px; }
.back .combo { margin-top: 14px; padding: 10px 12px; background: #F6E3DD; border-radius: 4px; }
.hint { text-align: center; color: var(--muted); font-size: 13px; margin: -4px 0 0; }

.actions { display: grid; gap: 10px; }
.report { font-size: 13px; color: var(--muted); }
.report summary { cursor: pointer; }
.foot { margin-top: auto; padding-top: 28px; color: var(--muted); font-size: 12px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .flip-inner, .reveal-title { transition: none; }
  .reveal-title.show .stamp { animation: none; transform: rotate(-6deg); opacity: 1; }
}

.debug { font: 12px/1.4 ui-monospace, monospace; white-space: pre-wrap; opacity: .8; margin: 24px 0; }
