:root {
  --pink:   #FFD6E0;
  --pink-2: #FFA8BD;
  --blue:   #D6E5FF;
  --blue-2: #A8C8FF;
  --green:  #D6F5D6;
  --green-2:#A8E0A8;
  --yellow: #FFF4C2;
  --yellow-2:#FFE38A;
  --purple: #E5D6FF;
  --purple-2:#C7A8FF;
  --ink:    #2b2b2b;
  --ink-2:  #555;
  --muted:  #888;
  --bg:     #FFFBF5;
  --line:   #ececec;
  --soft-shadow: 0 8px 24px rgba(0,0,0,.08);
  --card-shadow: 0 12px 32px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.04);

  /* 어린이 친화 액센트 */
  --accent:        #FF7AA2;   /* 진한 분홍 — primary 버튼 */
  --accent-dark:   #E55F88;
  --accent-soft:   #FFE7EE;
  --joy:           #FFC93C;   /* 노랑 — help/포인트 */
  --joy-dark:      #F0B400;
  --sky:           #5AA9FF;   /* 파랑 액센트 */
  --grass:         #62C68A;   /* 초록 액센트 */
  --grape:         #B388FF;   /* 보라 액센트 */
  --danger:        #FF5C5C;
  --danger-soft:   #FFE7E7;
  --bounce:        cubic-bezier(.34,1.56,.64,1);

  /* 카드 비율: 63 x 88 mm */
  --card-w: 260px;
  --card-h: 360px;

  /* 레이아웃 폭 */
  --content-max: 1040px;

  /* 어린이 친화 폰트 크기 */
  --fs-base: 16px;
  --fs-label: 16px;
  --fs-chip: 15px;
}

[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }

body {
  font-family: 'Noto Sans KR', 'Noto Sans JP', 'Noto Sans', sans-serif;
  font-size: var(--fs-base);
  /* 어린이 친화 배경 — 부드러운 그라데이션 + 도트 패턴 */
  background:
    radial-gradient(circle at 8% 12%, rgba(255,201,60,.10), transparent 22%),
    radial-gradient(circle at 92% 18%, rgba(122,168,255,.10), transparent 22%),
    radial-gradient(circle at 90% 88%, rgba(255,122,162,.10), transparent 25%),
    radial-gradient(circle at 12% 82%, rgba(124,221,151,.10), transparent 25%),
    var(--bg);
  min-height: 100vh;
}
html[lang="en"] body { font-family: 'Noto Sans', 'Noto Sans KR', sans-serif; }
html[lang="ja"] body { font-family: 'Noto Sans JP', 'Noto Sans KR', 'Noto Sans', sans-serif; }

/* ========== Header ========== */
.app-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  gap: 8px;
  box-shadow: 0 2px 0 rgba(255,201,60,.18);
}
.header-left { justify-self: start; }
.app-title {
  font-family: 'Black Han Sans', sans-serif;
  font-size: 30px; margin: 0; letter-spacing: 1px;
  justify-self: center;
  text-align: center;
  background: linear-gradient(120deg, #FF7AA2 0%, #FFC93C 50%, #5AA9FF 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.header-right { display: flex; align-items: center; gap: 10px; justify-self: end; }

.lang-dropdown { position: relative; }
.lang-btn {
  background: #fff; border: 2px solid var(--line); border-radius: 22px;
  padding: 8px 14px; cursor: pointer; font: inherit; font-weight: 600;
  transition: border-color .15s ease, transform .12s var(--bounce);
}
.lang-btn:hover { border-color: var(--sky); transform: translateY(-1px); }
.lang-btn .caret { margin-left: 4px; font-size: 11px; color: var(--muted); }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  list-style: none; padding: 6px; margin: 0;
  background: #fff; border: 2px solid var(--line); border-radius: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,.08); z-index: 20; min-width: 120px;
}
.lang-menu li { padding: 8px 12px; cursor: pointer; border-radius: 10px; font-weight: 600; }
.lang-menu li:hover { background: var(--accent-soft); color: var(--accent-dark); }

.help-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--joy) 0%, var(--joy-dark) 100%);
  color: #fff;
  border: none; font-weight: 800; cursor: pointer;
  font-size: 18px;
  box-shadow: 0 3px 0 rgba(240,180,0,.55), 0 4px 12px rgba(255,201,60,.4);
  transition: transform .12s var(--bounce), box-shadow .15s ease;
}
.help-btn:hover { transform: translateY(-2px) rotate(-6deg); box-shadow: 0 5px 0 rgba(240,180,0,.55), 0 8px 18px rgba(255,201,60,.5); }
.help-btn:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(240,180,0,.55); }

