/* 하루들 엽서 화면 스타일: 연민트 배경 · 검정 굵은 테두리 · 보라 형광펜 · 검정 알약 버튼 */
:root {
  --bg: #a8f3d8;
  --mint: #2ac1bc;
  --mint-frame: #8eecc8;
  --mint-line: #c4f1de;
  --mint-wash: #f1fcf7;
  --ink: #111111;
  --ink-soft: #2e2e33;
  --ink-muted: #6b6b73;
  --ink-faint: #a3a3ab;
  --purple: #d3b6f6;
  --purple-strong: #8b6fe8;
  --purple-wash: #f5effd;
  --yellow: #ffd66b;
  --red: #ef5a5a;
  --red-wash: #fff0f0;
  --red-pastel: #ffc9c4;
  --white: #ffffff;

  --border: 3px solid var(--ink);
  --font: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', sans-serif;
  --font-hand: 'Gaegu', 'Pretendard', cursive;
}

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

html,
body {
  margin: 0;
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}

button,
input {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible {
  outline: 3px solid var(--purple-strong);
  outline-offset: 3px;
}

main {
  outline: none;
  padding-bottom: calc(48px + env(safe-area-inset-bottom));
}

/* ---------- 헤더 ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 48px 8px;
}

.logo {
  display: inline-flex;
  align-items: baseline;
  font-family: var(--font-hand);
  font-size: 38px;
  line-height: 1;
  letter-spacing: -0.5px;
}

.logo-d {
  color: var(--purple-strong);
}

.logo-tag {
  margin-left: 8px;
  padding: 3px 8px 2px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--white);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  transform: translateY(-6px) rotate(-4deg);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.pill-badge {
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--white);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.header-link {
  border: 0;
  background: none;
  padding: 6px 2px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.header-link:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ---------- 공통 타이포 ---------- */
.title {
  margin: 0;
  font-size: clamp(34px, 4.2vw, 58px);
  font-weight: 800;
  line-height: 1.22;
  letter-spacing: -0.03em;
}

.title mark,
.title-sm mark,
.score mark {
  padding: 0 2px;
  background: linear-gradient(transparent 52%, var(--purple) 52%, var(--purple) 94%, transparent 94%);
  color: inherit;
}

.title-sm {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.title-xs {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
}

.lead {
  margin: 16px 0 32px;
  font-size: 18px;
  color: var(--ink-soft);
}

.back-link {
  align-self: flex-start;
  display: inline-block;
  margin-bottom: 20px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
}

.back-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--white);
  font-size: 14px;
  font-weight: 700;
}

/* ---------- 2단 레이아웃 (홈 · 문제 등록) ---------- */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 72px;
  max-width: 1200px;
  min-height: calc(100dvh - 120px);
  margin: 0 auto;
  padding: 24px 48px 40px;
}

/* 홈: 왼쪽 그림 없이 가운데 한 줄 */
.split-single {
  grid-template-columns: minmax(0, 560px);
  justify-content: center;
}

.side {
  display: flex;
  flex-direction: column;
  max-width: 560px;
}

/* ---------- 액자 ---------- */
.frame {
  justify-self: end;
  width: 100%;
  max-width: 540px;
  padding: 16px;
  background: var(--white);
  border: var(--border);
  border-radius: 30px;
}

.frame-inner {
  padding: 18px;
  background: var(--mint-frame);
  border: 2px solid var(--ink);
  border-radius: 6px;
}

.frame-photo {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  background: var(--white);
  border: var(--border);
  border-radius: 12px;
  overflow: hidden;
}

button.frame-photo {
  cursor: zoom-in;
}

.frame-photo img {
  width: 100%;
  max-height: 66vh;
  object-fit: contain;
  background: var(--white);
}

/* ---------- 카드 ---------- */
.card {
  background: var(--white);
  border: var(--border);
  border-radius: 28px;
  padding: 28px 32px 22px;
}

