/* 붙어라! — 엿 색(호박빛) + 따뜻한 미색 종이 */
:root {
  --paper: #fbf6ec;
  --card: #ffffff;
  --ink: #2a2118;
  --sub: #7a6a58;
  --line: #ecdfca;
  --yeot: #c8791f;      /* 엿 */
  --yeot-deep: #8f4f0c;
  --yeot-soft: #fbe7c6;
  --ok: #2f7d4f;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ---------- 메인 ---------- */
.wrap { max-width: 720px; margin: 0 auto; padding: 20px 16px 48px; }
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand h1 { margin: 0; font-size: 28px; letter-spacing: -0.5px; }
.brand h1 b { color: var(--yeot); }
.brand small { color: var(--sub); font-size: 13px; }
.tagline { margin: 6px 0 18px; color: var(--sub); font-size: 15px; line-height: 1.5; }

.counter {
  background: linear-gradient(135deg, #e39a3b, var(--yeot-deep));
  color: #fff; border-radius: var(--radius); padding: 18px 20px;
  display: flex; justify-content: space-between; align-items: flex-end; gap: 12px;
  box-shadow: 0 8px 24px rgba(143, 79, 12, .25);
}
.counter .label { font-size: 14px; opacity: .9; }
.counter .num { font-size: 40px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.counter .today { text-align: right; font-size: 14px; opacity: .95; }
.counter .today b { display: block; font-size: 22px; }

.search { position: sticky; top: 0; z-index: 5; background: var(--paper); padding: 14px 0 10px; }
.search input {
  width: 100%; font-size: 17px; padding: 14px 16px 14px 44px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%237a6a58' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='9' cy='9' r='6.5'/%3E%3Cpath d='M14 14l4.5 4.5'/%3E%3C/svg%3E") no-repeat 16px center;
  outline: none; color: var(--ink);
}
.search input:focus { border-color: var(--yeot); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--card); color: var(--sub);
  border-radius: 999px; padding: 6px 12px; font-size: 14px;
}
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

h2 { font-size: 18px; margin: 26px 0 10px; }
h2 .hint { font-size: 13px; color: var(--sub); font-weight: 400; margin-left: 6px; }

.top { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.top li a { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.top li:first-child a { border-top: 0; }
.top .rank { width: 26px; text-align: center; font-weight: 800; color: var(--sub); }
.top li:nth-child(-n+3) .rank { color: var(--yeot); font-size: 18px; }
.top .nm { flex: 1; font-weight: 600; }
.top .nm small { color: var(--sub); font-weight: 400; margin-left: 6px; }
.top .n { font-variant-numeric: tabular-nums; color: var(--yeot-deep); font-weight: 700; }
.empty { padding: 18px 16px; color: var(--sub); text-align: center; font-size: 15px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.u {
  display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); position: relative; min-height: 64px;
}
.u:active { transform: scale(.98); }
.u .gate { position: absolute; right: 10px; top: 12px; width: 18px; height: 14px; border-radius: 3px 3px 0 0; }
.u b { font-size: 15px; padding-right: 24px; word-break: keep-all; }
.u span { font-size: 12px; color: var(--sub); }
.u .c { color: var(--yeot-deep); }
.foot { margin-top: 28px; font-size: 12px; color: var(--sub); line-height: 1.6; }

/* ---------- 대학 방 ---------- */
body.room { overflow: hidden; height: 100dvh; background: #cfe3f0; overscroll-behavior: none; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.bar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 3; display: flex; align-items: center; gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(rgba(255,255,255,.85), rgba(255,255,255,0));
}
.back { width: 40px; height: 40px; border-radius: 50%; border: 0; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.12); font-size: 20px; display: grid; place-items: center; }
.bar .title { flex: 1; min-width: 0; }
.bar .title b { display: block; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .title span { font-size: 12px; color: var(--sub); }
.drag-hint { position: fixed; left: 50%; top: 54%; transform: translate(-50%, -50%); z-index: 2; background: rgba(42,33,24,.7); color: #fff; padding: 8px 14px; border-radius: 999px; font-size: 14px; pointer-events: none; transition: opacity .6s; }

.panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3;
  padding: 14px 16px max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(rgba(251,246,236,0), rgba(251,246,236,.95) 28%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.panel .count { text-align: center; }
.panel .count .big { font-size: 34px; font-weight: 800; color: var(--yeot-deep); font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.panel .count .small { font-size: 13px; color: var(--sub); }
.stick {
  width: 100%; max-width: 420px; border: 0; border-radius: 999px; padding: 17px 20px;
  font-size: 19px; font-weight: 800; color: #fff;
  background: linear-gradient(180deg, #e39a3b, var(--yeot-deep));
  box-shadow: 0 6px 0 #6b3a07, 0 10px 24px rgba(143,79,12,.35);
  transition: transform .08s, box-shadow .08s;
}
.stick:active { transform: translateY(4px); box-shadow: 0 2px 0 #6b3a07, 0 6px 14px rgba(143,79,12,.3); }
.stick:disabled { opacity: .7; }
.mine { font-size: 12px; color: var(--sub); }

.toast {
  position: fixed; left: 50%; top: 84px; z-index: 4; transform: translate(-50%, -20px); opacity: 0;
  background: #fff; color: var(--ink); border: 2px solid var(--yeot); border-radius: 14px;
  padding: 10px 16px; font-weight: 700; font-size: 16px; text-align: center; box-shadow: 0 8px 20px rgba(0,0,0,.12);
  transition: transform .25s, opacity .25s; pointer-events: none; width: max-content; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast b { color: var(--yeot-deep); }
.nogl { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--sub); }

/* 품질 개선 (2026-11-04) */
.panel .count .big.bump { animation: bump .45s ease-out; }
@keyframes bump { 0% { transform: scale(1); } 30% { transform: scale(1.25); color: #e0801a; } 100% { transform: scale(1); } }
.toast.special { background: linear-gradient(135deg, #fff6df, #ffe2b0); border-color: #e0801a; font-size: 17px; }

.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.hero .tagline { margin-bottom: 14px; }
.hero-gate { width: 112px; flex: none; margin-bottom: 6px; filter: drop-shadow(0 4px 6px rgba(143,79,12,.15)); }
.live {
  margin-top: 10px; display: flex; align-items: center; gap: 10px; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px; font-size: 14px; color: var(--sub);
}
.live .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #e0801a; box-shadow: 0 0 0 0 rgba(224,128,26,.6); animation: ping 1.6s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 8px rgba(224,128,26,0); } 100% { box-shadow: 0 0 0 0 rgba(224,128,26,0); } }
#liveText { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#liveText b { color: var(--ink); }
#liveText.in { animation: slideIn .4s ease-out; }
@keyframes slideIn { from { transform: translateY(100%); opacity: 0; } to { transform: none; opacity: 1; } }
.top li { position: relative; }
.top li::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: var(--w, 0%); background: var(--yeot-soft); opacity: .7; transition: width .6s; }
.top li a { position: relative; }
.u .gate { width: 24px; height: 20px; top: 10px; border-radius: 0; }
.u { transition: border-color .15s, box-shadow .15s; }
.u:hover { border-color: var(--yeot); box-shadow: 0 4px 12px rgba(143,79,12,.12); }

/* 물건 고르기 (2026-11-04) — 옆으로 넘겨서 엿·찹쌀떡·포크 */
.picker { width: 100%; max-width: 420px; display: flex; align-items: center; gap: 6px; }
.pk-arrow {
  flex: none; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 22px; line-height: 1; display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.pk-arrow:disabled { opacity: .3; }
.pk-track {
  flex: 1; min-width: 0; display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; overscroll-behavior-x: contain; touch-action: pan-x;
}
.pk-track::-webkit-scrollbar { display: none; }
.pk-item {
  flex: 0 0 100%; scroll-snap-align: center; display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 8px 10px; border-radius: 16px; background: rgba(255,255,255,.75); border: 1px solid var(--line);
}
.pk-icon { width: 54px; height: 54px; flex: none; transition: transform .3s; }
.pk-icon svg { width: 100%; height: 100%; }
.pk-item.on .pk-icon { transform: scale(1.12) rotate(-6deg); }
.pk-text { display: flex; flex-direction: column; }
.pk-text b { font-size: 18px; }
.pk-text span { font-size: 13px; color: var(--yeot-deep); font-weight: 700; }
.pk-dots { display: flex; gap: 6px; margin-top: -4px; }
.pk-dots i { width: 7px; height: 7px; border-radius: 50%; background: #d9c9ad; cursor: pointer; transition: width .2s; }
.pk-dots i.on { width: 18px; border-radius: 4px; background: var(--yeot); }
.panel { gap: 8px; }
.panel .count .big { font-size: 30px; }
@media (max-height: 640px) { .pk-icon { width: 42px; height: 42px; } .panel .count .big { font-size: 24px; } }

/* 3D 돌려 고르기 (2026-11-04) */
.pk-stage {
  flex: 1; min-width: 0; height: 118px; display: block; touch-action: none; cursor: grab;
  border-radius: 20px;
  background: radial-gradient(ellipse at 50% 70%, rgba(255,226,176,.85), rgba(255,255,255,0) 70%);
}
.pk-stage:active { cursor: grabbing; }
.pk-label { display: flex; align-items: baseline; gap: 8px; margin-top: -6px; }
.pk-label b { font-size: 18px; }
.pk-label span { font-size: 14px; color: var(--yeot-deep); font-weight: 700; }
.pk-label.in { animation: pkIn .3s ease-out; }
@keyframes pkIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (max-height: 640px) { .pk-stage { height: 90px; } }

/* 처음 온 사람 안내 (11/04 사장님: 젠지는 엿 붙이기를 모름) */
.hero-go {
  display: inline-block; margin: -4px 0 14px; padding: 11px 16px; border: 0; border-radius: 999px;
  font-size: 15px; font-weight: 800; color: #fff; background: linear-gradient(180deg, #e39a3b, var(--yeot-deep));
  box-shadow: 0 4px 0 #6b3a07, 0 8px 18px rgba(143,79,12,.25); cursor: pointer;
}
.hero-go:active { transform: translateY(3px); box-shadow: 0 1px 0 #6b3a07; }
.search.flash { animation: searchFlash 1.2s ease-out; border-radius: 14px; }
@keyframes searchFlash { 0%, 60% { box-shadow: 0 0 0 4px rgba(224,128,26,.45); } 100% { box-shadow: 0 0 0 0 rgba(224,128,26,0); } }

/* 대학 방 첫 방문: 손가락이 위로 슥 + 말풍선 */
.coach { position: fixed; inset: 0; z-index: 5; pointer-events: none; opacity: 0; transition: opacity .35s; }
.coach.show { opacity: 1; }
.coach-bubble {
  position: absolute; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 40px);
  background: #2a2118; color: #fff; font-weight: 800; font-size: 16px; text-align: center; line-height: 1.45;
  padding: 10px 16px; border-radius: 16px; box-shadow: 0 8px 20px rgba(0,0,0,.25);
}
.coach-bubble small { display: block; font-size: 12px; font-weight: 600; color: #ffd98a; }
.coach-bubble::after { content: ""; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%) rotate(45deg); width: 14px; height: 14px; background: #2a2118; }
.coach-hand { position: absolute; left: 50%; font-size: 44px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.3)); animation: coachSwipe 1.5s ease-in-out infinite; }
@keyframes coachSwipe {
  0% { transform: translate(-30%, 0) scale(1); opacity: 0; }
  12% { opacity: 1; transform: translate(-30%, 0) scale(.92); }
  55% { transform: translate(-30%, -90px) scale(1); opacity: 1; }
  75%, 100% { transform: translate(-30%, -110px); opacity: 0; }
}

/* 메인 정리 (11/04 사장님): 목록 위로 · 더 보기 · 하단 메뉴 4칸 */
#listTitle, #topBox, #campusBox { scroll-margin-top: 12px; }
.more-list {
  display: block; width: 100%; margin: 10px 0 4px; padding: 12px; border-radius: 14px;
  border: 1px dashed var(--line); background: var(--card); color: var(--yeot-deep); font-size: 15px; font-weight: 800; cursor: pointer;
}
.more-list[hidden] { display: none; }
#topBox.flash, #campusBox.flash { animation: secFlash 1.3s ease-out; border-radius: 16px; }
@keyframes secFlash { 0%, 50% { box-shadow: 0 0 0 4px rgba(224,128,26,.35); } 100% { box-shadow: 0 0 0 0 rgba(224,128,26,0); } }
.wrap { padding-bottom: calc(80px + env(safe-area-inset-bottom)); } /* 하단 메뉴에 맨 아래가 가리지 않게 */
.tabbar {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 40; width: 100%; max-width: 560px;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 6px max(6px, env(safe-area-inset-bottom));
  background: rgba(255,251,243,.96); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(80,50,20,.08);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.tabbar button {
  border: 0; background: none; padding: 4px 0; display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 12px; font-weight: 700; color: var(--ink); cursor: pointer; border-radius: 12px;
}
.tabbar button span { font-size: 21px; line-height: 1.2; }
.tabbar button:active { background: var(--yeot-soft); }
.view[hidden] { display: none !important; }
.tabbar button.on { color: var(--yeot-deep); }
.tabbar button.on span { transform: scale(1.12); }
.tabbar button span { transition: transform .15s; }
[data-view="rank"] #topBox, [data-view="fun"] #campusBox { margin-top: 18px; }