/* ========== Tabs ========== */
.tabs {
  display: flex; gap: 8px;
  padding: 14px 20px 0;
  max-width: var(--content-max); margin: 0 auto;
  justify-content: center;
  flex-wrap: wrap;
}
.tab {
  border: 2px solid transparent; background: rgba(255,255,255,.6); padding: 12px 22px;
  font: inherit; font-size: 16px; font-weight: 800; color: var(--muted); cursor: pointer;
  border-radius: 22px 22px 0 0;
  display: inline-flex; align-items: center; gap: 8px;
  transition: transform .15s var(--bounce), background .15s ease, color .15s ease;
}
.tab .tab-emoji { font-size: 20px; line-height: 1; }
.tab:hover { color: var(--ink); transform: translateY(-2px); }
.tab.active {
  background: #fff; color: var(--ink);
  border: 2px solid var(--line); border-bottom-color: #fff;
  box-shadow: 0 -3px 0 var(--accent);
}
.tab.active[data-tab="maker"]    { box-shadow: 0 -3px 0 var(--accent); }
.tab.active[data-tab="explorer"] { box-shadow: 0 -3px 0 var(--sky); }
.tab.active[data-tab="lotto"]    { box-shadow: 0 -3px 0 var(--joy-dark); }

/* ========== Main ========== */
.app-main {
  background: #fff; border: 2px solid var(--line); border-radius: 0 20px 20px 20px;
  max-width: var(--content-max);
  margin: 0 auto 24px;
  padding: 30px 34px;
  min-height: calc(100vh - 240px);
  box-shadow: 0 6px 0 rgba(0,0,0,.03);
}

h2 {
  margin-top: 0; text-align: center;
  font-family: 'Black Han Sans', sans-serif;
  font-size: 26px; letter-spacing: 0.5px;
}

.form-row { margin-bottom: 22px; max-width: 720px; margin-left: auto; margin-right: auto; }
.form-row label { display: block; font-weight: 800; margin-bottom: 10px; text-align: center; font-size: var(--fs-label); }

.chip-group { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip {
  border: 2px solid var(--line); background: #fff; border-radius: 22px;
  padding: 10px 16px; cursor: pointer; font: inherit; font-size: var(--fs-chip); font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px;
  transition: transform .14s var(--bounce), box-shadow .15s ease, background .15s ease, border-color .15s ease;
  min-height: 40px;
}
.chip .chip-emoji { font-size: 16px; line-height: 1; }
.chip:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 4px 10px rgba(0,0,0,.08); }
.chip:active { transform: translateY(0) scale(.98); }
.chip.active {
  border-color: var(--ink);
  box-shadow: 0 3px 0 var(--ink), 0 6px 14px rgba(0,0,0,.08);
  transform: translateY(-1px);
}

.chip.cat-mind.active     { background: var(--pink); }
.chip.cat-thought.active  { background: var(--blue); }
.chip.cat-body.active     { background: var(--green); }
.chip.cat-relation.active { background: var(--yellow); }
.chip.cat-etc.active      { background: var(--purple); }
.chip.chip-all.active     { background: linear-gradient(110deg, #FFD6E0, #FFF4C2 40%, #D6F5D6 70%, #D6E5FF); }

.chip.type-choice.active  { background: #FFE4D6; }
.chip.type-imagine.active { background: #E5D6FF; }
.chip.type-exp.active     { background: #D6F5D6; }
.chip.type-dilemma.active { background: #FFE7E7; }
.chip.type-etc.active     { background: #E0F4F4; }
#typeChips .chip.active   { color: var(--ink); }

.etc-input {
  margin: 10px auto 0; display: block;
  width: 100%; max-width: 360px;
  padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; font: inherit;
  transition: border-color .15s ease;
}
.etc-input:focus { outline: none; border-color: var(--sky); }

.palette {
  display: flex; align-items: center; gap: 8px;
  margin: 12px auto 0; flex-wrap: wrap; justify-content: center;
}
.swatch {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,.08); cursor: pointer;
  transition: transform .12s var(--bounce);
}
.swatch:hover { transform: scale(1.15); }
.swatch.active { outline: 3px solid var(--ink); outline-offset: 2px; transform: scale(1.1); }

#questionInput, #authorInput {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--line); border-radius: 14px; font: inherit;
  font-size: 16px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#questionInput:focus, #authorInput:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 4px rgba(90,169,255,.18); }
#questionInput { resize: vertical; min-height: 90px; }
#authorInput { max-width: 360px; display: block; margin: 0 auto; }

.primary-btn {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff; border: none; border-radius: 26px;
  padding: 14px 28px; font: inherit; font-weight: 800; font-size: 16px; cursor: pointer;
  box-shadow: 0 4px 0 var(--accent-dark), 0 6px 14px rgba(255,122,162,.35);
  transition: transform .14s var(--bounce), box-shadow .15s ease, filter .15s ease;
  letter-spacing: .3px;
}
.primary-btn:hover { transform: translateY(-2px); filter: brightness(1.05); box-shadow: 0 6px 0 var(--accent-dark), 0 10px 20px rgba(255,122,162,.45); }
.primary-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--accent-dark), 0 2px 6px rgba(255,122,162,.3); }

.ghost-btn {
  background: #fff; color: var(--ink); border: 2px solid var(--line); border-radius: 26px;
  padding: 12px 22px; font: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .14s var(--bounce);
}
.ghost-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); transform: translateY(-1px); }
.ghost-btn:active { transform: translateY(1px); }

.center-row {
  display: flex; justify-content: center; margin-top: 10px;
}
.center-row.gap { gap: 12px; flex-wrap: wrap; }

/* ========== Count banner (전체 카드 수) ========== */
.count-banner {
  max-width: 500px;
  margin: 0 auto 28px;
  padding: 16px 24px;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  background:
    radial-gradient(circle at 12% 50%, rgba(255,201,60,.25), transparent 40%),
    radial-gradient(circle at 95% 50%, rgba(255,122,162,.18), transparent 50%),
    #fff;
  border: 2px solid #f3e9d2;
  border-radius: 24px;
  box-shadow: 0 4px 0 rgba(255,201,60,.18), 0 8px 20px rgba(0,0,0,.04);
  animation: bannerFloat 4s ease-in-out infinite;
}
@keyframes bannerFloat { 50% { transform: translateY(-2px); } }
.count-icon { font-size: 32px; line-height: 1; animation: wave 2.4s ease-in-out infinite; }
@keyframes wave { 50% { transform: rotate(-12deg) scale(1.05); } }
.count-text { font-size: 15px; color: var(--ink-2); font-weight: 600; }
.count-num {
  font-family: 'Black Han Sans', sans-serif;
  font-size: 30px;
  background: linear-gradient(120deg, var(--accent) 0%, var(--joy-dark) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 0 6px;
  letter-spacing: 1px;
}

/* ========== Card (refined design) ========== */
.card-stage {
  display: flex; flex-wrap: wrap; gap: 32px; margin: 20px auto 28px;
  justify-content: center;
}
.card-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.card-label { font-size: 12px; color: var(--muted); }

.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 24px;
  background: var(--pink);
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
  padding: 20px 20px 18px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* === FRONT === */
.card-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  position: relative; z-index: 2;
}
.card-cat-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.7);
  padding: 5px 12px 5px 8px;
  border-radius: 999px;
  font-size: 12px; font-weight: 700;
  color: var(--ink);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,.55);
}
.card-cat-emoji { font-size: 14px; line-height: 1; }
.card-type-badge {
  display: inline-flex; align-items: center;
  background: rgba(255,255,255,.55);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700; color: var(--ink-2);
  border: 1px solid rgba(255,255,255,.5);
  backdrop-filter: blur(4px);
}