.card-q {
  margin: 4px 0 0;
  font-size: 18px;
  font-weight: 700;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 0 0;
  padding-top: 12px;
  border-top: 2px dashed var(--mint-line);
  font-size: 14px;
  color: var(--ink-soft);
}

/* 홈: 장르 고르기 */
.options {
  margin-top: 14px;
}

.option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 10px;
  border-bottom: 1.5px solid var(--mint-line);
  border-radius: 14px 14px 0 0;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.option:last-child {
  border-bottom: 0;
}

.option input {
  position: absolute;
  opacity: 0;
}

.option:hover,
.option:has(input:checked) {
  background: var(--mint-wash);
}

.option:has(input:focus-visible) {
  outline: 3px solid var(--purple-strong);
  outline-offset: -3px;
}

.option.is-disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.option-emoji {
  display: grid;
  flex: none;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 2px solid var(--ink-faint);
  border-radius: 14px;
  background: var(--white);
  font-size: 24px;
  transition: all 0.15s ease;
}

.option:has(input:checked) .option-emoji {
  border-color: var(--ink);
  background: var(--bg);
  transform: rotate(-4deg);
}

.option-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.option-title {
  font-size: 19px;
  font-weight: 800;
}

.option:has(input:checked) .option-title {
  align-self: flex-start;
  background: linear-gradient(transparent 55%, var(--purple) 55%);
}

.option-desc {
  font-size: 14px;
  color: var(--ink-muted);
}

.status {
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status-empty {
  background: #f0f0f2;
  color: var(--ink-muted);
}

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 26px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    transform 0.1s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-dark {
  background: var(--ink);
  color: var(--white);
}

.btn-dark:hover:not(:disabled) {
  background: #2c2c30;
}

.btn-line {
  background: var(--white);
}

.btn-line:hover {
  background: var(--mint-wash);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-muted);
}

.btn-ghost:hover {
  color: var(--red);
}

.btn-block {
  width: 100%;
  min-height: 70px;
  margin-top: 24px;
  font-size: 20px;
}

.btn-wide {
  width: 100%;
  min-height: 62px;
  font-size: 18px;
}

.btn-sm {
  min-height: 38px;
  padding: 0 16px;
  font-size: 14px;
  border-width: 2px;
}

.arrow {
  font-size: 1.15em;
  font-weight: 800;
}

.link {
  padding: 0;
  border: 0;
  background: none;
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link:disabled {
  opacity: 0.5;
}

.footnote {
  display: block;
  margin: 20px 0 0;
  font-size: 14px;
  color: var(--ink-soft);
  text-align: center;
}

.footnote a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- 퀴즈 화면: 사진 + 입력칸만 ---------- */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 12px 16px 24px;
}

.stage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(100%, 560px);
}

.stage-tag {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
}

.progress {
  display: flex;
  gap: 6px;
}

.progress i {
  width: 12px;
  height: 12px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--white);
}

.progress i.now {
  width: 26px;
  border-radius: 999px;
  background: var(--ink);
}

.progress i.hit {
  background: var(--mint);
}

.progress i.miss {
  background: var(--red);
}

.frame-stage {
  justify-self: auto;
  width: min(100%, 560px, calc(100dvh - 330px));
  min-width: 280px;
  max-width: none;
  padding: 12px;
  border-radius: 26px;
}

.frame-stage .frame-inner {
  padding: 12px;
}

.answer-bar {
  display: flex;
  gap: 8px;
  width: min(100%, 560px);
  padding: 6px;
  background: var(--white);
  border: var(--border);
  border-radius: 999px;
}

.answer-bar:focus-within {
  box-shadow: 0 0 0 4px var(--purple);
}

.answer-bar input {
  flex: 1;
  min-width: 0;
  padding: 0 18px;
  border: 0;
  background: transparent;
  font-size: 19px;
  outline: none;
}

