:root {
  --paper: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --ink: #18212f;
  --muted: #657185;
  --line: #d7dde8;
  --shadow: 0 18px 48px rgba(24, 33, 47, 0.12);
  --blue: #2563eb;
  --green: #0f9f6e;
  --orange: #f97316;
  --rose: #e11d48;
  --yellow: #eab308;
  --violet: #7c3aed;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  letter-spacing: 0;
  background:
    linear-gradient(90deg, rgba(24, 33, 47, 0.045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(24, 33, 47, 0.045) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

button {
  border: 0;
  font: inherit;
}

button:focus-visible,
.game-card:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.38);
  outline-offset: 3px;
}

.hidden {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 14px clamp(16px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: rgba(246, 247, 251, 0.9);
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #fff;
  font-weight: 900;
  background: #18212f;
  border-radius: 8px;
  box-shadow: inset 0 -5px 0 rgba(255, 255, 255, 0.12);
}

.brand-lockup h1,
.brand-lockup p,
.dashboard-head h2,
.dashboard-head p,
.game-titlebar h2,
.game-credit {
  margin: 0;
}

.brand-lockup h1 {
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.1;
}

.brand-lockup p,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.nav-button,
.close-button,
.option-button,
.plain-button,
#overlay-action-btn {
  min-height: 42px;
  padding: 0 15px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.nav-button:hover,
.close-button:hover,
.option-button:hover,
.plain-button:hover,
#overlay-action-btn:hover {
  transform: translateY(-1px);
  border-color: #aab4c4;
  box-shadow: 0 10px 24px rgba(24, 33, 47, 0.12);
}

.dashboard-view,
.game-view {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
}

.dashboard-view {
  padding: clamp(20px, 4vw, 46px) 0 48px;
}

.dashboard-head {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, 0.6fr);
  gap: 20px;
  align-items: end;
  padding: 18px 0 26px;
}

.dashboard-head h2 {
  max-width: 780px;
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1.02;
}

.dashboard-head p {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.game-card {
  position: relative;
  display: grid;
  min-height: 330px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 8px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 14px 38px rgba(24, 33, 47, 0.1);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.game-card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--accent), #fff 20%);
  box-shadow: var(--shadow);
}

.card-index {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #fff;
  font-weight: 900;
  border-radius: var(--radius);
  background: var(--accent);
}

.card-visual {
  display: grid;
  min-height: 98px;
  place-items: center;
}

.card-symbol {
  position: relative;
  width: 96px;
  height: 76px;
}

.card-symbol::before,
.card-symbol::after {
  position: absolute;
  content: "";
  border-radius: 999px;
  background: var(--accent);
}

.symbol-cake::before {
  left: 8px;
  right: 8px;
  bottom: 8px;
  height: 34px;
  border-radius: 24px 24px 10px 10px;
}

.symbol-cake::after {
  top: 8px;
  left: 32px;
  width: 30px;
  height: 30px;
  box-shadow: -24px 26px 0 rgba(24, 33, 47, 0.16), 24px 26px 0 rgba(24, 33, 47, 0.16);
}

.symbol-ship::before {
  left: 6px;
  right: 4px;
  bottom: 10px;
  height: 32px;
  clip-path: polygon(0 0, 100% 0, 82% 100%, 16% 100%);
  border-radius: 4px;
}

.symbol-ship::after {
  left: 48px;
  top: 8px;
  width: 32px;
  height: 46px;
  clip-path: polygon(0 0, 100% 22%, 0 100%);
  border-radius: 4px;
  background: rgba(24, 33, 47, 0.18);
}

.symbol-bird::before {
  left: 22px;
  top: 18px;
  width: 48px;
  height: 40px;
}

.symbol-bird::after {
  right: 18px;
  top: 28px;
  width: 28px;
  height: 18px;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  border-radius: 0;
  background: rgba(24, 33, 47, 0.18);
}

.symbol-draw::before {
  left: 10px;
  top: 12px;
  width: 76px;
  height: 52px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, transparent 45%, rgba(255, 255, 255, 0.85) 46% 54%, transparent 55%),
    var(--accent);
}

.symbol-draw::after {
  left: 18px;
  bottom: 12px;
  width: 60px;
  height: 8px;
  border-radius: 999px;
  background: rgba(24, 33, 47, 0.18);
}

.symbol-lock::before {
  left: 22px;
  bottom: 8px;
  width: 52px;
  height: 40px;
  border-radius: 8px;
}