.card-body {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  position: relative;
  padding: 22px 18px;
  z-index: 2;
}
.quote-mark {
  font-family: 'Noto Serif KR', 'Black Han Sans', Georgia, serif;
  font-size: 56px;
  line-height: 1;
  color: rgba(0,0,0,.22);
  font-weight: 700;
  user-select: none;
  letter-spacing: -2px;
  position: absolute;
  pointer-events: none;
}
.quote-mark.quote-open  { top: 8px; left: 6px; }
.quote-mark.quote-close { right: 6px; bottom: 2px; }
.card-question {
  font-size: 18px; font-weight: 700; line-height: 1.55;
  white-space: pre-wrap; word-break: keep-all;
  margin: 4px 4px;
  color: var(--ink);
}

.card-bottom {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; position: relative; z-index: 2;
  min-height: 28px;
}
.card-character {
  font-size: 28px; line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.08));
  min-width: 28px; min-height: 28px;
  display: inline-flex; align-items: center;
}
.card-author {
  font-size: 11px; color: rgba(0,0,0,.55); font-weight: 600;
  max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 그라데이션 — 어린이 친화 부드러움 */
.card-front::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 100% 0%, rgba(255,255,255,.5), transparent 50%),
    radial-gradient(circle at 0% 100%, rgba(255,255,255,.3), transparent 55%);
  pointer-events: none;
  z-index: 1;
}

/* === BACK (질문카드 / 질문은 나의 세계) === */
.card-back {
  background: #fff;
  align-items: center; justify-content: center; text-align: center;
  position: relative;
  padding: 28px 22px;
}
.card-back::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 50% 32%, var(--bk-color, var(--pink)) 0%, transparent 65%),
    radial-gradient(circle at 18% 82%, var(--bk-color-2, var(--pink-2)) 0%, transparent 40%),
    radial-gradient(circle at 82% 84%, var(--bk-color-2, var(--pink-2)) 0%, transparent 40%);
  opacity: .82;
  pointer-events: none;
}
.back-mark {
  position: relative; z-index: 2;
  font-family: 'Black Han Sans', sans-serif;
  font-size: 64px; line-height: 1;
  color: rgba(0,0,0,.55);
  margin-top: 18px; margin-bottom: 10px;
}
.back-title {
  position: relative; z-index: 2;
  font-family: 'Black Han Sans', sans-serif;
  font-size: 34px; letter-spacing: 1px;
  margin-bottom: 18px;
  color: var(--ink);
}
.back-tagline {
  position: relative; z-index: 2;
  font-size: 15px; font-weight: 700; line-height: 1.7;
  color: rgba(0,0,0,.7);
  letter-spacing: 0.5px;
}