.answer-bar .btn {
  min-height: 52px;
  border-width: 0;
}

input::placeholder {
  color: var(--ink-faint);
}

.stage-sub {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100%, 560px);
  padding: 0 8px;
}

/* 남은 시간 */
.timer {
  width: min(100%, 560px);
  height: 14px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--white);
  overflow: hidden;
}

.timer-fill {
  display: block;
  height: 100%;
  background: var(--mint);
  transform-origin: left center;
  transition: background-color 0.2s ease;
}

.timer-fill.is-low {
  background: var(--red);
}

.timer-sec {
  flex: none;
  min-width: 44px;
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.tried {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tried li {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--white);
  font-size: 13px;
  font-weight: 600;
}

.tried li.miss {
  color: var(--ink-muted);
  text-decoration: line-through;
}

.sub-actions {
  display: flex;
  gap: 14px;
  margin-left: auto;
}

.hint {
  width: min(100%, 560px);
  margin: 0;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--purple-wash);
  font-size: 15px;
  font-weight: 600;
}

.stage .btn-wide {
  width: min(100%, 560px);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* 한 판 결과 */
.stage-summary {
  max-width: 720px;
}

.stage-summary .stage-top {
  width: 100%;
}

.score {
  margin: 8px 0 0;
  font-size: clamp(56px, 8vw, 88px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
}

.rank-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 16px 22px;
  background: var(--white);
  border: var(--border);
  border-radius: 22px;
  font-weight: 700;
}

.rank-box p {
  margin: 0;
}

.rank-box.is-done:hover {
  background: var(--mint-wash);
}

.rank-box strong {
  font-size: 26px;
  font-weight: 800;
}

.rank-box strong small {
  font-size: 15px;
  color: var(--ink-muted);
}

/* 닉네임 등록: 결과 화면에서 눈에 띄게 (보라 스티커) */
.nick-form {
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  padding: 20px 22px;
  background: var(--purple-wash);
  box-shadow: 6px 6px 0 var(--purple-strong);
  animation: rise 0.3s ease;
}

.nick-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nick-emoji {
  display: grid;
  flex: none;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: var(--yellow);
  font-size: 26px;
  transform: rotate(-6deg);
}

.nick-form label {
  font-size: 19px;
  font-weight: 800;
}

.nick-sub {
  margin: 2px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}

.nick-form .btn {
  background: var(--purple-strong);
  border-color: var(--ink);
  color: var(--white);
}

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

.nick-row .input {
  flex: 1;
  min-width: 0;
  min-height: 52px;
}

.nick-form .form-error {
  margin: 0;
}

.scene-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.scene {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.scene-photo {
  position: relative;
  display: block;
  padding: 0;
  aspect-ratio: 1;
  background: var(--white);
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  overflow: hidden;
  cursor: zoom-in;
}

.scene-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scene-mark {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  font-family: var(--font-hand);
  font-size: 28px;
  line-height: 1;
}

.scene-mark.is-hit {
  background: var(--bg);
}

.scene-mark.is-miss {
  background: var(--red-pastel);
}

.scene-answer,
.scene-mine {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  text-align: center;
  overflow-wrap: anywhere;
}

.scene-answer {
  font-size: 14px;
  font-weight: 700;
}

/* 못 맞힌 문제: 내가 낸 답 */
.scene-mine {
  margin-top: -2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.scene-mine s {
  text-decoration-color: var(--red);
  text-decoration-thickness: 2px;
}

.scene-label {
  flex: none;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--white);
  font-size: 11px;
  font-weight: 800;
}

.scene-mine .scene-label {
  background: var(--red-pastel);
  color: var(--ink);
}

.summary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: min(100%, 560px);
}

.summary-actions .btn {
  min-height: 58px;
  font-size: 17px;
}

/* ---------- 랭킹 ---------- */
.board {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 48px 0;
}

.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.board-card {
  display: flex;
  flex-direction: column;
  padding: 22px 22px 16px;
  border-radius: 24px;
}

.board-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 800;
}

