/* apps/randnum/style.css — 랜덤 숫자 뽑기: 연보라 모눈종이 + 진남보라 잉크 + 플립 보드(스플릿 플랩) 숫자 릴 + 라임·바이올렛 포인트.
 * 둥근 흰 카드 + 부드러운 보라 그림자(dice·lotto 의 어긋난 굵은 그림자와 다르게). 모바일 한 줄(--app-width 480px).
 * 숫자는 언제나 JetBrains Mono(고정폭), 제목·버튼은 언어 파일 fonts → :root 변수(--font-display 등, 생성기가 이 파일 뒤에 둔다).
 * 공통 타이틀 바(G.topBar)·끝 화면(data-mg-end)은 --mg-* 변수로만 색을 맞춘다.
 */
:root {
  --paper: #f3f1ff;
  --grid: rgba(76, 58, 200, 0.07);
  --ink: #14112b;
  --ink-dim: rgba(20, 17, 43, 0.78);
  --ink-faint: rgba(20, 17, 43, 0.6);
  --violet: #6a48f5;
  --violet-2: #4b2fd1;
  --violet-soft: #e9e4ff;
  --lime: #c6ff3d;
  --coral: #ff5d73;
  --board: #17132f;
  --board-2: #241e4a;
  --line: rgba(20, 17, 43, 0.14);
  --card-shadow: 0 1px 0 rgba(20, 17, 43, 0.06), 0 10px 30px -12px rgba(76, 58, 200, 0.35);
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --font-display: 'Unbounded', var(--font-sans);
  --display-weight: 800;
  --wb: normal;
  --hyphens: manual;

  --mg-top-fg: var(--ink);
  --mg-top-badge-bg: var(--violet);
  --mg-top-badge-fg: #fff;
  --lang-bg: #fff;
  --lang-fg: var(--ink);
  --lang-border: var(--line);
  --mg-star-on: #f5a623;
  --mg-star-off: rgba(20, 17, 43, 0.16);
  --mg-heart-bg: #fff;
  --mg-heart-border: var(--coral);
  --mg-heart-fg: var(--coral);
  --mg-heart-on: var(--coral);
  --mg-share-bg: #fff;
  --mg-share-border: var(--line);
  --mg-x: var(--ink);
  --mg-tiktok: var(--ink);
  --mg-faq-bg: #fff;
  --mg-faq-border: var(--line);
  --mg-end-retry-bg: var(--violet);
  --mg-end-retry-fg: #fff;
  --toast-bg: var(--ink);
  --toast-fg: #fff;
}

html { background: var(--paper); }
body.rn-body {
  min-height: 100vh;
  color: var(--ink);
  line-height: 1.6;
  word-break: var(--wb);
  hyphens: var(--hyphens);
  -webkit-hyphens: var(--hyphens);
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
}
[hidden] { display: none !important; }

.rn-h1, .rn-kicker, .rn-h1-main, .rn-h1-main em, .rn-btn, .rn-h2, .rn-badge, .rn-doc h1, .rn-more-btn {
  font-family: var(--font-display);
}
.rn-num, .rn-input, .rn-chip, .rn-step, .rn-h-range, .rn-h-vals, .rn-tags li { font-family: var(--mono); }

.rn-shell { max-width: var(--app-width); margin: 0 auto; padding: 8px 16px 0; }
.rn-screen { padding-top: 12px; }