/* ========== Emoji picker ========== */
.emoji-picker {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: linear-gradient(180deg, #fff 0%, var(--bg) 100%);
  padding: 18px 18px; border-radius: 20px;
  margin: 0 auto 18px; max-width: 720px;
  border: 2px solid #f3eadf;
}
.emoji-hint {
  width: 100%; text-align: center; margin: 0 0 6px;
  font-weight: 600;
}
.emoji-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; width: 100%; }
.emoji-custom-row { display:flex; gap:8px; margin-top: 12px; width:100%; justify-content: center; align-items:center; flex-wrap:wrap; }
.custom-emoji-input { width: 140px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 14px; font: inherit; text-align: center; font-size: 18px; }
.custom-emoji-input:focus { outline: none; border-color: var(--sky); }
.emoji-list button {
  background: #fff; border: 2px solid var(--line); border-radius: 14px;
  width: 44px; height: 44px; font-size: 22px; cursor: pointer;
  transition: transform .12s var(--bounce), background .15s ease, border-color .15s ease;
  padding: 0;
}
.emoji-list button:hover { transform: scale(1.18) rotate(-4deg); border-color: var(--joy-dark); }
.emoji-list button.selected {
  background: var(--joy);
  border-color: var(--joy-dark);
  transform: scale(1.1);
  box-shadow: 0 3px 0 var(--joy-dark);
}
.emoji-tabs { display: flex; gap: 6px; width: 100%; flex-wrap: wrap; justify-content: center; }
.emoji-tab {
  background: #fff; border: 2px solid var(--line); border-radius: 18px;
  padding: 7px 16px; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .12s var(--bounce);
}
.emoji-tab:hover { transform: translateY(-1px); border-color: var(--sky); }
.emoji-tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.small-btn { padding: 8px 14px; font-size: 13px; }

/* ===== Card Explorer ===== */
.form-row.inline {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center;
  background: var(--bg);
  padding: 14px 18px;
  border-radius: 18px;
  border: 2px dashed #f3e0c8;
}
.form-row.inline label { margin: 0; font-size: 15px; }
#drawCount {
  width: 80px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px;
  font: inherit; font-size: 16px; font-weight: 700; text-align: center;
  transition: border-color .15s ease;
}
#drawCount:focus { outline: none; border-color: var(--sky); }

.draw-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  margin-top: 24px;
  justify-items: center;
}
.draw-card {
  width: 100%; max-width: 220px; aspect-ratio: 63 / 88;
  perspective: 1000px; cursor: pointer;
}
.draw-card .flipper {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform .6s ease;
}
.draw-card.flipped .flipper { transform: rotateY(180deg); }
.draw-card .face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  border-radius: 18px;
  box-shadow: var(--soft-shadow);
  padding: 12px; box-sizing: border-box;
  display: flex; flex-direction: column;
  overflow: hidden;
}

.draw-card .face.back {
  background: #fff;
  align-items: center; justify-content: center; text-align: center;
  position: relative;
}
.draw-card .face.back::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 50% 32%, var(--bk-color, var(--pink)) 0%, transparent 65%),
    radial-gradient(circle at 18% 82%, var(--bk-color-2, var(--pink-2)) 0%, transparent 40%),
    radial-gradient(circle at 82% 84%, var(--bk-color-2, var(--pink-2)) 0%, transparent 40%);
  opacity: .82;
  pointer-events: none;
}
.draw-card .face.back .b-mark {
  position: relative; z-index: 2;
  font-family: 'Black Han Sans', sans-serif; font-size: 40px; line-height: 1;
  color: rgba(0,0,0,.55); margin-bottom: 4px;
}
.draw-card .face.back .b-title {
  position: relative; z-index: 2;
  font-family: 'Black Han Sans', sans-serif; font-size: 22px; margin-bottom: 10px;
}
.draw-card .face.back .b-tagline {
  position: relative; z-index: 2;
  font-size: 12px; font-weight: 700; line-height: 1.6; color: rgba(0,0,0,.68);
  letter-spacing: 0.3px;
}

