/* 도트 UI 껍데기: 계단식 테두리·도트 글꼴. 색은 테마 변수만 사용. 게임·편집기·로그인·관리자 공통. */
:root { --px: 3px; --px-line: var(--fg); --font-pixel: 'Galmuri11', 'Galmuri9', var(--font-ui); }
body { font-family: var(--font-pixel); }
input, select, textarea, button { font-family: inherit; }
[hidden] { display: none !important; }
a.btn { color: var(--fg); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
a.btn.primary { color: var(--accent-fg); }

/* 계단 모서리 테두리: box-shadow 4방향 + 모서리 한 칸을 비워 둥근 도트 느낌 */
.px-box, .btn, .panel, .stage-card, .tool, .ed-tool, .rules, .sheet, .dlg-box, .ed-dialog, .menu-card, .auth-card, .toast, .theme-card {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--px-line),
    0 var(--px) 0 0 var(--px-line),
    calc(var(--px) * -1) 0 0 0 var(--px-line),
    var(--px) 0 0 0 var(--px-line),
    0 calc(var(--px) * 2) 0 0 rgba(0, 0, 0, .18) !important;
}
.btn { margin: var(--px); transition: transform .06s; }
.btn:not(:disabled):active { transform: translateY(var(--px)); }
.btn.primary { text-shadow: none; }
.tool.selected, .ed-tool.selected, .stage-card:hover, .menu-card:hover, .theme-card:not(:disabled):hover {
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--accent),
    0 var(--px) 0 0 var(--accent),
    calc(var(--px) * -1) 0 0 0 var(--accent),
    var(--px) 0 0 0 var(--accent),
    0 0 0 calc(var(--px) * 2) color-mix(in srgb, var(--accent) 35%, transparent) !important;
}
.sheet { border-radius: 0 !important; }
.stage-list { gap: 14px; padding: 4px; }
.toast { border-radius: 0 !important; }
.dlg-face { border-radius: 0; }
input, select, textarea { border-radius: 0 !important; border: 2px solid var(--px-line) !important; }
.board, .cells { border-radius: 0 !important; }
.board { box-shadow: 0 0 0 var(--px) var(--px-line), 0 calc(var(--px) * 2) 0 var(--px) rgba(0,0,0,.18) !important; }

/* 상단 사용자 바 */
.userbar { display: flex; align-items: center; gap: 8px; justify-content: flex-end; font-size: 13px; padding: 8px 4px 0; flex-wrap: wrap; }
.userbar .who { font-weight: 700; }
.userbar .role-admin { color: var(--accent); }
.userbar .btn { min-height: 32px; padding: 4px 10px; font-size: 12px; }

/* 메뉴 */
.menu-hero { display: flex; align-items: center; gap: 14px; margin: 8px 0 22px; }
.menu-hero .hero-sprite { width: 72px; height: 72px; flex: none; image-rendering: pixelated; }
.menu-hero .hero-sprite svg { width: 100%; height: 100%; display: block; }
.menu-hero h1 { font-size: 24px; }
.menu-grid { display: grid; gap: 16px; padding: 4px; }
.menu-card {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; text-decoration: none; color: var(--fg);
  background: var(--panel); padding: 14px 16px; cursor: pointer;
}
.menu-card .menu-icon { width: 48px; height: 48px; flex: none; display: flex; align-items: center; justify-content: center; background: var(--cell-alt); }
.menu-card .menu-icon svg { width: 80%; height: 80%; display: block; }
.menu-card strong { display: block; font-size: 17px; }
.menu-card.admin { background: color-mix(in srgb, var(--accent) 14%, var(--panel)); }
.menu-card .menu-arrow { margin-left: auto; color: var(--accent); font-size: 18px; }

/* 화면 머리 */
.screen-head { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; }
.screen-head h2 { font-size: 20px; flex: 1; }
.list-tools { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.list-tools input, .list-tools select { flex: 1; min-width: 120px; }
.stage-card .author { color: var(--accent); }
.empty { padding: 20px; text-align: center; }

/* 로그인 */
body.auth { display: flex; min-height: 100dvh; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: min(380px, 100%); background: var(--panel); padding: 24px 22px; }
.auth-card h1 { font-size: 22px; text-align: center; margin: 10px 0 4px; }
.auth-card .hero-sprite { width: 88px; height: 88px; margin: 0 auto; }
.auth-card .hero-sprite svg { width: 100%; height: 100%; display: block; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0 14px; }
.auth-tabs button { background: var(--cell-alt); border: 0; padding: 10px; font-weight: 700; }
.auth-tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-fg); }
.auth-card form { display: grid; gap: 10px; }
.auth-card label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.auth-card input { width: 100%; min-height: 42px; background: var(--bg); color: var(--fg); padding: 6px 10px; font-size: 15px; }
.auth-guest { display: flex; justify-content: center; margin: 14px 0 6px; }
.auth-guest .btn { width: 100%; justify-content: center; }
.auth-card .btn { width: calc(100% - var(--px) * 2); margin-top: 6px; }
.auth-msg { min-height: 1.4em; font-size: 13px; text-align: center; margin: 4px 0 0; }
.auth-msg.bad { color: var(--bad); }

