/*
  Shared look for the friend games (사주 궁합, 밸런스 게임).
  One paper table, one ink, one accent per game (--accent). The dashboard is a
  ledger: a sheet of paper whose rows are the friends who answered.
*/
:root {
  --ground: #E5DFD5;
  --paper: #F6F3ED;
  --paper-2: #ECE7DE;
  --ink: #1F1B17;
  --ink-soft: #5B5249;
  --accent: #A3302A;
  --accent-ink: #FFFFFF;
  --gold: #D9C6A3;

  --font-display: "Gowun Batang", "Noto Serif KR", serif;
  --font-text: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", sans-serif;
  --step-small: 0.875rem;
  --step-body: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  --step-lead: clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem);
  --step-head: clamp(2rem, 1.3rem + 3.2vw, 4rem);
  --step-title: clamp(2.75rem, 1.8rem + 3.6vw, 5rem);
  --margin: clamp(16px, 4vw, 48px);
  --gap: clamp(96px, 12vw, 176px);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--ground); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--font-text); font-size: var(--step-body); line-height: 1.55; word-break: keep-all; overflow-wrap: anywhere; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; margin: 0; letter-spacing: -0.02em; line-height: 1.12; text-wrap: balance; }
p { margin: 0; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 var(--margin); }
.num { font-variant-numeric: tabular-nums; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 20px; padding-bottom: 20px; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-display); font-weight: 700; min-height: 44px; }
.wordmark svg { width: 28px; height: 28px; flex: none; }
.bar nav a { text-decoration: none; font-size: var(--step-small); font-weight: 600; padding: 12px 0 12px 10px; color: var(--ink-soft); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; padding: 0 28px; border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; cursor: pointer; transition: transform 160ms var(--ease-out), filter 160ms; }
.btn:hover { filter: brightness(0.92); }
.btn:active { transform: scale(0.97); }
.btn.quiet { background: var(--paper-2); color: var(--ink); }
.btn[disabled] { opacity: 0.5; cursor: progress; }