.board-more {
  align-self: flex-end;
  margin-top: auto;
  padding-top: 10px;
  font-size: 14px;
  font-weight: 700;
}

.rank-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.rank-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 8px;
  border-bottom: 1.5px solid var(--mint-line);
}

.rank-list li:last-child {
  border-bottom: 0;
}

.rank-no {
  flex: none;
  width: 28px;
  font-weight: 800;
  text-align: center;
}

.rank-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-score {
  flex: none;
  font-size: 14px;
}

.rank-score b {
  font-size: 17px;
}

.rank-score small {
  margin-left: 4px;
  color: var(--ink-muted);
}

.rank-empty {
  margin: 8px 0;
  padding: 18px 0;
  font-size: 14px;
  color: var(--ink-muted);
  text-align: center;
}

.rank-card {
  padding: 16px 20px;
}

/* ---------- 일반 페이지 (랭킹 · 장면 · 관리) ---------- */
.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 48px 40px;
}

.page-wide {
  max-width: 1200px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.page-head .lead {
  margin-bottom: 0;
}

.page .lead {
  margin: 10px 0 0;
}

.filters {
  display: flex;
  gap: 8px;
  margin: 24px 0 20px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--white);
  font-size: 14px;
  font-weight: 700;
}

.filter small {
  font-size: 12px;
  color: var(--ink-muted);
}

.filter.active {
  background: var(--ink);
  color: var(--white);
}

.filter.active small {
  color: var(--bg);
}

.day-group {
  margin-bottom: 28px;
}

.day-title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 800;
}

.locked-today {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-radius: 20px;
  font-weight: 700;
}

.locked-today:hover {
  background: var(--mint-wash);
}

/* ---------- 가운데 카드 (로그인/빈 상태) ---------- */
.center-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 460px;
  margin: 48px auto 0;
  padding: 36px 32px 28px;
  text-align: center;
}

.center-card .lead {
  margin: 10px 0 24px;
  font-size: 16px;
}

.center-card .title-sm + .btn {
  margin-top: 20px;
}

.center-card .btn-block {
  margin-top: 4px;
}

.big-emoji {
  margin: 0 0 10px;
  font-size: 48px;
  line-height: 1.1;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.input {
  width: 100%;
  min-height: 58px;
  padding: 0 20px;
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  background: var(--white);
  font-size: 17px;
}

.input:focus {
  outline: none;
  box-shadow: 0 0 0 4px var(--purple);
}

.form-error {
  width: 100%;
  margin: 0 0 14px;
  padding: 10px;
  border-radius: 12px;
  background: var(--red-wash);
  color: var(--red);
  font-size: 14px;
  font-weight: 600;
}

/* ---------- 관리자 ---------- */
.settings-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto;
  align-items: center;
  gap: 24px;
  margin-top: 28px;
  padding: 22px 26px;
  border-radius: 24px;
}

.settings-head p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.settings-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-row {
  display: grid;
  grid-template-columns: 112px auto 1fr;
  align-items: center;
  gap: 12px;
}

.setting-label {
  font-weight: 700;
  white-space: nowrap;
}

.stepper {
  display: inline-flex;
  align-items: center;
  border: 2px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
}

.stepper button {
  width: 34px;
  height: 32px;
  border: 0;
  background: var(--white);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.stepper button:hover:not(:disabled) {
  background: var(--mint-wash);
}

.stepper button:disabled {
  opacity: 0.3;
  cursor: default;
}

.stepper output {
  min-width: 34px;
  font-weight: 800;
  text-align: center;
}

.setting-note {
  font-size: 13px;
  color: var(--ink-muted);
}

.settings-card + .settings-card {
  margin-top: 14px;
}

.btn-reset:not(:disabled):hover {
  border-color: var(--red);
  background: var(--red-wash);
  color: var(--red);
}

.setting-note.warn {
  color: var(--red);
  font-weight: 600;
}

.quiz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.quiz-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 14px 16px;
  border-radius: 22px;
}

