/* 한 줄 미니멀 톤 (docs/spec/screens.md 시각 톤). 웹폰트 없이 시스템 글꼴만 쓴다(N1). */
:root {
  --bg: #fafaf7;
  --fg: #111;
  --muted: #66665f;
  --line: #e4e4de;
  --soft: #f0efe9;
  --accent: #e64500;
  --stamp: #e64500;
  --error: #c0262d;
  --up: #d0103a;
  --down: #1d4ed8;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e0d;
    --fg: #f3f3ef;
    --muted: #a3a39c;
    --line: #2e2e2a;
    --soft: #1a1a18;
    --accent: #ff6a2b;
    --stamp: #ff6a2b;
    --error: #ff8a80;
    --up: #ff6b8a;
    --down: #7aa2ff;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family:
    system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  word-break: keep-all;
}

main,
.notice {
  max-width: 26rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 1rem;
}

h1:focus {
  outline: none;
}

.service-name {
  font-weight: 900;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  margin: 0;
}

.service-name i {
  font-style: normal;
  color: var(--accent);
}

.sentence {
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.38;
  letter-spacing: -0.03em;
  margin: 1.75rem 0 1.25rem;
}

.slot {
  color: var(--accent);
  border-bottom: 3px solid var(--accent);
  padding: 0 2px;
}

.slot.empty {
  color: var(--muted);
  border-bottom-color: var(--line);
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.25rem 0;
}

.error {
  color: var(--error);
  font-size: 0.9rem;
  margin: 0.25rem 0;
}

.field {
  margin: 1rem 0;
  border: 0;
  padding: 0;
}

label,
legend {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="date"] {
  width: 100%;
  min-height: 48px;
  padding: 0.6rem 0.9rem;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: 14px;
}

input:focus-visible {
  border-color: var(--accent);
}

button {
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 1rem;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}

button.primary {
  width: 100%;
  min-height: 56px;
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: 16px;
}

button.secondary {
  background: var(--soft);
  border-color: var(--soft);
}