/* start */
.start { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr); gap: clamp(32px, 5vw, 72px); align-items: start; padding-top: clamp(16px, 4vw, 48px); }
.start h1 { font-size: var(--step-head); }
.start .lede { margin-top: 18px; max-width: 34ch; font-size: var(--step-lead); line-height: 1.45; }
.steps { margin: 28px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 32px 1fr; gap: 12px; align-items: baseline; counter-increment: s; }
.steps li::before { content: counter(s); font-family: var(--font-display); font-weight: 700; color: var(--accent); font-size: var(--step-lead); }
.form { background: var(--paper); padding: clamp(20px, 3vw, 36px); display: grid; gap: 18px; }
.field { display: grid; gap: 8px; }
.field > label, .legend { font-weight: 600; font-size: var(--step-small); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--paper-2); padding: 6px; border-radius: 999px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--ink-soft); }
.seg input:checked + label { background: var(--ink); color: var(--paper); }
.seg input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }
.input { width: 100%; min-height: 52px; padding: 0 16px; background: var(--paper-2); border: 2px solid transparent; border-radius: 12px; font-size: var(--step-body); }
.input:focus { border-color: var(--ink); outline: none; }
.input:disabled { opacity: 0.45; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-size: var(--step-small); font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.hint { font-size: var(--step-small); color: var(--ink-soft); }
.error { font-size: var(--step-small); color: var(--accent); font-weight: 600; }
.form .btn { width: 100%; }
.saved { margin-top: 28px; display: grid; gap: 8px; }
.saved a { display: flex; justify-content: space-between; align-items: center; min-height: 52px; padding: 0 18px; background: var(--paper-2); border-radius: 12px; text-decoration: none; font-weight: 600; }
.invited { padding: 16px 18px; background: var(--paper-2); border-radius: 14px; font-weight: 600; }
.invited b { color: var(--accent); }

/* dashboard: the ledger */
.dash { padding-top: clamp(16px, 4vw, 40px); }
.dash h1 { font-size: var(--step-head); }
.dash .sub { margin-top: 12px; color: var(--ink-soft); max-width: 46ch; }
.dash-grid { margin-top: 32px; display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 20px; align-items: start; }
.panel { background: var(--paper); padding: clamp(20px, 3vw, 32px); }
.panel h2 { font-size: var(--step-lead); }
.panel > p { margin-top: 8px; color: var(--ink-soft); }
.invite-box { background: var(--ink); color: var(--paper); }
.invite-box > p { color: #CFC6B8; }
.invite-box .btns { margin-top: 20px; display: grid; gap: 10px; }
.keep { margin-top: 16px; padding-top: 16px; font-size: var(--step-small); color: #CFC6B8; }
.keep button { all: unset; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; display: inline-flex; align-items: center; color: var(--paper); font-weight: 600; }
.stat { display: flex; gap: 24px; margin-top: 20px; }
.stat b { display: block; font-family: var(--font-display); font-size: var(--step-head); line-height: 1; }
.stat span { font-size: var(--step-small); color: var(--ink-soft); }
.ledger-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.refresh { all: unset; cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; font-weight: 600; font-size: var(--step-small); color: var(--ink-soft); }
.danger { all: unset; cursor: pointer; margin-top: 28px; min-height: 44px; display: inline-flex; align-items: center; font-size: var(--step-small); font-weight: 600; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; }

.rank { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 8px; }
.rank .row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-areas: "no who pts" "no why why" "no del del"; column-gap: 12px; align-items: center; padding: 14px 16px; background: var(--paper-2); border-radius: 14px; }
.rank .no { grid-area: no; align-self: start; font-family: var(--font-display); font-weight: 700; font-size: var(--step-lead); text-align: center; }
.rank .top .no { color: var(--accent); }
.rank .who { grid-area: who; display: grid; }
.rank .who b { font-weight: 700; }
.rank .who em { font-style: normal; font-size: var(--step-small); color: var(--accent); }
.rank .who span { font-size: var(--step-small); color: var(--ink-soft); }
.rank .pts { grid-area: pts; font-family: var(--font-display); font-weight: 700; font-size: var(--step-lead); }
.rank .pts small { font-size: var(--step-small); color: var(--ink-soft); margin-left: 2px; }
.rank .me { background: var(--gold); }
.rank .why { grid-area: why; margin-top: 6px; font-size: var(--step-small); }
.rank .why summary { cursor: pointer; min-height: 32px; display: inline-flex; align-items: center; color: var(--ink-soft); font-weight: 600; }
.rank .del { grid-area: del; justify-self: start; all: unset; cursor: pointer; font-size: var(--step-small); color: var(--ink-soft); min-height: 32px; display: inline-flex; align-items: center; text-decoration: underline; text-underline-offset: 3px; }
.empty { margin-top: 20px; padding: 28px 20px; background: var(--paper-2); border-radius: 14px; color: var(--ink-soft); text-align: center; }
.reasons { display: grid; gap: 10px; margin-top: 8px; }
.reasons h4 { margin: 4px 0 0; font-size: var(--step-small); }
.reasons ul { margin: 0; padding-left: 1.1em; display: grid; gap: 6px; }
.reasons li b { display: block; }

/* waiting */
.loading { display: grid; justify-items: center; text-align: center; padding-top: clamp(16px, 5vh, 64px); padding-bottom: 48px; }
.loading h2 { font-size: var(--step-head); }
.track { display: block; width: min(560px, 100%); height: 10px; margin-top: 24px; background: var(--paper-2); border-radius: 999px; overflow: hidden; }
.track i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); }
.track i.run { transform: scaleX(1); transition: transform 5s linear; }
.go { margin-top: 24px; width: min(560px, 100%); }
.loading-ad { width: 100%; max-width: 680px; margin-top: 28px; text-align: left; }
.loading-ad .tag { display: block; margin-bottom: 8px; font-size: var(--step-small); color: var(--ink-soft); }
.loading-ad iframe { display: block; width: 100%; border: 0; border-radius: 16px; background: var(--paper); }
.ad-note { margin-top: 10px; font-size: var(--step-small); color: var(--ink-soft); }

