:root {
  /* 살짝 브라운 톤 */
  --bg: #f3e8da;
  --card: #fffdf9;
  --ink: #3d3027;
  --sub: #8a7765;
  --line: #e4d3be;
  --main: #e07e4e;
  --main-ink: #ffffff;
  --soft: #f5e1cc;
  --brown: #8a5a3b;
  --paper: #fffdf8;
  --mint: #7fd1b9;
  --shadow: 0 6px 18px rgba(120, 90, 50, 0.12);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.screen { position: fixed; inset: 0; height: 100dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.center { display: flex; align-items: center; justify-content: center; padding: 20px; }

/* ── 버튼 ── */
.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 48px; padding: 10px 16px;
  border: 0; border-radius: 14px; font-weight: 700; text-decoration: none; text-align: center;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-main { background: var(--main); color: var(--main-ink); }
.btn-soft { background: var(--soft); color: #8f4a24; }
.btn-ghost { background: transparent; color: var(--sub); border: 1.5px solid var(--line); }
.btn-signal {
  background: var(--main); color: #fff; font-size: 20px; min-height: 60px; border-radius: 18px;
  box-shadow: 0 6px 0 #d96a3e, 0 10px 20px rgba(217, 106, 62, 0.35);
}
.btn-signal:active { transform: translateY(4px); box-shadow: 0 2px 0 #d96a3e; }
.chip {
  border: 0; border-radius: 999px; padding: 8px 12px; min-height: 36px;
  background: rgba(255, 255, 255, 0.92); color: var(--ink); font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow); white-space: nowrap;
}
.fine { color: var(--sub); font-size: 13px; margin: 0; }
.lead { margin: 0; font-size: 17px; }

/* ── 로비: 화장실 벽 + 휴지걸이에서 풀려 내려온 화장지 ── */
#lobby {
  position: relative;
  padding: calc(22px + var(--safe-t)) 16px calc(24px + var(--safe-b));
  /* 은은한 타일 벽 */
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(138, 90, 59, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(138, 90, 59, 0.07) 1px, transparent 1px);
  background-size: 56px 56px;
  background-position: center top;
}
#lobby > * { max-width: 760px; margin-left: auto; margin-right: auto; }
#lobby > :not(.floaters) { position: relative; z-index: 1; }
.lobby-head { text-align: center; margin-bottom: 14px; }
.lobby-head h1 { margin: 0 0 4px; font-size: 34px; letter-spacing: -1px; color: #4a3122; }
.lobby-head h1 small { display: block; font-size: 14px; font-weight: 700; color: var(--brown); letter-spacing: 1px; margin-top: 2px; }
.lobby-head p { margin: 0; color: var(--sub); }
.lobby-head .today-total { margin-top: 10px; color: var(--ink); font-weight: 700; }
.lobby-head .today-total b { color: #c4693c; font-size: 20px; font-variant-numeric: tabular-nums; }

/* 휴지걸이: 양쪽 팔 + 가운데 화장지 롤 */
.tp { position: relative; padding: 0 6px; }
.tp-holder { position: relative; height: 66px; display: flex; align-items: center; }
.tp-arm {
  position: relative; flex: 0 0 22px; height: 58px; border-radius: 9px; z-index: 2;
  background: linear-gradient(90deg, #6f4529, #9c6a46 45%, #6f4529);
  box-shadow: 0 4px 8px rgba(60, 35, 15, 0.28);
}
.tp-arm::after { /* 롤을 꿰는 축 끝 */
  content: ''; position: absolute; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%;
  background: #c9a27a; box-shadow: inset 0 0 0 2px #7a4d2f;
}
.tp-arm.left::after { right: -4px; }
.tp-arm.right::after { left: -4px; }
.tp-roll {
  flex: 1; height: 56px; margin: 0 -2px; border-radius: 26px / 28px; z-index: 1;
  background: linear-gradient(180deg, #e7dccd 0%, #fffefb 30%, #fbf6ee 60%, #e3d6c4 100%);
  box-shadow: inset 0 -2px 0 rgba(160, 130, 95, 0.25), 0 3px 6px rgba(80, 55, 30, 0.15);
}
/* 롤 앞쪽에서 풀려 내려온 화장지 */
.tp-paper {
  position: relative; z-index: 3; margin: -26px 30px 0; padding-top: 18px;
  background-color: var(--paper);
  /* 엠보싱 점무늬 */
  background-image: radial-gradient(rgba(150, 115, 80, 0.09) 1.2px, transparent 1.6px);
  background-size: 14px 14px;
  filter: drop-shadow(0 8px 14px rgba(90, 60, 30, 0.16));
}
.tp-paper::before { /* 롤에서 막 풀려 나오는 곳의 그늘 */
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 26px;
  background: linear-gradient(180deg, rgba(170, 140, 105, 0.28), rgba(170, 140, 105, 0));
  pointer-events: none;
}
.tp-paper::after { /* 아래 끝: 뜯은 자국 */
  content: ''; position: absolute; left: 0; right: 0; bottom: -10px; height: 10px;
  background:
    linear-gradient(135deg, var(--paper) 50%, transparent 50%) 0 0 / 14px 10px repeat-x,
    linear-gradient(225deg, var(--paper) 50%, transparent 50%) 0 0 / 14px 10px repeat-x;
}
.tp-sheet { position: relative; padding: 18px 18px 20px; }
.tp-sheet + .tp-sheet { border-top: 2px dashed rgba(150, 115, 80, 0.35); } /* 절취선 */
.tp-sheet + .tp-sheet::before, .tp-sheet + .tp-sheet::after { /* 절취선 양 끝의 작은 홈 */
  content: ''; position: absolute; top: -7px; width: 12px; height: 12px; border-radius: 50%; background: var(--bg);
}
.tp-sheet + .tp-sheet::before { left: -6px; }
.tp-sheet + .tp-sheet::after { right: -6px; }
.tp-title { margin: 0 0 12px; font-size: 15px; font-weight: 800; color: var(--brown); text-align: center; letter-spacing: 0.5px; }

.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 700px) { .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card {
  position: relative; display: flex; flex-direction: column; gap: 6px; text-align: left;
  background: rgba(255, 255, 255, 0.72); border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 11px 11px;
  min-height: 150px; transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.card.open { cursor: pointer; }
.card.open:hover, .card.open:focus-visible { border-color: var(--main); outline: none; transform: translateY(-2px); box-shadow: 0 6px 14px rgba(120, 80, 45, 0.14); }
.card .icon { font-size: 30px; line-height: 1; }
.card .name { font-size: 18px; font-weight: 800; color: #4a3122; }
.card .desc { color: var(--sub); font-size: 13px; flex: 1; }
.card .nums { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.card .nums b { color: #c4693c; font-variant-numeric: tabular-nums; }
.card .go { margin-top: 4px; color: var(--main); font-weight: 800; font-size: 14px; }
.card.closed { background: rgba(240, 230, 216, 0.6); cursor: not-allowed; color: #9a8f81; }
.card.closed .icon { filter: grayscale(1); opacity: 0.6; }
.card .badge {
  position: absolute; top: 10px; right: 10px; background: #e8dccb; color: #7a6c5a;
  font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 999px;
}
.lobby-error { text-align: center; color: #b3492a; margin: 12px 0 0; }

/* 둘째 칸: 후기 + 후원 */
.tp-more { display: flex; flex-direction: column; gap: 14px; }
.review-form { display: flex; flex-direction: column; gap: 6px; }
.review-label { font-weight: 800; font-size: 14px; color: var(--brown); }
.review-row { display: flex; gap: 8px; }
.review-row input {
  flex: 1; min-width: 0; min-height: 46px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 12px;
  background: #fff; font-size: 16px;
}
.review-row input:focus { outline: none; border-color: var(--main); }
.review-row .btn { width: auto; flex: 0 0 auto; min-width: 76px; min-height: 46px; border-radius: 12px; }
.review-msg { margin: 0; font-size: 13px; color: var(--sub); }
.btn-donate {
  gap: 8px; background: #fff; color: #8f4a24; border: 1.5px dashed #d4ad8c; border-radius: 12px;
}
.btn-donate small { font-weight: 600; color: var(--sub); font-size: 13px; }
.pay-icons { display: inline-flex; gap: 4px; margin-left: 4px; }
.pay-ico { width: 22px; height: 22px; flex: 0 0 auto; display: block; }
.btn-pay .pay-ico { margin-right: 8px; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7); border-radius: 50%; }
.btn-donate:hover { background: #fff6ee; }

/* 떠오르는 후기(화면 양옆) */
.floaters, #lobby > .floaters { position: fixed; inset: 0; max-width: none; margin: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.floater {
  position: absolute; max-width: 210px; padding: 8px 12px; border-radius: 16px 16px 16px 4px;
  background: #fffdf9; color: var(--ink); font-size: 13px; font-weight: 600; line-height: 1.35;
  box-shadow: 0 6px 18px rgba(80, 50, 25, 0.16); opacity: 0;
  animation-name: float-up; animation-duration: 12s; animation-timing-function: linear; animation-fill-mode: forwards;
}
.floater.behind { font-size: 12px; animation-name: float-up-dim; }
@keyframes float-up-dim {
  0% { transform: translateY(0) rotate(var(--tilt)); opacity: 0; }
  12% { opacity: 0.7; }
  70% { opacity: 0.6; }
  100% { transform: translateY(var(--rise)) rotate(var(--tilt)); opacity: 0; }
}
@keyframes float-up {
  0% { transform: translateY(0) rotate(var(--tilt)); opacity: 0; }
  12% { opacity: 0.95; }
  70% { opacity: 0.85; }
  100% { transform: translateY(var(--rise)) rotate(var(--tilt)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .floaters { display: none; } }
.lobby-foot { margin-top: 26px; text-align: center; }
@media (max-width: 420px) {
  .tp { padding: 0; }
  .tp-paper { margin-left: 22px; margin-right: 22px; }
  .tp-sheet { padding: 16px 12px 18px; }
  .lobby-head h1 { font-size: 30px; }
}

/* ── 가운데 패널(대기·결과·끊김) ── */
.panel {
  width: 100%; max-width: 380px; background: var(--card); border-radius: 22px; box-shadow: var(--shadow);
  padding: 26px 20px 20px; display: flex; flex-direction: column; gap: 12px; text-align: center; margin: auto;
}
.panel h2 { margin: 0; font-size: 24px; }
.big-emoji { font-size: 54px; line-height: 1; }
.rank { margin: 0; font-size: 19px; font-weight: 800; color: #d96a3e; }

/* ── 장소 안 ── */
#room { overflow: hidden; background: #dfe9ee; touch-action: none; }
#stage, #stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#labels { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.label {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -100%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  pointer-events: none; will-change: transform;
}
.label .tag {
  pointer-events: auto; cursor: pointer; border: 0;
  background: rgba(40, 34, 28, 0.62); color: #fff; font-size: 11px; font-weight: 600;
  padding: 3px 7px; border-radius: 9px; white-space: pre-line; text-align: center; line-height: 1.2; max-width: 96px;
}
.label.me .tag { background: var(--main); }
.label.npc .tag, .label.staff .tag { cursor: default; }
.label.staff .tag { background: #3f6fb5; }
.label .bubble {
  background: #fff; color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.3;
  padding: 7px 11px; border-radius: 14px; box-shadow: var(--shadow);
  width: max-content; max-width: min(220px, 62vw); text-align: center; position: relative;
}
.label .bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -6px; margin-left: -6px;
  border: 6px solid transparent; border-top-color: #fff; border-bottom: 0;
}
.label.staff .bubble { background: #eaf2ff; }
.label.staff .bubble::after { border-top-color: #eaf2ff; }

.hud-top {
  position: absolute; left: 0; right: 0; top: 0; padding: calc(10px + var(--safe-t)) 10px 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.me-card {
  background: rgba(255, 255, 255, 0.92); border-radius: 14px; padding: 7px 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-width: 0; flex: 0 1 auto;
}
.me-card strong { font-size: 15px; }
.me-card span { font-size: 12px; color: var(--sub); }
.top-btns { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: 0 0 auto; }
.ticker {
  position: absolute; left: 50%; top: var(--ticker-top, calc(104px + var(--safe-t))); transform: translateX(-50%);
  background: rgba(40, 34, 28, 0.7); color: #fff; font-size: 13px; padding: 6px 12px; border-radius: 999px;
  max-width: calc(100% - 24px); text-align: center; pointer-events: none;
}
.loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); font-weight: 700; color: var(--sub); z-index: 3;
}
.hud-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 0 12px calc(14px + var(--safe-b));
  display: flex; flex-direction: column; gap: 10px; max-width: 560px; margin: 0 auto; z-index: 2;
}
.chat { display: flex; gap: 8px; }
.chat input {
  flex: 1; min-width: 0; min-height: 46px; border: 2px solid var(--line); border-radius: 14px; padding: 0 12px;
  background: rgba(255, 255, 255, 0.96); font-size: 16px;
}
.chat input:focus { outline: none; border-color: var(--main); }
.chat .btn { width: auto; flex: 0 0 auto; min-width: 76px; min-height: 46px; white-space: nowrap; }
.who {
  position: absolute; left: 12px; right: 12px; bottom: calc(150px + var(--safe-b)); max-width: 360px; margin: 0 auto;
  background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 14px; z-index: 4;
  display: flex; flex-direction: column; gap: 8px; text-align: center;
}
.who-name { font-weight: 800; }

/* ── 아오키 마리코 현상 작은 팝업 ── */
.aoki-link {
  font: inherit; color: #8a5a3b; background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: underline dotted; text-underline-offset: 3px; font-weight: 700;
}
.pop-wrap {
  position: fixed; inset: 0; background: rgba(40, 34, 28, 0.35); z-index: 25;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.pop {
  width: 100%; max-width: 300px; background: #fffaf2; border: 2px solid #d9c3a5; border-radius: 18px;
  padding: 16px 16px 12px; box-shadow: 0 8px 24px rgba(40, 30, 20, 0.25); font-size: 14px; line-height: 1.55;
}
.pop h3 { margin: 0 0 8px; font-size: 16px; color: #4a3122; }
.pop p { margin: 0 0 6px; color: var(--ink); }
.pop .pop-real { font-weight: 800; color: #c4693c; }
.pop .btn { width: 100%; margin-top: 6px; }

/* ── 후원 창 ── */
.sheet-wrap {
  position: fixed; inset: 0; background: rgba(40, 34, 28, 0.45); z-index: 20;
  display: flex; align-items: flex-end; justify-content: center; padding: 12px;
}
.sheet {
  width: 100%; max-width: 420px; background: #fff; border-radius: 22px; padding: 22px 18px calc(16px + var(--safe-b));
  display: flex; flex-direction: column; gap: 10px; text-align: center;
}
.sheet h2 { margin: 0; font-size: 20px; }

.toast {
  position: fixed; left: 50%; bottom: calc(160px + var(--safe-b)); transform: translateX(-50%);
  background: rgba(40, 34, 28, 0.9); color: #fff; padding: 10px 16px; border-radius: 14px; font-size: 14px;
  max-width: calc(100% - 32px); text-align: center; z-index: 30; pointer-events: none;
}

@media (max-width: 339px) {
  .cards { grid-template-columns: 1fr; }
  .card { min-height: 0; }
}
@media (max-height: 600px) {
  .btn-signal { min-height: 48px; font-size: 17px; }
  .hud-bottom { gap: 7px; }
  .card-pop { padding: 9px 12px 10px; }
  .card-pop-title { padding-bottom: 3px; margin-bottom: 5px; font-size: 12px; }
  .card-pop-text { font-size: 14px; line-height: 1.35; }
}
/* 가로로 눕힌 휴대폰: 자막을 맨 위 가운데로 올려 아래 버튼들과 떨어뜨린다 */
@media (max-height: 520px) and (min-width: 600px) {
  .ticker { top: calc(10px + var(--safe-t)); max-width: calc(100% - 440px); }
  .hud-bottom { flex-direction: row; flex-wrap: wrap; align-items: flex-end; max-width: none; }
  .hud-bottom > .btn, .hud-bottom > .chat, .hud-bottom > .action-row { flex: 1 1 200px; }
  .card-pop { flex: 0 0 100%; }
}

/* ── 장소별 추가 요소(시험 등) ── */
#room-badge { font-size: 13px; color: #d96a3e; font-variant-numeric: tabular-nums; margin-top: 2px; }
#room-badge.urgent { color: #c0392b; }
.btn-action { background: #fff; color: var(--ink); border: 2px solid var(--line); min-height: 46px; box-shadow: var(--shadow); }
.action-row { display: flex; gap: 8px; }
.action-row > .btn { flex: 1 1 0; min-width: 0; padding-left: 8px; padding-right: 8px; }
.action-row[hidden], .action-row > [hidden] { display: none; }
.btn-action.on { background: #1d2733; color: #8ff3ff; border-color: #2fd6ff; }

/* 시험: AI 안경(렌즈 위에 뜨는 화면) */
.glasses { position: absolute; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }
.glasses svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.glasses .lens-ui {
  position: absolute; top: 18%; width: 34%; display: flex; flex-direction: column; gap: 5px;
  font: 700 12px/1.3 ui-monospace, Consolas, monospace; color: #8ff3ff; text-shadow: 0 0 6px rgba(47, 214, 255, 0.9);
}
.glasses .lens-ui.l { left: 9%; }
.glasses .lens-ui.r { right: 9%; text-align: right; }
.glasses .lens-ui .hd { font-size: 10px; letter-spacing: 1.5px; opacity: 0.9; }
.glasses .lens-ui .ln, .glasses .lens-ui .hd { align-self: flex-start; background: rgba(3, 16, 24, 0.62); padding: 2px 7px; border-radius: 4px; }
.glasses .lens-ui.r .ln, .glasses .lens-ui.r .hd { align-self: flex-end; }
.glasses .lens-ui .bar { width: 100%; }
.glasses .lens-ui .warn { color: #ffd36b; text-shadow: 0 0 6px rgba(255, 170, 40, 0.9); }
.glasses .lens-ui .bar { height: 5px; background: rgba(143, 243, 255, 0.25); border-radius: 3px; overflow: hidden; }
.glasses .lens-ui .bar i { display: block; height: 100%; background: #8ff3ff; transition: width 0.6s; }
.glasses .scan { position: absolute; left: 0; right: 0; height: 2px; background: rgba(143, 243, 255, 0.45); box-shadow: 0 0 10px #2fd6ff; animation: scan 2.6s linear infinite; }
@keyframes scan { from { top: 12%; } to { top: 82%; } }
.glasses .reticle { position: absolute; left: 50%; top: 45%; width: 46px; height: 46px; margin: -23px; border: 2px solid rgba(143, 243, 255, 0.7); border-radius: 50%; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.25); opacity: 0.4; } }
.glasses.taken { animation: glasses-off 0.6s ease-in forwards; }
@keyframes glasses-off { to { transform: translateY(-40%) scale(1.15); opacity: 0; } }
@media (max-width: 520px) { .glasses .lens-ui { font-size: 10px; top: 14%; width: 38%; } .glasses .lens-ui.l { left: 6%; } .glasses .lens-ui.r { right: 6%; } }
.card-pop {
  align-self: center; transform: rotate(-1.5deg); margin-bottom: 4px;
  width: min(310px, 100%); background: #fffef8; border: 1.5px solid #d8d2c0; border-radius: 6px;
  box-shadow: 0 10px 28px rgba(60, 50, 30, 0.28); padding: 14px 16px 16px; pointer-events: none;
}
.card-pop-title { font-weight: 800; font-size: 13px; color: var(--sub); border-bottom: 1.5px solid #3b332b; padding-bottom: 6px; margin-bottom: 10px; }
.card-pop-text { font-size: 16px; font-weight: 600; white-space: pre-line; line-height: 1.5; }
/* 겹치는 순서: 3D < 이름표 < 버튼·정보 < 자막 < 문제 카드 */
#labels { z-index: 1; }
.hud-top { z-index: 2; }
.ticker { z-index: 3; }

/* 미션 정보(도서관 등): 여러 줄, 시간이 얼마 안 남으면 깜빡인다 */
#room-badge { white-space: pre-line; line-height: 1.35; }
#room-badge.urgent { animation: urgent-blink 0.8s steps(2, jump-none) infinite; }
@keyframes urgent-blink { from { opacity: 1; } to { opacity: 0.45; } }

/* 숨바꼭질: 숨을 곳 고르기 창과 미니맵 */
.picker {
  position: absolute; left: 12px; right: 12px; bottom: calc(96px + var(--safe-b)); max-width: 380px; margin: 0 auto;
  background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 14px; z-index: 4;
  display: flex; flex-direction: column; gap: 10px; text-align: center;
}
.picker-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.picker-list .btn { flex-direction: column; min-height: 52px; padding: 6px 8px; line-height: 1.25; }
.picker-list .btn small { font-weight: 600; font-size: 12px; opacity: 0.75; }
.picker-list .btn:last-child:nth-child(odd) { grid-column: 1 / -1; }
.minimap {
  position: absolute; right: 10px; top: calc(178px + var(--safe-t)); width: 104px; height: 104px;
  background: rgba(255, 255, 255, 0.9); border-radius: 16px; box-shadow: var(--shadow); z-index: 2; pointer-events: none;
}
@media (max-height: 520px) {
  .picker { bottom: calc(64px + var(--safe-b)); padding: 10px; }
  .picker-list { grid-template-columns: repeat(5, 1fr); }
  .picker-list .btn:last-child:nth-child(odd) { grid-column: auto; }
  .minimap { top: auto; bottom: calc(70px + var(--safe-b)); width: 84px; height: 84px; }
}

/* 긴장감 효과: 화면 가장자리가 조여 온다 */
.vignette {
  position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.6s ease; --vig: rgba(120, 10, 10, 0.85);
  background: radial-gradient(ellipse at center, transparent 42%, var(--vig) 118%);
}

/* 가운데 뜨는 창(도서관 책장 등) */
.overlay {
  position: absolute; inset: 0; z-index: 6; background: rgba(40, 34, 28, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.overlay-box {
  width: 100%; max-width: 400px; background: #fffdf7; border-radius: 18px; box-shadow: var(--shadow);
  padding: 16px; display: flex; flex-direction: column; gap: 10px; text-align: center;
}
.shelf-title { font-weight: 800; }
.shelf-row {
  display: flex; align-items: flex-end; gap: 3px; height: 150px; padding: 8px 8px 0;
  background: #6f5b45; border-radius: 8px; border-bottom: 10px solid #4d3f30;
}
.spine {
  flex: 1 1 0; min-width: 0; border: 0; border-radius: 3px 3px 0 0; padding: 0; position: relative;
  box-shadow: inset -3px 0 0 rgba(0, 0, 0, 0.18), inset 2px 0 0 rgba(255, 255, 255, 0.18);
}
.spine::after { content: ""; position: absolute; left: 22%; right: 22%; top: 14%; height: 5px; background: rgba(255, 255, 255, 0.55); border-radius: 2px; }
.spine.on { outline: 3px solid var(--main); outline-offset: 1px; transform: translateY(-8px); }
.shelf-info { min-height: 46px; white-space: pre-line; font-weight: 700; font-size: 15px; display: flex; align-items: center; justify-content: center; }
@media (max-height: 520px) {
  .overlay-box { max-width: 620px; padding: 10px; gap: 6px; }
  .shelf-row { height: 96px; }
  .shelf-info { min-height: 0; font-size: 14px; }
}

/* 시험 교실: 멀리 있는 자리는 이름표를 숨긴다 */
.label.far .tag { display: none; }

/* 다있소 진열대 팝업: 물건 아이콘 */
.goods-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 10px; background: #eef0ec; border-radius: 10px; }
.goods { aspect-ratio: 1; border: 2px solid transparent; border-radius: 10px; background: #fff; display: flex; align-items: center; justify-content: center; padding: 0; }
.goods img { width: 74%; height: 74%; display: block; object-fit: contain; pointer-events: none; }
.goods.jelly { border-color: #f2799a; background: #fff3f6; animation: jelly 0.7s ease; }
@keyframes jelly { 0% { transform: scale(1, 1); } 30% { transform: scale(1.18, 0.82); } 55% { transform: scale(0.9, 1.12); } 75% { transform: scale(1.06, 0.95); } 100% { transform: scale(1, 1); } }
.goods.on { border-color: var(--main); transform: translateY(-3px); }
@media (max-height: 520px) { .goods-grid { grid-template-columns: repeat(8, 1fr); } }

/* 후원 버튼(실제 로고 대신 직접 그린 아이콘) */
.btn-pay { display: flex; align-items: center; justify-content: center; text-decoration: none; font-weight: 800; }
.btn-kakao { background: #ffe14d; color: #2b2410; }
.donate-qr { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px; border-radius: 14px; background: #fff8d6; }
.donate-qr img { width: 164px; height: 164px; image-rendering: pixelated; background: #fff; border-radius: 8px; }
.btn-toss { background: #3d7bf2; color: #fff; }

/* 책장·진열대 앞에 서 있으면 그 위에 뜨는 버튼 */
.shelf-pop {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer;
  border: 0; border-radius: 999px; padding: 9px 15px; font-size: 14px; font-weight: 800;
  background: var(--main); color: #fff; box-shadow: 0 6px 16px rgba(60, 40, 20, 0.3); white-space: nowrap;
  animation: shelf-pop-in 0.25s ease-out;
}
.shelf-pop::after {
  content: ""; position: absolute; left: 50%; bottom: -7px; margin-left: -7px;
  border: 7px solid transparent; border-top-color: var(--main); border-bottom: 0;
}
.shelf-pop[hidden] { display: none; }
@keyframes shelf-pop-in { from { opacity: 0; margin-top: 8px; } to { opacity: 1; margin-top: 0; } }

/* 휴대폰 조이스틱(왼쪽 아래, 반투명) */
.joy {
  position: absolute; left: 16px; bottom: 150px; width: 120px; height: 120px; border-radius: 50%; z-index: 2;
  background: rgba(255, 255, 255, 0.28); border: 2px solid rgba(255, 255, 255, 0.55); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  touch-action: none; -webkit-user-select: none; user-select: none; backdrop-filter: blur(2px);
}
.joy.on { background: rgba(255, 255, 255, 0.4); }
.joy-knob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  background: rgba(255, 138, 91, 0.75); border: 2px solid rgba(255, 255, 255, 0.85); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

/* 가운데 위 시간 표시 */
.timer {
  position: absolute; left: 50%; top: calc(10px + var(--safe-t)); transform: translateX(-50%); z-index: 3;
  width: min(250px, calc(100% - 24px)); background: rgba(255, 253, 247, 0.96); border: 2px solid #3b332b; border-radius: 16px;
  box-shadow: 0 6px 18px rgba(40, 30, 20, 0.25); padding: 7px 12px 9px; pointer-events: none;
}
.timer-main { display: flex; align-items: center; gap: 10px; }
.timer-clock { width: 40px; height: 40px; flex: 0 0 auto; }
.timer-txt { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.timer-txt span { font-size: 12px; font-weight: 700; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer-txt b { font-size: 30px; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: 1px; color: #3b332b; }
.timer-bar { margin-top: 6px; height: 7px; border-radius: 4px; background: #eadfcf; overflow: hidden; }
.timer-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #f0a23a, #e8584a); transition: width 0.25s linear; }
.timer-taxi { margin-top: 7px; }
.timer-taxi .road { position: relative; height: 26px; border-radius: 6px; background: #5b5f66; overflow: hidden; }
.timer-taxi .road::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 2px dashed rgba(255, 255, 255, 0.7); }
.taxi-car { position: absolute; left: 0; bottom: 1px; width: 38px; height: 21px; transition: left 0.3s linear; }
.taxi-shop { position: absolute; right: 3px; bottom: 1px; width: 22px; height: 22px; }
.timer-taxi .meter { display: flex; justify-content: space-between; align-items: baseline; margin-top: 5px; padding: 3px 8px; border-radius: 6px; background: #1f2328; color: #9cff8a; font-family: ui-monospace, Consolas, monospace; }
.timer-taxi .meter span { font-size: 11px; color: #c9d1c7; }
.timer-taxi .meter b { font-size: 17px; font-variant-numeric: tabular-nums; }
.timer.urgent { border-color: #c0392b; animation: timer-pulse 1s ease-in-out infinite; }
.timer.urgent .timer-txt b { color: #c0392b; }
.timer.urgent .timer-clock { animation: clock-ring 0.5s linear infinite; }
.timer.critical { animation-duration: 0.5s; background: #fff1ee; }
.timer.critical .timer-clock { animation-duration: 0.25s; }
@keyframes timer-pulse { 50% { box-shadow: 0 0 0 6px rgba(192, 57, 43, 0.25), 0 6px 18px rgba(40, 30, 20, 0.25); } }
@keyframes timer-pulse-mini { 50% { box-shadow: 0 0 0 4px rgba(192, 57, 43, 0.22); } }
/* 맨 위에 붙인다 */
.timer { top: calc(4px + var(--safe-t)); }
/* 서점·숨바꼭질·시험: 상자 없이 작고 반투명한 한 줄(시계·이름·남은 시간 + 얇은 막대) */
.timer:not(.with-taxi) {
  width: auto; max-width: calc(100% - 24px); padding: 3px 12px 4px 6px; border: 0; border-radius: 999px;
  background: rgba(255, 253, 247, 0.55); box-shadow: 0 2px 8px rgba(40, 30, 20, 0.12);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.timer:not(.with-taxi) .timer-main { gap: 6px; }
.timer:not(.with-taxi) .timer-clock { width: 20px; height: 20px; }
.timer:not(.with-taxi) .timer-txt { flex-direction: row; align-items: baseline; gap: 6px; }
.timer:not(.with-taxi) .timer-txt span { font-size: 11px; color: #4d3f33; }
.timer:not(.with-taxi) .timer-txt b { font-size: 17px; letter-spacing: 0.5px; }
.timer:not(.with-taxi) .timer-bar { margin-top: 2px; height: 3px; background: rgba(60, 40, 20, 0.1); }
.timer:not(.with-taxi).urgent { border: 0; background: rgba(255, 241, 238, 0.7); animation-name: timer-pulse-mini; }
.timer:not(.with-taxi).critical { background: rgba(255, 225, 220, 0.82); }
.timer.tight .timer-txt span { display: none; } /* 좁은 화면: 이름은 빼고 시계와 시간만 */
/* 다있소: 택시 그림은 그대로, 크기만 작게 */
.timer.with-taxi { width: min(200px, calc(100% - 24px)); padding: 5px 10px 7px; border-width: 1.5px; border-radius: 13px; }
.timer.with-taxi .timer-main { gap: 8px; }
.timer.with-taxi .timer-clock { width: 28px; height: 28px; }
.timer.with-taxi .timer-txt span { font-size: 11px; }
.timer.with-taxi .timer-txt b { font-size: 22px; }
.timer.with-taxi .timer-bar { margin-top: 4px; height: 5px; }
.timer.with-taxi .timer-taxi { margin-top: 5px; }
.timer.with-taxi .timer-taxi .road { height: 20px; }
.timer.with-taxi .taxi-car { width: 30px; height: 16px; }
.timer.with-taxi .taxi-shop { width: 17px; height: 17px; }
.timer.with-taxi .timer-taxi .meter { margin-top: 4px; padding: 2px 6px; }
.timer.with-taxi .timer-taxi .meter span { font-size: 10px; }
.timer.with-taxi .timer-taxi .meter b { font-size: 14px; }
@keyframes clock-ring { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }

/* 카드 아래 링크(예: 예스24 상품 페이지) */
.card-pop-link { display: inline-block; margin-top: 8px; font-size: 13px; font-weight: 800; color: #2b6cb0; pointer-events: auto; text-decoration: underline; }
.card-pop-link[hidden] { display: none; }