.symbol-lock::after {
  left: 32px;
  top: 8px;
  width: 32px;
  height: 34px;
  border: 10px solid rgba(24, 33, 47, 0.18);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  background: transparent;
}

.game-card h3 {
  margin: 12px 0 8px;
  font-size: 21px;
}

.game-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.card-meta {
  display: grid;
  gap: 8px;
  align-self: end;
}

.concept-pill {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 6px 9px;
  color: color-mix(in srgb, var(--accent), #101827 35%);
  font-size: 12px;
  font-weight: 900;
  border: 1px solid color-mix(in srgb, var(--accent), #fff 58%);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent), #fff 90%);
}

.card-actions {
  display: flex;
  gap: 8px;
}

.plain-button {
  width: fit-content;
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.ghost-button {
  color: var(--ink);
  border-color: var(--line);
  background: var(--surface);
}

.game-view {
  padding: 22px 0 44px;
}

.game-titlebar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.game-titlebar h2 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.03;
}

.title-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-credit {
  color: var(--muted);
  font-size: 14px;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr) minmax(250px, 300px);
  gap: 12px;
  align-items: stretch;
}

.status-panel,
.scene-panel,
.control-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(24, 33, 47, 0.08);
}

.status-panel,
.control-panel {
  padding: 14px;
}

.status-panel {
  display: grid;
  align-content: start;
  gap: 10px;
}

.status-row {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.status-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-row strong {
  font-size: 22px;
}

.scene-panel {
  position: relative;
  min-height: 560px;
  overflow: hidden;
}

.control-panel {
  display: grid;
  align-content: start;
  gap: 12px;
}

.control-panel h3 {
  margin: 0;
  font-size: 18px;
}

.control-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.option-grid {
  display: grid;
  gap: 8px;
}

.option-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 50px;
  padding: 10px 12px;
  text-align: left;
  background: var(--surface);
}

.option-button strong {
  color: var(--blue);
}

.answer-input {
  width: 100%;
  height: 52px;
  padding: 0 12px;
  color: var(--ink);
  font: inherit;
  font-size: 22px;
  font-weight: 900;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.answer-input:focus {
  outline: 3px solid rgba(37, 99, 235, 0.18);
  border-color: var(--blue);
}

.game-overlay,
.pdf-viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(24, 33, 47, 0.52);
}

.overlay-card,
.pdf-viewer-card {
  width: min(100%, 520px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.overlay-card {
  padding: 24px;
}

.overlay-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.overlay-card h3 {
  margin: 6px 0 10px;
  font-size: 28px;
}

.overlay-card p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

#overlay-action-btn {
  width: 100%;
  color: #fff;
  border-color: var(--ink);
  background: var(--ink);
}

.pdf-viewer {
  z-index: 120;
}

.pdf-viewer-card {
  width: min(100%, 940px);
  max-height: 90dvh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.pdf-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.pdf-viewer-head h3 {
  margin: 0;
}

.close-button {
  width: 42px;
  padding: 0;
  font-size: 26px;
}

.pdf-sheets {
  display: grid;
  gap: 12px;
  padding: 14px;
  overflow: auto;
}

.pdf-sheets img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.pattern-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.mini-token {
  display: grid;
  min-width: 44px;
  height: 44px;
  place-items: center;
  padding: 0 10px;
  color: #fff;
  font-weight: 900;
  border-radius: 999px;
  background: var(--token, var(--blue));
}

.missing-token {
  color: var(--ink);
  border: 2px dashed #aab4c4;
  background: #fff;
}

.cake-stage {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100%;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.08), transparent 38%),
    linear-gradient(0deg, rgba(15, 159, 110, 0.08), transparent 52%),
    #fff;
}

.scene-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.scene-caption h3,
.scene-caption p {
  margin: 0;
}

.scene-caption p {
  color: var(--muted);
}

.bakery-counter {
  display: grid;
  place-items: center;
  padding: 26px;
}

.cake-plate {
  position: relative;
  width: min(84%, 460px);
  height: 280px;
}

.plate {
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 10px;
  height: 30px;
  border-radius: 50%;
  background: #dfe5ee;
  box-shadow: inset 0 -8px 0 rgba(24, 33, 47, 0.08);
}