.quiz-thumb {
  display: block;
  aspect-ratio: 1;
  border: 2px solid var(--ink);
  border-radius: 14px;
  overflow: hidden;
  background: var(--mint-wash);
}

.quiz-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.quiz-info {
  padding: 0 4px;
}

.quiz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tag {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 700;
}

.quiz-head time {
  font-size: 12px;
  color: var(--ink-muted);
}

.quiz-answer {
  margin: 8px 0 2px;
  font-size: 20px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.quiz-meta {
  margin: 0;
  font-size: 13px;
  color: var(--ink-muted);
  overflow-wrap: anywhere;
}

.quiz-actions {
  display: flex;
  gap: 4px;
  margin-top: 12px;
}

/* 등록 폼 */
.upload-form .side {
  width: 100%;
}

.form-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  padding: 0;
  font-size: 15px;
  font-weight: 800;
}

.field-label small {
  margin-left: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
}

.seg-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.seg {
  position: relative;
  cursor: pointer;
}

.seg input {
  position: absolute;
  opacity: 0;
}

.seg span {
  display: inline-flex;
  align-items: center;
  padding: 9px 18px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  transition: all 0.12s ease;
}

.seg:hover span {
  background: var(--mint-wash);
}

.seg input:checked + span {
  background: var(--ink);
  color: var(--white);
}

.seg input:focus-visible + span {
  outline: 3px solid var(--purple-strong);
  outline-offset: 2px;
}

.input-line {
  width: 100%;
  height: 46px;
  padding: 0;
  border: 0;
  border-bottom: 1.5px solid var(--mint-line);
  background: transparent;
  font-size: 18px;
  outline: none;
}

.input-line:focus {
  border-bottom: 2px solid var(--ink);
}

.form-card .card-foot {
  margin-top: 0;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  aspect-ratio: 1;
  padding: 24px;
  background: var(--white);
  border: 3px dashed var(--ink);
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.dropzone[hidden],
.preview[hidden] {
  display: none;
}

.dropzone:hover,
.dropzone.dragging {
  background: var(--mint-wash);
}

.dropzone-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
  border: var(--border);
  border-radius: 50%;
  background: var(--bg);
  font-size: 32px;
  font-weight: 800;
}

.dropzone-text {
  font-family: var(--font-hand);
  font-size: 26px;
}

.dropzone-sub {
  font-size: 14px;
  color: var(--ink-muted);
}

.photo-reset {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--white);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- 토스트 · 확대 보기 ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(32px + env(safe-area-inset-bottom));
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 14px 22px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--white);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 틀렸을 때: 붉은 파스텔 스티커 + 살짝 흔들기 */
#toast.is-miss {
  border: var(--border);
  background: var(--red-pastel);
  color: var(--ink);
}

/* 맞혔을 때: 민트 스티커 */
#toast.is-hit {
  border: var(--border);
  background: var(--mint-frame);
  color: var(--ink);
}

#toast.is-miss.show {
  animation: toast-shake 0.36s ease;
}

@keyframes toast-shake {
  0%,
  100% {
    transform: translate(-50%, 0);
  }
  25% {
    transform: translate(calc(-50% - 6px), 0) rotate(-2deg);
  }
  75% {
    transform: translate(calc(-50% + 6px), 0) rotate(2deg);
  }
}

dialog.zoom {
  max-width: min(94vw, 820px);
  max-height: 94vh;
  padding: 0;
  border: var(--border);
  border-radius: 18px;
  background: var(--white);
  overflow: auto;
}

dialog.zoom::backdrop {
  background: rgb(17 17 17 / 65%);
}

dialog.zoom img {
  width: auto;
  max-height: 84vh;
  margin: 0 auto;
}

