@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css');

:root {
  --bg: #f5efe7;
  --card: #ffffff;
  --ink: #2a1d16;
  --muted: #7d6d61;
  --line: #e6dccf;
  --choco: #3b2216;
  --choco2: #55311f;
  --red: #d8323c;
  --red-dark: #b32630;
  --gold: #d4a017;
  --blue: #2f6fd6;
  --green: #1f9e7a;
  --soft: #faf6f0;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(59, 34, 22, .06), 0 8px 24px rgba(59, 34, 22, .07);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Pretendard', system-ui, -apple-system, 'Malgun Gothic', sans-serif;
  font-size: 18px;
  overflow: hidden;
}
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
svg.px { image-rendering: pixelated; display: block; filter: var(--glow, none); }

/* 등급 표식: 희귀는 파란 테, 전설은 금빛이 천천히 숨 쉰다. 선생님 특제는 모두가 받으니 옅게만. */
svg.px.r-rare { --glow: drop-shadow(0 0 var(--gr, 2px) rgba(47, 111, 214, .42)); }
svg.px.r-legend { --glow: drop-shadow(0 0 var(--gr, 4px) rgba(240, 150, 0, .9)); }
svg.px.r-special { --glow: drop-shadow(0 0 var(--gr, 2px) rgba(216, 50, 60, .22)); }
svg.px.r-legend .aura { animation: aura 2.6s steps(8) infinite alternate; }
.card3d svg.px .aura, .delivered svg.px .aura, .legendpop svg.px .aura { animation-timing-function: ease-in-out; }
svg.px .tw { opacity: 0; animation: twinkle 2.7s steps(1) infinite; }
@keyframes aura { from { opacity: .45; } to { opacity: 1; } }
@keyframes twinkle { 0% { opacity: 0; } 58% { opacity: .55; } 72% { opacity: 1; } 86% { opacity: .55; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  svg.px.r-legend .aura { animation: none; }
  svg.px .tw { animation: none; opacity: .8; }
}

/* 상단 바 */
.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  background: var(--choco);
  color: #f7ecdf;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; letter-spacing: -0.02em; white-space: nowrap; }
.brand svg { height: 40px; width: auto; transform: rotate(28deg); }
.tabs { display: flex; gap: 6px; margin: 0 auto; }
.tabs button {
  border: 0; background: transparent; color: #cdb9a7;
  padding: 10px 22px; border-radius: 12px; font-size: 19px; font-weight: 700;
}
.tabs button.on { background: #f7ecdf; color: var(--choco); }
.tabs button .badge { display: inline-block; min-width: 24px; padding: 1px 7px; margin-left: 6px; border-radius: 99px; background: var(--red); color: #fff; font-size: 14px; }
.me { margin-left: auto; display: flex; gap: 10px; align-items: center; font-size: 17px; white-space: nowrap; }
.tabs + .me { margin-left: 0; }
.tabs.hidden + .me { margin-left: auto; }
.chip { padding: 6px 12px; border-radius: 99px; background: rgba(255, 255, 255, .1); }
.chip b { color: #ffd77a; }
.chip.cname { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.outbtn { position: relative; border: 1px solid rgba(255, 255, 255, .25); background: transparent; color: #cdb9a7; border-radius: 10px; padding: 7px 12px; margin-left: -8px; font-size: 15px; font-weight: 700; white-space: nowrap; }
.outbtn:hover { background: rgba(255, 255, 255, .1); color: #f7ecdf; }
.outbtn.arm, .outbtn.arm:hover { background: var(--red); border-color: var(--red); color: #fff; }
.outbtn.arm::after {
  content: '한 번 더 누르면 나가요'; position: absolute; top: calc(100% + 14px); right: 0; z-index: 40;
  padding: 9px 14px; border-radius: 10px; background: var(--choco); color: #fff; font-size: 16px; box-shadow: 0 8px 20px rgba(0, 0, 0, .25);
}
.helpbtn { border: 1px solid rgba(255, 255, 255, .25); background: transparent; color: #cdb9a7; border-radius: 10px; padding: 7px 12px; font-size: 15px; font-weight: 700; white-space: nowrap; }
.helpbtn:hover { background: rgba(255, 255, 255, .1); color: #f7ecdf; }

main { height: calc(100% - 68px); padding: 20px 24px; }
.view { height: 100%; }

/* 공통 카드와 버튼 */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.panel h2 { margin: 0 0 4px; font-size: 21px; letter-spacing: -0.02em; }
.panel .sub { margin: 0 0 14px; color: var(--muted); font-size: 16px; }
.scroll { overflow-y: auto; min-height: 0; flex: 1; }

.btn {
  border: 0; border-radius: 14px; padding: 14px 26px;
  background: var(--red); color: #fff; font-weight: 800; font-size: 20px;
  box-shadow: 0 3px 0 var(--red-dark);
  transition: transform .06s, box-shadow .06s, opacity .2s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--red-dark); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: var(--soft); color: var(--ink); box-shadow: 0 2px 0 var(--line); border: 1px solid var(--line); }
.btn.dark { background: var(--choco2); box-shadow: 0 3px 0 #24140c; }
.btn.small { padding: 8px 14px; font-size: 16px; border-radius: 10px; }
.btn kbd { font: inherit; font-size: 14px; opacity: .75; margin-left: 8px; padding: 2px 6px; border: 1px solid currentColor; border-radius: 6px; }

.field { width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 14px 16px; font-size: 22px; background: #fff; outline: none; }
.field:focus { border-color: var(--choco2); }
.err { color: var(--red); font-weight: 700; min-height: 26px; margin: 10px 0 0; }

.rar { display: inline-block; font-size: 13px; font-weight: 800; padding: 2px 8px; border-radius: 6px; color: #fff; }
.rar.common { background: #8a7f73; }
.rar.rare { background: var(--blue); }
.rar.legend { background: var(--gold); }
.rar.special { background: var(--red); }
.rar.custom { background: var(--green); }

/* 번호 고르기 */
.numgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 10px; }
.numgrid button {
  height: 64px; border-radius: 12px; border: 2px solid var(--line); background: #fff;
  font-size: 24px; font-weight: 800; color: var(--ink); position: relative;
}
.numgrid button:hover:not(:disabled) { border-color: var(--choco2); }
.numgrid button.sel { background: var(--choco); color: #fff; border-color: var(--choco); }
/* 1~12번, 51~61번처럼 끊어진 번호는 새 줄에서 시작한다 */
.numgrid button.gs { grid-column-start: 1; }
.numgrid button.mine { border-color: var(--gold); }
.numgrid button:disabled { background: #efe9e1; color: #b7aa9d; cursor: not-allowed; }
.numgrid button .tag { position: absolute; left: 0; right: 0; bottom: 3px; font-size: 11px; font-weight: 700; color: var(--red); }
.numgrid button.sel .tag { color: #ffd77a; }

/* 입장 화면 */
.join { height: 100%; display: grid; place-items: center; }
.join .panel { width: min(560px, 100%); padding: 32px; }
.join .panel.wide { width: min(980px, 100%); max-height: 100%; }
.join h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: -0.03em; }
.join .row { display: flex; gap: 12px; margin-top: 18px; }
.teacherlink { align-self: flex-end; margin-top: 4px; font-size: 14px; color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--line); }
.teacherlink:hover { color: var(--ink); }
.join .row .field { flex: 1; text-align: center; letter-spacing: .3em; font-weight: 800; font-size: 32px; }

/* 첫 화면: 왼쪽은 놀이 설명, 오른쪽은 입장 코드 */
.landing { width: min(1180px, 100%); display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(340px, 1fr); gap: 48px; align-items: center; }
.hero { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.kicker { margin: 0 0 10px; font-size: 16px; font-weight: 800; color: var(--red); }
/* 첫 화면 오른쪽: 빼빼로데이 기간을 크게 적고, 그 아래에 입장 코드 */
.side { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.when { margin: 0; display: flex; flex-direction: column; gap: 2px; padding: 14px 22px 16px; border-radius: var(--radius); background: var(--choco); color: #fff; box-shadow: var(--shadow); }
.when span { font-size: 16px; font-weight: 800; color: #ffd77a; }
.when b { font-size: clamp(26px, 2.9vw, 40px); line-height: 1.15; font-weight: 900; letter-spacing: -0.03em; }
#v-code .hero h1 { margin: 0; font-size: 44px; line-height: 1.18; letter-spacing: -0.04em; }
.lead { margin: 14px 0 0; font-size: 18px; color: var(--muted); }
.flow { list-style: none; margin: 26px 0 0; padding: 0; counter-reset: flow; width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.flow li { counter-increment: flow; position: relative; display: flex; flex-direction: column; gap: 4px; padding: 14px 16px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.flow li::before { content: counter(flow); position: absolute; top: 12px; left: 12px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--choco); color: #fff; font-size: 14px; font-weight: 800; }
.flow .fart { height: 86px; margin-bottom: 6px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.flow .fart svg { height: 76px; width: auto; transform: rotate(16deg); }
#flowDex svg { height: 58px; }
.flow .fart svg.lock { filter: brightness(0); opacity: .13; }
.flow .fart svg.lock .aura, .flow .fart svg.lock .tw { display: none; }
.fmsg { align-self: flex-start; margin-top: 6px; padding: 6px 10px; border-radius: 10px 10px 10px 2px; background: var(--soft); border: 1px solid var(--line); font-size: 14px; font-weight: 700; }
.flow li > b { font-size: 19px; letter-spacing: -0.02em; }
.flow li > span { font-size: 15px; line-height: 1.45; color: var(--muted); word-break: keep-all; text-wrap: balance; }
.guidebtn { margin-top: 22px; }
#v-code .panel.entry { width: auto; padding: 30px 30px 24px; }
.entry h2 { font-size: 24px; margin-bottom: 6px; }

/* 뽑기 화면 */
.pullview { display: grid; grid-template-columns: 1.25fr 1fr; gap: 20px; height: 100%; }
.stage {
  position: relative; overflow: hidden;
  background: radial-gradient(circle at 50% 42%, #fff8ee 0, #f3e6d6 60%, #ead9c5 100%);
  align-items: center; justify-content: center; gap: 22px;
}
.stage .left { position: absolute; top: 18px; left: 22px; font-size: 17px; color: var(--muted); }
.stage .left b { font-size: 30px; color: var(--ink); margin: 0 2px; }
.stage .note { color: var(--muted); font-size: 16px; text-align: center; margin: 0; }

.scene { width: 220px; height: 220px; perspective: 900px; display: grid; place-items: center; margin-top: 10px; }
.cube { width: 150px; height: 150px; position: relative; transform-style: preserve-3d; animation: spin 9s linear infinite; }
.cube .f {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, transparent 42%, #f2c94c 42%, #f2c94c 58%, transparent 58%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .06) 0 8px, transparent 8px 16px),
    var(--red);
  border: 4px solid var(--red-dark);
  image-rendering: pixelated;
}
.cube .f.t, .cube .f.b {
  background:
    linear-gradient(90deg, transparent 42%, #f2c94c 42%, #f2c94c 58%, transparent 58%),
    linear-gradient(0deg, transparent 42%, #f2c94c 42%, #f2c94c 58%, transparent 58%),
    var(--red);
}
.cube .f1 { transform: translateZ(75px); }
.cube .f2 { transform: rotateY(180deg) translateZ(75px); }
.cube .f3 { transform: rotateY(90deg) translateZ(75px); filter: brightness(.86); }
.cube .f4 { transform: rotateY(-90deg) translateZ(75px); filter: brightness(.86); }
.cube .t { transform: rotateX(90deg) translateZ(75px); filter: brightness(1.08); }
.cube .b { transform: rotateX(-90deg) translateZ(75px); filter: brightness(.7); }
.cube .label {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-weight: 900; font-size: 22px; color: #fff; text-shadow: 0 2px 0 var(--red-dark); letter-spacing: -0.02em;
}
@keyframes spin { from { transform: rotateX(-22deg) rotateY(0); } to { transform: rotateX(-22deg) rotateY(360deg); } }
.scene.shake .cube { animation: spinfast .9s cubic-bezier(.3, .1, .3, 1) forwards; }
@keyframes spinfast {
  0% { transform: rotateX(-22deg) rotateY(0) scale(1); }
  30% { transform: rotateX(-10deg) rotateY(300deg) scale(.92); }
  70% { transform: rotateX(-30deg) rotateY(900deg) scale(1.1); }
  100% { transform: rotateX(-22deg) rotateY(1440deg) scale(1.25); opacity: .2; }
}
.pullbtn { font-size: 24px; padding: 18px 46px; }

.hand { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; align-content: start; }
.tile {
  border: 2px solid var(--line); border-radius: 14px; background: #fff; padding: 10px 6px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: var(--ink);
  position: relative;
}
.tile .art { height: 92px; display: flex; align-items: flex-end; justify-content: center; }
.tile .art svg { max-height: 92px; width: auto; height: auto; transform: rotate(18deg); }
.tile .nm { font-size: 14px; font-weight: 700; line-height: 1.25; word-break: keep-all; }
button.tile:hover { border-color: var(--choco2); }
.tile.sel { border-color: var(--red); background: #fff4f4; box-shadow: 0 0 0 3px rgba(216, 50, 60, .15); }
.tile.rare { border-color: #c3d5f4; background: linear-gradient(180deg, #f3f7ff, #fff); }
.tile.legend { border-color: #ead18a; background: linear-gradient(180deg, #fffaea, #fff); }
.tile.custom { border-color: #a9dccb; background: linear-gradient(180deg, #effaf6, #fff); }
.tile.sel.rare, .tile.sel.legend, .tile.sel.custom { border-color: var(--red); }
.tile .nm small { display: block; margin-top: 2px; font-size: 11px; font-weight: 700; color: var(--green); }
/* 수제 빼빼로를 만드는 칸 */
.tile.make { border-style: dashed; border-color: #8fcbb9; background: #f4fbf8; }
.tile.make .art { position: relative; }
.tile.make.new .art svg { opacity: .3; }
.tile.make.new .art::after {
  content: '+'; position: absolute; left: 50%; top: 50%; width: 38px; height: 38px; margin: -19px 0 0 -19px;
  border-radius: 50%; background: var(--green); color: #fff; font-size: 28px; font-weight: 800; line-height: 36px; text-align: center;
}
.empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 17px; line-height: 1.6; }
.hand .empty, .dex .empty { grid-column: 1 / -1; }
/* 뽑기 화면 아래: 받은 개수와 도감. 누르면 내 빼빼로 상자 */
.mysum { flex: none; margin-top: 12px; display: flex; align-items: baseline; gap: 8px; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--soft); color: var(--muted); font-size: 17px; font-weight: 700; text-align: left; }
.mysum > span { white-space: nowrap; }
.mysum b { font-size: 22px; color: var(--ink); margin: 0 1px; }
.mysum .dot { color: #c9bcae; }
.mysum .go { margin-left: auto; color: var(--red); font-size: 16px; white-space: nowrap; }
.mysum .go::after { content: ' ›'; }
.mysum:hover { border-color: var(--choco2); }

/* 선물하기 */
.giftview { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; height: 100%; }
.step { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--choco); color: #fff; font-size: 15px; margin-right: 6px; vertical-align: 2px; }
/* 번호 칸은 남는 높이에 맞춰 줄어든다. 30명이 크롬북 한 화면에 스크롤 없이 들어가게. */
.giftview .numgrid { grid-template-columns: repeat(5, 1fr); grid-auto-rows: minmax(40px, 52px); }
.giftview .numgrid button { height: auto; font-size: 20px; }
.surprise { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; }
.hint { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--soft); border: 1px dashed var(--line); font-size: 15px; line-height: 1.5; color: var(--muted); }
.hint b { color: var(--red); }
.hint span { white-space: nowrap; font-weight: 700; color: var(--ink); margin-left: 4px; }
.surprise b { font-size: 24px; letter-spacing: -0.02em; }
.surprise p { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.6; }
.qbox {
  width: 120px; height: 120px; display: grid; place-items: center;
  background: linear-gradient(90deg, transparent 42%, #f2c94c 42%, #f2c94c 58%, transparent 58%), var(--red);
  border: 5px solid var(--red-dark); border-radius: 8px;
  color: #fff; font-size: 64px; font-weight: 900; text-shadow: 0 3px 0 var(--red-dark);
  animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }
.delivered { display: flex; flex-direction: column; align-items: center; gap: 16px; color: #fff; text-align: center; }
.delivered .big { font-size: 40px; font-weight: 900; letter-spacing: -0.03em; }
.delivered .big b { color: #ffd77a; }
.delivered svg { height: 260px; width: auto; transform: rotate(16deg); --gr: 9px; }
.delivered p { margin: 0; font-size: 18px; color: #f3e3d1; }
textarea.field { resize: none; height: 130px; font-size: 20px; line-height: 1.5; }
.count { text-align: right; color: var(--muted); font-size: 14px; margin: 6px 0 12px; }
.summary { display: flex; gap: 14px; align-items: center; background: var(--soft); border: 1px dashed var(--line); border-radius: 14px; padding: 12px; margin-bottom: 14px; min-height: 96px; }
.summary svg { max-height: 74px; width: auto; transform: rotate(18deg); }
.summary .t { font-size: 17px; line-height: 1.5; }
.summary .edit { margin-left: auto; flex: none; }
.flyaway { animation: fly .8s ease-in forwards; }
@keyframes fly { to { transform: translate(260px, -120px) rotate(40deg) scale(.4); opacity: 0; } }

/* 내 상자 */
.boxview { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; height: 100%; }
.dex { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; align-content: start; }
.dex .tile { padding: 6px 2px; gap: 3px; border-width: 1px; }
.dex .tile .art { height: 62px; }
.dex .tile .art svg { max-height: 62px; }
.dex .tile .nm { font-size: 12px; }
.dex .tile.locked .art svg { filter: brightness(0); opacity: .12; }
.dex .tile.locked .aura, .dex .tile.locked .tw { display: none; }
.dex .tile.locked .nm { color: #b9ab9d; }
.dex .tile .cnt { position: absolute; top: 4px; right: 6px; font-size: 12px; font-weight: 800; color: var(--red); }
.dex .tile .nm small { font-size: 10px; }
.dexsep { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 8px; margin-top: 8px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 16px; font-weight: 800; }
.dexsep b { color: var(--green); }
.dexsep span { font-size: 13px; font-weight: 500; color: var(--muted); }
.msgs { display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--soft); }
.msg svg { height: 58px; width: auto; transform: rotate(18deg); flex: none; }
.msg .who { font-size: 14px; color: var(--muted); font-weight: 700; }
.msg .who .rar { font-size: 11px; padding: 1px 6px; margin-left: 2px; vertical-align: 1px; }
.msg .txt { font-size: 18px; line-height: 1.45; word-break: break-all; }
.msg.hiddenmsg .txt { color: #b9ab9d; font-style: italic; }
.msg.new { animation: pop .6s ease; }
@keyframes pop { 0% { transform: scale(.9); background: #fff1c7; } 100% { transform: scale(1); } }

/* 결과 카드 (3D 뒤집기) */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(30, 18, 12, .62); backdrop-filter: blur(3px);
}
.reveal { display: flex; flex-direction: column; align-items: center; gap: 18px; perspective: 1200px; }
.card3d {
  width: 340px; height: 470px; position: relative; transform-style: preserve-3d;
  animation: flipin .9s cubic-bezier(.2, .8, .25, 1.15) both;
}
@keyframes flipin { from { transform: rotateY(540deg) scale(.4); } to { transform: rotateY(0) scale(1); } }
.card3d .face {
  position: absolute; inset: 0; border-radius: 22px; backface-visibility: hidden;
  background: #fffaf3; border: 6px solid #8a7f73;
  display: flex; flex-direction: column; align-items: center; padding: 18px 22px; text-align: center;
  box-shadow: 0 30px 60px rgba(0, 0, 0, .35);
}
.card3d.rare .face { border-color: var(--blue); }
.card3d.legend .face { border-color: var(--gold); background: radial-gradient(circle at 50% 35%, #fff6d6, #fffaf3 70%); }
.card3d.special .face { border-color: var(--red); }
.card3d .art { flex: 1; display: grid; place-items: center; min-height: 0; width: 100%; }
.card3d .art svg { max-height: 290px; width: auto; height: auto; transform: rotate(16deg); --gr: 9px; filter: var(--glow, drop-shadow(0 0 0 transparent)) drop-shadow(6px 8px 0 rgba(59, 34, 22, .15)); }
.card3d .nm { font-size: 28px; font-weight: 900; margin: 8px 0 6px; letter-spacing: -0.03em; }
.card3d .ds { font-size: 17px; color: var(--muted); line-height: 1.5; word-break: keep-all; min-height: 52px; }
.rays { position: absolute; width: 900px; height: 900px; z-index: -1; pointer-events: none;
  background: repeating-conic-gradient(rgba(255, 215, 110, .28) 0 10deg, transparent 10deg 20deg);
  animation: rot 14s linear infinite; mask: radial-gradient(circle, #000 20%, transparent 62%); -webkit-mask: radial-gradient(circle, #000 20%, transparent 62%); }
@keyframes rot { to { transform: rotate(360deg); } }
.reveal .actions { display: flex; gap: 12px; }
.reveal .tip { color: #f3e3d1; font-size: 16px; margin: 0; }

/* 수제 빼빼로 만들기 창. 빼빼로를 가로로 눕혀 놓고 칸을 찍는다. */
.maker {
  width: min(1180px, calc(100vw - 48px)); max-height: calc(100vh - 24px); overflow-y: auto;
  background: var(--card); border-radius: 20px; padding: 22px 26px;
  display: flex; flex-direction: column; gap: 16px; box-shadow: 0 30px 60px rgba(0, 0, 0, .35); outline: none;
}
.mhead { display: flex; align-items: center; gap: 14px; }
.mhead h2 { margin: 0; font-size: 23px; letter-spacing: -0.02em; white-space: nowrap; }
.mhead p { margin: 0; flex: 1; color: var(--muted); font-size: 16px; }
.mbody { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 24px; }
.mleft { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.mstick { flex: 1; display: flex; align-items: center; padding: 18px 20px; background: var(--soft); border: 1px solid var(--line); border-radius: 14px; }
.mgrid {
  flex: 31 1 0; display: grid; grid-template-columns: repeat(31, 1fr); grid-template-rows: repeat(6, 1fr); aspect-ratio: 31 / 6;
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair;
}
.mgrid i { background: var(--base); box-shadow: inset 0 0 0 1px rgba(128, 128, 128, .3); }
.mgrid i.off { background: transparent; box-shadow: none; }
.mstub { flex: 3.5 1 0; aspect-ratio: 3.5 / 4; background: #e2b77a; border-radius: 0 4px 4px 0; box-shadow: inset 0 -5px 0 rgba(59, 34, 22, .12); }
.mrow { display: flex; align-items: center; gap: 12px; min-height: 38px; }
.mlab { flex: none; width: 40px; font-size: 16px; font-weight: 800; color: var(--muted); }
.msw { display: flex; flex-wrap: wrap; gap: 8px; }
.msw button { width: 36px; height: 36px; padding: 0; border: 1px solid rgba(42, 29, 22, .22); border-radius: 8px; background: var(--c); }
.msw.round button { border-radius: 50%; }
.msw button.on { box-shadow: 0 0 0 2px #fff, 0 0 0 5px var(--ink); }
.msw button.eraser { width: auto; padding: 0 14px; background: #fff; color: var(--ink); font-size: 15px; font-weight: 700; }
#mkBaseName { font-size: 16px; }
.mright { display: flex; flex-direction: column; gap: 10px; }
.mprev {
  flex: 1; min-height: 190px; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(circle at 50% 42%, #fff8ee 0, #f3e6d6 100%); border: 1px solid var(--line); border-radius: 14px;
}
.mprev svg { height: 170px; width: auto; transform: rotate(16deg); filter: drop-shadow(4px 6px 0 rgba(59, 34, 22, .15)); }
.mright label { font-size: 15px; font-weight: 800; color: var(--muted); margin-bottom: -4px; }
.maker .field { font-size: 19px; padding: 11px 14px; }
.mnote { margin: 0; font-size: 14px; color: var(--muted); text-align: center; }
.mnote b { color: var(--green); }

/* 사용법 창. 왼쪽은 화면 캡처, 오른쪽은 설명. 빨간 테두리가 볼 곳을 차례로 짚는다. */
#guide { z-index: 70; }
.guide {
  width: min(1480px, calc(100vw - 48px), calc((100vh - 130px) * 2 + 470px));
  max-height: calc(100vh - 24px); overflow-y: auto;
  background: var(--card); border-radius: 20px; padding: 18px 24px 22px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 30px 60px rgba(0, 0, 0, .35); outline: none;
}
.ghead { display: flex; align-items: center; gap: 16px; }
.ghead h2 { margin: 0; font-size: 23px; letter-spacing: -0.02em; white-space: nowrap; }
.gseg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--soft); border: 1px solid var(--line); }
.gseg button { border: 0; background: transparent; color: var(--muted); padding: 6px 16px; border-radius: 9px; font-size: 16px; font-weight: 800; white-space: nowrap; }
.gseg button.on { background: var(--choco2); color: #fff; }
.gcount { margin-left: auto; font-size: 16px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.gbody { display: grid; grid-template-columns: minmax(0, 1fr) clamp(320px, 26vw, 400px); gap: 24px; }
.gshot { position: relative; align-self: start; }
.gclip { position: absolute; inset: 0; overflow: hidden; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); }
.gclip img { display: block; width: 100%; height: 100%; opacity: 0; }
.gclip img.in { opacity: 1; transition: opacity .35s ease; }
.gspot {
  position: absolute; border: 3px solid var(--red); border-radius: 10px; pointer-events: none; opacity: 0;
  box-shadow: 0 0 0 3000px rgba(30, 18, 12, .3);
  transition: left .6s cubic-bezier(.4, 0, .2, 1), top .6s cubic-bezier(.4, 0, .2, 1), width .6s cubic-bezier(.4, 0, .2, 1), height .6s cubic-bezier(.4, 0, .2, 1), opacity .3s;
}
.gspot::after { content: ''; position: absolute; inset: -3px; border: 3px solid var(--red); border-radius: 12px; animation: gping 1.6s ease-out infinite; }
@keyframes gping { from { inset: -3px; opacity: .9; } to { inset: -15px; opacity: 0; } }
.gtag {
  position: absolute; display: flex; align-items: center; gap: 8px; max-width: 64%; padding: 5px 12px 5px 5px; border-radius: 99px;
  background: var(--choco); color: #fff; font-size: 15px; font-weight: 700; white-space: nowrap; pointer-events: none; opacity: 0;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .25);
  transition: opacity .22s;
}
.gtag b { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--red); font-size: 14px; }
.gtag span { overflow: hidden; text-overflow: ellipsis; }
.gspot.show, .gtag.show { opacity: 1; }
.gtext { min-width: 0; display: flex; flex-direction: column; gap: 9px; }
.gtext.in { animation: gin .35s ease; }
@keyframes gin { from { opacity: 0; transform: translateX(14px); } }
.gbar { display: flex; gap: 6px; }
.gbar button { flex: 1; height: 14px; padding: 0; border: 0; background: linear-gradient(var(--line), var(--line)) center / 100% 6px no-repeat; }
.gbar button.on { background-image: linear-gradient(var(--red), var(--red)); }
.gtext h3 { margin: 2px 0 0; font-size: clamp(22px, 3.4vh, 30px); line-height: 1.25; letter-spacing: -0.03em; word-break: keep-all; }
#gDesc { margin: 0; font-size: clamp(16px, 2.4vh, 20px); line-height: 1.55; word-break: keep-all; }
.gpts { list-style: none; margin: 2px 0 0; padding: 0; counter-reset: gp; display: flex; flex-direction: column; gap: 2px; }
.gpts li {
  counter-increment: gp; display: flex; align-items: flex-start; gap: 10px; padding: 6px 10px; border-radius: 10px;
  font-size: clamp(15px, 2.3vh, 19px); font-weight: 700; line-height: 1.4; color: var(--muted); cursor: pointer; word-break: keep-all;
  transition: background .25s, color .25s;
}
.gpts li::before {
  content: counter(gp); flex: none; width: 24px; height: 24px; margin-top: 1px; border-radius: 50%; display: grid; place-items: center;
  background: var(--line); color: var(--ink); font-size: 14px; font-weight: 800; transition: background .25s, color .25s;
}
.gpts li.on { background: #fff4f4; color: var(--ink); }
.gpts li.on::before { background: var(--red); color: #fff; }
.gnote { margin: 0; padding: 9px 12px; border-radius: 10px; background: var(--soft); border: 1px dashed var(--line); font-size: 15px; line-height: 1.5; color: var(--muted); word-break: keep-all; }
.gnav { margin-top: auto; padding-top: 4px; display: flex; gap: 10px; }
.gnav .btn { flex: 1; padding: 12px 16px; font-size: 18px; }
.gnav .btn.ghost { flex: 0 0 auto; }
@media (prefers-reduced-motion: reduce) {
  .gspot, .gtag, .gclip img.in { transition: none; }
  .gspot::after, .gtext.in { animation: none; }
}

/* 알림 */
#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--choco); color: #fff; padding: 14px 22px; border-radius: 14px; font-size: 18px; font-weight: 700; box-shadow: var(--shadow); animation: tin .25s ease; }
@keyframes tin { from { transform: translateY(14px); opacity: 0; } }

.closed-banner { background: #fff1c7; border: 1px solid #ecd58a; color: #6b5310; border-radius: 12px; padding: 10px 14px; font-weight: 700; font-size: 16px; text-align: center; }

@media (max-height: 640px) {
  .scene { transform: scale(.8); margin: -20px 0; }
  .card3d { width: 300px; height: 410px; }
  .card3d .art svg { max-height: 230px; }
  .giftview .numgrid { gap: 6px; grid-auto-rows: minmax(36px, 52px); }
  .maker { padding: 16px 22px; gap: 12px; }
  .mstick { padding: 12px 16px; }
  .mprev { min-height: 150px; }
  .mprev svg { height: 130px; }
  #v-code .hero h1 { font-size: 40px; }
  .flow { margin-top: 22px; }
  .flow .fart { height: 76px; }
  .flow .fart svg { height: 68px; }
  #flowDex svg { height: 52px; }
}

/* 손가락으로 쓰는 기기에서는 엔터 안내를 숨긴다 */
@media (hover: none) and (pointer: coarse) {
  .btn kbd { display: none; }
}

/* 휴대폰 세로 화면: 한 화면에 맞추지 않고 페이지를 위아래로 넘긴다.
   위쪽 막대는 두 줄(로고·버튼 / 탭)로 나누고, 패널은 위아래로 쌓는다. */
@media (max-width: 760px) {
  html, body { height: auto; min-height: 100%; }
  body { overflow-x: hidden; overflow-y: auto; }
  .topbar { position: sticky; top: 0; z-index: 30; height: auto; min-height: 56px; flex-wrap: wrap; padding: 8px 12px; gap: 8px 10px; }
  .brand { font-size: 18px; }
  .brand svg { height: 32px; }
  .topbar:has(.tabs:not(.hidden)) .bname { display: none; }
  .tabs { order: 10; width: 100%; margin: 0; gap: 4px; }
  .tabs button { flex: 1; padding: 8px 4px; font-size: 16px; white-space: nowrap; }
  .tabs button .badge { margin-left: 4px; }
  .tabs + .me { margin-left: auto; }
  .me { gap: 6px; font-size: 14px; }
  .chip { padding: 4px 9px; }
  .chip.cname { display: none; }
  .outbtn, .helpbtn { padding: 6px 9px; font-size: 14px; }
  .outbtn { margin-left: -4px; }
  main { height: auto; padding: 12px; }
  .view { height: auto; }
  .panel { padding: 16px; scroll-margin-top: 112px; }

  /* 입장 */
  .join { height: auto; place-items: start center; }
  .join .panel { padding: 22px 18px; }
  .join h1 { font-size: 24px; }
  .numgrid { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
  .numgrid button { height: 56px; font-size: 21px; }

  /* 뽑기 · 선물하기 · 내 상자 */
  .pullview, .giftview, .boxview { grid-template-columns: minmax(0, 1fr); height: auto; gap: 12px; }
  .stage { min-height: 380px; padding-top: 56px; }
  .stage .left { top: 14px; left: 16px; }
  .hand { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .mysum { padding: 10px 14px; font-size: 15px; }
  .mysum b { font-size: 20px; }
  .mysum .gt { display: none; }
  .mysum .go::after { font-size: 22px; }
  .tile .art { height: 80px; }
  .tile .art svg { max-height: 80px; }
  .giftview .numgrid { grid-auto-rows: 48px; gap: 6px; }
  textarea.field { height: 110px; font-size: 18px; }
  .boxview > .panel:nth-child(2) { order: -1; }
  .dex { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  /* 결과 카드와 깜짝 배달 */
  .overlay { overflow: hidden; }
  .reveal { padding: 0 12px; gap: 14px; }
  .card3d { width: min(300px, 78vw); height: min(420px, 58vh); }
  .card3d .art svg { max-height: min(240px, 30vh); }
  .card3d .nm { font-size: 24px; }
  .card3d .ds { font-size: 15px; }
  .reveal .actions { flex-wrap: wrap; justify-content: center; }
  .rays { width: 640px; height: 640px; }
  .delivered { padding: 0 16px; }
  .delivered .big { font-size: 26px; }
  .delivered svg { height: 200px; }

  /* 수제 빼빼로: 휴대폰에서는 빼빼로를 세워서 그린다. 왼쪽은 빼빼로, 오른쪽은 도구. */
  .maker { width: calc(100vw - 16px); max-height: calc(100vh - 16px); padding: 14px; gap: 10px; border-radius: 16px; }
  .mhead { flex-wrap: wrap; gap: 4px 10px; }
  .mhead h2 { font-size: 19px; }
  .mhead p { order: 3; flex-basis: 100%; font-size: 14px; }
  #mkClose { margin-left: auto; }
  .mbody { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: repeat(6, auto) 1fr; column-gap: 14px; row-gap: 10px; align-items: start; }
  .mleft, .mright { display: contents; }
  .mstick { grid-column: 1; grid-row: 1 / 8; flex-direction: column; align-items: center; padding: 8px; }
  .mrow, .mright > * { grid-column: 2; }
  .mprev { display: none; }
  .mrow { flex-wrap: wrap; gap: 6px 8px; min-height: 0; }
  .mlab { width: 100%; font-size: 14px; }
  .msw { gap: 6px; }
  .msw button { width: 30px; height: 30px; }
  .msw button.eraser { padding: 0 10px; font-size: 14px; }
  #mkBaseName { font-size: 14px; }
  .mright label { margin: 0; }
  .maker .field { font-size: 17px; padding: 9px 12px; }
  .mrow .btn.small { padding: 6px 10px; font-size: 14px; }
  .mnote { text-align: left; }
  /* 칸 크기는 화면 높이에 맞춘다: 빼빼로 31칸 + 손잡이 3.5칸 */
  .mstick.vert { --cs: min(calc((100vh - 180px) / 34.5), 24px); }
  .mgrid.vert { flex: none; width: calc(var(--cs) * 6); height: calc(var(--cs) * 31); aspect-ratio: auto; grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(31, 1fr); }
  .mstick.vert .mstub { flex: none; width: calc(var(--cs) * 4); height: calc(var(--cs) * 3.5); aspect-ratio: auto; border-radius: 0 0 4px 4px; box-shadow: inset -5px 0 0 rgba(59, 34, 22, .12); }

  /* 첫 화면 */
  .landing { grid-template-columns: 1fr; gap: 22px; padding-bottom: 8px; }
  .side { order: -1; gap: 10px; }
  #v-code .panel.entry { padding: 22px 20px 16px; }
  .entry h2 { font-size: 22px; }
  .join .row .field { min-width: 0; font-size: 28px; }
  .kicker { font-size: 15px; margin-bottom: 6px; }
  .when { padding: 10px 18px 12px; }
  .when span { font-size: 14px; }
  .when b { font-size: 28px; }
  #v-code .hero h1 { font-size: 30px; }
  .lead { font-size: 16px; margin-top: 10px; }
  .flow { grid-template-columns: 1fr; gap: 8px; margin-top: 18px; }
  .flow li { display: grid; grid-template-columns: 104px minmax(0, 1fr); align-content: center; column-gap: 14px; row-gap: 2px; padding: 10px 14px 10px 40px; }
  .flow li::before { top: 50%; left: 10px; margin-top: -13px; }
  .flow .fart { grid-row: 1 / 3; height: 64px; margin: 0; }
  .flow .fart svg { height: 56px; }
  #flowDex svg { height: 42px; }
  .fmsg { font-size: 12px; padding: 4px 7px; margin-top: 2px; }
  .guidebtn { width: 100%; margin-top: 16px; }

  /* 사용법 창 */
  .guide { width: calc(100vw - 16px); max-height: calc(100vh - 16px); padding: 14px 14px 16px; gap: 12px; border-radius: 16px; }
  .ghead { gap: 10px; }
  .ghead h2 { font-size: 20px; }
  .gseg button { padding: 5px 11px; font-size: 15px; }
  .gcount { font-size: 14px; }
  .gbody { grid-template-columns: 1fr; gap: 12px; }
  .gtag { font-size: 12px; gap: 5px; padding: 3px 9px 3px 3px; max-width: 80%; }
  .gtag b { width: 18px; height: 18px; font-size: 11px; }
  .gtext h3 { font-size: 21px; }
  #gDesc { font-size: 16px; }
  .gpts li { font-size: 15px; padding: 5px 8px; }
  .gnote { font-size: 14px; }
}
/* 주소 막대가 들어갔다 나왔다 하는 휴대폰에서는 보이는 높이에 맞춘다 */
@supports (height: 100dvh) {
  @media (max-width: 760px) {
    .maker, .guide { max-height: calc(100dvh - 16px); }
    .mstick.vert { --cs: min(calc((100dvh - 180px) / 34.5), 24px); }
  }
}

/* 첫 화면 아래: 이용약관 · 개인정보처리방침 */
.join { position: relative; }
.legal { position: absolute; left: 0; right: 0; bottom: 4px; display: flex; justify-content: center; gap: 8px; font-size: 13px; color: var(--muted); }
.legal a { color: var(--muted); text-decoration: none; }
.legal a:hover { color: var(--ink); text-decoration: underline; }
@media (max-width: 760px) {
  .legal { position: static; margin: 20px 0 8px; }
}

/* 빼빼로데이가 끝난 뒤 첫 화면의 하루 기록: 도트 그림 칸, 올라가는 숫자, 쏟아지는 수제 빼빼로 */
.recap { position: relative; width: min(980px, 100%); padding: 16px 20px 0; border-radius: 16px; overflow: hidden; background: var(--choco); color: #f7ecdf; box-shadow: var(--shadow); }
.recap .rhead { position: relative; z-index: 2; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.recap .rhead b { font-size: 20px; letter-spacing: -0.02em; }
.recap .rhead span { color: #ffd77a; font-weight: 700; font-size: 16px; }
.recap .rnums { position: relative; z-index: 2; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.recap .rt { display: flex; flex-direction: column; align-items: center; padding: 8px 4px 9px; border-radius: 12px; background: rgba(255, 255, 255, .08); animation: rpop .5s cubic-bezier(.3, 1.3, .5, 1) calc(var(--i) * 90ms) both; }
.recap .ri { height: 60px; display: flex; align-items: center; justify-content: center; gap: 1px; margin-bottom: 2px; }
.recap .ri svg { height: 52px; width: auto; transform: rotate(18deg); }
.recap .ri svg.big { height: 60px; }
.recap .rt b { font-size: 26px; letter-spacing: -0.02em; line-height: 1.15; color: #fff; font-variant-numeric: tabular-nums; }
.recap .rt span { font-size: 13px; color: #cdb9a7; font-weight: 700; text-align: center; }
@keyframes rpop { from { opacity: 0; transform: translateY(12px) scale(.94); } }
.recap .rpile { position: relative; z-index: 1; height: 96px; margin: 4px -20px 0; cursor: pointer; }
.recap .rdrop { position: absolute; bottom: 0; animation: rfall .9s cubic-bezier(.35, 1.25, .5, 1) var(--d) both; }
.recap .rdrop svg { height: 54px; width: auto; display: block; }
@keyframes rfall {
  from { transform: translateY(-260px) rotate(var(--r0)); opacity: 0; }
  12% { opacity: 1; }
  to { transform: translateY(var(--y)) rotate(var(--r)); }
}
.hero .recap { margin-top: 22px; }
.hero:has(.recap:not(.hidden)) .flow { display: none; }
.join:has(> .recap:not(.hidden)) { align-content: center; gap: 16px; }
.join:has(> .recap:not(.hidden)) .classes { height: min(430px, 100%); }
@media (max-width: 760px) {
  .recap .rnums { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .recap .rpile { height: 80px; }
  .recap .rdrop svg { height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .recap .rt, .recap .rdrop { animation: none; }
  .recap .rdrop { transform: translateY(var(--y)) rotate(var(--r)); }
}

/* 내 상자: 받은 한마디 제목 옆 '그림으로 저장' */
.msghead { display: flex; align-items: center; gap: 10px; }
.msghead h2 { margin: 0 0 4px; }
.msghead .btn { margin-left: auto; }