/* 관리자 */
body.admin-page .screen { display: block; max-width: 1100px; }
.adm-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.adm-tabs .btn[aria-selected="true"] { background: var(--accent); color: var(--accent-fg); }
.adm-section[hidden] { display: none; }
.adm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.adm-table th, .adm-table td { padding: 8px 6px; text-align: left; border-bottom: 2px dashed var(--cell-alt); vertical-align: middle; }
.adm-table th { color: var(--muted); font-weight: 400; font-size: 12px; }
.adm-table .num { width: 36px; color: var(--accent); font-weight: 700; }
.adm-table .acts { white-space: nowrap; text-align: right; }
.adm-table .acts .btn { min-height: 32px; padding: 3px 9px; font-size: 12px; }
.adm-table tr.dragging { opacity: .4; }
.adm-table tr.drop-before td { box-shadow: inset 0 3px 0 var(--accent); }
.drag-handle { cursor: grab; color: var(--muted); user-select: none; padding: 0 4px; }
.dropzone { border: 3px dashed var(--grid-line); padding: 18px; text-align: center; margin-bottom: 14px; background: var(--panel); }
.dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.upload-report { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13px; text-align: left; }
.upload-report li { padding: 3px 0; }
.upload-report .ok { color: var(--ok); }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; background: var(--cell-alt); margin-left: 6px; }
.tag.warn { background: var(--bad); color: #fff; }
@media (max-width: 700px) {
  .adm-table .hide-sm { display: none; }
  .adm-table .acts { white-space: normal; }
  .adm-table .acts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px; }
  .adm-table th:first-child, .adm-table td:first-child { padding: 0; width: 18px; }
  .adm-table td, .adm-table th { padding: 8px 4px; }
}

/* ── 도트 아이콘 ── */
.px-ico { display: inline-flex; width: 1.05em; height: 1.05em; vertical-align: -0.16em; flex: none; }
.px-ico svg { width: 100%; height: 100%; display: block; }
.btn .px-ico, .icon-btn .px-ico { width: 1.1em; height: 1.1em; }
.icon-btn .px-ico { width: 20px; height: 20px; }
.btn, .icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.stars { display: inline-flex; gap: 1px; align-items: center; }
.stars .px-ico { width: 16px; height: 16px; }
.stars.big .px-ico { width: 32px; height: 32px; }
.diff { display: inline-flex; gap: 1px; vertical-align: -0.1em; }
.diff .px-ico { width: .75em; height: .75em; }
.sheet h2 { display: flex; align-items: center; gap: 8px; }
.sheet h2 .px-ico { width: 30px; height: 30px; }
.check .px-ico, .sol-status .px-ico, .upload-report .px-ico, .log-stuck .px-ico { margin-right: 4px; }
.status dd .px-ico { color: var(--accent); }
.title-ico { width: 24px !important; height: 24px !important; vertical-align: -4px; margin-right: 4px; }
.dropzone .btn { cursor: pointer; }

/* <details> 기본 삼각형 기호 대신 도트 화살표 */
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: ''; display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -1px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 7' shape-rendering='crispEdges' fill='%232a2633'%3E%3Crect x='2' y='0' width='1' height='7'/%3E%3Crect x='3' y='1' width='1' height='5'/%3E%3Crect x='4' y='2' width='1' height='3'/%3E%3Crect x='5' y='3' width='1' height='1'/%3E%3C/svg%3E") center / contain no-repeat;
  image-rendering: pixelated; transition: transform .12s;
}
details[open] > summary::before { transform: rotate(90deg); }

/* 보드 위 도트 */
.token.token-px { background: none !important; clip-path: none; border-radius: 0; padding: 0; width: calc(var(--cell) * .66); height: calc(var(--cell) * .66); text-shadow: none; }
.token.token-px.small { width: calc(var(--cell) * .42); height: calc(var(--cell) * .42); }
.token.token-px svg { width: 100%; height: 100%; display: block; }
.status dd .token-px, .doors .token-px, .supply-item .token-px { width: 22px; height: 22px; }
.pedestal.pedestal-px { position: relative; border: 0; background: none; width: calc(var(--cell) * .8); height: calc(var(--cell) * .8); }
.pedestal.pedestal-px > svg { width: 100%; height: 100%; display: block; }
.pedestal.pedestal-px > .token { position: absolute; left: 50%; top: -6%; transform: translateX(-50%); }
.obj .pin.px-ico { position: absolute; top: -12%; right: -14%; width: 40%; height: 40%; font-size: inherit; }
.edge-label { display: inline-flex; align-items: center; gap: 1px; }
.edge-label .px-ico { width: 1.1em; height: 1.1em; }
.stuck-mark .px-ico, .probe-badge .px-ico { width: 70%; height: 70%; }
.reject-badge { display: inline-flex; align-items: center; gap: 2px; }
.reject-badge .px-ico { width: 10px; height: 10px; }
.menu-arrow .px-ico { width: 20px; height: 20px; }
.userbar .who .px-ico { color: var(--accent); }
.drag-handle .px-ico { width: 14px; height: 14px; }
.ed-tool-icon { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; }
.ed-tool-icon svg, .ed-tool-icon .sprite-pixel { width: 22px; height: 22px; display: block; }
.ed-tool-icon .px-ico { width: 18px; height: 18px; }