.zoom-caption {
  margin: 0;
  padding: 12px 16px 14px;
  border-top: 2px solid var(--ink);
  font-size: 18px;
  font-weight: 800;
  text-align: center;
}

.zoom-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--white);
  font-weight: 800;
  cursor: pointer;
}

/* ---------- 포츈쿠키 네컷 ---------- */
.cookie-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* 하루들 네컷 원고: 흰 종이 위 2×2 칸, 아래에 제목과 날짜 */
.comic {
  container-type: inline-size;
  width: 100%;
  padding: 18px 18px 10px;
  border: var(--border);
  border-radius: 18px;
  background: var(--white);
  transform: rotate(-0.6deg);
}

.comic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2.5px;
  border: 2.5px solid var(--ink);
  border-radius: 3px;
  background: var(--ink);
}

.comic-panel {
  position: relative;
  display: block;
  aspect-ratio: 1;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--white);
  overflow: hidden;
  text-align: left;
}

.comic-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.comic-caption {
  position: absolute;
  top: 6%;
  left: 7%;
  margin: 0;
  font-family: var(--font-hand);
  font-size: 4.6cqw;
  line-height: 1.2;
  white-space: nowrap;
}

.comic-footer {
  display: flex;
  justify-content: space-between;
  margin: 8px 2px 0;
  font-family: var(--font-hand);
  font-size: 4cqw;
}

/* 1~3칸: 들어오면 한 칸씩 차례로 나타나요. */
.p1 {
  --start: 0.1s;
}

.p2 {
  --start: 0.6s;
}

.p3 {
  --start: 1.1s;
}

:where(.p1, .p2, .p3) .comic-img:not(.after) {
  animation: panel-in 0.45s cubic-bezier(0.2, 1.3, 0.4, 1) var(--start) backwards;
}

:where(.p1, .p2, .p3) .comic-caption {
  animation: write 0.5s steps(8) calc(var(--start) + 0.2s) backwards;
}

/* 3칸: 직접 눌러서 깨는 칸 */
.p3 {
  cursor: pointer;
}

.p3:disabled {
  cursor: default;
}

.p3:focus-visible {
  outline-offset: -6px;
}

.p3 .before {
  transform-origin: 50% 70%;
}

.cookie-page:not(.is-cracked) .p3 .before {
  animation:
    panel-in 0.45s cubic-bezier(0.2, 1.3, 0.4, 1) var(--start) backwards,
    cookie-idle 1.6s ease-in-out 1.8s infinite;
}

.p3 .after,
.sfx {
  visibility: hidden;
}

.tap-hint {
  position: absolute;
  bottom: 5%;
  left: 50%;
  padding: 3px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--purple);
  font-size: 3cqw;
  font-weight: 700;
  white-space: nowrap;
  transform: translateX(-50%);
  animation:
    fade-in 0.3s ease 1.7s backwards,
    hint-bob 1.4s ease-in-out 2s infinite;
}

.sfx {
  position: absolute;
  top: 17%;
  right: 7%;
  font-family: var(--font-hand);
  font-size: 9cqw;
  line-height: 1;
  text-shadow:
    2px 2px 0 var(--white),
    -2px -2px 0 var(--white),
    2px -2px 0 var(--white),
    -2px 2px 0 var(--white);
  transform: rotate(-10deg);
}

.is-cracked .p3 .before,
.is-cracked .tap-hint {
  visibility: hidden;
}

.is-cracked .p3 .after,
.is-cracked .sfx {
  visibility: visible;
}

.is-cracked .p3 .after {
  animation: impact 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.is-cracked .sfx {
  animation: sfx-pop 0.4s cubic-bezier(0.2, 1.8, 0.4, 1) 0.05s backwards;
}

/* 4칸: 쿠키를 깨야 채워져요. */
.p4-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-hand);
  font-size: 22cqw;
  color: var(--mint-line);
  animation: fade-in 0.3s ease 1.6s backwards;
}