.draw-card .face.front {
  transform: rotateY(180deg);
  background: var(--pink);
  position: relative;
}
.draw-card .face.front::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 100% 0%, rgba(255,255,255,.45), transparent 50%),
    radial-gradient(circle at 0% 100%, rgba(255,255,255,.3), transparent 55%);
  pointer-events: none;
}
.draw-card .d-top {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  position: relative; z-index: 2;
}
.draw-card .d-cat {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,.72); padding: 3px 9px;
  border-radius: 999px; font-size: 11px; font-weight: 700;
  border: 1px solid rgba(255,255,255,.55);
}
.draw-card .d-type {
  display: inline-flex; align-items: center;
  background: rgba(255,255,255,.5); padding: 2px 9px;
  border-radius: 999px; font-size: 10px; font-weight: 700; color: var(--ink-2);
  border: 1px solid rgba(255,255,255,.5);
}
.draw-card .d-body {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  position: relative; z-index: 2; padding: 14px 12px;
}
.draw-card .d-q {
  font-weight: 700; line-height: 1.4;
  font-size: 13px; word-break: keep-all; white-space: pre-wrap;
}
.draw-card .d-quote-l, .draw-card .d-quote-r {
  font-family: 'Noto Serif KR', Georgia, serif;
  font-size: 32px; line-height: 1; color: rgba(0,0,0,.22); font-weight: 700;
  position: absolute; pointer-events: none;
}
.draw-card .d-quote-l { top: 4px; left: 4px; }
.draw-card .d-quote-r { right: 4px; bottom: 2px; }
.draw-card .d-bottom {
  display: flex; justify-content: space-between; align-items: center;
  position: relative; z-index: 2; gap: 4px; min-height: 20px;
}
.draw-card .d-char { font-size: 18px; line-height: 1; }
.draw-card .d-author {
  font-size: 9px; color: rgba(0,0,0,.5); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%;
}