.cake-base {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 34px;
  height: 92px;
  border: 1px solid #b88149;
  border-radius: 28px 28px 12px 12px;
  background:
    linear-gradient(0deg, rgba(255, 255, 255, 0.3), transparent),
    #f3be7c;
  box-shadow: inset 0 -14px 0 rgba(136, 88, 39, 0.16);
}

.cake-cream {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 112px;
  height: 44px;
  border-radius: 28px;
  background: #fff5df;
  box-shadow: inset 0 -8px 0 rgba(237, 198, 115, 0.22);
}

.topping {
  position: absolute;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  animation: popIn 260ms ease both;
}

.topping.strawberry {
  background: var(--rose);
}

.topping.choco {
  background: #6d4c41;
}

.topping.banana {
  color: #5d4200;
  background: var(--yellow);
}

.topping.cream {
  color: #6b4a00;
  background: #ffe5aa;
}

.topping.kiwi {
  background: var(--green);
}

.topping.blueberry {
  background: var(--blue);
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translate(-50%, -40%) scale(0.65);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.ship-stage {
  display: grid;
  min-height: 100%;
  padding: 18px;
  background:
    linear-gradient(180deg, #e9f7ff 0 48%, #cfeaf8 49% 58%, #2d7da6 59% 100%);
}

.ship-wrap {
  position: relative;
  align-self: end;
  min-height: 390px;
}

.ship-hull {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 64px;
  height: 150px;
  border-radius: 0 0 80px 80px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0 2px, transparent 2px 80px),
    #8b4c2e;
  box-shadow: inset 0 -20px 0 rgba(24, 33, 47, 0.18);
  clip-path: polygon(0 0, 100% 0, 86% 100%, 13% 100%);
}

.ship-mast {
  position: absolute;
  left: 50%;
  bottom: 160px;
  width: 12px;
  height: 200px;
  background: #5b3925;
  transform: translateX(-50%);
}

.ship-sail {
  position: absolute;
  left: 50%;
  bottom: 230px;
  width: 130px;
  height: 120px;
  background: #fff;
  border: 1px solid var(--line);
  clip-path: polygon(0 0, 100% 22%, 0 100%);
}

.escape-track {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 230px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.track-step {
  display: grid;
  height: 74px;
  place-items: center;
  color: var(--ink);
  font-weight: 900;
  border: 1px solid rgba(24, 33, 47, 0.2);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.84);
}

.track-step.done {
  color: #fff;
  background: var(--green);
}

.dodo-token {
  position: absolute;
  left: 8%;
  bottom: 178px;
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  color: #fff;
  font-weight: 900;
  border-radius: 50% 50% 44% 44%;
  background: var(--orange);
  transition: left 260ms ease;
}

.dodo-token::after {
  position: absolute;
  right: -14px;
  top: 23px;
  width: 22px;
  height: 16px;
  content: "";
  background: #f6c453;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.bird-stage {
  display: grid;
  min-height: 100%;
  padding: 18px;
  background: #f9fbff;
}

.pattern-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(64px, 1fr));
  gap: 10px;
  align-self: center;
  width: min(100%, 620px);
  margin: 0 auto;
}

.bird-cell {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.bird-cell.missing {
  border: 2px dashed #aab4c4;
  background: repeating-linear-gradient(135deg, #fff 0 10px, #f2f5fa 10px 20px);
}

.bird-tile {
  display: grid;
  width: min(68px, 72%);
  height: min(68px, 72%);
  place-items: center;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  border-radius: 50% 50% 42% 42%;
}

.tile-crow {
  background: #1f2937;
}

.tile-dodo {
  background: var(--orange);
}

.tile-kiwi {
  background: var(--green);
}

.tile-pigeon {
  background: var(--blue);
}

.draw-stage {
  display: grid;
  min-height: 100%;
  padding: 18px;
  background: #fff;
}

.art-board {
  position: relative;
  align-self: center;
  width: min(100%, 660px);
  height: 430px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, #eaf4ff 0 58%, #e6f6ed 58% 100%);
}

.art-layer {
  position: absolute;
  opacity: 0.12;
  transition: opacity 260ms ease, transform 260ms ease;
}

.art-layer.active {
  opacity: 1;
  transform: translateY(0);
}

.sun {
  top: 38px;
  right: 56px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--yellow);
}

.cloud {
  top: 76px;
  left: 60px;
  width: 150px;
  height: 54px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 44px 6px 0 8px #fff, 86px -4px 0 0 #fff;
}

.house {
  left: 230px;
  bottom: 84px;
  width: 190px;
  height: 150px;
  border-radius: 8px;
  background: #ef745c;
}

.house::before {
  position: absolute;
  left: -18px;
  right: -18px;
  top: -74px;
  height: 88px;
  content: "";
  background: #334155;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.road {
  left: 140px;
  right: 140px;
  bottom: -40px;
  height: 170px;
  border-radius: 50% 50% 0 0;
  background: #94a3b8;
  clip-path: polygon(38% 0, 62% 0, 100% 100%, 0 100%);
}

.prison-stage {
  display: grid;
  min-height: 100%;
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(24, 33, 47, 0.05) 1px, transparent 1px),
    #fff;
  background-size: 44px 44px;
}

