@font-face {
  font-family: "Nanum Barun Pen";
  src: url("https://hangeul.pstatic.net/hangeul_static/webfont/NanumBarunpen/NanumBarunpenR.woff") format("woff");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Nanum Barun Pen";
  src: url("https://hangeul.pstatic.net/hangeul_static/webfont/NanumBarunpen/NanumBarunpenB.woff") format("woff");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: "Nanum Barun Pen", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  color: #38241f;
  background: #faf0e5;
  --accent: #a03429;
  --line: #e4c4b3;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; }
.bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 17px max(20px, calc((100vw - 1040px) / 2));
  border-bottom: 1px solid var(--line); font-size: .8rem;
  background: #fff6ec;
}
.bar a { text-decoration: none; }
.bar a[href="#guide"] {
  padding: 7px 12px; border-radius: 999px;
  background: #f5d9c8; color: #72382b; font-weight: 700;
}
.bar a[href="#guide"]:hover { background: #efc9b4; }
.brand {
  display: block; width: clamp(138px, 30vw, 188px); aspect-ratio: 6.3;
  background: url("cards/49.jpg") 50% 48.5% / 270% auto no-repeat;
  mix-blend-mode: multiply;
}
main { width: min(100% - 36px, 1040px); margin-inline: auto; }
.play {
  display: grid; place-items: center; text-align: center;
  min-height: 350px; margin-block: 28px 52px;
  border: 1px solid #e1ab91; border-radius: 6px;
  background: linear-gradient(125deg, #fff5e6, #f9d8c2);
}
.intro { width: 100%; min-width: 0; padding: clamp(24px, 6vw, 72px); }
h1 {
  margin: 0;
  font-weight: 800; font-size: clamp(3.7rem, 9.5vw, 7rem);
  line-height: 1.04; letter-spacing: -.09em; white-space: nowrap;
}
h1 span { color: var(--accent); margin-inline-start: .08em; }
.intro-copy { margin: 20px 0 25px; color: #69574d; font-size: .95rem; line-height: 1.65; word-break: keep-all; }
#start span { margin-inline-start: 15px; }
#start-status { color: var(--accent); font-size: .84rem; }
body:has(#viewer[open]) { overflow: hidden; }
#viewer {
  position: fixed; inset: 0;
  width: 100%; max-width: none;
  height: 100dvh; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: #2c1d1a; color: #fff5e8;
}
.viewer-layout {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%; gap: 8px;
  padding: max(8px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));
}
.rotate-hint { display: none; margin: 0; color: #f9d9bf; font-size: .85rem; }
.table { grid-row: 2; display: grid; place-items: center; min-height: 0; min-width: 0; }
.table img { display: block; grid-area: 1 / 1; width: min(100cqw, 141.33cqh); height: auto; }
@media (orientation: portrait) and (pointer: coarse) {
  .rotate-hint { display: block; }
}
.table { position: relative; overflow: hidden; container-type: size; }
.table [hidden] { display: none; }
#turning-page {
  z-index: 1;
  transform-origin: left center;
  backface-visibility: hidden;
  pointer-events: none;
}
.controls { grid-row: 3; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 10px; }
#status:empty, #start-status:empty { display: none; }
#status { margin: 0 3px; color: #f9d9bf; font-size: .8rem; }
button {
  border: 1px solid transparent; border-radius: 999px;
  padding: 12px 22px; min-height: 46px;
  font: inherit; font-weight: 750; cursor: pointer;
}
#start { width: min(100%, 288px); min-height: 64px; font-size: 1.15rem; }
#start, #draw { background: var(--accent); color: white; }
#start:hover, #draw:hover { background: #87311f; }
#start:disabled, #draw:disabled { opacity: .65; cursor: wait; }
#reset { background: transparent; border-color: #c8a995; color: #fff5e8; }
:focus-visible { outline: 3px solid #6e402c; outline-offset: 4px; }
#viewer :focus-visible { outline-color: #ffd5a8; }
#guide { padding: 0 0 46px; }
h2 { margin: 0 0 14px; letter-spacing: -.04em; }
#guide > h2 {
  display: flex; align-items: center; gap: 12px;
  color: #74362b; font-size: 1.1rem;
}
#guide > h2::before {
  content: ""; width: 8px; height: 8px; border-radius: 2px;
  background: #a03429; transform: rotate(45deg);
}
#guide > h2::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.guide-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 32px; }
.guide-panel {
  padding: 0 18px 15px; border: 1px solid #e6c9ac; border-radius: 6px;
  background: #f4e3d0;
}
.guide-panel h3 {
  margin: 0 -18px 11px; padding: 9px 18px;
  border-radius: 5px 5px 0 0;
  background: #66513b; color: #fff6ec; font-size: .92rem;
}
.guide-intro { margin-bottom: 18px; }
.guide-panel ol, .guide-panel ul, .guide-intro p {
  margin: 0; padding-inline-start: 1.35em; color: #58473f;
  font-size: .84rem; line-height: 1.7; word-break: keep-all;
}
.guide-intro p { padding-inline-start: 0; }
.guide-panel li + li { margin-top: 4px; }
.guide-panel li::marker { color: var(--accent); }
.site-footer {
  padding: 20px 20px 22px; border-top: 1px solid var(--line);
  background: #f3dfd3; color: #634e45; font-size: .625rem; line-height: 1.55;
}
.footer-terms, .footer-credits { max-width: 650px; margin-inline: auto; }
.footer-terms h2 { margin: 0 0 5px; color: #312722; font-size: .6875rem; letter-spacing: 0; }
.footer-terms p { margin: 0 0 5px; }
.footer-credits {
  margin-block: 12px 4px; padding-top: 9px; border-top: 1px solid var(--line);
  text-align: center; font-size: .625rem;
}
.footer-credits div { display: flex; justify-content: center; flex-wrap: wrap; gap: 0 .55em; }
.footer-credits dt { font-weight: 700; color: #312722; }
.footer-credits dd { margin: 0; overflow-wrap: anywhere; }
.footer-logo { display: block; width: 76px; height: auto; margin: 0 auto; }
@media (max-width: 650px) {
  .play { min-height: 290px; margin-block: 18px 32px; }
  .intro { padding: 26px 24px 24px; }
  .intro-copy { margin: 13px 0 17px; }
  .guide-grid { grid-template-columns: 1fr; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .viewer-layout {
    grid-template-rows: minmax(0, 1fr);
    grid-template-columns: minmax(0, 1fr) min(calc(100% - 100px), 141.33dvh) minmax(88px, 1fr);
    gap: 6px;
    padding-block: 4px;
  }
  .rotate-hint { display: none; }
  .table { grid-area: 1 / 2; }
  .controls {
    grid-area: 1 / 3;
    flex-direction: column;
    flex-wrap: nowrap;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .controls button { width: min(100%, 112px); min-height: 44px; padding: 6px; font-size: .85rem; }
  #status { text-align: center; }
}