/* ===== Lotto view ===== */
.lotto-desc { text-align: center; margin-top: -4px; margin-bottom: 22px; font-size: 15px; font-weight: 600; }
.lotto-stage {
  display: flex; justify-content: center; align-items: center;
  min-height: 380px;
  margin: 12px auto 18px;
  padding: 12px;
}
.lotto-empty {
  text-align: center;
  font-size: 16px;
  padding: 70px 20px;
}
.lotto-empty::before {
  content: '🎁';
  display: block;
  font-size: 48px;
  margin-bottom: 12px;
  opacity: .8;
  animation: wave 2.5s ease-in-out infinite;
}
.lotto-card {
  width: var(--card-w); height: var(--card-h); aspect-ratio: 63 / 88;
  perspective: 1000px;
  animation: lottoIn .5s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes lottoIn {
  from { opacity: 0; transform: scale(.7) rotate(-8deg); }
  to   { opacity: 1; transform: scale(1) rotate(0); }
}
.lotto-card .flipper {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform .6s ease;
  cursor: pointer;
}
.lotto-card.flipped .flipper { transform: rotateY(180deg); }
.lotto-card .face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  border-radius: 22px;
  box-shadow: var(--card-shadow);
  padding: 18px; box-sizing: border-box;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.lotto-card .face.back   { background: #fff; align-items: center; justify-content: center; text-align: center; }
.lotto-card .face.front  { transform: rotateY(180deg); background: var(--pink); }
.lotto-card .face.back::before, .lotto-card .face.front::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
}
.lotto-card .face.back::before {
  background:
    radial-gradient(circle at 50% 32%, var(--bk-color, var(--pink)) 0%, transparent 65%),
    radial-gradient(circle at 18% 82%, var(--bk-color-2, var(--pink-2)) 0%, transparent 40%),
    radial-gradient(circle at 82% 84%, var(--bk-color-2, var(--pink-2)) 0%, transparent 40%);
  opacity: .82;
}
.lotto-card .face.front::before {
  background:
    radial-gradient(circle at 100% 0%, rgba(255,255,255,.45), transparent 50%),
    radial-gradient(circle at 0% 100%, rgba(255,255,255,.3), transparent 55%);
}
.lotto-card .face.back .b-mark {
  position: relative; z-index: 2; font-family: 'Black Han Sans', sans-serif;
  font-size: 60px; line-height: 1; color: rgba(0,0,0,.55); margin-bottom: 8px;
}
.lotto-card .face.back .b-title {
  position: relative; z-index: 2; font-family: 'Black Han Sans', sans-serif;
  font-size: 32px; margin-bottom: 14px;
}
.lotto-card .face.back .b-tagline {
  position: relative; z-index: 2;
  font-size: 14px; font-weight: 700; line-height: 1.7; color: rgba(0,0,0,.7);
  letter-spacing: 0.4px;
}
.lotto-card .face.front .l-top {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  position: relative; z-index: 2;
}
.lotto-card .face.front .l-cat {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.7); padding: 5px 12px 5px 8px;
  border-radius: 999px; font-size: 12px; font-weight: 700;
  border: 1px solid rgba(255,255,255,.55);
}
.lotto-card .face.front .l-type {
  background: rgba(255,255,255,.55); padding: 4px 12px;
  border-radius: 999px; font-size: 11px; font-weight: 700; color: var(--ink-2);
  border: 1px solid rgba(255,255,255,.5);
}
.lotto-card .face.front .l-body {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  position: relative; z-index: 2; padding: 22px 18px;
}
.lotto-card .face.front .l-q {
  font-weight: 700; line-height: 1.55; font-size: 18px;
  word-break: keep-all; white-space: pre-wrap; margin: 4px 4px;
}
.lotto-card .face.front .l-quote-l,
.lotto-card .face.front .l-quote-r {
  font-family: 'Noto Serif KR', Georgia, serif;
  font-size: 56px; line-height: 1; color: rgba(0,0,0,.22); font-weight: 700;
  position: absolute; pointer-events: none;
}
.lotto-card .face.front .l-quote-l { top: 8px; left: 6px; }
.lotto-card .face.front .l-quote-r { right: 6px; bottom: 2px; }
.lotto-card .face.front .l-bottom {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; position: relative; z-index: 2; min-height: 28px;
}
.lotto-card .face.front .l-char { font-size: 28px; line-height: 1; }
.lotto-card .face.front .l-author {
  font-size: 11px; color: rgba(0,0,0,.55); font-weight: 600;
  max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.admin-error-box {
  background: #fff8f0; border: 1px solid #ffd0a0; border-radius: 12px;
  padding: 20px 24px; max-width: 560px; margin: 0 auto;
}
.admin-error-title { font-weight: 700; font-size: 16px; margin: 0 0 10px; }
.admin-error-box ol { padding-left: 20px; line-height: 1.9; margin: 8px 0; }
.admin-error-box code {
  background: #f0ece4; padding: 2px 6px; border-radius: 4px; font-size: 13px;
}

.empty-state, .loading-state {
  grid-column: 1 / -1;
  text-align: center; padding: 50px 20px; color: var(--muted);
  font-size: 15px; font-weight: 600;
}
.empty-state::before {
  content: '🔍';
  display: block;
  font-size: 42px;
  margin-bottom: 10px;
  opacity: .7;
}
.loading-state::before {
  content: '⏳';
  display: block;
  font-size: 36px;
  margin-bottom: 10px;
  animation: wave 1.6s ease-in-out infinite;
}

.action-row {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px;
}

/* ========== Footer ========== */
.app-footer {
  text-align: center; padding: 16px;
  color: var(--muted); font-size: 13px;
}
.app-footer a { color: var(--muted); text-decoration: none; }
.app-footer a:hover { color: var(--ink); text-decoration: underline; }

/* ========== Modal ========== */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 200;
  padding: 16px;
  animation: modalFade .18s ease-out;
}
@keyframes modalFade { from { background: rgba(0,0,0,0); } to { background: rgba(0,0,0,.45); } }
.modal-inner {
  background: #fff; border-radius: 24px;
  padding: 34px 30px 26px;
  max-width: 92vw; width: 420px;
  position: relative;
  box-shadow: 0 16px 48px rgba(0,0,0,.22);
  border: 2px solid #f3e9d2;
  animation: modalPop .25s var(--bounce);
}
@keyframes modalPop {
  from { transform: scale(.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.modal-inner h3 {
  margin: 0 0 8px;
  font-size: 22px;
  font-family: 'Black Han Sans', sans-serif;
  letter-spacing: 0.5px;
  text-align: center;
}
.modal-inner p { margin: 0 0 18px; text-align: center; }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 36px; height: 36px;
  background: var(--bg); border: 2px solid var(--line); font-size: 16px; cursor: pointer;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: background .15s ease, transform .14s var(--bounce);
}
.modal-close:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); transform: rotate(90deg); }
.help-list { padding-left: 26px; line-height: 2; margin: 8px 0 12px; }
.help-list li { padding-left: 6px; font-size: 15px; }
.help-list li::marker { color: var(--accent); font-weight: 800; }
.export-row { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

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

/* ========== Admin gate (hidden entry) ========== */
.admin-gate {
  position: fixed; right: 10px; bottom: 10px;
  width: 14px; height: 14px; border-radius: 50%;
  background: rgba(0,0,0,.12); border: none; padding: 0;
  cursor: pointer; z-index: 30;
  transition: background .2s ease, transform .2s ease;
}
.admin-gate:hover { background: rgba(0,0,0,.35); transform: scale(1.2); }

/* ========== Admin overlay ========== */
.admin-overlay {
  position: fixed; inset: 0; background: #fbfaf6; z-index: 100;
  display: flex; flex-direction: column; overflow: hidden;
}
.admin-header {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px 22px; border-bottom: 2px solid var(--line);
  background: #fff;
  box-shadow: 0 2px 0 rgba(0,0,0,.03);
}
.admin-title-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.admin-title-row h2 {
  margin: 0; text-align: left;
  font-family: 'Black Han Sans', sans-serif;
  font-size: 22px; letter-spacing: 0.5px;
  display: inline-flex; align-items: center; gap: 8px;
}
.admin-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-header-actions .ghost-btn { padding: 8px 16px; font-size: 14px; }
.admin-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.admin-tools input[type="search"],
.admin-tools select {
  padding: 9px 12px; border: 2px solid var(--line); border-radius: 12px; font: inherit; font-size: 14px;
  background: #fff;
  transition: border-color .15s ease;
}
.admin-tools input[type="search"]:focus,
.admin-tools select:focus { outline: none; border-color: var(--sky); }
.admin-search-wrap {
  position: relative; display: inline-flex; align-items: center;
}
.admin-search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  pointer-events: none; font-size: 14px; opacity: .6;
}
.admin-search-wrap input[type="search"] { padding-left: 32px; min-width: 200px; }