.prison-wrap {
  position: relative;
  align-self: center;
  width: min(100%, 620px);
  height: 420px;
  margin: 0 auto;
}

.cell-door {
  position: absolute;
  left: 50%;
  top: 18px;
  width: 260px;
  height: 330px;
  border: 8px solid #1f2937;
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(90deg, transparent 0 38px, rgba(31, 41, 55, 0.9) 38px 48px),
    #edf2f7;
  transform: translateX(-50%);
  transition: transform 300ms ease, opacity 300ms ease;
}

.cell-door.open {
  transform: translateX(-84%) rotateY(18deg);
  opacity: 0.56;
}

.friend {
  position: absolute;
  left: 50%;
  top: 150px;
  display: grid;
  width: 86px;
  height: 112px;
  place-items: center;
  color: #fff;
  font-weight: 900;
  border-radius: 42px 42px 20px 20px;
  background: var(--green);
  transform: translateX(-50%);
}

.lock-stack {
  position: absolute;
  right: 26px;
  top: 44px;
  display: grid;
  gap: 10px;
}

.lock-dot {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  color: #fff;
  font-weight: 900;
  border-radius: var(--radius);
  background: #64748b;
}

.lock-dot.done {
  background: var(--green);
}

.life-row {
  display: flex;
  gap: 6px;
}

.life-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--rose);
}

.life-dot.empty {
  background: #cbd5e1;
}

@media (max-width: 1180px) {
  .game-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 920px) {
  .dashboard-head,
  .game-shell,
  .game-titlebar {
    grid-template-columns: 1fr;
  }

  .dashboard-head,
  .game-titlebar {
    display: grid;
    align-items: start;
  }

  .title-actions {
    justify-content: space-between;
  }

  .scene-panel {
    min-height: 480px;
  }

  .status-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .topbar {
    min-height: 66px;
  }

  .brand-lockup p {
    display: none;
  }

  .game-grid {
    grid-template-columns: 1fr;
  }

  .game-card {
    min-height: 250px;
  }

  .status-panel {
    grid-template-columns: 1fr;
  }

  .title-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    width: 100%;
  }

  .pattern-board {
    gap: 6px;
  }

  .scene-panel {
    min-height: 430px;
  }

  .cake-plate {
    width: 100%;
  }

  .escape-track {
    left: 4%;
    right: 4%;
    gap: 6px;
  }
}

/* Layout refresh: mission map dashboard + stage-first play screen. */
.dashboard-view {
  width: min(1380px, calc(100% - 32px));
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
  gap: 18px;
  padding-top: clamp(18px, 3vw, 34px);
}

.dashboard-head {
  position: sticky;
  top: 96px;
  display: flex;
  min-height: 580px;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  padding: 22px;
  border: 1px solid var(--line);
  border-left: 8px solid var(--ink);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.08), transparent 42%),
    var(--surface);
  box-shadow: 0 14px 36px rgba(24, 33, 47, 0.08);
}

.dashboard-head::after {
  content: "01  02  03  04  05";
  display: block;
  width: 100%;
  margin-top: 24px;
  padding-top: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  border-top: 1px solid var(--line);
  word-spacing: 12px;
}

.dashboard-head h2 {
  max-width: 8.4em;
  font-size: clamp(32px, 3.6vw, 48px);
  line-height: 1.04;
  overflow-wrap: normal;
  text-wrap: pretty;
  word-break: keep-all;
}

.dashboard-head p {
  max-width: 26ch;
  font-size: 15px;
}

.game-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-auto-rows: minmax(190px, auto);
  gap: 14px;
  align-items: stretch;
}

