:root {
  --bg: #0a0b09;
  --panel: rgba(18, 20, 15, 0.9);
  --field: #080907;
  --line: #2b2f24;
  --line-strong: #474d3b;
  --text: #e6e3d5;
  --muted: #9b9d8c;
  --blood: #a3231b;
  --blood-hi: #c8352a;
  --toxic: #9fcc4f;
  --warn: #e3a33c;
  --error: #ff7b6f;
  --radius: 6px;
  --font: "Noto Sans KR", system-ui, -apple-system, "Malgun Gothic", sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html,
body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, #2c1310 0%, transparent 60%),
    radial-gradient(ellipse 80% 50% at 50% 115%, #151b0e 0%, transparent 65%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

/* 필름 노이즈 + 비네팅 */
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 180px 40px rgba(0, 0, 0, 0.85);
}

.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 48px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ---------------------------------------------------------------- 타이틀 */

.brand { text-align: center; }

.brand-title { margin: 0; }

/* 로고는 아래 메뉴(440px)보다 넓게, 화면 가운데에 */
.brand-logo {
  position: relative;
  left: 50%;
  display: block;
  width: min(620px, calc(100vw - 32px));
  height: auto;
  transform: translateX(-50%);
}

.brand-sub {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.menu {
  display: grid;
  gap: 10px;
  margin-top: 44px;
}

.menu-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.2em;
}

.menu-divider::before,
.menu-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* 두 버튼을 한 줄에 반씩 */
.menu-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ---------------------------------------------------------------- 버튼 */

.btn {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: 700 1rem/1.2 var(--font);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, transform 0.05s;
}

.btn:hover { border-color: var(--muted); background: rgba(255, 255, 255, 0.06); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  border-color: var(--blood-hi);
  background: var(--blood);
  color: #fff;
}

.btn-primary:hover { border-color: #e2493d; background: var(--blood-hi); }

.btn-ghost { background: transparent; border-style: dashed; }

.btn-small { padding: 10px 12px; font-size: 0.9rem; }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

[aria-busy="true"] .btn-primary { cursor: progress; }

.btn:focus-visible,
.link-btn:focus-visible,
input:focus-visible {
  outline: 2px solid var(--toxic);
  outline-offset: 2px;
}

.link-btn {
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font: 500 0.9rem var(--font);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link-btn:hover { color: var(--text); }

.back { display: block; margin: 20px auto 0; }

/* ---------------------------------------------------------------- 패널/폼 */

.panel {
  padding: 28px 22px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--blood);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.panel-warn { border-top-color: var(--warn); }

.panel-kicker {
  margin: 0 0 6px;
  color: var(--toxic);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1.3;
}

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

.hint strong { color: var(--text); }

form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 500;
}

.field > span {
  display: flex;
  justify-content: space-between;
}

.counter { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }

.field-hint {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}

input:not([type="checkbox"]) {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--text);
  font: 400 1rem var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:not([type="checkbox"]):focus {
  outline: none;
  border-color: var(--toxic);
  box-shadow: 0 0 0 3px rgba(159, 204, 79, 0.18);
}

input::placeholder { color: #5a5d50; }

.input-code {
  font-family: var(--font-mono) !important;
  font-size: 1.2rem !important;
  letter-spacing: 0.16em;
  text-align: center;
}

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

.form-error:empty { display: none; }

.notice {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--warn);
  background: rgba(227, 163, 60, 0.08);
  font-size: 0.88rem;
}

.panel-links {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
}

.captcha:empty { display: none; }
.captcha { min-height: 65px; }

.row {
  display: flex;
  gap: 8px;
}

.row > .btn { flex: 1; }

/* ---------------------------------------------------------------- 코드 발급 */

.code-display {
  display: block;
  margin: 18px 0 12px;
  padding: 18px 8px;
  border: 1px dashed var(--warn);
  border-radius: var(--radius);
  background: #070806;
  color: var(--warn);
  font: 700 clamp(1.4rem, 7vw, 1.9rem) var(--font-mono);
  letter-spacing: 0.12em;
  text-align: center;
  white-space: nowrap;
  user-select: all;
}

.warn-list {
  margin: 18px 0;
  padding-left: 1.15em;
  color: var(--muted);
  font-size: 0.88rem;
}

.warn-list li + li { margin-top: 4px; }
.warn-list strong { color: var(--text); }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 14px;
  font-size: 0.93rem;
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--blood-hi);
}

/* ---------------------------------------------------------------- 로비 */

.info {
  display: grid;
  gap: 6px;
  margin: 16px 0 0;
  font-size: 0.92rem;
}

.info div { display: flex; gap: 12px; }
.info dt { width: 5.5em; color: var(--muted); }
.info dd { margin: 0; }

.placeholder {
  margin: 22px 0;
  padding: 32px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.placeholder p { margin: 0 0 4px; color: var(--text); }

/* ---------------------------------------------------------------- 배경 설명 */

/* 가운데 좁은 칸(.shell)을 벗어나 화면 전체를 쓴다 */
.intro {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* 상단 이미지 자리: 화면 높이의 75% */
.intro-image {
  position: relative;
  flex: none;
  height: 75vh;
  height: 75dvh;
  overflow: hidden;
  background: #050605;
}

.intro-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 이미지 아래쪽을 글 영역 배경색으로 자연스럽게 이어준다 */
.intro-image::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 30%;
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none;
}

.intro-image-placeholder {
  position: absolute;
  inset: 16px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  text-align: center;
}

/* 하단 글 영역 + 오른쪽 아래 다음 버튼 */
.intro-bottom {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px max(16px, 5vw) 16px;
}

.intro-text {
  flex: 1;
  min-height: 0;
  max-width: 62ch;
  margin: 0;
  overflow-y: auto;
  font-size: clamp(0.95rem, 2.2vw, 1.12rem);
  line-height: 1.75;
  white-space: pre-line;
}

.intro-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.intro-progress {
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.intro-next {
  width: auto;
  min-width: 120px;
}

.intro-enter { animation: intro-fade 0.6s ease both; }

@keyframes intro-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------------------------------------------------------------- 기타 */

.screen-loading { align-items: center; text-align: center; }

.loading-text {
  color: var(--muted);
  letter-spacing: 0.1em;
}

.dots::after {
  content: "";
  animation: dots 1.4s steps(4) infinite;
}

@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #1a1c16;
  font-size: 0.9rem;
  transform: translateX(-50%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

@media (prefers-reduced-motion: reduce) {
  .dots::after,
  .intro-enter { animation: none; }
  .btn { transition: none; }
}