button[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.chips {
  border: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 0;
}

.chips .chip {
  flex: 1 1 auto;
  font-size: 0.9rem;
}

.chip[aria-pressed="true"] {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
  font-weight: 700;
}

[role="listbox"] {
  margin: 0.4rem 0;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  max-height: 18rem;
  overflow-y: auto;
}

[role="option"] {
  min-height: 44px;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}

[role="option"]:last-child {
  border-bottom: 0;
}

[role="option"][aria-selected="true"] {
  background: var(--soft);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.option-meta {
  color: var(--muted);
  margin-left: 0.5rem;
}

.picked,
.receipt {
  background: var(--soft);
  border-radius: 14px;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
}

.receipt dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 1rem;
  margin: 0.25rem 0;
}

.receipt dt {
  color: var(--muted);
}

.receipt dd {
  margin: 0;
  text-align: right;
}

.buy-action {
  margin-top: 1.25rem;
}

.guide {
  font-size: 0.9rem;
  margin: 0 0 0.6rem;
}

.zero {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.4rem 0 0;
}

.stamp {
  display: inline-block;
  border: 3px solid var(--stamp);
  color: var(--stamp);
  border-radius: 8px;
  padding: 0.2rem 0.75rem;
  font-weight: 800;
  transform: rotate(-6deg);
  margin: 0.5rem 0;
}

.stamp.just {
  animation: stamp 0.4s ease-out;
}

@keyframes stamp {
  from {
    transform: scale(2) rotate(-6deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(-6deg);
    opacity: 1;
  }
}

.actions {
  display: grid;
  gap: 0.5rem;
  margin: 1rem 0;
}

.copy-box input {
  margin-top: 0.5rem;
}

.notice {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.7;
  padding-top: 1.5rem;
}

.notice p {
  margin: 0;
}

/* 그때 샀다면 칸 */
.whatif-box {
  border-top: 1.5px solid var(--line);
  margin-top: 2rem;
  padding-top: 1.25rem;
}

.whatif-box h2 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}

.whatif-box .chip {
  background: var(--soft);
  border-color: var(--soft);
}

.whatif-box .chip[aria-disabled="true"] {
  text-decoration: line-through;
  opacity: 0.55;
}

.whatif-date {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.whatif-date input {
  flex: 1;
}

.whatif-date button {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
  min-height: 48px;
}

/* 결과 화면 */
.result-q {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.4;
  margin: 0.5rem 0 1rem;
}

.reveal-stage {
  position: relative;
  min-height: 260px;
  border-radius: 18px;
  overflow: hidden;
  background: var(--soft);
  perspective: 900px;
  display: grid;
}

.result-card {
  display: grid;
  place-content: center;
  text-align: center;
  padding: 1.25rem 1rem;
  z-index: 1;
}

.result-card:focus {
  outline: none;
}

.result-card p {
  margin: 0;
}

.result-card .stamp {
  font-size: 1.6rem;
  justify-self: center;
}

.big-pct {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-top: 0.25rem;
}

.result-card.up .big-pct {
  color: var(--up);
}

.result-card.down .big-pct {
  color: var(--down);
}

.money {
  font-weight: 700;
  margin-top: 0.25rem;
}

.tier-label {
  display: none;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.skip {
  display: block;
  margin: 0.5rem auto 0;
  border: 0;
  text-decoration: underline;
  color: var(--muted);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
}

/* 1. 긁는 복권 */
.reveal-scratch canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  transition: opacity 0.3s;
}

.reveal-scratch canvas.fade {
  opacity: 0;
}

.pill {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  background: var(--fg);
  color: var(--bg);
  border: 0;
  border-radius: 999px;
  font-size: 0.9rem;
}

/* 2. 표지 뜯기 */
.cover {
  width: 100%;
  border: 0;
  border-radius: 0;
  display: grid;
  place-content: center;
  gap: 0.4rem;
  color: #fff;
  background: repeating-linear-gradient(135deg, #222 0 14px, #2c2c2c 14px 28px);
  transform-origin: 50% 0;
  transition:
    transform 0.65s cubic-bezier(0.5, -0.3, 0.4, 1),
    opacity 0.65s;
}

.cover b {
  font-size: 1.9rem;
  font-weight: 900;
}

.cover span {
  opacity: 0.85;
}

.cover::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 16px;
  background:
    radial-gradient(circle at 8px 16px, var(--soft) 7px, transparent 7.5px) 0 0 / 16px 16px repeat-x;
}

.cover.off {
  transform: rotateX(105deg);
  opacity: 0;
  pointer-events: none;
}

/* 3. 캡슐 뽑기 */
.machine {
  background: radial-gradient(circle at 50% 30%, #3d2f7a, #1a1238);
  transition: opacity 0.3s;
}

.dome {
  position: absolute;
  left: 50%;
  top: 14px;
  width: 170px;
  height: 140px;
  margin-left: -85px;
  overflow: hidden;
  border: 4px solid #ffffff55;
  border-radius: 85px 85px 16px 16px;
  background: radial-gradient(circle at 35% 30%, #ffffff55, #ffffff11 60%);
}

.dome i {
  position: absolute;
  width: 38px;
  height: 38px;
  border-radius: 50%;
}

.base {
  position: absolute;
  left: 50%;
  top: 148px;
  width: 190px;
  height: 62px;
  margin-left: -95px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  box-shadow: 0 6px 0 #8f2a00;
}

.lever {
  position: relative;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.35s;
}

.lever::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 6px;
  bottom: 6px;
  width: 10px;
  margin-left: -5px;
  border-radius: 4px;
  background: #ffc93c;
}

.machine.turn .lever {
  transform: rotate(270deg);
}

.capsule {
  position: absolute;
  left: 50%;
  top: 218px;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-40px);
  transition:
    transform 0.4s cubic-bezier(0.3, 1.6, 0.6, 1),
    opacity 0.15s;
}

.capsule::before,
.capsule::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 22px;
  transition: transform 0.3s;
}

.capsule::before {
  top: 0;
  border-radius: 22px 22px 0 0;
  background: var(--cap, #ffc93c);
}

.capsule::after {
  bottom: 0;
  border-radius: 0 0 22px 22px;
  background: #fff;
}

.tier-normal .capsule {
  --cap: #9fb4cc;
}

.tier-miss .capsule {
  --cap: #5b6068;
}

.machine.drop .capsule {
  opacity: 1;
  transform: translateY(0);
}

.machine.open .capsule::before {
  transform: translate(-16px, -8px) rotate(-35deg);
}

.machine.open .capsule::after {
  transform: translate(16px, 2px) rotate(25deg);
}

.machine-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  margin: 0;
  text-align: center;
  color: #fff;
  font-size: 0.8rem;
  opacity: 0.8;
}

.reveal-gacha .tier-label {
  display: block;
}

.reveal-gacha.revealed .result-card {
  animation: pop 0.45s ease-out;
}

.reveal-gacha.revealed.tier-ssr {
  background: radial-gradient(circle at 50% 50%, #fff1a8, #ffb81c 60%, #c97800);
}

.reveal-gacha.revealed.tier-ssr .result-card {
  color: #3b2200;
}

.reveal-gacha.revealed.tier-ssr .tier-label,
.reveal-gacha.revealed.tier-ssr .hint {
  color: #6b3f00;
}

.reveal-gacha.revealed.tier-ssr .stamp {
  color: #7a1d00;
  border-color: #7a1d00;
}

.reveal-gacha.revealed.tier-ssr .big-pct {
  color: #8a0022;
}

.reveal-gacha.revealed.tier-miss {
  background: repeating-linear-gradient(45deg, #9aa0a8 0 10px, #8b9199 10px 20px);
}

.reveal-gacha.revealed.tier-miss .result-card,
.reveal-gacha.revealed.tier-miss .result-card * {
  color: #15171a;
  border-color: #15171a;
}

.kkwang {
  position: absolute;
  top: 18px;
  right: -34px;
  z-index: 2;
  padding: 4px 44px;
  transform: rotate(30deg);
  background: #15171a;
  color: #fff;
  font-weight: 900;
  font-size: 1.2rem;
}

/* 4. 그림일기(/r/) */
.diary-page {
  padding: 1rem 1.1rem 3.5rem;
  background:
    repeating-linear-gradient(transparent 0 33px, #b9d3f0 33px 34px) 0 92px / 100% 100% no-repeat,
    #fffdf6;
  color: #1c2a5a;
  transform-origin: 50% 0;
  transition:
    transform 0.65s cubic-bezier(0.5, -0.3, 0.4, 1),
    opacity 0.65s;
}

.diary-page p {
  margin: 0;
}

.diary-date {
  font-weight: 700;
  border-bottom: 2px solid #1c2a5a;
  padding-bottom: 0.35rem;
}

.diary-title {
  padding: 0.35rem 0;
  border-bottom: 2px solid #1c2a5a;
  margin-bottom: 0.2rem !important;
}

.diary-line {
  line-height: 34px;
}

.diary-page.off {
  transform: rotateX(105deg);
  opacity: 0;
  pointer-events: none;
}

.reveal-diary.revealed {
  background: #fffdf6;
  color: #1c2a5a;
}

.reveal-diary.revealed .stamp {
  border-radius: 50%;
  border-width: 4px;
  padding: 1.1rem 0.9rem;
  color: #d92d20;
  border-color: #d92d20;
  font-size: 1.2rem;
  animation: stamp 0.4s ease-out;
}

.reveal-diary.revealed .hint {
  color: #4a5578;
}

/* 5. 타임머신(/w/) */
.machine-tm {
  padding: 0.9rem 1rem 3.5rem;
  background: #d9d2bf;
  color: #3a3326;
}

.tm-label {
  margin: 0.2rem 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.tm-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 0.4rem;
}

.led {
  display: block;
  padding: 0.3rem 0;
  border-radius: 8px;
  background: #111;
  text-align: center;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 1.7rem;
  font-weight: 700;
}

.tm-row.from .led {
  color: #ff5a4e;
  text-shadow: 0 0 8px #ff5a4e88;
}

.tm-row.now .led {
  color: #5cf08a;
  text-shadow: 0 0 8px #5cf08a88;
}

.machine-tm.warp .tm-row.now .led {
  animation: flicker 0.14s steps(2) infinite;
}

.machine-tm.arrive {
  animation: flash 0.35s ease-out forwards;
}

.reveal-timemachine.revealed {
  background: #0b1a0f;
  color: #5cf08a;
}

.reveal-timemachine.revealed .result-card {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
}

.reveal-timemachine.revealed .stamp {
  color: #5cf08a;
  border-color: #5cf08a;
  transform: none;
}

.reveal-timemachine.revealed .big-pct {
  color: #ffc23d;
}

.reveal-timemachine.revealed .hint {
  color: #8fd8a6;
}

@keyframes flicker {
  50% {
    opacity: 0.55;
  }
}

@keyframes flash {
  to {
    background: #fff;
    opacity: 0;
  }
}

@keyframes pop {
  from {
    transform: scale(0.4) rotateY(90deg);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stamp.just,
  .reveal-diary.revealed .stamp,
  .reveal-gacha.revealed .result-card {
    animation: none;
  }
}