.game-grid::before {
  position: absolute;
  inset: 60px 7% auto 7%;
  height: 72%;
  content: "";
  border: 2px dashed rgba(24, 33, 47, 0.16);
  border-left: 0;
  border-bottom: 0;
  border-radius: 0 90px 0 0;
  pointer-events: none;
}

.game-card {
  min-height: 0;
  isolation: isolate;
}

.game-card:nth-child(1) {
  grid-column: 1 / span 4;
  grid-row: 1;
}

.game-card:nth-child(2) {
  grid-column: 5 / span 4;
  grid-row: 1;
  margin-top: 34px;
}

.game-card:nth-child(3) {
  grid-column: 2 / span 4;
  grid-row: 2;
}

.game-card:nth-child(4) {
  grid-column: 6 / span 3;
  grid-row: 2;
  margin-top: 42px;
}

.game-card:nth-child(5) {
  grid-column: 1 / span 5;
  grid-row: 3;
}

.game-card::after {
  position: absolute;
  right: 14px;
  bottom: 12px;
  z-index: -1;
  color: color-mix(in srgb, var(--accent), #fff 78%);
  content: "RULE";
  font-size: 48px;
  font-weight: 950;
  letter-spacing: 0;
}

.card-visual {
  position: absolute;
  top: 14px;
  right: 12px;
  min-height: 72px;
  opacity: 0.9;
  transform: scale(0.82);
  transform-origin: top right;
}

.card-index {
  margin-bottom: 44px;
}

.card-meta {
  margin-top: 12px;
}

.game-view {
  width: min(1280px, calc(100% - 32px));
}

.game-titlebar {
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-top: 6px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(24, 33, 47, 0.08);
}

.game-titlebar h2 {
  font-size: clamp(24px, 3vw, 38px);
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "status"
    "scene"
    "controls";
}

.status-panel {
  grid-area: status;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.scene-panel {
  grid-area: scene;
  min-height: 600px;
}

.control-panel {
  position: sticky;
  bottom: 12px;
  z-index: 20;
  grid-area: controls;
  grid-template-columns: minmax(190px, 0.44fr) minmax(0, 0.78fr) minmax(260px, 1.2fr);
  align-items: start;
  gap: 14px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
}

.control-panel > h3 {
  min-height: 50px;
  display: flex;
  align-items: center;
}

.control-copy {
  grid-column: 2;
  grid-row: 1;
  padding-left: 14px;
  border-left: 3px solid var(--line);
}

.control-panel .option-grid {
  grid-column: 3;
  grid-row: 1 / span 3;
  grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
  align-self: stretch;
}

.control-panel form.option-grid {
  align-content: start;
}

.rule-card {
  display: grid;
  grid-column: 1 / span 2;
  grid-row: 2;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.rule-label {
  color: var(--ink);
  font-size: 13px;
}

.rule-sequence {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  line-height: 1.2;
}

.rule-chip {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  color: #fff;
  font-size: clamp(15px, 2vw, 20px);
  font-weight: 900;
  border-radius: 999px;
  background: var(--ink);
}

.rule-chip.is-missing {
  color: var(--ink);
  border: 2px dashed #8b97aa;
  background: #fff;
}

.rule-separator {
  color: var(--muted);
  font-size: 22px;
  font-weight: 900;
}

.rule-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.sep-comma .rule-separator {
  transform: translateY(4px);
}

.sep-none .rule-chip {
  width: 100%;
  border-radius: var(--radius);
  font-size: clamp(22px, 4vw, 34px);
}

.scene-caption p {
  max-width: 60ch;
  line-height: 1.45;
}

@media (max-width: 1120px) {
  .dashboard-view {
    display: block;
  }

  .dashboard-head {
    position: static;
    min-height: auto;
    margin-bottom: 16px;
  }

  .dashboard-head h2,
  .dashboard-head p {
    max-width: none;
  }

  .game-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: auto;
  }

  .game-grid::before {
    display: none;
  }

  .game-card:nth-child(n) {
    grid-column: auto;
    grid-row: auto;
    margin-top: 0;
  }

  .control-panel {
    grid-template-columns: 1fr;
  }

  .control-panel .option-grid {
    grid-column: auto;
    grid-row: auto;
  }

  .control-copy,
  .rule-card {
    grid-column: auto;
    grid-row: auto;
  }
}

@media (max-width: 680px) {
  .dashboard-view,
  .game-view {
    width: min(100% - 20px, 680px);
  }

  .game-grid {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }

  .rule-chip {
    min-height: 38px;
    padding: 7px 10px;
  }
}

/* ===== 디버깅 페이퍼 반영 (v2) ===== */

/* 공통: 이모지 규칙 칩 */
.chip-emoji .rule-chip {
  min-width: 50px;
  color: var(--ink);
  font-size: 26px;
  border: 1px solid var(--line);
  background: #fff;
}

.chip-emoji .rule-chip.is-missing {
  font-size: 20px;
  border: 2px dashed #8b97aa;
}

.chip-emoji .rule-chip.is-covered {
  border: 2px solid #f2c1cf;
  background: #fdf0f4;
}

/* 공통: 제한시간 바 */
.timer-track {
  position: relative;
  display: flex;
  align-items: center;
  width: min(220px, 40vw);
  height: 26px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}

.timer-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  background: var(--green);
  transition: width 100ms linear, background 200ms ease;
}

.timer-fill.danger {
  background: var(--rose);
}

.timer-text {
  position: relative;
  z-index: 1;
  width: 100%;
  color: var(--ink);
  font-size: 13px;
  text-align: center;
}

/* 1. 케이크 가게: 이모지 토핑 + 고양이 */
.topping-emoji {
  position: absolute;
  font-size: 36px;
  transform: translate(-50%, -50%);
  animation: popIn 260ms ease both;
  filter: drop-shadow(0 3px 4px rgba(24, 33, 47, 0.25));
}

.bakery-counter {
  position: relative;
}

.cat-buddy {
  position: absolute;
  right: 18px;
  bottom: 14px;
  display: grid;
  gap: 6px;
  justify-items: end;
}

.cat-face {
  font-size: 44px;
  filter: drop-shadow(0 3px 4px rgba(24, 33, 47, 0.2));
}

.cat-speech {
  max-width: 190px;
  padding: 8px 10px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: 12px 12px 2px 12px;
  background: #fff;
  box-shadow: 0 6px 14px rgba(24, 33, 47, 0.1);
}

.difficulty-grid .option-button strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

/* 2. 도도새의 탈출: 5문제 트랙 + 디테일 도도새 + 불구이 장면 */
.escape-track {
  grid-template-columns: repeat(5, 1fr);
}

.dodo-holder {
  position: absolute;
  bottom: 152px;
  width: 96px;
  transition: left 300ms ease;
}

.dodo-svg {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 4px 6px rgba(24, 33, 47, 0.3));
}