/* friend's result */
.result { padding-top: clamp(16px, 4vw, 40px); }
.verdict { text-align: center; }
.verdict .seal { width: clamp(140px, 16vw, 180px); aspect-ratio: 1; margin: 0 auto 20px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); border-radius: 50%; }
.verdict .seal b { display: block; font-family: var(--font-display); font-size: var(--step-head); line-height: 1; }
.verdict .seal span { font-size: var(--step-small); font-weight: 600; }
.verdict h1 { font-size: var(--step-head); }
.verdict p { margin: 12px auto 0; max-width: 42ch; color: var(--ink-soft); }
.two { margin-top: 40px; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.two .panel ul { margin: 12px 0 0; padding-left: 1.1em; display: grid; gap: 12px; }
.two .panel li b { display: block; }
.board { margin-top: 40px; }
.cta { margin-top: 40px; background: var(--ink); color: var(--paper); padding: clamp(24px, 4vw, 48px); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 32px; align-items: end; }
.cta h2 { font-size: var(--step-head); max-width: 14ch; }
.cta p { margin-top: 12px; color: #CFC6B8; }

/* reading + footer */
section.block { padding-top: var(--gap); }
.faq h2 { font-size: var(--step-head); }
.faq details { margin-top: 14px; background: var(--paper); border-radius: 14px; padding: 4px 20px; max-width: 760px; }
.faq summary { cursor: pointer; min-height: 52px; display: flex; align-items: center; font-weight: 600; }
.faq details p { padding-bottom: 18px; color: var(--ink-soft); }
.footer { margin-top: var(--gap); padding: 0 var(--margin) 48px; }
.back-card { background: var(--paper); max-width: 1080px; margin: 0 auto; padding: 40px clamp(24px, 5vw, 64px) 28px; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; font-size: var(--step-small); color: var(--ink-soft); }
.back-card address { font-style: normal; display: grid; gap: 8px; }
.back-card .imprint { grid-column: 1 / -1; text-align: center; }

/* ads */
.gad { display: block; max-width: 970px; margin: 12px auto; padding: 0 var(--margin); }
.gad:empty { display: none; }
.gad ins { max-height: 120px; overflow: hidden; }
.gad ins[data-ad-status="unfilled"] { display: none !important; }
body.is-loading .gad { display: none; }
.cdock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--ground); padding: 8px var(--margin) calc(8px + env(safe-area-inset-bottom)); }
.cdock .in { position: relative; max-width: 680px; margin: 0 auto; }
.cdock .tag { display: block; margin-bottom: 4px; padding-right: 36px; font-size: 13px; line-height: 1.4; color: var(--ink-soft); }
.cdock iframe { display: block; width: 100%; border: 0; border-radius: 12px; background: var(--paper); }
.cdock .x { position: absolute; top: -12px; right: -8px; width: 44px; height: 44px; border: 0; background: none; color: var(--ink-soft); font-size: 18px; line-height: 1; cursor: pointer; }
body.has-cdock { padding-bottom: calc(var(--cdock-h, 0px) + 16px); }
body.is-loading .cdock { display: none; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 30; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 12px 20px; border-radius: 999px; font-size: var(--step-small); font-weight: 600; }

@media (max-width: 860px) {
  .start, .dash-grid, .two, .cta, .back-card { grid-template-columns: minmax(0, 1fr); }
  .row2 { grid-template-columns: minmax(0, 1fr); }
  .cta .btn { width: 100%; }
  .rank .row { padding: 12px; grid-template-columns: 36px minmax(0, 1fr) auto; }
  /* Once friends have answered, the ranking is what the owner comes back for. */
  .dash-grid.has-entries .invite-box { order: 2; }
  .dash-grid { margin-top: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}