.view-toggle {
  display: inline-flex; border: 2px solid var(--line); border-radius: 22px; overflow: hidden;
  background: #fff;
}
.view-toggle .vt {
  background: #fff; border: none; padding: 8px 18px; cursor: pointer; font: inherit;
  font-weight: 700; font-size: 14px;
  transition: background .15s ease, color .15s ease;
}
.view-toggle .vt:hover { background: var(--bg); }
.view-toggle .vt.active { background: var(--ink); color: #fff; }

.admin-stats {
  padding: 10px 22px; color: var(--ink-2); font-size: 13px; font-weight: 600;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.admin-content { flex: 1; overflow: auto; padding: 18px 22px; }

.admin-empty {
  text-align: center; padding: 60px 20px;
}
.admin-empty-emoji { font-size: 48px; margin-bottom: 10px; opacity: .8; }

/* List view */
.admin-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  background: #fff; border-radius: 14px; overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,.04);
}
.admin-table th, .admin-table td {
  border-bottom: 1px solid var(--line); padding: 10px 8px; vertical-align: top; text-align: left;
}
.admin-table th {
  background: var(--bg); position: sticky; top: 0; z-index: 2;
  font-weight: 800; text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px;
  color: var(--ink-2);
}
.admin-table tbody tr:hover { background: rgba(255,201,60,.05); }
.admin-table td input,
.admin-table td select,
.admin-table td textarea {
  width: 100%; padding: 6px 8px; border: 1.5px solid transparent; border-radius: 8px;
  font: inherit; background: transparent;
  transition: border-color .15s ease, background .15s ease;
}
.admin-table td input:hover,
.admin-table td select:hover,
.admin-table td textarea:hover { background: var(--bg); }
.admin-table td input:focus,
.admin-table td select:focus,
.admin-table td textarea:focus { border-color: var(--sky); background: #fff; outline: none; box-shadow: 0 0 0 3px rgba(90,169,255,.15); }
.admin-table td.actions { white-space: nowrap; }
.admin-table tr.dirty {
  background: rgba(255,184,74,.08);
}
.admin-table tr.dirty td:first-child { box-shadow: inset 4px 0 0 #ffb84a; }
.admin-table tr.dirty td.actions::before {
  content: '● 미저장';
  display: block; font-size: 10px; color: #c47800;
  font-weight: 700; margin-bottom: 4px;
}
.admin-table .color-dot {
  display: inline-block; width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,.12); vertical-align: middle; margin-right: 6px;
}

/* Card view */
.admin-cards {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.admin-card {
  border: 2px solid var(--line); border-radius: 18px; padding: 16px;
  background: #fff; display: flex; flex-direction: column; gap: 10px;
  transition: transform .15s var(--bounce), box-shadow .15s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.admin-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.admin-card.dirty { border-color: #ffb84a; box-shadow: 0 4px 12px rgba(255,184,74,.2); }
.admin-card .ac-top {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
}
.admin-card .ac-cat {
  padding: 4px 12px; border-radius: 14px; font-size: 12px; font-weight: 800;
  border: 1px solid rgba(0,0,0,.08);
}
.admin-card .ac-meta { font-size: 11px; color: var(--muted); }
.admin-card textarea {
  width: 100%; min-height: 80px; padding: 10px; border: 2px solid var(--line);
  border-radius: 10px; resize: vertical; font: inherit; font-size: 14px;
  transition: border-color .15s ease;
}
.admin-card textarea:focus { outline: none; border-color: var(--sky); }
.admin-card .ac-row {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.admin-card select, .admin-card input[type="text"] {
  padding: 7px 10px; border: 2px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px;
  transition: border-color .15s ease;
}
.admin-card select:focus, .admin-card input[type="text"]:focus { outline: none; border-color: var(--sky); }
.admin-card .ac-actions { display: flex; gap: 8px; justify-content: flex-end; }
.danger-btn {
  background: var(--danger-soft); color: var(--danger); border: 2px solid #ffc7c7;
  border-radius: 18px; padding: 7px 14px; cursor: pointer; font: inherit; font-size: 13px;
  font-weight: 700;
  transition: background .15s ease, transform .12s var(--bounce);
}
.danger-btn:hover { background: var(--danger); color: #fff; border-color: var(--danger); transform: translateY(-1px); }
.danger-btn-lg {
  padding: 12px 24px; font-size: 15px; border-radius: 22px;
}

/* Admin delete confirmation preview */
.admin-delete-preview {
  margin: 12px 0 0;
  padding: 14px;
  border-radius: 14px;
  background: var(--bg);
  border: 2px dashed var(--line);
}
.del-card {
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.del-meta { display: flex; gap: 6px; margin-bottom: 8px; }
.del-badge {
  background: rgba(255,255,255,.7);
  padding: 3px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 700;
}
.del-badge-type { background: rgba(255,255,255,.5); }
.del-q { font-weight: 700; font-size: 14px; line-height: 1.5; }
.del-author { font-size: 12px; color: rgba(0,0,0,.55); margin-top: 6px; }

/* Admin add modal form */
.admin-add-form {
  display: grid; gap: 8px; margin-top: 6px;
}
.admin-add-form .aa-label {
  font-weight: 800; font-size: 13px; margin-top: 8px;
}
.admin-add-form select,
.admin-add-form input[type="text"],
.admin-add-form textarea {
  width: 100%; padding: 10px 12px; border: 2px solid var(--line);
  border-radius: 12px; font: inherit; font-size: 14px; box-sizing: border-box;
  transition: border-color .15s ease;
}
.admin-add-form select:focus,
.admin-add-form input[type="text"]:focus,
.admin-add-form textarea:focus { outline: none; border-color: var(--sky); }
.admin-add-form textarea { resize: vertical; min-height: 80px; }

/* ========== Toast ========== */
.toast {
  position: fixed; bottom: 36px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 26px;
  z-index: 50; font-size: 15px; font-weight: 700;
  box-shadow: 0 6px 18px rgba(0,0,0,.22);
  animation: toastIn .3s var(--bounce);
}
@keyframes toastIn {
  from { transform: translate(-50%, 30px); opacity: 0; }
  to   { transform: translate(-50%, 0); opacity: 1; }
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .app-header { padding: 12px 14px; }
  .app-title { font-size: 24px; }
  .tabs { padding: 10px 12px 0; gap: 6px; }
  .tab { padding: 10px 14px; font-size: 14px; }
  .tab .tab-emoji { font-size: 18px; }
  .app-main {
    margin: 0 10px 16px;
    padding: 22px 16px;
    border-radius: 0 16px 16px 16px;
  }
  .form-row { margin-bottom: 18px; }
  .form-row label { font-size: 15px; }
  .chip { padding: 9px 14px; font-size: 14px; min-height: 40px; }
  .card-stage { gap: 22px; }
  .primary-btn { padding: 13px 24px; font-size: 15px; }
  .ghost-btn { padding: 11px 18px; font-size: 14px; }
  .modal-inner { padding: 28px 22px 22px; }

  .count-banner { padding: 14px 18px; }
  .count-num { font-size: 26px; }

  /* admin */
  .admin-header { padding: 12px 14px; }
  .admin-title-row h2 { font-size: 19px; }
  .admin-tools { gap: 8px; }
  .admin-content { padding: 14px 12px; }
  .admin-search-wrap input[type="search"] { min-width: 0; }
}

@media (max-width: 480px) {
  :root {
    --card-w: 240px;
    --card-h: 332px;
    --fs-base: 15px;
  }
  .app-title { font-size: 22px; }
  .header-right { gap: 6px; }
  .lang-btn { padding: 7px 12px; font-size: 13px; }
  .help-btn { width: 36px; height: 36px; font-size: 16px; }

  .app-main {
    margin: 0 8px 12px;
    padding: 18px 12px;
  }
  h2 { font-size: 22px; }

  .tab { padding: 9px 12px; font-size: 13px; gap: 5px; }
  .tab .tab-emoji { font-size: 16px; }
  /* On very small screens hide tab labels — emoji + active accent enough */
  .tab .tab-label { display: inline; }

  .card-stage { gap: 18px; }
  .card-question { font-size: 16px; }
  .quote-mark { font-size: 46px; }
  .back-title { font-size: 28px; }
  .back-mark { font-size: 52px; }
  .back-tagline { font-size: 13px; }

  .form-row { margin-bottom: 16px; }
  .chip-group { gap: 8px; }
  .chip { padding: 8px 12px; font-size: 13px; }
  .chip .chip-emoji { font-size: 14px; }

  .draw-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .draw-card { max-width: none; }
  .draw-card .d-q { font-size: 12px; }
  .draw-card .face.back .b-title { font-size: 18px; }
  .draw-card .face.back .b-mark  { font-size: 32px; }

  .lotto-card .face.front .l-q { font-size: 16px; }
  .lotto-card .face.front .l-quote-l,
  .lotto-card .face.front .l-quote-r { font-size: 46px; }
  .lotto-card .face.back .b-title { font-size: 26px; }
  .lotto-card .face.back .b-mark { font-size: 50px; }

  .action-row { gap: 8px; }
  .primary-btn { padding: 12px 20px; font-size: 14px; }
  .ghost-btn   { padding: 10px 16px; font-size: 14px; }

  .emoji-picker { padding: 14px; }
  .emoji-list button { width: 40px; height: 40px; font-size: 20px; }

  .modal-inner { padding: 26px 18px 20px; width: 100%; }
  .modal-inner h3 { font-size: 20px; }

  .count-banner { padding: 12px 16px; gap: 10px; }
  .count-icon { font-size: 26px; }
  .count-text { font-size: 13px; }
  .count-num { font-size: 24px; }

  /* admin: mobile */
  .admin-tools { width: 100%; }
  .admin-tools input[type="search"],
  .admin-tools select { flex: 1; min-width: 100px; }
  .admin-cards { grid-template-columns: 1fr; }
  /* Hide bulky list view on tiny screens (card view is more readable) */
  .admin-table { font-size: 12px; }
}