/* ---------------- 제목 ---------------- */
.rn-h1 { margin: 6px 0 8px; text-align: center; line-height: 1.18; font-weight: var(--display-weight); }
.rn-kicker {
  display: inline-block; margin-bottom: 12px; padding: 4px 12px; border-radius: 999px;
  background: var(--ink); color: var(--lime); font-size: 13px; letter-spacing: 0.02em; line-height: 1.4;
}
.rn-h1-main { display: block; font-size: 28px; color: var(--ink); overflow-wrap: break-word; letter-spacing: -0.01em; }
.rn-h1-main em {
  font-style: normal; color: #fff; background: var(--violet); padding: 0 8px; border-radius: 10px;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
.rn-hook { margin: 0 auto 16px; max-width: 390px; text-align: center; font-size: 15px; color: var(--ink-dim); }

/* ---------------- 입력 카드 ---------------- */
.rn-card { padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--card-shadow); }
.rn-label { display: block; margin: 0 0 6px; font-size: 13.5px; font-weight: 800; line-height: 1.35; color: var(--ink-dim); }
.rn-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.rn-chip {
  min-width: 0; min-height: 40px; padding: 4px 2px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--violet-soft); color: var(--violet-2); font-size: 14.5px; font-weight: 800; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.rn-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--lime); }
.rn-range { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 8px; }
.rn-range-arrow { padding-bottom: 12px; font-size: 18px; font-weight: 800; color: var(--violet); }
.rn-field { display: block; min-width: 0; }
.rn-input {
  display: block; width: 100%; min-width: 0; min-height: 50px; padding: 8px 12px;
  border: 2px solid var(--line); border-radius: 14px; background: #fbfaff; color: var(--ink);
  font-size: 20px; font-weight: 800; line-height: 1.2; -moz-appearance: textfield; appearance: textfield;
}
.rn-input::-webkit-outer-spin-button, .rn-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.rn-input:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 4px rgba(106, 72, 245, 0.18); }
.rn-input[aria-invalid="true"] { border-color: var(--coral); box-shadow: 0 0 0 4px rgba(255, 93, 115, 0.18); }
.rn-input-text { font-family: var(--font-sans); font-size: 16px; font-weight: 600; }
.rn-input::placeholder { color: rgba(20, 17, 43, 0.38); font-weight: 500; }

.rn-count { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.rn-count .rn-label { margin: 0; }
.rn-stepper { display: flex; align-items: stretch; flex: 0 0 auto; }
.rn-step {
  width: 44px; min-height: 48px; border: 2px solid var(--line); background: var(--violet-soft); color: var(--violet-2);
  font-size: 22px; font-weight: 800; cursor: pointer; line-height: 1;
}
.rn-step:first-child { border-radius: 14px 0 0 14px; border-right: 0; }
.rn-step:last-child { border-radius: 0 14px 14px 0; border-left: 0; }
.rn-input-count { width: 84px; min-height: 48px; border-radius: 0; text-align: center; padding: 6px 4px; }

.rn-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.rn-switch {
  position: relative; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 10px;
  border: 1.5px solid var(--line); border-radius: 14px; background: #fbfaff; cursor: pointer;
  font-size: 14px; font-weight: 700; line-height: 1.3;
}
.rn-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rn-switch-ui {
  position: relative; flex: 0 0 auto; width: 38px; height: 22px; border-radius: 999px; background: rgba(20, 17, 43, 0.18); transition: background 0.15s;
}
.rn-switch-ui::after {
  content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.15s;
}
.rn-switch input:checked + .rn-switch-ui { background: var(--violet); }
.rn-switch input:checked + .rn-switch-ui::after { transform: translateX(16px); }
.rn-switch input:focus-visible + .rn-switch-ui { outline: 3px solid var(--lime); outline-offset: 2px; }

.rn-more-btn {
  display: flex; align-items: center; gap: 6px; margin: 14px 0 0; padding: 4px 0; border: 0; background: none;
  color: var(--violet-2); font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.rn-more-btn::after { content: '▾'; transition: transform 0.15s; }
.rn-more-btn[aria-expanded="true"]::after { transform: rotate(180deg); }
.rn-more { margin-top: 8px; padding-top: 12px; border-top: 1.5px dashed var(--line); }
.rn-more .rn-field + .rn-hint + .rn-field { margin-top: 12px; }
.rn-hint { margin: 6px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--ink-faint); }

.rn-error {
  margin: 12px 0 0; padding: 10px 14px; border-radius: 14px; background: #fff0f2; border: 1.5px solid var(--coral);
  color: #b3203a; font-size: 14px; font-weight: 700; line-height: 1.45;
}

/* ---------------- 버튼 ---------------- */
.rn-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: 58px; margin: 16px 0 0; padding: 12px 18px; border: 0; border-radius: 18px;
  font-size: 18px; font-weight: var(--display-weight); line-height: 1.25; cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.2s;
}
.rn-btn-primary {
  background: linear-gradient(135deg, var(--violet), var(--violet-2)); color: #fff;
  box-shadow: 0 6px 0 var(--ink), 0 14px 24px -10px rgba(76, 58, 200, 0.6);
}
.rn-btn-primary:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.rn-btn:disabled { opacity: 0.6; cursor: default; }
.rn-btn:focus-visible, .rn-chip:focus-visible, .rn-step:focus-visible, .rn-more-btn:focus-visible, .rn-mini:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; }
.rn-fair { margin: 12px 0 0; text-align: center; font-size: 12.5px; font-weight: 700; color: var(--ink-faint); }
.rn-btn-ghost {
  min-height: 48px; margin: 0; padding: 8px 10px; font-size: 14px; background: var(--violet-soft); color: var(--violet-2);
  border: 1.5px solid rgba(106, 72, 245, 0.25); border-radius: 14px;
}
.rn-mini {
  padding: 4px 10px; border: 1.5px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink-dim);
  font-size: 12.5px; font-weight: 700; cursor: pointer;
}