.dodo-svg.flipped {
  transform: rotate(180deg);
}

.roast-mode {
  background: linear-gradient(180deg, #2b2118 0 55%, #17110c 100%);
}

.roast-mode .scene-caption h3,
.roast-mode .scene-caption p {
  color: #f8e9d2;
}

.roast-stage {
  display: grid;
  align-self: center;
  justify-items: center;
  gap: 2px;
  padding: 30px 0 50px;
}

.roast-spit {
  width: 120px;
  padding-bottom: 6px;
  border-bottom: 5px solid #6f4a24;
  animation: roastTurn 2.4s ease-in-out infinite;
}

.roast-fire {
  font-size: 44px;
  animation: flicker 700ms ease-in-out infinite alternate;
}

.roast-logs {
  font-size: 32px;
}

@keyframes roastTurn {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
}

@keyframes flicker {
  from { transform: scale(1); opacity: 0.85; }
  to { transform: scale(1.12); opacity: 1; }
}

/* 3. 새 규칙 찾기: 무늬판 아래 선택 버튼 */
.bird-choice {
  align-self: start;
  width: min(100%, 620px);
  margin: 16px auto 0;
  text-align: center;
}

.bird-choice p {
  margin: 0 0 10px;
  color: var(--muted);
  font-weight: 800;
}

.bird-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.bird-option {
  min-width: 108px;
  padding: 14px 18px;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(24, 33, 47, 0.2);
  transition: transform 140ms ease;
}

.bird-option:hover {
  transform: translateY(-3px) scale(1.04);
}

/* 4. 사칙연산 규칙 찾기: 모눈종이 + 카운트다운 */
.grid-paper-wrap {
  position: relative;
  align-self: center;
  width: min(100%, 560px);
  margin: 0 auto;
}

.grid-paper {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  overflow: hidden;
  border: 2px solid #93c5fd;
  border-radius: var(--radius);
  background: #fff;
}

.grid-cell {
  aspect-ratio: 1;
  border-right: 1px solid #dbeafe;
  border-bottom: 1px solid #dbeafe;
  transition: background 300ms ease;
}

.countdown-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  color: var(--blue);
  font-size: clamp(64px, 14vw, 120px);
  font-weight: 950;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
}

