/* 스쿨버스 탈출! 주차장 슬라이드 */
:root {
  --sb-bg: #fffbeb;
  --sb-surface: #ffffff;
  --sb-ink: #1e293b;
  --sb-muted: #526071;
  --sb-border: #e7dec8;
  --sb-yellow: #eab308;
  --sb-yellow-dark: #ca8a04;
  --sb-lot: #334155;
  --sb-cell: #475569;
  --sb-shadow: 0 12px 28px rgba(30, 41, 59, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: var(--sb-bg); color: var(--sb-ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", -apple-system, sans-serif;
}
.sb-app {
  max-width: 1060px; margin: 0 auto; min-height: 100dvh;
  padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 14px;
}
.sb-topbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.sb-topbar-left, .sb-topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sb-brand-title { margin: 0; font-size: 1.15rem; font-weight: 800; }

.sb-btn-ghost, .sb-btn-pill, .sb-btn-primary, .sb-btn-secondary {
  font-family: inherit; cursor: pointer; border: none; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-weight: 700; transition: transform 0.12s ease, background 0.15s ease;
}
.sb-btn-ghost {
  background: #fff; color: var(--sb-ink); border: 1.5px solid var(--sb-border);
  border-radius: 12px; padding: 8px 13px; font-size: 0.92rem; min-height: 40px;
}
.sb-btn-ghost:hover { background: #fef3c7; border-color: var(--sb-yellow); }
.sb-btn-sm { padding: 7px 12px; font-size: 0.88rem; }
.sb-btn-pill {
  background: #fff; color: var(--sb-ink); border: 1.5px solid var(--sb-border);
  border-radius: 999px; padding: 7px 13px; font-size: 0.88rem; min-height: 38px;
}
.sb-btn-pill:hover { background: #fef9c3; border-color: var(--sb-yellow); }
.sb-btn-share { background: #ecfdf5; border-color: #6ee7b7; color: #065f46; }
.sb-btn-primary {
  background: linear-gradient(135deg, #facc15, #ea580c); color: #fff;
  border-radius: 16px; padding: 13px 26px; font-size: 1.05rem; font-weight: 800;
  box-shadow: 0 8px 20px rgba(234, 88, 12, 0.24);
}
.sb-btn-secondary {
  background: #f1f5f9; color: var(--sb-ink); border: 1.5px solid #cbd5e1;
  border-radius: 14px; padding: 12px 20px; font-size: 0.96rem;
}
.sb-screen[hidden], .sb-modal-backdrop[hidden] { display: none !important; }

/* Lobby */
.sb-lobby-card {
  background: #fff; border: 2px solid var(--sb-border); border-radius: 26px;
  padding: 22px; box-shadow: var(--sb-shadow); display: flex; flex-direction: column; gap: 20px;
}
.sb-setup-head { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.sb-setup-head h2 { margin: 0; font-size: 1.5rem; }
.sb-setup-head button { margin-inline-start: auto; }
.sb-tier-summary { font-size: 0.9rem; font-weight: 800; color: #047857; }
.sb-btn-start { min-width: 210px; }

.sb-tier-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.sb-tier-tab {
  font-family: inherit; cursor: pointer; background: #f8fafc; color: var(--sb-muted);
  border: 1.5px solid var(--sb-border); border-radius: 12px; padding: 9px 14px; font-weight: 800; font-size: 0.9rem;
}
.sb-tier-tab.is-active { background: #fef3c7; border-color: var(--sb-yellow); color: #854d0e; }
.sb-puzzle-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.sb-puzzle-card {
  font-family: inherit; cursor: pointer; text-align: left; background: #fcfaf4;
  border: 2px solid var(--sb-border); border-radius: 16px; padding: 13px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.sb-puzzle-card:hover { border-color: var(--sb-yellow); transform: translateY(-1px); }
.sb-puzzle-card.is-cleared { background: #f0fdf4; border-color: #86efac; }
.sb-puzzle-card-top { display: flex; justify-content: space-between; font-size: 0.82rem; font-weight: 800; color: var(--sb-muted); }
.sb-puzzle-card-title { font-size: 1rem; font-weight: 800; color: var(--sb-ink); }
.sb-puzzle-card-meta { font-size: 0.8rem; color: var(--sb-muted); }

/* Play Screen */
html[data-classroom-playing] .sb-body {
  background: #fdf1dd url("../img/play-world.74b36aecbbf3.webp") center bottom / cover no-repeat fixed;
}
html[data-classroom-playing] .sb-app { max-width: 1440px; min-height: calc(100dvh - var(--classroom-play-height)); }
.sb-play {
  display: grid; grid-template-columns: minmax(150px, 200px) minmax(0, 630px) minmax(150px, 230px);
  gap: clamp(12px, 3vw, 40px); align-items: start; justify-content: center;
}
.sb-play-tools {
  display: grid; gap: 12px; padding: 16px; border: 1px solid var(--sb-border); border-radius: 20px;
  background: #fff9ed; box-shadow: var(--sb-shadow);
}
.sb-play-tools p { margin: 0; word-break: keep-all; line-height: 1.55; }
.sb-drag-tip { text-align: left; }
.sb-hud-actions button { min-height: 44px; }
#btn-hint { background: #ffde70; border-color: #c98307; color: #5a3006; }
@media (min-width: 901px) {
  .sb-hud { display: grid; gap: 14px; }
  .sb-hud-stats { display: grid; grid-template-columns: 1fr 1fr; }
  .sb-hud-stats .sb-stat-pill { min-width: 0; }
  .sb-hud-stats .sb-stat-pill span { font-size: .82rem; }
  .sb-hud-stats .sb-stat-pill strong { font-size: 1.3rem; }
  #btn-hint { min-width: 100px; font-size: 1rem; }
}
.sb-play :focus-visible { outline: 3px solid #7350b4; outline-offset: 3px; }
.sb-hud {
  width: 100%; background: #fff; border: 2px solid var(--sb-border); border-radius: 18px;
  padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.sb-hud-left, .sb-hud-stats, .sb-hud-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sb-puzzle-info { display: flex; flex-direction: column; }
.sb-puzzle-tier { font-size: 0.78rem; font-weight: 700; color: var(--sb-muted); }
.sb-puzzle-name { font-size: 1.05rem; font-weight: 900; }
.sb-stat-pill {
  background: #f8fafc; border: 1.5px solid #e2e8f0; border-radius: 12px;
  padding: 5px 12px; display: flex; flex-direction: column; align-items: center; min-width: 72px;
}
.sb-stat-pill span { font-size: 0.72rem; font-weight: 700; color: var(--sb-muted); }
.sb-stat-pill strong { font-size: 1rem; font-weight: 900; }

.sb-hint-banner {
  margin: 0; padding: 9px 16px; border-radius: 12px; background: #fef9c3;
  border: 1.5px solid #facc15; color: #854d0e; font-weight: 800; font-size: 0.94rem;
}

.sb-board-stage { width: 100%; display: flex; justify-content: center; padding: 6px 34px 0 0; }
.sb-lot-frame {
  position: relative; display: flex; align-items: center;
  background: #1e293b; padding: 14px; border-radius: 24px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.22);
}
.sb-board {
  position: relative;
  width: min(50vw, 565px, calc(100dvh - 210px)); aspect-ratio: 1;
  background: var(--sb-lot); border-radius: 14px;
  display: grid; grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(6, 1fr);
  gap: 6px; padding: 6px; touch-action: none; user-select: none;
}
.sb-grid-cell {
  background: var(--sb-cell); border-radius: 8px;
}
.sb-grid-cell.is-exit-lane {
  background: rgba(250, 204, 21, 0.2);
}
.sb-exit-gate {
  position: absolute; right: -46px; top: calc(14px + 6px + (100% - 40px) * 2 / 6);
  height: calc((100% - 40px) / 6); width: 46px;
  background: linear-gradient(90deg, #facc15, #f97316); color: #fff;
  border-radius: 0 14px 14px 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 900;
  line-height: 1.1; box-shadow: 4px 4px 14px rgba(234, 88, 12, 0.3);
}
.sb-exit-gate strong { font-size: 1.1rem; }

.sb-vehicle {
  position: absolute; border-radius: 13px; cursor: grab; touch-action: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; color: #fff; font-size: 0.9rem;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.2), 0 4px 10px rgba(0, 0, 0, 0.28);
  transition: left 0.12s ease, top 0.12s ease, transform 0.12s ease;
  border: 2.5px solid rgba(255, 255, 255, 0.45);
}
.sb-vehicle.is-dragging { cursor: grabbing; transition: none; z-index: 15; transform: scale(1.03); }
.sb-vehicle.is-selected { outline: 3px solid #fde047; outline-offset: 2px; z-index: 12; }
.sb-vehicle.is-hint { animation: sb-pulse 0.9s infinite; outline: 4px solid #fde047; z-index: 14; }
@keyframes sb-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.7); }
  50% { box-shadow: 0 0 0 10px rgba(250, 204, 21, 0); }
}

.sb-bus-art { width: 90%; height: 95%; background: url("../img/school-bus.227b4f7bc72b.webp") center / contain no-repeat; }
.sb-kind-bus { background: linear-gradient(135deg, #facc15, #f59e0b); color: #78350f; border-color: #fef08a; }
.sb-kind-truck { background: linear-gradient(135deg, #f97316, #dc2626); }
.sb-kind-mint { background: linear-gradient(135deg, #34d399, #059669); }
.sb-kind-sky { background: linear-gradient(135deg, #38bdf8, #0284c7); }
.sb-kind-coral { background: linear-gradient(135deg, #fb7185, #e11d48); }
.sb-kind-lavender { background: linear-gradient(135deg, #a78bfa, #7c3aed); }

.sb-play-footer {
  grid-column: 2; width: 100%; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
}
.sb-drag-tip { font-size: 0.94rem; color: var(--sb-muted); font-weight: 700; }

/* Modals */
.sb-modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 1000;
}
.sb-modal-card {
  width: 100%; max-width: 460px; background: #fff; border-radius: 24px; padding: 24px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.25);
}
.sb-clear-card { text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.sb-clear-badge { background: #fef08a; color: #854d0e; font-weight: 900; padding: 6px 14px; border-radius: 999px; }
.sb-stars { font-size: 2.2rem; letter-spacing: 6px; }
.sb-clear-meta { margin: 0; color: var(--sb-muted); font-weight: 700; }
.sb-clear-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.sb-modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.sb-modal-head h2 { margin: 0; font-size: 1.2rem; }
.sb-modal-close { width: 34px; height: 34px; border-radius: 50%; border: none; background: #f1f5f9; font-weight: 800; cursor: pointer; }
.sb-help-list { margin: 0 0 18px; padding-left: 20px; display: flex; flex-direction: column; gap: 9px; line-height: 1.55; color: #334155; }
.sb-modal-foot { display: flex; justify-content: flex-end; }
.sb-qr-desc { margin: 0 0 12px; color: var(--sb-muted); font-size: 0.92rem; }
.sb-qr-box { display: flex; justify-content: center; padding: 12px; background: #f8fafc; border-radius: 16px; margin-bottom: 12px; }
.sb-qr-url-row { display: flex; gap: 8px; }
.sb-qr-url { flex: 1; min-width: 0; border: 1.5px solid #cbd5e1; border-radius: 12px; padding: 8px 10px; font-size: 0.85rem; background: #f8fafc; }
.sb-copy-feedback { margin: 8px 0 0; min-height: 1.2em; font-size: 0.86rem; font-weight: 700; color: #059669; text-align: center; }

@media (max-width: 900px) {
  .sb-play { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .sb-play-footer { grid-column: 1; }
  .sb-board { width: min(calc(100vw - 98px), 510px); }
  .sb-play-tools { padding: 10px 12px; }
}
@media (max-width: 520px) {
  .sb-app { padding-inline: 10px; }
  .sb-lobby-card { padding: 14px; }
  .sb-setup-head button { margin-inline-start: 0; }
  .sb-puzzle-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sb-hud { padding: 8px; border-radius: 14px; }
  .sb-puzzle-name { font-size: .9rem; }
  .sb-hud-left { flex: 1 1 125px; gap: 4px; }
  .sb-hud-stats { gap: 4px; }
  .sb-hud-stats .sb-stat-pill { min-width: 52px; padding-inline: 5px; }
  .sb-board-stage { padding-right: 24px; }
  .sb-lot-frame { padding: 6px; border-radius: 15px; }
  .sb-board { width: calc(100vw - 62px); gap: 3px; padding: 3px; }
  .sb-exit-gate { right: -24px; width: 24px; top: 34%; height: 16%; font-size: .64rem; }
  .sb-vehicle { border-radius: 7px; border-width: 1.5px; }
  .sb-kind-bus { font-size: .66rem; }
  .sb-grid-cell { border-radius: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .sb-vehicle, .sb-puzzle-card { animation: none !important; transition: none; }
}

[data-classroom-game-stage] .cg-guide-entry { display: none; }
[data-game-native-reset][data-play-native-control] { display: none; }

#modal-clear { inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; border: 0; padding: 0; background: transparent; }
#modal-clear:not([open]) { display: none; }
#modal-clear[open] { position: fixed; display: grid; place-items: center; }
#modal-clear::backdrop { background: #10182791; }

body.sb-body #classroom-play-toolbar h1 { overflow-wrap: normal; word-break: keep-all; }

.sb-drag-figure { display: none; }
@media (min-width: 1200px) and (min-height: 800px) {
  .sb-play { margin-top: 22px; }
  .sb-board { width: min(50vw, 610px, calc(100dvh - 227px)); }
  .sb-drag-figure { display: block; width: 100%; height: auto; border-radius: 12px; }
  .sb-play-tools { margin-top: 34px; }
  .sb-drag-tip { font-size: 1.04rem; }
  .sb-hud-stats .sb-stat-pill { min-height: 65px; justify-content: center; }
}