/* ---------------- 결과: 플립 보드 ---------------- */
.rn-result { margin-top: 22px; }
.rn-result-card { padding: 18px 16px 16px; background: var(--board); border: 0; color: #fff; container-type: inline-size; }
.rn-result-card.is-shared { box-shadow: 0 0 0 3px var(--lime), var(--card-shadow); }
.rn-badge {
  display: inline-block; margin: 0 0 8px; padding: 3px 12px; border-radius: 999px; background: var(--lime); color: var(--ink);
  font-size: 13px; line-height: 1.5;
}
.rn-result-card .rn-h2 { color: #fff; }
.rn-h2 { margin: 0; font-size: 18px; font-weight: var(--display-weight); line-height: 1.3; }
.rn-res-label { margin: 4px 0 0; font-size: 16px; font-weight: 800; color: var(--lime); overflow-wrap: anywhere; }
.rn-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.rn-tags li { padding: 2px 9px; border-radius: 8px; background: var(--board-2); color: rgba(255, 255, 255, 0.82); font-size: 12px; font-weight: 700; line-height: 1.6; }

.rn-reels {
  --len: 3; --fs: 34px;
  display: grid; gap: 8px; margin: 16px 0 4px;
  grid-template-columns: repeat(auto-fill, minmax(calc(var(--len) * 0.64em + 1.3em), 1fr));
  font-size: min(var(--fs), calc(100cqw / (var(--len) * 0.64 + 1.3)));
}
.rn-reels.is-one { --fs: 92px; grid-template-columns: 1fr; }
.rn-reels.is-few { --fs: 40px; }
.rn-reels.is-mid { --fs: 26px; gap: 6px; }
.rn-reels.is-many { --fs: 17px; gap: 5px; max-height: 360px; overflow-y: auto; padding-right: 2px; }
.rn-tile {
  position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; padding: 0.28em 0.2em;
  border-radius: 0.24em; background: linear-gradient(180deg, #2c2559 0 49.5%, #221c48 50.5% 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 0.08em 0 rgba(0, 0, 0, 0.45); overflow: hidden;
}
.rn-tile::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(0, 0, 0, 0.55); }
.rn-num { position: relative; color: var(--lime); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -0.02em; }
.rn-tile.is-rolling .rn-num { color: rgba(198, 255, 61, 0.55); filter: blur(0.6px); animation: rn-roll 0.11s linear infinite; }
@keyframes rn-roll { 0% { transform: translateY(-18%); } 100% { transform: translateY(18%); } }
.rn-tile.is-landed { animation: rn-land 0.38s cubic-bezier(0.2, 1.5, 0.4, 1); }
.rn-tile.is-landed .rn-num { color: var(--lime); }
@keyframes rn-land { 0% { transform: scale(1.12); background: #3a2f80; } 100% { transform: scale(1); } }
.rn-reels.is-one .rn-tile { padding: 0.22em 0.2em; }

.rn-shared-note { margin: 10px 0 0; font-size: 13px; line-height: 1.5; color: rgba(255, 255, 255, 0.78); }
.rn-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.rn-result-card .rn-btn-ghost { background: var(--board-2); color: #fff; border-color: rgba(255, 255, 255, 0.16); }

/* ---------------- 최근 기록 ---------------- */
.rn-history-card { margin-top: 14px; }
.rn-history-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rn-history-note { margin: 2px 0 8px; font-size: 12.5px; color: var(--ink-faint); }
.rn-history-list { margin: 0; padding: 0; list-style: none; }
.rn-history-list li {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 8px; padding: 8px 2px; border-top: 1.5px dashed var(--line);
  font-size: 14px; line-height: 1.4;
}
.rn-history-list li:first-child { border-top: 0; }
.rn-h-range { padding: 1px 8px; border-radius: 8px; background: var(--ink); color: var(--lime); font-size: 12px; font-weight: 800; }
.rn-h-label { font-weight: 800; color: var(--violet-2); overflow-wrap: anywhere; }
.rn-h-time { margin-left: auto; font-size: 12px; color: var(--ink-faint); }
.rn-h-vals { flex: 1 0 100%; color: var(--ink-dim); font-size: 13.5px; font-weight: 700; overflow-wrap: anywhere; }

/* ---------------- 개인정보처리방침 ---------------- */
.rn-doc { padding: 28px 0 36px; line-height: 1.8; font-size: 14.5px; color: var(--ink-dim); }
.rn-doc h1 { font-size: 24px; font-weight: var(--display-weight); color: var(--ink); margin-bottom: 20px; }
.rn-doc h2 { font-size: 16px; font-weight: 800; color: var(--ink); margin: 26px 0 8px; }
.rn-doc a { color: var(--violet-2); text-decoration: underline; }
.site-footer { margin-top: 28px; }

/* 언어별 */
html:lang(th) .rn-h1-main, html:lang(th) .rn-h2, html:lang(th) .rn-label, html:lang(th) .rn-btn, html:lang(th) .rn-switch { line-height: 1.5; letter-spacing: 0; }
html:lang(vi) .rn-h1-main { line-height: 1.32; }
html:lang(ja) .rn-h1-main, html:lang(ja) .rn-hook { word-break: auto-phrase; }
html:lang(zh) .rn-h1, html:lang(zh) .rn-btn, html:lang(zh) .rn-h2, html:lang(th) .rn-h1, html:lang(th) .rn-btn, html:lang(th) .rn-h2,
html:lang(vi) .rn-h1, html:lang(vi) .rn-btn, html:lang(vi) .rn-h2 { font-family: var(--font-display); }

@media (max-width: 374px) {
  .rn-h1-main { font-size: 24px; }
  .rn-card { padding: 14px 12px; }
  .rn-chip { font-size: 13px; }
  .rn-input { font-size: 18px; padding: 8px 10px; }
  .rn-range .rn-input { font-size: 15px; padding: 8px 8px; letter-spacing: -0.03em; }
  .rn-range { gap: 6px; }
  .rn-switch { font-size: 13px; padding: 6px 8px; }
  .rn-input-count { width: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  .rn-tile.is-rolling .rn-num, .rn-tile.is-landed { animation: none; }
  .rn-btn, .rn-chip, .rn-switch-ui, .rn-switch-ui::after { transition: none; }
}