/* 5. 감옥을 열어라: 폭탄 + 폭발 + 흔들리는 입력 */
.caption-side {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.bomb {
  position: absolute;
  left: calc(50% + 64px);
  top: 220px;
  font-size: 42px;
  transform: translateX(-50%);
  animation: bombPulse 900ms ease-in-out infinite alternate;
}

@keyframes bombPulse {
  from { transform: translateX(-50%) scale(1); }
  to { transform: translateX(-50%) scale(1.14); }
}

.prison-stage.exploded {
  background: radial-gradient(circle at 50% 55%, #fde68a 0 12%, #f97316 32%, #7c2d12 70%, #431407 100%);
}

.prison-stage.exploded .scene-caption h3,
.prison-stage.exploded .scene-caption p {
  color: #fff7ed;
}

.explosion-wrap {
  display: grid;
  place-items: center;
  min-height: 300px;
  font-size: clamp(90px, 20vw, 170px);
  animation: popIn 300ms ease both;
}

.lock-feedback {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--rose);
  font-size: 14px;
  font-weight: 800;
}

.answer-input.shake {
  animation: shakeX 300ms ease;
  border-color: var(--rose);
}

/* ===== 개발 과정(디버깅 스토리) 페이지 ===== */
.topbar-actions {
  display: flex;
  gap: 8px;
}

.process-view {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(20px, 4vw, 46px) 0 56px;
}

.process-head {
  max-width: 860px;
  margin-bottom: 26px;
  padding: 22px;
  border: 1px solid var(--line);
  border-left: 8px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 14px 36px rgba(24, 33, 47, 0.08);
}

.process-head h2 {
  margin: 6px 0 12px;
  font-size: clamp(26px, 4vw, 40px);
  line-height: 1.08;
  word-break: keep-all;
}

.process-head p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.process-head p strong {
  color: var(--ink);
}

.process-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.process-flow span {
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 800;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}

.process-flow span:last-child {
  color: #fff;
  border-color: var(--ink);
  background: var(--ink);
}

.process-flow b {
  color: var(--muted);
}

#process-list {
  display: grid;
  gap: 18px;
}

.process-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 8px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 14px 38px rgba(24, 33, 47, 0.1);
}

.process-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.process-card-head .card-index {
  margin-bottom: 0;
}

.process-card-title {
  flex: 1;
  min-width: 0;
}

.process-card-title h3 {
  margin: 0 0 2px;
  font-size: 21px;
}

.process-card-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.process-steps {
  display: grid;
  grid-template-columns: 1.1fr 1.1fr 0.9fr;
  gap: 0;
}

.process-step {
  padding: 16px 18px;
  border-left: 1px solid var(--line);
}

.process-step:first-child {
  border-left: 0;
}

.step-tag {
  display: inline-block;
  margin-bottom: 10px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  border-radius: 999px;
}

.step-final {
  background: color-mix(in srgb, var(--accent), #fff 94%);
}

.step-final .step-tag {
  color: #fff;
  background: var(--accent);
}

.step-paper .step-tag {
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.step-draft {
  background: #f8fafc;
}

.step-draft .step-tag {
  color: var(--muted);
  border: 1px dashed #aab4c4;
  background: #fff;
}

.process-step ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 7px;
  font-size: 14px;
  line-height: 1.55;
}

.step-draft ul {
  color: var(--muted);
}

.process-step blockquote {
  margin: 0 0 12px;
  padding: 10px 12px;
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.65;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface-2);
  word-break: keep-all;
}

.paper-thumb-button {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.paper-thumb-button span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.paper-thumb {
  width: 100%;
  max-height: 190px;
  object-fit: cover;
  object-position: top;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.paper-thumb-button:hover .paper-thumb {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(24, 33, 47, 0.16);
}

#open-process-inline-btn {
  margin-top: 14px;
}

@media (max-width: 920px) {
  .process-steps {
    grid-template-columns: 1fr;
  }

  .process-step {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .process-step:first-child {
    border-top: 0;
  }

  .process-card-head {
    flex-wrap: wrap;
  }
}

@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  50% { transform: translateX(7px); }
  75% { transform: translateX(-4px); }
}