.cookie-page:not(.is-cracked) .p4 > :not(.p4-empty) {
  visibility: hidden;
}

.is-cracked .p4-empty {
  display: none;
}

.is-cracked .p4 .comic-img {
  animation: panel-in 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) 0.35s backwards;
}

.is-cracked .p4 .comic-caption {
  animation: write 0.5s steps(8) 0.5s backwards;
}

/* 그림 속 빈 쪽지(s04.webp) 안쪽에 맞춘 자리 */
.fortune-slip {
  position: absolute;
  top: 29.6%;
  left: 20.5%;
  right: 20.5%;
  height: 14.4%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 2%;
  overflow: hidden;
  font-family: var(--font-hand);
  font-size: 4cqw;
  line-height: 1.15;
  text-align: center;
  text-wrap: balance;
}

.is-cracked .fortune-slip {
  animation: slip-in 0.4s cubic-bezier(0.2, 1.6, 0.4, 1) 0.75s backwards;
}

/* 좁은 화면에선 쪽지 글씨가 작아서 아래에 한 번 더 크게 보여줘요. */
.cookie-result {
  display: none;
}

.cookie-tip {
  margin: 22px 0 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
}

.cookie-again {
  max-width: 320px;
  margin-top: 24px;
}

.cookie-again[hidden] {
  display: none;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: scale(0.92) rotate(-2deg);
  }
}

@keyframes write {
  from {
    clip-path: inset(0 100% 0 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes hint-bob {
  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(-3px);
  }
}

@keyframes cookie-idle {
  0%,
  100% {
    transform: rotate(-1.5deg);
  }
  50% {
    transform: rotate(1.5deg) translateY(-2px);
  }
}

@keyframes impact {
  0% {
    transform: scale(1.12) rotate(-3deg);
  }
  40% {
    transform: scale(0.97) rotate(1deg);
  }
}

@keyframes sfx-pop {
  from {
    opacity: 0;
    transform: rotate(-30deg) scale(0.2);
  }
}

@keyframes slip-in {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
}

/* ---------- 반응형 ---------- */
@media (max-width: 900px) {
  .app-header {
    padding: 18px 16px 4px;
  }

  .logo {
    font-size: 30px;
  }

  .pill-badge {
    display: none;
  }

  .split {
    grid-template-columns: minmax(0, 1fr);
    gap: 36px;
    min-height: 0;
    padding: 16px 16px 24px;
  }

  .frame {
    justify-self: center;
    max-width: 480px;
    padding: 12px;
    border-radius: 24px;
  }

  .frame-inner {
    padding: 12px;
  }

  .frame-stage {
    width: 100%;
    min-width: 0;
  }

  .side {
    max-width: none;
  }

  .lead {
    margin: 12px 0 24px;
    font-size: 16px;
  }

  .card {
    padding: 22px 20px 18px;
    border-radius: 24px;
  }

  .btn-block {
    min-height: 62px;
    margin-top: 18px;
    font-size: 18px;
  }

  .board {
    padding: 8px 16px 0;
  }

  .board-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .page {
    padding: 16px 16px 32px;
  }

  .settings-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .center-card {
    margin: 24px 16px 0;
    padding: 28px 20px 22px;
  }
}

@media (max-width: 520px) {
  .is-cracked .cookie-result {
    display: block;
    margin: 20px 0 0;
    padding: 12px 20px;
    border: 2px solid var(--ink);
    border-radius: 6px;
    background: var(--white);
    box-shadow: 4px 4px 0 var(--yellow);
    font-family: var(--font-hand);
    font-size: 24px;
    text-align: center;
    transform: rotate(-1.5deg);
  }
}

@media (max-width: 420px) {
  .answer-bar .btn {
    padding: 0 18px;
  }

  .scene-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .setting-row {
    grid-template-columns: 104px auto;
  }

  .setting-note {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