/* ── 허스키 도트 애니메이션 ── */
/* 멈춰 있을 때 숨쉬기(2프레임 계단식), 이동 중에는 걷기 프레임(JS)이 대신한다 */
.husky:not(.moving):not(.celebrating):not(.stuck) .sprite-husky { animation: breathe 1.4s steps(1, end) infinite; transform-origin: 50% 100%; }
@keyframes breathe { 50% { transform: scaleY(.94) translateY(3%); } }
.husky.success .sprite-husky { animation: none; }
.husky.celebrating .husky-inner { animation: hop-joy .5s steps(4, end) 3; }
@keyframes hop-joy { 50% { transform: translateY(calc(var(--cell) * -.35)); } }
.husky.stuck .sprite-husky { animation: shiver .18s steps(2, end) 4; transform: rotate(0); }
@keyframes shiver { 50% { transform: translateX(-6%); } }

/* ── 1.1 바닥 타일·썰매·워프 ── */
.tile { position: absolute; inset: 0; pointer-events: none; display: block; }
.tile svg { width: 100%; height: 100%; display: block; }
.tile-warp { inset: 4%; animation: warp-spin 2.4s steps(8, end) infinite; }
@keyframes warp-spin { to { transform: rotate(360deg); } }
.cell.collapsed { box-shadow: none; }
.cell.warp-flash .tile-warp { animation: warp-pop .7s steps(5, end); }
@keyframes warp-pop { 40% { transform: scale(1.3); filter: brightness(1.8); } }
.husky-inner.warp-in { animation: warp-in .5s steps(5, end); }
@keyframes warp-in { 0% { transform: scale(0) rotate(-180deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.husky-inner.sledding .sprite-husky { transform: translateY(-6%) rotate(-4deg); }
.husky-inner.sledding::after { /* 썰매 자국 */
  content: ''; position: absolute; left: 18%; right: 18%; bottom: 6%; height: 10%;
  background: repeating-linear-gradient(90deg, #8a93a3 0 3px, transparent 3px 6px); opacity: .8;
}
@media (prefers-reduced-motion: reduce) { .tile-warp, .husky-inner.warp-in, .cell.warp-flash .tile-warp { animation: none; } }

/* ── 탈출 연출 ── */
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 6; overflow: visible; }
.fx.fx-out { opacity: 0; transition: opacity .3s; }
.fx-glow {
  position: absolute; left: calc(var(--ex) * var(--cell)); top: calc(var(--ey) * var(--cell));
  width: var(--cell); height: var(--cell);
  animation: exit-glow .5s steps(2, end) 3;
}
@keyframes exit-glow { 50% { box-shadow: inset 0 0 0 4px #ffd23f, 0 0 0 4px #ffd23f; background: rgba(255, 210, 63, .35); } }
.fx-bit {
  position: absolute; left: calc((var(--ex) + .5) * var(--cell)); top: calc((var(--ey) + .5) * var(--cell));
  width: max(4px, calc(var(--cell) * .13)); height: max(4px, calc(var(--cell) * .13));
  background: var(--c); box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
  animation: fx-bit 1.3s steps(13, end) var(--d) both;
}
@keyframes fx-bit {
  0% { transform: translate(0, 0); opacity: 1; }
  45% { transform: translate(calc(var(--dx) * var(--cell)), calc(var(--dy) * var(--cell))); opacity: 1; }
  100% { transform: translate(calc(var(--dx) * var(--cell) * 1.15), calc((var(--dy) + 1.6) * var(--cell))); opacity: 0; }
}
.fx-banner {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  font-family: var(--font-pixel); font-weight: 700; white-space: nowrap;
  font-size: clamp(26px, calc(var(--cell) * .95), 56px); color: #ffd23f; letter-spacing: 2px;
  text-shadow: 3px 0 #2d2a4a, -3px 0 #2d2a4a, 0 3px #2d2a4a, 0 -3px #2d2a4a, 3px 3px #2d2a4a, -3px 3px #2d2a4a, 3px -3px #2d2a4a, -3px -3px #2d2a4a, 0 6px rgba(0, 0, 0, .25);
  animation: banner-pop .9s steps(6, end) both;
}
@keyframes banner-pop {
  0% { transform: translate(-50%, -50%) scale(.2); opacity: 0; }
  40% { transform: translate(-50%, -50%) scale(1.25); opacity: 1; }
  60% { transform: translate(-50%, -50%) scale(.95); }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .husky .sprite-husky, .husky.celebrating .husky-inner, .fx-glow, .fx-banner { animation: none !important; }
}

/* ── 테마 선택 ── */
.themes-total { display: flex; align-items: center; gap: 4px; margin: -6px 0 12px; }
.themes-total .px-ico { width: 16px; height: 16px; }
.theme-list { display: grid; gap: 16px; padding: 4px; }
.theme-card {
  position: relative; display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--panel); padding: 14px 16px 14px 22px; cursor: pointer; color: var(--fg);
}
.theme-card::before { /* 테마 색 띠 (계단 모양) */
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; background: var(--tc);
  box-shadow: 3px 0 0 color-mix(in srgb, var(--tc) 45%, transparent);
}
.theme-card.empty { cursor: default; background: var(--cell); }
.theme-card.empty .theme-icon { filter: grayscale(.9) opacity(.55); }
.theme-icon { width: 64px; height: 64px; flex: none; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--tc) 14%, var(--panel)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc) 40%, transparent); }
.theme-icon svg { width: 80%; height: 80%; display: block; }
.theme-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.theme-label { align-self: flex-start; font-size: 11px; font-weight: 700; color: #fff; background: var(--tc); padding: 1px 6px; }
.theme-name { font-size: 18px; }
.theme-bar { display: block; height: 8px; margin: 6px 0 2px; background: var(--cell-alt); box-shadow: 0 0 0 2px var(--px-line); position: relative; }
.theme-bar > span { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--tc) 0 6px, color-mix(in srgb, var(--tc) 75%, #fff) 6px 8px); }
.theme-stats { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; color: var(--muted); }
.theme-stats .px-ico { width: 13px; height: 13px; }
.theme-goal { color: var(--muted); }
#screen-select .screen-head { align-items: center; }
.select-icon { width: 44px; height: 44px; flex: none; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--tc, var(--accent)) 14%, var(--panel)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc, var(--accent)) 40%, transparent); }
.select-icon svg { width: 80%; height: 80%; display: block; }
.select-head { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.select-head small { font-weight: 700; color: var(--tc, var(--accent)); }
#screen-select .stage-no { color: var(--tc, var(--accent)); }

/* 관리자: 테마 */
.theme-counts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 10px; }
.theme-count { display: inline-flex; align-items: center; gap: 4px; }
.theme-count::before { content: ''; width: 10px; height: 10px; background: var(--tc); box-shadow: 0 0 0 2px var(--px-line); }
.theme-count b { color: var(--tc); }
.theme-select { min-height: 32px; padding: 2px 6px; font-size: 12px; border-left: 8px solid var(--tc) !important; }

/* 도트 테두리 그림자가 화면 가장자리에서 1~3px 삐져나와 가로 스크롤이 생기지 않도록 */
html, body { overflow-x: clip; }

/* ── 잠금 ── */
.stage-card.locked, .theme-card.locked { cursor: not-allowed; background: var(--cell); }
.stage-card.locked { opacity: .7; }
.stage-card.locked .stage-no .px-ico { width: 20px; height: 20px; color: var(--muted); }
.theme-card.locked .theme-icon { filter: grayscale(.9) opacity(.55); }

/* ── 유저 스테이지 목록: 삭제 버튼·쪽 넘김 ── */
.stage-row { display: flex; gap: 6px; align-items: stretch; }
.stage-row .stage-card { flex: 1; min-width: 0; }
.row-del { align-self: center; color: var(--muted); }
.row-del:hover { color: var(--bad); }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin: 12px 0; }
.stage-card .px-ico-heart, .stage-card .px-ico-heartEmpty { vertical-align: -2px; }

/* ── 좋아요·체감 난이도 ── */
.like-btn { gap: 4px; padding: 0 6px; }
.like-btn .like-count { font-size: 13px; font-weight: 700; }
.like-btn[aria-pressed="true"] { color: var(--bad); }
.rate-box { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin: 8px 0 2px; }
.rate-dot { border: 0; background: none; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.rate-dot.on { color: var(--accent); }
.rate-dot .px-ico { width: 18px; height: 18px; }
.report-reasons { border: 0; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.report-reasons label { display: flex; gap: 8px; align-items: center; }
.report-reasons label[hidden] { display: none; }
#report-dialog textarea { width: 100%; }

/* ── 순위 ── */
.rank-sheet { max-height: 80vh; overflow: auto; }
.rank-list { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 4px; }
.rank-list li { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 8px; align-items: center; padding: 6px 8px; background: var(--cell); }
.rank-list li.me { background: var(--accent); color: var(--accent-fg); }
.rank-list li.rank-gap { display: block; text-align: center; background: none; color: var(--muted); padding: 0; }
.rank-no { font-weight: 800; text-align: center; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-score { font-size: 12px; }
.rank-list .stars .px-ico { width: 12px; height: 12px; }
.rank-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ── 관리자: 신고 ── */
.report-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.report-item ul { margin: 6px 0; padding-left: 18px; }
.report-item .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.report-dialogue { margin: 6px 0; }
.report-dialogue ol { margin: 4px 0 8px; padding-left: 20px; }

/* ── 손님 · 추천 줄 · 플레이 통계 ── */
.theme-card.guest { cursor: pointer; text-decoration: none; color: inherit; }
.guest-note p { margin: 6px 2px; }
.row-stats { align-self: center; color: var(--muted); }
.row-stats:hover { color: var(--accent); }
.user-highlights { display: grid; gap: 10px; margin: 0 0 12px; }
.user-highlights h3 { font-size: 14px; margin: 0 0 6px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.hl-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.hl-card { display: grid; gap: 3px; text-align: left; padding: 8px 10px; background: var(--panel); border: 2px solid var(--line, #0003); cursor: pointer; color: inherit; font: inherit; min-width: 0; }
.hl-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hl-card small { font-size: 12px; display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.hl-card:hover { border-color: var(--accent); }
.stats-dialog { width: min(560px, calc(100vw - 32px)); }
.stats-dialog h3 { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; }
.stats-nums { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; margin: 8px 0; }
.stats-nums div { background: var(--cell-alt); padding: 6px 8px; }
.stats-nums dt { font-size: 12px; color: var(--muted); }
.stats-nums dd { margin: 2px 0 0; font-size: 18px; font-weight: 800; }
.stats-view h4 { margin: 12px 0 6px; font-size: 14px; }
.stats-heat { display: grid; gap: 2px; max-width: 420px; }
.heat-cell { aspect-ratio: 1; background: var(--cell); display: flex; align-items: center; justify-content: center; position: relative; font-size: 11px; min-width: 0; }
.heat-cell.void { background: var(--bg); opacity: .35; }
.heat-cell .heat-mark { position: absolute; left: 2px; top: 0; font-size: 10px; color: var(--muted); }
.heat-cell b { color: #fff; text-shadow: 0 1px 0 #0008; }

/* ── 관리자 대시보드 ── */
.dash-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); align-items: start; }
.dash-card h3 { margin: 0 0 8px; font-size: 16px; }
.dash-kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; margin: 0 0 8px; }
.dash-kv div { background: var(--cell-alt); padding: 5px 7px; min-width: 0; }
.dash-kv dt { font-size: 11px; color: var(--muted); }
.dash-kv dd { margin: 2px 0 0; font-weight: 800; font-size: 15px; overflow-wrap: anywhere; }
.dash-list { margin: 0 0 8px; padding-left: 18px; display: grid; gap: 3px; }
.dash-errors { max-height: 220px; overflow: auto; overflow-wrap: anywhere; }
.dash-bars { display: grid; grid-template-columns: repeat(14, 1fr); gap: 2px; height: 80px; align-items: end; }
.dash-bar { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; }
.dash-bar span { width: 100%; background: var(--accent); min-height: 1px; }
.dash-bar small { font-size: 9px; color: var(--muted); }
.click-row { cursor: pointer; }
.click-row:hover { background: var(--cell-alt); }
.note-warn { color: #b7791f; }

/* 메뉴 NEW 표시 (업데이트 내역) */
.menu-card .new-badge { margin-left: 6px; font-size: 11px; font-weight: 800; padding: 1px 5px; background: #e5484d; color: #fff; vertical-align: 2px; }

/* ── 1.3 스토리 요소: 감시 카메라 · 미끼 간식 · 우리 레버 · 정전 ── */
.cell.cam-sight::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--cam, #e5484d) 34%, transparent) 0 4px, color-mix(in srgb, var(--cam, #e5484d) 14%, transparent) 4px 8px);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--cam, #e5484d) 60%, transparent); }
.obj-camera { position: relative; }
.obj-camera .token { position: absolute; right: 2px; top: 2px; }
.tile-lever { inset: 6%; }
.tile-button { inset: 8%; }
.obj-camera .spin-mark.px-ico { position: absolute; left: 0; bottom: 0; width: 38%; height: 38%; color: #e5484d; }
.tile-lever.open { animation: lever-pop .4s steps(3, end); }
@keyframes lever-pop { 50% { transform: scale(1.18); } }
.dark-layer { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.dark-cell { position: absolute; left: calc(var(--x) * var(--cell)); top: calc(var(--y) * var(--cell)); width: var(--cell); height: var(--cell);
  background: #15131f; box-shadow: 0 0 0 1px #15131f; }
.dark-cell.dark-mark { background: rgba(21,19,31,.38); box-shadow: inset 0 0 0 2px #8e4ec6; }
.husky.caught .sprite-husky { animation: caught-flash .5s steps(2, end) 3; }
@keyframes caught-flash { 50% { filter: drop-shadow(0 0 6px #e5484d) brightness(1.4); } }
.husky.asleep .sprite-husky { transform: rotate(90deg) translateX(10%); filter: grayscale(.5); }
.husky.asleep::after { content: 'z z'; position: absolute; right: 0; top: -6px; font-size: calc(var(--cell) * .28); font-weight: 800; color: #6b5bd6; }
@media (prefers-reduced-motion: reduce) { .tile-lever.open, .husky.caught .sprite-husky { animation: none; } }
.stage-rules { display: block; width: 100%; font-size: 12px; color: #8e4ec6; font-weight: 700; margin-top: 2px; }

/* 메뉴: 스토리 모드 카드 (어두운 밤 톤) */
.menu-card.story { background: linear-gradient(120deg, #0d1020 0%, #1b2240 60%, #2a2f55 100%) !important; color: #eef1ff !important; position: relative; overflow: hidden; }
.menu-card.story .menu-icon { background: #1f2747; }
.menu-card.story::after { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: radial-gradient(1px 1px at 20% 30%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 70% 20%, #fff 50%, transparent 51%), radial-gradient(1.5px 1.5px at 85% 65%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 40% 80%, #fff 50%, transparent 51%); }

/* 장 최종전 카드 */
.stage-card.final { border-color: var(--tc, var(--accent)); background: color-mix(in srgb, var(--tc, var(--accent)) 10%, var(--panel)); }
.stage-card.final .stage-no .px-ico { width: 22px; height: 22px; }
.final-tag { display: inline-block; font-size: 11px; font-weight: 800; padding: 1px 6px; margin-right: 6px; background: var(--tc, var(--accent)); color: #fff; vertical-align: 2px; }

/* ── 설정 창 (사용자 바의 톱니 단추) ── */
.userbar .set-open { min-width: 32px; padding: 4px 6px; }
.userbar .set-open .px-ico { width: 18px; height: 18px; display: block; }
.set-dialog { border: 3px solid var(--ink, #2d2a4a); border-radius: 0; background: var(--panel); color: var(--fg); padding: 18px; width: min(400px, calc(100vw - 32px)); box-shadow: 4px 4px 0 rgba(0,0,0,.35); }
.set-dialog::backdrop { background: rgba(0,0,0,.5); }
.set-dialog h3 { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; }
.set-dialog h3 .px-ico { width: 22px; height: 22px; }
.set-dialog h4 { margin: 14px 0 6px; font-size: 12px; opacity: .7; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0; }
.set-label { font-size: 14px; font-weight: 700; flex: none; }
.set-row input[type="range"] { flex: 1; max-width: 220px; min-height: 32px; }
.set-choice { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.set-choice .btn { min-height: 34px; padding: 4px 9px; font-size: 12px; }
.set-choice .btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg, #fff); }
.set-note { font-size: 12px; opacity: .7; margin: 12px 0 0; }
.set-dialog .dialog-actions { display: flex; justify-content: flex-end; margin-top: 12px; }

/* 관리자: 대전 기록 */
.adm-scroll { overflow-x: auto; }
#tab-duels > .panel { margin-top: 12px; }
#tab-duels h3 { margin: 0 0 8px; }
.duel-rules { border-top: 2px dashed var(--cell-alt); padding-top: 6px; margin-top: 6px; }
.duel-rules p { margin: 0 0 4px; font-size: 13px; }
.duel-log { margin: 8px 0; padding-left: 26px; max-height: 55vh; overflow: auto; font-size: 14px; }
.duel-log li { padding: 6px 0; border-bottom: 2px dashed var(--cell-alt); }
.duel-log .team-red { color: #e5484d; }
.duel-log .team-blue { color: #3e7bdd; }
#tab-duels .adm-table th:first-child, #tab-duels .adm-table td:first-child { padding: 8px 6px; width: auto; white-space: nowrap; }

/* ── 판 메뉴 (메인 메뉴를 작은 판으로: js/game/menu-board.js) ── */
.menu-mode-row { display: flex; justify-content: flex-end; margin: -6px 0 8px; }
.mg-root { display: flex; justify-content: center; }
.mg-board { --mg: 64px; position: relative; display: grid; grid-template-columns: repeat(var(--w), var(--mg)); grid-auto-rows: var(--mg); border: var(--px) solid var(--fg); background: var(--panel); box-shadow: 4px 4px 0 rgba(0,0,0,.25); }
.mg-cell { position: relative; padding: 0; margin: 0; border: 0; border-radius: 0; background: var(--panel); color: var(--fg); font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 0; overflow: hidden; -webkit-tap-highlight-color: transparent; }
.mg-cell.alt { background: var(--cell-alt); }
.mg-cell:hover:not(.station) { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 50%, transparent); }
.mg-cell:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 2; }
.mg-cell.station { background: color-mix(in srgb, var(--accent) 16%, var(--panel)); box-shadow: inset 0 0 0 var(--px) var(--fg); }
.mg-cell.station.story { background: linear-gradient(140deg, #0d1020, #2a2f55); color: #eef1ff; }
.mg-cell.station.admin { background: color-mix(in srgb, var(--accent) 34%, var(--panel)); }
.mg-cell.station.entering { animation: mg-enter .32s steps(4) both; }
@keyframes mg-enter { 50% { filter: brightness(1.6); transform: scale(1.08); } }
.mg-icon { width: 52%; height: 52%; display: block; }
.mg-icon svg { width: 100%; height: 100%; display: block; }
.mg-label { font-size: clamp(9px, calc(var(--mg) * .17), 13px); font-weight: 700; line-height: 1.1; white-space: nowrap; }
.mg-badge { position: absolute; top: 3px; right: 3px; font-size: 9px; font-weight: 800; padding: 0 3px; background: #e5484d; color: #fff; }
.mg-treat { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; --cell: var(--mg); }
.mg-treat .obj { position: static; }
.mg-treat svg, .mg-treat .sprite-pixel { width: calc(var(--mg) * .5); height: calc(var(--mg) * .5); display: block; }
.mg-cell.station .mg-treat { align-items: flex-start; justify-content: flex-start; padding: 2px; }
.mg-cell.station .mg-treat svg, .mg-cell.station .mg-treat .sprite-pixel { width: calc(var(--mg) * .3); height: calc(var(--mg) * .3); }
.mg-husky { position: absolute; left: 0; top: 0; width: var(--mg); height: var(--mg); padding: calc(var(--mg) * .1); box-sizing: border-box; pointer-events: none; z-index: 3;
  transform: translate(calc(var(--x) * var(--mg)), calc(var(--y) * var(--mg))); transition: transform .19s steps(6); }
.mg-husky svg { width: 100%; height: 100%; display: block; }
.mg-husky.moving svg { animation: mg-bob .19s steps(2) infinite; }
@keyframes mg-bob { 50% { transform: translateY(-6%); } }
.mg-help { text-align: center; margin: 10px 0 0; }
@media (prefers-reduced-motion: reduce) { .mg-husky { transition: none; } .mg-husky.moving svg, .mg-cell.station.entering { animation: none; } }

/* ── 앱 틀: 화면 전환 · 아래 탭 · 게임 안 대화창 · 타이틀 화면 ── */
/* 페이지를 옮길 때 새로 고침처럼 깜박이지 않게(지원하는 브라우저에서만) */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out .12s ease-out both; }
::view-transition-new(root) { animation: vt-in .18s ease-out both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { ::view-transition-old(root), ::view-transition-new(root) { animation: none; } }

.tabbar-wrap { display: none; }
@media (max-width: 720px) {
  .tabbar-wrap { display: block; }
  .tabbar-spacer { height: calc(62px + env(safe-area-inset-bottom, 0px)); }
  .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--panel, #fff); color: var(--fg, #2a2633); border-top: var(--px, 3px) solid var(--fg, #2a2633); view-transition-name: tabbar; }
  .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; padding: 6px 2px; border: 0; border-radius: 0; background: none; color: inherit; font: inherit; font-size: 11px; font-weight: 700; text-decoration: none; cursor: pointer; opacity: .6; -webkit-tap-highlight-color: transparent; }
  .tab .px-ico { width: 24px; height: 24px; display: block; }
  .tab[aria-current="page"] { opacity: 1; color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
  .tab:active { background: color-mix(in srgb, var(--accent) 16%, transparent); }
  /* 탭 줄이 있으면 위쪽 계정 줄과 '메뉴로' 링크는 필요 없다(내 정보 탭이 대신한다) */
  body.has-tabbar #userbar, body.has-tabbar .st-title-top { display: none; }
  /* 화면을 다 쓰는 곳에서는 숨긴다: 플레이 · 대전 중 · 스토리 진행 중 */
  body[data-screen="play"] .tabbar-wrap,
  body.duel-page[data-view="match"] .tabbar-wrap,
  body.story-page:not([data-screen="title"]):not([data-screen="chapters"]):not([data-screen="chapter"]) .tabbar-wrap { display: none; }
}
body.story-page .tabbar { background: #101426; color: #eef1ff; border-top-color: #2a3050; }

.app-dialog { border: var(--px, 3px) solid var(--fg); border-radius: 0; background: var(--panel); color: var(--fg); padding: 18px; width: min(380px, calc(100vw - 32px)); box-shadow: 4px 4px 0 rgba(0,0,0,.35); }
.app-dialog::backdrop { background: rgba(0,0,0,.5); }
.app-dialog h3 { margin: 0 0 8px; }
.app-dialog p { margin: 0 0 4px; line-height: 1.5; }
.app-dialog label { display: block; font-size: 13px; margin-bottom: 4px; }
.app-dialog input { width: 100%; min-height: 42px; padding: 0 10px; font: inherit; border: 2px solid var(--fg); background: var(--panel); color: var(--fg); box-sizing: border-box; }
.app-dialog .dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.app-dialog .btn { min-height: 42px; min-width: 84px; }
.btn.danger { background: #e5484d; color: #fff; }

.set-account { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.set-who { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; }
.set-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.set-links .btn, .set-account .btn { min-height: 36px; padding: 4px 10px; font-size: 13px; }
.set-pw { display: grid; gap: 4px; margin-top: 8px; padding: 10px; border: 2px dashed var(--cell-alt); }
.set-pw label { font-size: 12px; }
.set-pw input { min-height: 38px; padding: 0 8px; font: inherit; border: 2px solid var(--fg); background: var(--panel); color: var(--fg); }
.set-pw .btn { margin-top: 6px; }
.set-dialog { max-height: calc(100dvh - 32px); overflow: auto; }

.splash { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer;
  padding: env(safe-area-inset-top, 0px) 16px env(safe-area-inset-bottom, 0px); background: linear-gradient(180deg, #1b2240 0%, #2a2f55 55%, #f08c00 160%); color: #fff; text-align: center; transition: opacity .25s ease-out; }
.splash.out { opacity: 0; pointer-events: none; }
.splash-in { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.splash-husky { width: min(42vw, 180px); aspect-ratio: 1; animation: splash-bob 1.2s steps(2) infinite; }
.splash-husky svg { width: 100%; height: 100%; display: block; }
.splash h1 { margin: 6px 0 0; font-size: clamp(34px, 11vw, 56px); line-height: 1.15; letter-spacing: .02em; text-shadow: 4px 4px 0 rgba(0,0,0,.45); }
.splash-sub { margin: 0; opacity: .85; font-size: 15px; }
.splash-start { margin-top: 26px; padding: 12px 26px; border: 3px solid #fff; border-radius: 0; background: #f08c00; color: #fff; font: inherit; font-size: 18px; font-weight: 800; cursor: pointer; box-shadow: 4px 4px 0 rgba(0,0,0,.4); animation: splash-blink 1.1s steps(2) infinite; }
.splash-ver { position: absolute; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); margin: 0; font-size: 12px; opacity: .6; }
@keyframes splash-bob { 50% { transform: translateY(-4%); } }
@keyframes splash-blink { 50% { filter: brightness(1.25); } }
@media (prefers-reduced-motion: reduce) { .splash-husky, .splash-start { animation: none; } .splash { transition: none; } }

/* ── 스테이지 점검(관리자): 플레이 화면의 [편집]·[메모], 메모 창, 점검판, 제작소의 돌아가기 줄 ── */
.review-tools { display: inline-flex; gap: 4px; margin-left: 6px; flex: none; }
.review-btn { min-height: 30px; padding: 2px 8px; font-size: 12px; border-style: dashed; }
.review-dialog { width: min(460px, calc(100vw - 32px)); }
.review-kinds { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 10px; }
.review-kinds .btn { min-height: 36px; min-width: 0; padding: 4px 10px; font-size: 13px; }
.review-kinds .btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg, #fff); }
.review-dialog textarea { width: 100%; box-sizing: border-box; padding: 8px; font: inherit; border: 2px solid var(--fg); background: var(--panel); color: var(--fg); resize: vertical; }
.review-old, .review-notes, .review-issues { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.review-notes { list-style: none; padding-left: 0; }
.review-notes li.done, .review-old li.done { opacity: .5; text-decoration: line-through; }
.review-notes .icon-btn { min-width: 0; min-height: 0; padding: 0 2px; vertical-align: -3px; }
.review-issues li { color: var(--bad, #e5484d); }
#tab-review .adm-table th:first-child, #tab-review .adm-table td:first-child { padding: 8px 6px; width: auto; }
.review-table td { vertical-align: top; }
.review-table tr.is-story td:first-child { box-shadow: inset 4px 0 0 #5b6cff; }
.review-status.fix { background: color-mix(in srgb, #e5484d 22%, var(--panel)); }
.review-status.done { background: color-mix(in srgb, #30a46c 22%, var(--panel)); }
.back-to-play { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 50; display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--panel); color: var(--fg); border: var(--px, 3px) solid var(--accent); box-shadow: 4px 4px 0 rgba(0,0,0,.3); font-size: 13px; font-weight: 700; white-space: nowrap; }
.back-to-play .btn { min-height: 36px; padding: 4px 12px; font-size: 13px; }

/* 스테이지 미리 보기(관리자 점검 탭): 맵 보기 · 크게 보기 */
.review-view { display: inline-flex; gap: 4px; }
.review-view .btn[aria-pressed="true"], .preview-sols .btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg, #fff); }
.review-maps { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.review-map { display: flex; flex-direction: column; gap: 6px; padding: 10px; background: var(--panel); border: var(--px, 3px) solid var(--fg); }
.review-map.fix { border-color: #e5484d; }
.review-map.done { border-color: #30a46c; }
.cand-group { margin: 18px 0; }
.cand-group h3 { margin: 0 0 8px; }
.review-map header { display: flex; flex-direction: column; }
.review-map header strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.review-map p { margin: 0; }
.review-map .acts { display: flex; gap: 4px; margin-top: auto; }
.review-map .acts .btn { flex: 1; min-height: 32px; padding: 2px 6px; font-size: 12px; }
.review-map-pic { display: flex; align-items: center; justify-content: center; min-height: 120px; padding: 6px; border: 0; background: var(--cell-alt); cursor: zoom-in; overflow: hidden; }
.review-map-note { color: #b54708; }
.stage-preview { display: flex; justify-content: center; pointer-events: none; }
.stage-preview .board { flex: none; }
.preview-dialog { width: min(720px, calc(100vw - 32px)); }
.preview-board { display: flex; justify-content: center; overflow: auto; padding: 8px; background: var(--cell-alt); }
.preview-sols { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
