/* ════════════════════════════════════════
   RESET & TOKENS
════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Mona Sans 12 (모나12) — see assets/fonts/LICENSE-MONA.txt */
@font-face {
  font-family: "Mona Sans 12";
  src: url("assets/fonts/MonaS12.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Mona Sans 12";
  src: url("assets/fonts/MonaS12-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Mona Sans 12 KR";
  src: url("assets/fonts/MonaS12TextKR.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Mona Sans 12 KR";
  src: url("assets/fonts/MonaS12TextKR.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Mona Sans 12 Emoji";
  src: url("assets/fonts/Mona12Emoji.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg:        #F8F9FA;
  --surface:   #FFFFFF;
  --border:    #E5E7EB;
  --border2:   #D1D5DB;
  --text:      #111827;
  --text-sub:  #6B7280;
  --text-dim:  #9CA3AF;
  --blue:      #4F46E5;
  --blue-lt:   #EEF2FF;
  --orange:    #EA580C;
  --orange-lt: #FFF7ED;
  --green:     #16A34A;
  --green-lt:  #F0FDF4;
  --red:       #DC2626;
  --gold:      #D97706;
  --font: "Mona Sans 12", "Mona Sans 12 KR", "Mona Sans 12 Emoji";
  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  font-family: var(--font);
}

body {
  min-height: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  overflow-x: hidden;
  overflow-y: hidden;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

/* ════════════════════════════════════════
   VIEW SWITCHER
════════════════════════════════════════ */
.view {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: none;
  flex-direction: column;
  justify-content: flex-start;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  background: var(--bg);
}
.view.active { display: flex; }

#survival.survival-view {
  position: fixed;
  inset: 0;
  padding: 0;
  overflow: hidden;
}
#survival.survival-view.active {
  display: flex;
  flex-direction: column;
}
#survival .survival-hub-btn {
  position: absolute;
  top: max(0.65rem, env(safe-area-inset-top, 0px));
  left: max(1rem, env(safe-area-inset-left, 0px));
  z-index: 20;
  margin: 0;
  padding: 0.42rem 0.78rem;
  border: 2px solid #ffffff;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-family: var(--font);
  font-size: clamp(0.88rem, 2.8vw, 1rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: #ffffff;
  -webkit-text-stroke: 1.15px #9ca3af;
  paint-order: stroke fill;
  text-shadow: none;
  transition: opacity 0.15s, transform 0.15s;
}
#survival .survival-hub-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}
#survival .survival-hub-btn:active {
  transform: translateY(0);
  opacity: 0.85;
}
#survival .survival-hub-btn:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}
#survival .survival-frame {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: var(--bg);
}

#personal-color.personal-color-view {
  position: fixed;
  inset: 0;
  padding: 0;
  overflow: hidden;
}
#personal-color.personal-color-view.active {
  display: flex;
  flex-direction: column;
}
#personal-color .personal-color-frame {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #f2f0ed;
}

/* 허브 배경 별 — 문서 흐름에 쌓이지 않도록 고정 */
#stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
#stars .star {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  animation: hub-star-twinkle var(--dur, 3s) ease-in-out infinite alternate;
  opacity: var(--op, 0.4);
}
@keyframes hub-star-twinkle {
  from { opacity: calc(var(--op, 0.4) * 0.45); }
  to   { opacity: var(--op, 0.4); }
}

/* ════════════════════════════════════════
   HUB
════════════════════════════════════════ */
.hub-header {
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  padding: 1.2rem 2rem;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.hub-logo {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  max-width: 900px;
  margin: 0 auto;
}

.hub-npc {
  width: 72px;
  height: 72px;
  object-fit: contain;
  image-rendering: pixelated;
  cursor: pointer;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.hub-npc:hover { transform: scale(1.12) rotate(-4deg); }

.hub-eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--blue);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.hub-title {
  font-size: 1.65rem;
  font-weight: 900;
  line-height: 1.2;
  color: var(--text);
  letter-spacing: -0.5px;
}
.hub-title em {
  font-style: normal;
  color: var(--blue);
}

.hub-desc {
  font-size: 0.82rem;
  color: var(--text-sub);
  margin-top: 0.3rem;
}

.hub-intro-headline {
  display: flex;
  flex-direction: column;
  transform: translateY(2px);
}

/* GRID */
.hub-grid {
  flex: 1;
  display: flex;
  gap: 1.2rem;
  padding: 1.5rem 2rem;
  overflow: hidden;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  align-items: stretch;
}

/* GAME CARDS */
a.game-card {
  text-decoration: none;
  color: inherit;
}
.game-card {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  position: relative;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  overflow: hidden;
}
.game-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border2);
}
.game-card:active { transform: translateY(-1px); }

.card-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  width: fit-content;
}
.card-badge.new {
  color: var(--orange);
  border-color: var(--orange);
  background: var(--orange-lt);
  animation: badgePulse 1.8s ease-in-out infinite alternate;
}
@keyframes badgePulse {
  from { opacity: 1; }
  to   { opacity: 0.5; }
}

.card-icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-icon { font-size: 1.8rem; }
.card-icon--img.card-icon--fortune-cookie {
  width: 1.85rem;
  height: 1.85rem;
  object-fit: contain;
  image-rendering: auto;
  display: block;
}
.card-body h2 {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 0.35rem;
  letter-spacing: -0.3px;
}
.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.card-body p {
  font-size: 0.8rem;
  color: var(--text-sub);
  line-height: 1.6;
}

.card-arrow {
  position: absolute;
  bottom: 1.2rem;
  right: 1.2rem;
  font-size: 1.1rem;
  color: var(--text-dim);
  transition: transform 0.2s, color 0.2s;
}
.game-card:hover .card-arrow { transform: translateX(4px); color: var(--blue); }

.hub-footer {
  text-align: center;
  padding: 0.8rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  border-top: 1.5px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.hub-footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
}

.hub-footer-legal {
  margin: 0;
  text-align: center;
  line-height: 1.55;
  max-width: 52rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.15rem 0.35rem;
}
.hub-footer-line {
  display: inline;
}
.hub-footer-legal a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.hub-footer-legal a:hover {
  color: var(--blue);
}

/* ════════════════════════════════════════
   오락실 · 화이트 + 모나12
════════════════════════════════════════ */
#hub.hub--8bit {
  /* 착착봇 톤 · 메뉴(흰 영역) 바깥 하늘 */
  --h8-sky-top: #c9ecfc;
  --h8-sky-mid: #8fd4f5;
  --h8-sky-bottom: #6ec4eb;
  --h8-bg: #8fd4f5;
  --h8-panel: #ffffff;
  --h8-card: #ffffff;
  --h8-text: #111827;
  --h8-dim: #6b7280;
  --h8-border: #e5e7eb;
  position: relative;
  justify-content: flex-start;
  min-height: 0;
  height: 100%;
  max-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background-color: var(--h8-bg);
  background-image: linear-gradient(
    165deg,
    var(--h8-sky-top) 0%,
    var(--h8-sky-mid) 42%,
    var(--h8-sky-bottom) 100%
  );
  color: var(--h8-text);
  font-family: var(--font);
  align-items: center;
}

#hub.hub--8bit > * {
  position: relative;
  z-index: 1;
}

#hub.hub--8bit .hub-intro,
#hub.hub--8bit .hub-grid,
#hub.hub--8bit .hub-footer,
#hub.hub--8bit .hub-route-log {
  width: 100%;
  max-width: 1160px;
  margin-inline: auto;
  box-sizing: border-box;
}

#hub.hub--8bit .hub-grid {
  flex: 0 0 auto;
  overflow: visible;
  max-width: 1160px;
  margin-inline: auto;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  padding-left: max(1.5rem, env(safe-area-inset-left, 0px));
  padding-right: max(1.5rem, env(safe-area-inset-right, 0px));
}

#hub.hub--8bit .hub-intro {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  flex-shrink: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding:
    calc(env(safe-area-inset-top, 0px) + 0.9rem)
    max(2rem, env(safe-area-inset-right, 0px))
    1.15rem
    max(2rem, env(safe-area-inset-left, 0px));
  gap: 0.75rem 1rem;
  background: var(--h8-panel);
  border: none;
  border-radius: 0 0 16px 16px;
  box-shadow: 0 8px 28px rgba(46, 140, 190, 0.18);
}

#hub.hub--8bit .hub-intro-inner {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1.2rem;
  flex: 1;
  min-width: 0;
}

#hub.hub--8bit .hub-intro-copy {
  text-align: left;
}

#hub.hub--8bit .hub-plaza-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  min-width: 56px;
  min-height: 56px;
  padding: 0;
  padding-top: 3px;
  margin: 0;
  cursor: pointer;
  font: inherit;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
#hub.hub--8bit .hub-card-icon--plaza {
  background: #ecfdf5;
}
#hub.hub--8bit .hub-plaza-btn:hover {
  border-color: #86efac;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.2);
}
#hub.hub--8bit .hub-plaza-btn:active {
  transform: scale(0.96);
}
#hub.hub--8bit .hub-plaza-icon {
  width: 2.45rem;
  height: 2.45rem;
  display: block;
  flex-shrink: 0;
  pointer-events: none;
  transform: translateY(2px);
}
#hub.hub--8bit .hub-plaza-icon,
#hub.hub--8bit .hub-plaza-icon rect {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hub-route-log {
  display: none;
  margin: 0;
  padding: 0.5rem max(2rem, env(safe-area-inset-right, 0px)) 0.65rem max(2rem, env(safe-area-inset-left, 0px));
  max-height: 6rem;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.65rem;
  line-height: 1.45;
  color: #6b7280;
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--h8-border, #e5e7eb);
  white-space: pre-wrap;
  word-break: break-all;
}
.hub-route-log.hub-route-log--visible {
  display: block;
}

#hub.hub--8bit .hub-bot-mascot {
  display: block;
  line-height: 0;
  flex-shrink: 0;
}

#hub.hub--8bit .hub-bot-mascot picture {
  display: block;
  line-height: 0;
}

#hub.hub--8bit .hub-bot-img {
  width: 80px;
  height: auto;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 8px;
  box-shadow: none;
  background: rgba(255, 255, 255, 0.55);
}

#hub.hub--8bit .hub-eyebrow {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--h8-dim);
  margin-bottom: 0.2rem;
  background: none;
  border: none;
  padding: 0;
  box-shadow: none;
}

#hub.hub--8bit .hub-title {
  font-size: clamp(1.25rem, 4vw, 1.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--h8-text);
  text-shadow: none;
}
#hub.hub--8bit .hub-title em {
  color: inherit;
  font-style: normal;
}

#hub.hub--8bit .hub-desc {
  color: var(--h8-dim);
  font-size: 0.85rem;
  font-weight: 500;
}

#hub.hub--8bit:not(.hub--menu-open) .hub-grid {
  display: none;
}

#hub.hub--8bit .game-card {
  background: var(--h8-card);
  border: 1px solid var(--h8-border);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  color: var(--h8-text);
}
#hub.hub--8bit .game-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  border-color: #d1d5db;
  opacity: 1;
}
#hub.hub--8bit .game-card:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

#hub.hub--8bit .card-badge {
  border: 1px solid var(--h8-border);
  border-radius: 999px;
  color: var(--h8-dim);
  background: #f9fafb;
  font-weight: 600;
  box-shadow: none;
}
#hub.hub--8bit .card-badge.new {
  color: #c2410c;
  background: #fff7ed;
  border-color: #fdba74;
  box-shadow: none;
  animation: none;
}

#hub.hub--8bit .card-icon-wrap {
  border-radius: 12px;
  border: 1px solid var(--h8-border);
  box-shadow: none;
}

#hub.hub--8bit .hub-card-icon--1 { background: #fff7ed; }
#hub.hub--8bit .hub-card-icon--2 { background: #fdf2f8; }
#hub.hub--8bit .hub-card-icon--3 { background: #eef2ff; }
#hub.hub--8bit .hub-card-icon--4 { background: #fff7ed; }
#hub.hub--8bit .hub-card-icon--5 { background: #f0fdf4; }
#hub.hub--8bit .hub-card-icon--6 { background: #f5f3ff; }

#hub.hub--8bit .card-body h2 {
  color: var(--h8-text);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-shadow: none;
}
#hub.hub--8bit .card-body p {
  color: var(--h8-dim);
  line-height: 1.5;
  font-weight: 500;
}

#hub.hub--8bit .card-arrow {
  color: var(--h8-dim);
  font-weight: 600;
  font-size: 1.05rem;
}
#hub.hub--8bit .game-card:hover .card-arrow {
  color: #4f46e5;
}

#hub.hub--8bit .hub-footer {
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 14px 14px 0 0;
  color: var(--h8-dim);
  font-weight: 500;
  font-size: 0.68rem;
  letter-spacing: 0;
  line-height: 1.55;
  padding: 0.85rem max(1.25rem, env(safe-area-inset-right, 0px)) max(0.85rem, env(safe-area-inset-bottom, 0px)) max(1.25rem, env(safe-area-inset-left, 0px));
  box-shadow: none;
}
#hub.hub--8bit .hub-footer-legal a:hover {
  color: #4f46e5;
}

/* ════════════════════════════════════════
   HUB · 데스크톱 / 넓은 화면
════════════════════════════════════════ */
@media (min-width: 701px) {
  #hub.hub--8bit .hub-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    align-items: stretch;
    padding: 1.25rem max(1.5rem, env(safe-area-inset-right, 0px)) 1.5rem max(1.5rem, env(safe-area-inset-left, 0px));
  }

  #hub.hub--8bit .game-card {
    flex: unset;
    width: auto;
    min-width: 0;
    max-width: none;
    margin-inline: 0;
  }

  #hub.hub--8bit .card-body h2 {
    font-size: clamp(0.92rem, 1.1vw, 1.05rem);
  }

  #hub.hub--8bit .card-body p {
    font-size: clamp(0.72rem, 0.85vw, 0.8rem);
  }

  #hub.hub--8bit .hub-footer-legal {
    flex-direction: row;
    flex-wrap: wrap;
  }
  #hub.hub--8bit .hub-footer-line {
    display: inline;
  }
  #hub.hub--8bit .hub-footer-line + .hub-footer-line::before {
    content: ' · ';
    white-space: pre;
  }
}

@media (min-width: 1025px) {
  #hub.hub--8bit .hub-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.1rem;
  }
}

/* ════════════════════════════════════════
   GAME 4 · 서울 메이어 메이커
════════════════════════════════════════ */
#maker .maker-layout {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem 1rem max(0.75rem, env(safe-area-inset-bottom, 0px));
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
}

.maker-play-fit {
  --maker-fit-scale: 1;
  width: min(100%, 560px);
  max-width: 100%;
  margin: -30px auto 0;
  flex: 0 1 auto;
  min-height: 0;
  max-height: calc(100dvh - 3.5rem);
  max-height: calc(100vh - 3.5rem);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: hidden;
}

.maker-play-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  flex: 0 0 auto;
  gap: 0.35rem;
  transform: scale(var(--maker-fit-scale, 1));
  transform-origin: top center;
  will-change: transform;
}

.maker-brand {
  text-align: center;
  font-size: clamp(1.05rem, 3.5vw, 1.35rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #4f46e5;
  margin-bottom: 0.35rem;
}

.maker-hint {
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--text-sub);
  text-align: center;
  margin-bottom: 0.85rem;
}

.maker-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  flex: 0 1 auto;
  min-height: 0;
}

/* 원오 옷입히기 — 중앙 확대 */
.maker-dress-zone {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  min-width: 0;
  padding: 0.15rem 0;
}

.maker-character-panel {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: min(100%, 540px);
  max-width: 100%;
  gap: 0.5rem;
}

.maker-character-title {
  margin: 0;
  width: 100%;
  font-size: clamp(0.72rem, 2.4vw, 0.88rem);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-align: center;
  color: #78350f;
  user-select: none;
}

.maker-equipped--compact {
  width: 100%;
  max-width: 100%;
  padding: 0.2rem 0.15rem 0.28rem;
}

.maker-equipped--compact .maker-equipped-title {
  display: none;
}

.maker-equipped--compact .maker-equipped-slots {
  gap: 0.15rem;
  padding: 0.15rem 0.08rem;
}

.maker-equipped--compact .maker-eq-img {
  width: 100%;
  height: 100%;
}

.maker-equipped--compact .maker-eq-caption {
  font-size: 0.55rem;
  line-height: 1.15;
}

/* 하위 호환 */
.maker-preview-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

/* 캐릭터 프리뷰 */
.maker-preview {
  position: relative;
  width: min(100%, 280px);
  aspect-ratio: 1 / 1;
}

/* 누끼 착용: 원본 캔버스 비율(1536×1024) — 레이어 위치 어긋남 방지 */
.maker-preview.maker-preview--nukki-wear {
  aspect-ratio: 1536 / 1024;
  width: min(100%, 380px);
  max-width: min(100%, 380px);
  background: #fff;
  border-radius: var(--radius);
  border: 2px solid var(--border2);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* 베이스 캐릭터 이미지 */
.maker-layer-base {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  object-position: center center;
  pointer-events: none;
  z-index: 1;
}

/*
 * 슬롯 영역 — body-base.png (500×500 전신 어린원오) 픽셀 분석 기반
 *
 * Layering (z-index):
 *   body-base(1) < shoes(2) < bottom(3) < top(4) < head(5)
 *   → 상의(4)가 하의(3) 위 — 바지 밖으로 입힌 느낌
 *
 * 구조: body-base, head, top, bottom, shoes 모두 동일한 500×500 프레임을 공유.
 *   각 옷 이미지는 body-base 와 같은 좌표계에 그려져야 한다.
 *   → 모든 슬롯이 프리뷰 전체(left=0, top=0, 100%×100%)를 덮으며,
 *     z-index 만으로 layering 순서를 제어한다.
 */
.maker-slot-container {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.maker-slot-container[data-slot="head"]   { z-index: 5; }
.maker-slot-container[data-slot="top"]    { z-index: 4; }  /* 상의 — 하의보다 위 */
.maker-slot-container[data-slot="bottom"] { z-index: 3; }
.maker-slot-container[data-slot="shoes"]  { z-index: 2; }

/*
 * 옷 레이어: 흰/밝은 배경은 multiply 로 베이스 위에서 사라지게 함.
 * 주의: 이 img 에 transform / filter / opacity(<1) 를 주면 일부 브라우저에서
 *       mix-blend-mode 백드롭이 깨져 흰 사각형이 그대로 보일 수 있음 → 위치·크기는
 *       absolute + width/height 로만 조정할 것.
 */
.maker-layer-item {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 100%;
  /* 모든 레이어 동일 500×500 프레임 — 가운데 정렬 */
  object-fit: contain;
  object-position: center center;
  mix-blend-mode: multiply;
  pointer-events: none;
  display: block;
}

/* 알파(누끼) PNG: 일반 합성이 가장 자연스러움 — JS 가 maker-layer-item--has-alpha 부여 */
.maker-layer-item.maker-layer-item--has-alpha {
  mix-blend-mode: normal;
}

/* 누끼 착용 프리뷰: 레이어 전부 일반 합성 + 축소 시 부드럽게(계단 현상 방지) */
.maker-preview--nukki-wear .maker-layer-base,
.maker-preview--nukki-wear .maker-layer-item {
  mix-blend-mode: normal;
  image-rendering: auto;
}

/* 비어있는 슬롯은 숨김 */
.maker-slot-container:not(.has-item) { visibility: hidden; }

/* dressuppieces(500×500)용 — 머리만 위쪽 정렬 */
.maker-preview:not(.maker-preview--nukki-wear) .maker-slot-container[data-slot="head"] .maker-layer-item {
  object-position: center top;
}

#maker-canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 2;
  opacity: 1;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.maker-equipped {
  width: 100%;
  max-width: 384px;
  padding: 0.45rem 0.5rem 0.55rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.maker-equipped-title {
  display: block;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 0.35rem;
}

.maker-equipped-slots {
  display: flex;
  justify-content: space-between;
  gap: 4px;
}

.maker-eq-slot {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.maker-eq-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  image-rendering: pixelated;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: #fff;
  display: block;
}

.maker-eq-slot.is-empty .maker-eq-img {
  opacity: 0;
  pointer-events: none;
}

.maker-eq-slot.is-empty {
  position: relative;
}

.maker-eq-slot.is-empty::after {
  content: '—';
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-dim);
  opacity: 0.45;
  pointer-events: none;
}

.maker-eq-slot:not(.is-empty) {
  cursor: pointer;
}

.maker-eq-slot.maker-eq-slot--nudge-focus .maker-eq-img {
  outline: 2px solid var(--accent, #2563eb);
  outline-offset: 2px;
  border-color: var(--accent, #2563eb);
}

.maker-eq-caption {
  font-size: 0.58rem;
  font-weight: 800;
  color: var(--text-sub);
  letter-spacing: -0.02em;
}

.maker-inv-section {
  flex: 0 0 auto;
  width: min(100%, 540px);
  max-width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  align-self: center;
}

.maker-inv-header {
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(0.7rem, 2vw, 0.9rem);
  font-weight: 900;
  letter-spacing: 0.15em;
  text-align: center;
  color: #92400e;
  margin: 0;
  padding: 0.1em 0;
  user-select: none;
}

.maker-inv-spacehint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  font-size: 0.72rem;
  font-weight: 700;
  color: #92400e;
  opacity: 0.75;
  margin-top: 0.1rem;
  user-select: none;
}

/* 모바일 전용 — Space 대신 탭하는 확정 버튼 (데스크톱에서는 숨김) */
.maker-mobile-pick-btn {
  display: none;
}

.maker-key-btn,
.maker-key-space {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 0.15em 0.55em;
  border-radius: 4px;
  border: 1.5px solid #c9a227;
  background: #fef9c3;
  color: #78350f;
  box-shadow: 0 2px 0 #c9a227;
  line-height: 1.4;
}

.maker-inventory {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.maker-inv-row {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s;
  cursor: pointer;
}

.maker-inv-row.active-row {
  border-color: #eab308;
  box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.28);
}

.maker-inv-row.active-row .maker-inv-label {
  background: linear-gradient(180deg, #ca8a04 0%, #a16207 100%);
  color: #fff;
}

.maker-inv-label {
  width: 4.5rem;
  min-width: 4.5rem;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-dim);
  text-align: center;
  padding: 0.4rem 0.25rem;
  border: none;
  border-right: 1.5px solid var(--border);
  background: var(--bg);
  letter-spacing: 0.03em;
  transition: background 0.15s, color 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  line-height: 1.2;
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
}
.maker-inv-label:focus-visible {
  outline: 2px solid #eab308;
  outline-offset: -2px;
}
.maker-inv-label-name {
  display: block;
}
.maker-inv-label-pick { display: none; }
.maker-inv-row.active-row .maker-inv-label-pick {
  opacity: 1;
}

.maker-inv-list {
  display: flex;
  gap: 4px;
  padding: 5px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.maker-inv-btn {
  width: 54px;
  height: 54px;
  min-width: 54px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 3px;
  transition: border-color 0.12s, background 0.12s;
  flex-shrink: 0;
}

.maker-inv-btn:hover {
  border-color: var(--blue);
  background: var(--blue-lt);
}

.maker-inv-btn.selected {
  border: 2.5px solid #f59e0b;
  background: #fef3c7;
  box-shadow: 0 0 0 2px #fcd34d55;
}

/* SPACE 커서(방향키로 이동 중인 항목) */
.maker-inv-btn.cursor {
  border: 2.5px solid #eab308;
  background: #fef9c3;
  box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.35);
  transform: scale(1.08);
}

.maker-inv-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
}

/* 엔딩 확인 버튼 */
.maker-action-bar {
  text-align: center;
  margin-top: 0.75rem;
}

.maker-space-btn {
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 800;
  background: #f59e0b;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 2.5rem;
  cursor: pointer;
  letter-spacing: 0.06em;
  box-shadow: 0 2px 8px rgba(245,158,11,0.4);
  transition: all 0.15s;
  animation: pulseBtn 1.5s ease-in-out infinite alternate;
}

.maker-space-btn:hover {
  background: #d97706;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(245,158,11,0.5);
}

.maker-space-btn:active { transform: translateY(0); }

.maker-play-again-btn {
  background: #16a34a;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.45);
  animation: none;
  margin-bottom: 0.5rem;
}

.maker-play-again-btn:hover {
  background: #15803d;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.5);
}

@keyframes pulseBtn {
  from { box-shadow: 0 2px 8px rgba(245,158,11,0.4); }
  to   { box-shadow: 0 4px 18px rgba(245,158,11,0.75); }
}

/* SPACE 힌트 바 */
.maker-spacebar-hint {
  text-align: center;
  margin-top: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  font-weight: 700;
}
.maker-spacebar-hint kbd {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border2);
  background: var(--bg);
  font-size: 0.78rem;
  font-family: var(--font);
}
.maker-spacebar-hint strong { color: #ca8a04; }

.maker-lose-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  margin: 0 auto;
  transform: translateX(-6px);
}

.maker-lose-actions .main-btn {
  flex: 0 1 auto;
  min-width: 0;
  padding: 0.58rem 0.95rem;
  font-size: 0.88rem;
}

.maker-lose-retry {
  margin-right: 0.12rem;
}

/* 혼종/꽝 오버레이 — #maker 직속 fixed (스크롤·레이아웃과 분리) */
.maker-lose {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(4px);
  z-index: 55;
  padding: 1rem;
  pointer-events: none;
}

.maker-lose.is-open {
  display: flex;
  pointer-events: auto;
}

.maker-lose.is-open .maker-lose-card {
  pointer-events: auto;
}

#maker .maker-layout.maker-layout--lose-open .maker-play-fit,
#maker .maker-layout.maker-layout--dressup-suppressed .maker-play-fit {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  user-select: none;
}

#maker .maker-layout.maker-layout--dressup-suppressed .maker-play-stack {
  transform: none !important;
  will-change: auto;
}

/* 양피지 알림/엔딩 글상자 공통 */
.parchment-panel {
  --parchment-ink: #3d2e1a;
  --parchment-muted: #5c4a32;
  --parchment-edge: #b8956a;
  background:
    radial-gradient(ellipse 110% 70% at 18% 8%, rgba(255, 252, 240, 0.92), transparent 52%),
    radial-gradient(ellipse 90% 65% at 88% 92%, rgba(196, 150, 88, 0.22), transparent 48%),
    linear-gradient(168deg, #faf0d4 0%, #f4e4bc 42%, #e6d2a6 100%);
  color: var(--parchment-ink);
  border: 3px solid var(--parchment-edge);
  border-radius: 3px;
  box-shadow:
    inset 0 0 52px rgba(139, 98, 48, 0.14),
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    0 12px 36px rgba(0, 0, 0, 0.32);
}

.maker-lose-card {
  padding: 1.35rem 1.5rem;
  max-width: 340px;
  text-align: center;
}

.maker-lose-title {
  font-size: 1.75rem;
  font-weight: 900;
  color: #8b2e2e;
  margin-bottom: 0.5rem;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.maker-lose-sub {
  font-size: 0.9rem;
  color: var(--parchment-muted);
  line-height: 1.55;
  margin-bottom: 1rem;
  font-weight: 700;
}

.maker-lose-sub strong {
  color: var(--parchment-ink);
}

.maker-lose-note {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
  opacity: 0.82;
}

/* ── 메이커 인트로 (허브에서 진입 시 최초 화면) ── */
#maker.maker-view {
  position: relative;
  overflow: hidden;
}

#maker.maker-view.active {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100vh;
}
#maker .topbar {
  position: relative;
  z-index: 40;
}

/* ════════════════════════════════════════
   메이커 프롤로그 오버레이
════════════════════════════════════════ */
.maker-intro-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.6rem, 2vh, 1.2rem);
  padding:
    max(0.75rem, env(safe-area-inset-top, 0px))
    max(0.75rem, env(safe-area-inset-right, 0px))
    max(0.75rem, env(safe-area-inset-bottom, 0px))
    max(0.75rem, env(safe-area-inset-left, 0px));
  cursor: pointer;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background-color: #020208;
}
.maker-intro-overlay--open { display: flex; }

/* 타이틀 스플래시 (우주 배경 + 타이틀 이미지 버튼) */
.maker-title-splash {
  position: relative;
  z-index: 2;
  display: none;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  margin: auto;
  pointer-events: auto;
}
.maker-intro-overlay--title .maker-title-splash {
  display: flex;
}
.maker-intro-overlay--title .maker-plg-inner,
.maker-intro-overlay--title .maker-plg-descent {
  display: none !important;
}
.maker-title-splash[hidden] {
  display: none !important;
}
.maker-title-hit {
  position: relative;
  display: block;
  margin: 0 auto;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  line-height: 0;
  -webkit-tap-highlight-color: transparent;
}
.maker-title-hit::before {
  content: "";
  position: absolute;
  inset: -5px;
  z-index: -1;
  pointer-events: none;
  border: 2px solid rgba(255, 248, 210, 0.95);
  box-shadow:
    0 0 6px 1px rgba(255, 235, 150, 0.55),
    0 0 18px 4px rgba(255, 210, 90, 0.45),
    0 0 32px 8px rgba(255, 180, 60, 0.28),
    inset 0 0 12px 1px rgba(255, 255, 220, 0.2);
  animation: maker-title-glow 1.65s ease-in-out infinite;
}
.maker-title-hit:focus-visible {
  outline: 2px solid rgba(255, 248, 220, 0.9);
  outline-offset: 6px;
}
.maker-title-hit:active .maker-title-splash-img {
  transform: scale(0.985);
}
.maker-title-splash-img {
  display: block;
  width: min(92vw, 26rem);
  height: auto;
  max-height: min(68vh, 440px);
  object-fit: contain;
  image-rendering: pixelated;
  transition: transform 0.12s ease;
}
@keyframes maker-title-glow {
  0%, 100% {
    opacity: 0.12;
    border-color: rgba(255, 230, 160, 0.35);
    box-shadow:
      0 0 4px 0 rgba(255, 220, 120, 0.15),
      0 0 10px 2px rgba(255, 200, 80, 0.1);
  }
  45%, 55% {
    opacity: 1;
    border-color: rgba(255, 252, 220, 1);
    box-shadow:
      0 0 8px 2px rgba(255, 240, 170, 0.85),
      0 0 22px 6px rgba(255, 215, 100, 0.65),
      0 0 38px 10px rgba(255, 185, 70, 0.4),
      inset 0 0 14px 2px rgba(255, 255, 230, 0.35);
  }
}

/* 밤하늘 배경 — 오버레이 전체 */
.maker-intro-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: #020208 url("assets/maker-cosmos-bg.png?v=6") no-repeat center center / cover;
}

/* ── 하강 원오 박스 (초상화와 동일한 액자 스타일) ── */
.maker-plg-descent {
  display: none;
  flex: 0 0 auto;
  z-index: 2;
  pointer-events: none;
  box-sizing: border-box;
  padding: 3px;
  background: #f0f0eb;
  border: 2px solid #fff;
  box-shadow: inset 0 0 0 1px #1a1a1a, 0 2px 0 rgba(0,0,0,0.35);
  overflow: hidden;
  width: clamp(150px, 36vw, 260px);
  height: clamp(180px, 44vw, 320px);
}
.maker-intro-overlay--descent .maker-plg-descent {
  display: flex;
  align-items: center;
  justify-content: center;
}
.maker-plg-descent-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}

/* ── 대화창·초상화 묶음 ── */
.maker-plg-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  width: min(100%, 44rem);
  flex-shrink: 0;
  pointer-events: none;
}
.maker-plg-inner button { pointer-events: auto; }

.maker-plg-title {
  margin: 0;
  font-size: clamp(0.7rem, 2.2vw, 0.82rem);
  font-weight: 700;
  letter-spacing: 0.28em;
  color: rgba(200,215,235,0.75);
  text-shadow: 0 1px 0 rgba(0,0,0,0.8);
  text-transform: uppercase;
}

/* ── 대화창 + 초상화 그룹 (초상화 위 · 대화창 아래) ── */
.maker-plg-stage {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0.45rem;
  width: min(100%, 32rem);
  max-width: min(100%, 32rem);
  margin: 0.65rem auto 0;
  flex-shrink: 0;
}
.maker-plg-dialogue-col {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  min-width: 0;
}
.maker-plg-dialogue-col .maker-plg-textbox {
  width: 100%;
  max-width: none;
  align-self: stretch;
}
.maker-plg-stage .maker-plg-portrait-wrap {
  order: -1;
  align-self: center;
}
.maker-plg-stage--lift150 { /* 미사용 */ }
.maker-plg-stage--layout-locked { flex-shrink: 0; }

/* ── 초상화 공통 액자 ── */
.maker-plg-portrait-wrap {
  display: none;
  opacity: 0;
  flex: 0 0 auto;
  box-sizing: border-box;
  padding: 3px;
  background: #f0f0eb;
  border: 2px solid #fff;
  box-shadow: inset 0 0 0 1px #1a1a1a, 0 2px 0 rgba(0,0,0,0.35);
  overflow: hidden;
  align-self: flex-end;
}
.maker-plg-portrait-wrap--visible {
  display: flex;
  align-items: stretch;
  justify-content: center;
  opacity: 1;
}

/* 해태 — 정사각 액자, 이미지는 박스 너비 비율로 좌측 크롭(264px 기준 80px → 화면 크기와 무관) */
.maker-plg-portrait-wrap--guardian {
  --guardian-crop-shift: 30.303%;
  --guardian-frame: clamp(185px, 37vw, 264px);
  position: relative;
  width: var(--guardian-frame);
  height: var(--guardian-frame);
  min-width: var(--guardian-frame);
  min-height: var(--guardian-frame);
  max-width: var(--guardian-frame);
  max-height: var(--guardian-frame);
  flex-shrink: 0;
  margin-inline: auto;
  align-self: center;
  transform: none;
  overflow: hidden;
}
.maker-plg-portrait-wrap--guardian.maker-plg-portrait-wrap--visible {
  display: block;
}
.maker-plg-portrait-wrap--guardian::before,
.maker-plg-portrait-wrap--guardian::after {
  display: none !important;
  content: none !important;
}
.maker-plg-portrait-wrap--guardian .maker-plg-portrait {
  position: absolute;
  inset: 0 auto 0 0;
  left: calc(-1 * var(--guardian-crop-shift, 30.303%));
  width: calc(100% + var(--guardian-crop-shift, 30.303%));
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  display: block;
  object-fit: cover;
  object-position: center center;
  image-rendering: auto;
  background: #020208;
  pointer-events: none;
}

/* 승천 원오 줄 — 이미지 위·대화창과 같은 너비, 높이는 이미지 비율 유지 */
.maker-plg-stage--descent-portrait {
  flex-direction: column;
  align-items: stretch;
  width: min(100%, 32rem);
  max-width: min(100%, 32rem);
  gap: 0.45rem;
}
.maker-plg-stage--descent-portrait .maker-plg-textbox {
  width: 100%;
  min-width: 0;
  max-width: none;
  align-self: stretch;
  flex: 0 0 auto;
}
.maker-plg-stage--descent-portrait .maker-plg-portrait-wrap--descent,
.maker-plg-stage--descent-portrait .maker-plg-portrait-wrap--kid-final {
  order: -1;
  width: fit-content;
  max-width: 100%;
  height: auto;
  min-height: 0;
  padding: 2px 2px;
  margin: 0 auto;
  align-self: center;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.maker-plg-stage--descent-portrait .maker-plg-portrait-wrap--descent .maker-plg-portrait,
.maker-plg-stage--descent-portrait .maker-plg-portrait-wrap--kid-final .maker-plg-portrait {
  width: auto;
  height: auto;
  max-width: min(100%, 32rem);
  max-height: min(42vh, 220px);
  display: block;
  object-fit: contain;
  object-position: center bottom;
  image-rendering: auto;
  background: transparent;
}
.maker-plg-stage--descent-portrait .maker-plg-portrait-wrap--kid-final .maker-plg-portrait {
  object-position: center center;
  image-rendering: pixelated;
}

/* 10살 원오 — 세로 액자, 전신 contain */
.maker-plg-portrait-wrap:not(.maker-plg-portrait-wrap--guardian):not(.maker-plg-portrait-wrap--descent):not(.maker-plg-portrait-wrap--kid-final) {
  width: clamp(121px, 24.2vw, 187px);
  height: clamp(165px, 33vw, 264px);
  flex-shrink: 0;
}
.maker-plg-portrait-wrap:not(.maker-plg-portrait-wrap--guardian):not(.maker-plg-portrait-wrap--descent):not(.maker-plg-portrait-wrap--kid-final) .maker-plg-portrait {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  display: block;
  object-fit: contain;
  object-position: center center;
  image-rendering: pixelated;
  background: transparent;
}
.maker-plg-portrait { display: block; }

/* ── 대화창 ── */
.maker-plg-textbox {
  position: relative;
  flex: 0 1 auto;
  width: min(100%, 32rem);
  min-width: min(100%, 16rem);
  min-height: 6.5rem;
  align-self: flex-end;
  padding: 0.95rem 1rem 0.85rem;
  box-sizing: border-box;
  background: #3d1418;
  border: 2px solid #f5f5f5;
  border-radius: 0;
  box-shadow: 0 2px 0 rgba(0,0,0,0.35);
  font-size: clamp(0.86rem, 2.4vw, 0.98rem);
  line-height: 1.72;
  color: #fff;
  text-align: left;
}
.maker-plg-textbox--locked { flex: 0 0 auto; overflow: hidden; }
.maker-plg-textbox-inner { position: relative; width: 100%; }
.maker-plg-text-reserve {
  visibility: hidden;
  pointer-events: none;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: break-word;
}
.maker-plg-text-reserve .plg-speaker,
.maker-plg-text-reserve .plg-hl { color: #fff; font-weight: 800; }
.maker-plg-text-typing { position: absolute; inset: 0; overflow: hidden; }
.maker-plg-text .plg-speaker {
  color: #fff;
  font-size: inherit;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.maker-plg-text .plg-hl {
  color: #fff;
  font-weight: 800;
}

.maker-plg-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  width: 100%;
  margin-top: 0.32rem;
  pointer-events: auto;
}
.maker-plg-nav {
  position: static;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  pointer-events: auto;
}
.maker-plg-nav--left {
  justify-content: flex-start;
}
.maker-plg-nav--right {
  justify-content: flex-end;
  margin-left: auto;
}
.maker-plg-nav-btn {
  font-family: var(--font);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
  padding: 0.28rem 0.5rem;
  border-radius: 3px;
  border: 1px solid rgba(245, 245, 245, 0.55);
  background: rgba(0, 0, 0, 0.22);
  color: rgba(255, 252, 248, 0.92);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}
.maker-plg-nav-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.38);
  border-color: rgba(255, 255, 255, 0.75);
}
.maker-plg-nav-btn:active:not(:disabled) {
  transform: translateY(1px);
}
.maker-plg-nav-btn:disabled {
  opacity: 0.38;
  cursor: default;
}
.maker-plg-nav-btn--primary {
  border-color: rgba(255, 255, 255, 0.7);
  background: rgba(74, 26, 32, 0.72);
}
.maker-plg-nav-btn--skip {
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-inline: 0.45rem;
}

/* 탭하여 계속 — 텍스트박스 안 하단 오른쪽 */
.maker-plg-tap-hint {
  position: absolute;
  right: 0.55rem;
  bottom: 0.42rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: rgba(210, 230, 255, 0.65);
  letter-spacing: 0.04em;
  pointer-events: none;
  white-space: nowrap;
}

.maker-plg-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: #fff;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: plg-blink 0.55s step-end infinite;
}
@keyframes plg-blink { 0%,100%{opacity:1} 50%{opacity:0} }

.maker-plg-start {
  pointer-events: auto;
  width: 100%;
  max-width: 44rem;
  padding: 0.75rem 1rem;
  font-family: var(--font);
  font-size: 0.98rem;
  font-weight: 800;
  color: #fff;
  /* 대화창(.maker-plg-textbox)과 같은 적갈색 */
  background: #3d1418;
  border: 2px solid #f5f5f5;
  border-radius: 0;
  cursor: pointer;
  letter-spacing: 0.06em;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  transition: background 0.12s ease, transform 0.12s ease, box-shadow 0.25s ease;
}
.maker-plg-start:hover {
  background: #4a1a20;
}
.maker-plg-start:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

/* 마지막 질문 후: 강조는 크기·테두리만 (노란 글로우 없음) */
.maker-plg-start--ready {
  color: #fff;
  background: #4a1a20;
  border-color: #f5f5f5;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.maker-plg-start--ready:hover {
  background: #5c2228;
  color: #fff;
}
.maker-plg-start--ready:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

/* 조작 안내: 별도 네모 박스 없이 본문만 */
.maker-plg-hint {
  font-size: clamp(0.76rem, 2.6vw, 0.88rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  line-height: 1.55;
  width: 100%;
  max-width: 44rem;
  margin: 0.35rem 0 0;
  padding: 0;
  color: rgba(210, 230, 255, 0.88);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
  background: none;
  border: none;
  box-shadow: none;
}

.maker-plg-hint-line {
  display: inline-block;
  width: 100%;
}

.maker-plg-hint-line--next {
  color: rgba(235, 245, 255, 0.95);
  margin-bottom: 0.1rem;
}

.maker-plg-hint-line--skip {
  color: rgba(220, 230, 245, 0.9);
  font-weight: 700;
}

.maker-plg-hint kbd {
  display: inline;
  padding: 0;
  margin: 0 0.04em;
  font-size: inherit;
  font-family: inherit;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: rgba(235, 245, 255, 0.95);
  background: none;
  border: none;
  box-shadow: none;
  vertical-align: baseline;
}

/* 메이커 전체 · 엔딩 카드와 맞춘 황금 톤 + 큰 인벤토리 아이콘 */
#maker .maker-brand {
  color: #f5d76a;
  text-shadow: 0 0 20px rgba(201, 162, 39, 0.35);
}
#maker .maker-hint {
  color: rgba(255, 248, 232, 0.82);
}

#maker .maker-main {
  width: 100%;
  max-width: 100%;
  align-items: center;
  overflow: visible;
}

#maker .maker-dress-zone {
  width: 100%;
}

#maker .maker-character-panel {
  position: static;
  flex-shrink: 0;
  align-self: center;
  width: min(100%, 540px);
  overflow: hidden;
}

#maker .maker-character-panel .maker-preview {
  width: min(100%, clamp(260px, 88vw, 460px));
  max-width: 100%;
  aspect-ratio: 1 / 1;
}

#maker .maker-character-panel .maker-preview.maker-preview--nukki-wear {
  width: min(100%, clamp(200px, min(88vw, 38dvh), 460px));
  max-width: 100%;
  max-height: min(38dvh, 460px);
  aspect-ratio: 1536 / 1024;
}

#maker .maker-character-panel .maker-equipped--compact {
  --maker-eq-side: clamp(30px, 8.5vw, 44px);
  background: #fff;
  border: 2px solid #c9a227;
  box-shadow: 0 0 12px rgba(201, 162, 39, 0.14);
}

#maker .maker-character-panel .maker-equipped--compact .maker-equipped-slots {
  justify-content: space-between;
  gap: 0.12rem;
  padding: 0.18rem 0.06rem;
}

#maker .maker-character-panel .maker-eq-slot {
  max-width: 54px;
  flex: 1 1 0;
  min-width: 0;
}

#maker .maker-character-panel .maker-eq-caption {
  font-size: 0.52rem;
}

#maker .maker-nudge-bar {
  display: none !important;
}

#maker .maker-preview-column {
  flex-shrink: 1;
  max-width: 100%;
  min-width: 0;
  overflow: visible;
  align-items: center;
}

#maker .maker-preview {
  border: 2px solid #9a7b2e;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 0 20px rgba(201, 162, 39, 0.2);
  background: #fffdf5;
  width: min(100%, 280px);
  aspect-ratio: 1 / 1;
}

#maker .maker-preview.maker-preview--nukki-wear {
  aspect-ratio: 1536 / 1024;
  width: min(100%, 380px);
  max-width: min(100%, 380px);
}

#maker .maker-nudge-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.35rem;
  width: 100%;
  max-width: min(100%, 460px);
}

#maker .maker-nudge-hint {
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(214, 188, 106, 0.85);
  letter-spacing: -0.02em;
}

#maker .maker-nudge-btns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.2rem;
}

#maker .maker-nudge-btn {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1;
  color: #2a2210;
  background: linear-gradient(180deg, #f0d78a 0%, #c9a227 100%);
  border: 2px solid #7c6224;
  border-radius: 6px;
  cursor: pointer;
  image-rendering: pixelated;
}

#maker .maker-nudge-btn:active {
  transform: translateY(1px);
}

#maker .maker-nudge-btn--scale {
  min-width: 2.25rem;
  font-size: 1rem;
}

#maker .maker-equipped {
  --maker-eq-side: clamp(52px, min(100px, 22vw), 100px);
  background: #fff;
  border: 2px solid #c9a227;
  box-shadow: 0 0 16px rgba(201, 162, 39, 0.18), inset 0 0 0 1px rgba(255, 220, 150, 0.08);
  max-width: min(100%, 460px);
  overflow: hidden;
}
#maker .maker-equipped-title {
  color: #e8c547;
  display: block;
  width: 100%;
  text-align: center;
}

#maker .maker-equipped-slots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  align-content: center;
  overflow: hidden;
  gap: 0.45rem;
  row-gap: 0.5rem;
  padding: 0.5rem 0.35rem;
  width: 100%;
  max-width: 100%;
}

#maker .maker-eq-slot {
  position: relative;
  display: grid;
  grid-template-rows: var(--maker-eq-side) auto;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-items: center;
  overflow: hidden;
  border-radius: var(--radius-sm, 10px);
  min-width: 0;
  flex: 1 1 0;
  max-width: 120px;
}

#maker .maker-eq-img {
  grid-row: 1;
  grid-column: 1;
  width: 100%;
  height: 100%;
  max-width: none;
  box-sizing: border-box;
  border-color: #7c6224;
  background: #fff;
  display: block;
  object-fit: contain;
  object-position: center center;
  image-rendering: pixelated;
  border-radius: var(--radius-sm, 8px);
  transform: none;
}

/* 착용 중 — 머리·상의·하의·신발 동일 크기(신발 기준) */
#maker .maker-eq-slot:not(.is-empty) {
  cursor: pointer;
  overflow: hidden;
}
#maker #maker-eq-wrap-head:not(.is-empty) {
  z-index: 1;
}

#maker .maker-eq-slot.maker-eq-slot--nudge-focus .maker-eq-img {
  border-color: #c9a227;
  box-shadow:
    inset 0 0 0 1px #c9a227,
    0 0 0 2px rgba(201, 162, 39, 0.45);
}

#maker .maker-eq-slot.is-empty::after {
  content: '—';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, var(--maker-eq-side));
  height: var(--maker-eq-side);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 800;
  opacity: 0.45;
  pointer-events: none;
  color: rgba(100, 85, 60, 0.45);
  box-sizing: border-box;
}

#maker .maker-eq-caption {
  grid-row: 2;
  grid-column: 1;
  color: #d6bc6a;
  font-size: 0.72rem;
  text-align: center;
}
#maker .maker-inv-section {
  flex: 0 0 auto;
  width: min(100%, 540px);
  max-width: 100%;
  min-width: 0;
  gap: 0.45rem;
  align-self: center;
  container-type: inline-size;
}

#maker .maker-inventory {
  container-type: inline-size;
  container-name: maker-inv;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 0.55rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#maker .maker-inv-header {
  font-size: clamp(0.7rem, 3.5cqi, 0.95rem);
  color: #78350f;
  letter-spacing: 0.18em;
  padding: 0.25em 0.5em;
  border-bottom: 1.5px solid #e7d59a;
  text-align: center;
}

#maker .maker-inv-spacehint {
  font-size: clamp(0.6rem, 2.5cqi, 0.72rem);
  color: #78350f;
  opacity: 0.8;
  padding: 0.2em 0.5em;
  border-top: 1.5px solid #e7d59a;
  text-align: center;
}

#maker .maker-key-btn,
#maker .maker-key-space {
  font-size: clamp(0.55rem, 2.2cqi, 0.65rem);
}

#maker .maker-inv-label {
  cursor: pointer;
}

#maker .maker-inv-row {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-width: 0;
  width: 100%;
  max-width: min(100%, 640px);
  margin-inline: auto;
  border-radius: var(--radius-sm, 10px);
  background: #fff;
  border: 2px solid #c9a227;
  box-shadow: 0 0 14px rgba(201, 162, 39, 0.22), inset 0 0 0 1px rgba(255, 220, 150, 0.06);
}

#maker .maker-inv-row.active-row {
  border-color: #f5d76a;
  box-shadow: 0 0 0 2px rgba(245, 215, 106, 0.35), 0 0 22px rgba(201, 162, 39, 0.45);
}

#maker .maker-inv-row.active-row .maker-inv-label {
  background: linear-gradient(180deg, #a16207 0%, #713f12 100%);
  color: #fffef5;
}

#maker .maker-inv-label {
  flex-shrink: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  text-align: center;
  line-height: 1.25;
  word-break: keep-all;
  width: clamp(4.5rem, 18cqi, 5.75rem);
  min-width: clamp(4.5rem, 18cqi, 5.75rem);
  background: #fff;
  color: #92400e;
  border-right-color: #e7d59a;
  font-size: clamp(0.65rem, 2.8cqi, 0.82rem);
  padding: clamp(0.3rem, 1.2cqi, 0.55rem) 0.2rem;
}
#maker .maker-inv-label-pick { display: none; }

#maker .maker-inv-list {
  flex: 1 1 0%;
  min-width: 0;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: 1fr;
  aspect-ratio: 5 / 1;
  align-items: stretch;
  justify-items: stretch;
  align-self: center;
  gap: clamp(3px, 0.9cqi, 6px);
  padding: clamp(4px, 1cqi, 7px) clamp(5px, 1.5cqi, 10px);
  box-sizing: border-box;
  background: #fff;
  overflow: hidden;
}

#maker .maker-inv-btn {
  position: relative;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  padding: clamp(1px, 0.35cqi, 4px);
  overflow: hidden;
  border-radius: var(--radius-sm, 8px);
  background: #fff;
  border: 2px solid #6b5a2a;
  box-sizing: border-box;
  pointer-events: none;
}

#maker .maker-inv-btn img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center center;
  image-rendering: pixelated;
  display: block;
  pointer-events: none;
}

/* 신발 행도 다른 슬롯과 동일 그리드(썸네일은 makerNormalizeInvThumb 가 정규화). scale(3) 는
   흰 배경·캔버스가 칸 밖으로 튀어나와 위 행을 덮었으므로 제거함. */
#maker .maker-inv-row[data-slot="shoes"] {
  overflow: hidden;
  z-index: auto;
}
#maker .maker-inv-row[data-slot="shoes"] .maker-inv-list {
  overflow: hidden;
}
#maker .maker-inv-row[data-slot="shoes"] .maker-inv-btn {
  overflow: hidden;
}
#maker .maker-inv-row[data-slot="shoes"] .maker-inv-btn img {
  transform: none;
}

#maker .maker-inv-btn:hover,
#maker .maker-inv-btn.selected,
#maker .maker-inv-btn.cursor,
#maker .maker-inv-btn--spin {
  z-index: 1;
}

@supports not (container-type: inline-size) {
  #maker .maker-inv-label {
    width: clamp(48px, 14vw, 78px);
    min-width: clamp(48px, 14vw, 78px);
    font-size: clamp(0.65rem, 3.2vw, 0.82rem);
    padding: clamp(0.3rem, 1.5vw, 0.55rem) 0.2rem;
  }

  #maker .maker-inv-list {
    gap: clamp(3px, 1vw, 6px);
    padding: clamp(5px, 1.5vw, 8px) clamp(5px, 2vw, 10px);
  }
}

#maker .maker-inv-btn--spin {
  border-color: #ca8a04 !important;
  background: #fef9c3 !important;
  box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.45);
}
#maker .maker-inv-btn:hover {
  border-color: #e8c547;
  background: #fafafa;
}
#maker .maker-inv-btn.selected {
  border: 2px solid #fbbf24;
  background: #fffbeb;
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.45);
}
#maker .maker-inv-btn.cursor {
  border-color: #eab308;
  background: #fef9c3;
  box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.35);
}
#maker .maker-spacebar-hint {
  color: rgba(255, 245, 224, 0.78);
}
#maker .maker-spacebar-hint kbd {
  border-color: #7c6224;
  background: #1a1510;
  color: #fce174;
}
#maker .maker-spacebar-hint strong {
  color: #f5d76a;
}

/* ════════════════════════════════════════
   SHARED TOPBAR
════════════════════════════════════════ */
.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  padding: max(0.5rem, env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px)) 0.5rem max(1rem, env(safe-area-inset-left, 0px));
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  z-index: 10;
}

.back-btn {
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-sub);
  padding: 0.45rem 0.85rem;
  min-height: 44px;
  min-width: 44px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.back-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-lt); }

.topbar-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-title--g2-with-icon {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}
.topbar-title--g2-with-icon .topbar-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  font-weight: 700;
}
.g2-topbar-fortune-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  object-fit: contain;
  image-rendering: auto;
  display: block;
}
.maker-topbar-crown {
  font-size: 1.15rem;
  line-height: 1;
  flex-shrink: 0;
  display: inline-block;
}

.topbar-meta {
  font-size: 0.8rem;
  color: var(--text-sub);
  white-space: nowrap;
}
.topbar-meta strong { color: var(--green); font-weight: 700; }

/* BUTTONS */
.main-btn {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 2rem;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(79,70,229,0.35);
  letter-spacing: 0.2px;
}
.main-btn:hover { background: #4338CA; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(79,70,229,0.4); }
.main-btn:active { transform: translateY(0); }
.main-btn.orange { background: var(--orange); box-shadow: 0 2px 8px rgba(234,88,12,0.35); }
.main-btn.orange:hover { background: #C2410C; box-shadow: 0 4px 14px rgba(234,88,12,0.4); }

.pill-btn {
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  min-height: 44px;
  cursor: pointer;
  color: var(--text-sub);
  transition: all 0.15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pill-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-lt); }

.icon-btn {
  font-family: var(--font);
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-sub);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.icon-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-lt); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ════════════════════════════════════════
   GAME 1
════════════════════════════════════════ */
.g1-timer-bar,
.g3-timer-bar {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.45rem 1rem 0.4rem;
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.g1-timer-head,
.g3-timer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.g1-timer-label,
.g3-timer-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
}
.g1-chances-bar,
.g3-chances-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
}
.g1-chances-label,
.g3-chances-label { flex-shrink: 0; }
.g1-chances-slots,
.g3-chances-slots {
  display: inline-flex;
  align-items: center;
  gap: 0.12rem;
  letter-spacing: 0.02em;
}
.g1-chance,
.g3-chance {
  font-size: 0.95rem;
  line-height: 1;
}
.g1-chance--on,
.g3-chance--on { color: #e11d48; }
.g1-chance--off,
.g3-chance--off { color: var(--border); }
.g1-chances-count,
.g3-chances-count {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.g1-chances-count strong,
.g3-chances-count strong { color: #e11d48; }
.g1-chances-bar--warn .g1-chances-count strong,
.g1-chances-bar--warn .g1-chance--on,
.g3-chances-bar--warn .g3-chances-count strong,
.g3-chances-bar--warn .g3-chance--on { color: #ea580c; }
.g1-timer-display,
.g3-timer-display {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  margin-left: 0.35rem;
}
.g1-timer-bar--warn .g1-timer-display,
.g3-timer-bar--warn .g3-timer-display { color: #ea580c; }
.g1-timer-track,
.g3-timer-track {
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.g1-timer-fill,
.g3-timer-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #16a34a, #86efac);
  transition: width 0.2s linear;
}
.g1-timer-bar--warn .g1-timer-fill,
.g3-timer-bar--warn .g3-timer-fill {
  background: linear-gradient(90deg, #c2410c, #fb923c);
}
.g1-timeup-overlay,
.g3-timeup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 120;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}
.g1-timeup-overlay--open,
.g3-timeup-overlay--open { display: flex; }
.g1-timeup-card,
.g3-timeup-card {
  max-width: 22rem;
  width: 100%;
  padding: 1.35rem 1.5rem 1.5rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-md);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.g1-timeup-title,
.g3-timeup-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
}
.g1-timeup-sub,
.g3-timeup-sub {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-dim);
}
.g1-timeup-card .main-btn,
.g3-timeup-card .main-btn { margin-top: 0.25rem; }

.g1-clear-overlay { z-index: 130; }
.g1-clear-card {
  border-color: #fbbf24;
  box-shadow: 0 8px 32px rgba(251, 191, 36, 0.25), var(--shadow-md);
}
.g1-clear-emoji {
  margin: 0;
  font-size: 2.5rem;
  line-height: 1;
  animation: g1-clear-bounce 0.6s ease-in-out infinite alternate;
}
@keyframes g1-clear-bounce {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-6px) scale(1.08); }
}
.g1-clear-title {
  color: #b45309;
}
.g1-clear-sub { margin-bottom: 0.15rem; }
.g1-clear-hub-btn { margin-top: 0; }
.g1-confetti-wrap {
  position: fixed;
  inset: 0;
  z-index: 125;
  pointer-events: none;
  overflow: hidden;
}
.g1-confetti-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#game1.view.active {
  overflow: hidden;
}

.g1-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 0.8rem 1rem;
  padding-bottom: max(0.8rem, env(safe-area-inset-bottom, 0px));
  gap: 0.7rem;
}

.g1-info-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  box-shadow: none;
  min-height: 0;
}

.g1-info-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  flex: 0 1 auto;
  min-width: 0;
}

.g1-target-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.g1-target-card--thumb {
  flex: 0 0 auto;
  padding: 0.08rem 0.12rem;
  align-self: center;
}

.g1-target-card--label {
  flex: 0 1 auto;
  min-width: 0;
  width: 100%;
  padding: 0.85rem 1.2rem;
  box-sizing: border-box;
}

.g1-thumb {
  width: 120px;
  height: 120px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
  display: block;
}

.g1-target-label {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  color: var(--text);
  white-space: nowrap;
}

.g1-hint-btn {
  flex: 0 0 auto;
  align-self: center;
  margin: 0;
  min-width: 4.5rem;
  padding: 0.42rem 1rem;
  min-height: 0;
  height: auto;
}

.g1-tries-badge {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-sub);
  white-space: nowrap;
}

.g1-scene-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  position: relative;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #111;
  box-shadow: var(--shadow-sm);
}

.g1-scene-viewport {
  flex: 1;
  width: 100%;
  min-height: 0;
  position: relative;
  overflow: hidden;
  touch-action: none;
  cursor: crosshair;
}

.g1-scene-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform-origin: center center;
  will-change: transform;
}

.g1-scene-container .g1-scene-bg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  image-rendering: pixelated;
  position: relative;
  z-index: 0;
  user-select: none;
  -webkit-user-drag: none;
}

.g1-scene-frame #g1-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.g1-scene-viewport.g1-scene-viewport--zoomed {
  cursor: grab;
}
.g1-scene-viewport.g1-scene-viewport--zoomed.g1-scene-viewport--dragging {
  cursor: grabbing;
}

.g1-status-bar {
  flex-shrink: 0;
  min-height: 1.5rem;
  display: flex;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--green);
  white-space: pre-line;
}

/* ════════════════════════════════════════
   GAME 2 – 포춘쿠키 먹은 원오를 찾아라!
════════════════════════════════════════ */
.g2-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1rem max(1rem, env(safe-area-inset-left, 0px)) max(1rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-right, 0px));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  gap: 1rem;
}

.g2-phase {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.g2-instruction {
  display: none;
}

.g2-chars {
  width: 100%;
  position: relative;
  min-height: 520px;
  overflow: visible;
  padding-top: 0.25rem;
}

/* 보여주기: 가로 3열 (원래 크기 유지, 줄바꿈 없음) */
.g2-chars:not(.g2-chars--shell) {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 1.5rem;
  justify-content: center;
  align-items: flex-end;
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.g2-chars:not(.g2-chars--shell)::-webkit-scrollbar {
  display: none;
}

.g2-chars:not(.g2-chars--shell) .g2-char-slot {
  flex: 0 0 auto;
}

/* 떡먹은 용만이 보너스식: 3칸 바닥 고정, 좌우 슬라이드 + 위로 살짝 튀며 섞임 */
.g2-chars--shell {
  min-height: 520px;
}

@keyframes g2-shell-hop-pop {
  0%   { transform: translateX(-50%) translateY(0); }
  42%  { transform: translateX(-50%) translateY(-160px); }
  100% { transform: translateX(-50%) translateY(0); }
}

@keyframes g2-tongue-lick-inner {
  0%, 100% { transform: rotate(-3deg) translate(0, 0); }
  50%      { transform: rotate(-2deg) translate(2px, 2px); }
}

/* 삼킴: 쿠키·혀가 함께 아래로 내려가며 먹어 치우는 것처럼만 보이게 */
@keyframes g2-feed-swallow {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  40% {
    opacity: 1;
    transform: translateY(18%) scale(0.98);
  }
  100% {
    opacity: 0;
    transform: translateY(55%) scale(0.5);
  }
}

.g2-chars--shell .g2-char-slot {
  position: absolute;
  bottom: 0;
  left: 16.666%;
  transform: translateX(-50%);
  width: 30%;
  max-width: 360px;
  min-width: 180px;
  box-sizing: border-box;
  z-index: 1;
  transition: left 0.24s cubic-bezier(0.42, 0, 0.58, 1);
  will-change: left, transform;
}

.g2-char-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  transition: filter 0.3s, transform 0.3s;
  flex-shrink: 0;
}

.g2-char-figure {
  position: relative;
  display: inline-block;
  line-height: 0;
}

.g2-char-figure img {
  display: block;
  width: 320px;
  height: 400px;
  object-fit: contain;
  object-position: bottom center;
  image-rendering: pixelated;
  transition: filter 0.3s, transform 0.3s;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.12));
}

.g2-char-slot.has-cookie .g2-char-figure img {
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.12)) drop-shadow(0 0 0 transparent);
}

/* 스프라이트 위 오버레이: 손·입 근처에 픽셀 쿠키·혀 */
.g2-cookie-indicator {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.08s ease-out;
}
.g2-cookie-indicator.visible { opacity: 1; }

.g2-pix-eat-wrap {
  position: absolute;
  inset: 0;
  /* 손 위 쿠키 & 입가 혀 — 같은 박스 크기 */
  --g2-eat-icon-size: 3rem;
}

/* 입 앞 한 덩어리: flex + 고정 gap 으로 쿠키–혀 간격 */
.g2-pix-eat-cluster {
  --g2-eat-cluster-gap: 5px;
  position: absolute;
  left: 50%;
  top: 11%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: var(--g2-eat-cluster-gap);
  width: max-content;
  min-height: var(--g2-eat-icon-size, 3rem);
  pointer-events: none;
}

/* 셔플(쉘) 레이아웃: 캐릭터가 작아지므로 쿠키·혀를 같은 비율로 줄임 */
.g2-chars--shell .g2-pix-eat-wrap {
  --g2-eat-icon-size: clamp(2.1rem, 6.5vw, 2.75rem);
}

/* 클러스터 안: flex 가운데 정렬 — 쿠키는 입(혀) 쪽으로 기울임 */
.g2-pix-hand-cookie {
  position: relative;
  flex: 0 0 auto;
  transform: rotate(22deg);
  transform-origin: 100% 50%;
  opacity: 0.96;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,0.22));
}

.g2-pix-mouth-tongue {
  position: relative;
  flex: 0 0 auto;
  opacity: 0.96;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,0.2));
}

/* 기억 단계: 삼킴 때만 혀 핥기 정지(애니는 span에 걸림) */
#g2-chars-show.g2-swallow-run .g2-char-slot.has-cookie .g2-pix-mouth-tongue .g2-pix-emoji--tongue {
  animation: none;
}
/* 기억 단계도 셔플·고르기와 동일 스프라이트 크기(.g2-char-figure img) — 작았다 커지는 느낌 제거 */
#g2-chars-show .g2-pix-eat-wrap {
  /* 기억 단계 입가 아이콘(쿠키·혀) — 예전 작은 비율 유지, 캐릭터 크기만 셔플과 동일 */
  --g2-eat-icon-size: clamp(1.15rem, 3.6vw, 1.75rem);
  --g2-eat-above: 0rem;
}

#g2-chars-show .g2-pix-eat-cluster {
  top: 30%;
  transform: translateX(-50%) translateY(calc(-1 * var(--g2-eat-above)));
  min-height: calc(var(--g2-eat-icon-size) * 0.92);
}

/* 기억·삼킴: 포춘쿠키 1.2 스케일 */
#g2-chars-show .g2-pix-hand-cookie {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  width: calc(var(--g2-eat-icon-size) * 1.2);
  height: calc(var(--g2-eat-icon-size) * 1.2);
  flex: 0 0 auto;
  overflow: visible;
  transform: rotate(24deg);
  transform-origin: 100% 50%;
}
#g2-chars-show .g2-pix-hand-cookie .g2-icon-fortune-cookie--hand {
  width: var(--g2-eat-icon-size);
  height: var(--g2-eat-icon-size);
  transform: scale(1.2);
  transform-origin: 100% 50%;
}

/* 기억 단계: 머리 위 고정 + 혀 핥기(낙하 없음) */
#g2-chars-show:not(.g2-swallow-run) .g2-char-slot.has-cookie .g2-cookie-indicator.visible .g2-pix-mouth-tongue .g2-pix-emoji--tongue {
  animation: g2-tongue-lick-inner 0.85s steps(2, end) infinite;
}

@media (prefers-reduced-motion: reduce) {
  #g2-chars-show:not(.g2-swallow-run) .g2-char-slot.has-cookie .g2-cookie-indicator.visible .g2-pix-hand-cookie {
    transform: rotate(24deg);
  }
  #g2-chars-show:not(.g2-swallow-run) .g2-char-slot.has-cookie .g2-cookie-indicator.visible .g2-pix-hand-cookie .g2-icon-fortune-cookie--hand {
    transform: scale(1.2);
    transform-origin: 100% 50%;
  }
  #g2-chars-show:not(.g2-swallow-run) .g2-char-slot.has-cookie .g2-cookie-indicator.visible .g2-pix-mouth-tongue .g2-pix-emoji--tongue {
    animation: g2-tongue-lick-inner 0.85s steps(2, end) infinite;
  }
}

/* 삼킴 (딜레이 없음, 재생만 — JS G2_SWALLOW_MS 와 동기) */
#g2-chars-show.g2-swallow-run .g2-char-slot.has-cookie .g2-cookie-indicator.visible .g2-pix-eat-wrap {
  transform-origin: 50% 10%;
  animation: g2-feed-swallow 0.5s ease-in 0s forwards;
  will-change: transform, opacity;
}

.g2-pix-emoji {
  display: block;
  line-height: 1;
  font-style: normal;
  user-select: none;
  -webkit-user-select: none;
}
.g2-icon-fortune-cookie {
  display: block;
  line-height: 0;
  object-fit: contain;
  image-rendering: auto;
  user-select: none;
  -webkit-user-select: none;
}
.g2-icon-fortune-cookie--hand {
  width: var(--g2-eat-icon-size, 3rem);
  height: var(--g2-eat-icon-size, 3rem);
}
.g2-pix-mouth-tongue .g2-pix-emoji--tongue {
  font-size: var(--g2-eat-icon-size, 3rem);
  line-height: 1;
  width: var(--g2-eat-icon-size, 3rem);
  height: var(--g2-eat-icon-size, 3rem);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: g2-tongue-lick-inner 0.85s steps(2, end) infinite;
  transform-origin: center center;
}

.g2-char-label { display: none; }

.g2-char-slot.clickable {
  cursor: pointer;
}
.g2-char-slot.clickable .g2-char-figure img {
  transition: transform 0.22s ease, filter 0.22s ease;
}

/* 고르기 단계 — 마우스를 올린 캐릭터만 캐릭터별 색으로 빛남 */
@keyframes g2-pick-glow-cyan {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(34, 211, 238, 0.85)) drop-shadow(0 0 26px rgba(34, 211, 238, 0.45)); }
  50% { filter: drop-shadow(0 0 22px rgba(34, 211, 238, 1)) drop-shadow(0 0 42px rgba(34, 211, 238, 0.7)); }
}
@keyframes g2-pick-glow-gold {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(251, 191, 36, 0.9)) drop-shadow(0 0 26px rgba(251, 191, 36, 0.45)); }
  50% { filter: drop-shadow(0 0 22px rgba(251, 191, 36, 1)) drop-shadow(0 0 42px rgba(251, 191, 36, 0.7)); }
}
@keyframes g2-pick-glow-magenta {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(244, 114, 182, 0.9)) drop-shadow(0 0 26px rgba(244, 114, 182, 0.45)); }
  50% { filter: drop-shadow(0 0 22px rgba(244, 114, 182, 1)) drop-shadow(0 0 42px rgba(244, 114, 182, 0.7)); }
}
#g2-chars-pick .g2-char-slot.clickable:hover .g2-char-figure img {
  transform: scale(1.05) translateY(-8px);
}
#g2-chars-pick .g2-char-slot.clickable[data-logical="0"]:hover .g2-char-figure img {
  animation: g2-pick-glow-cyan 1.1s ease-in-out infinite;
}
#g2-chars-pick .g2-char-slot.clickable[data-logical="1"]:hover .g2-char-figure img {
  animation: g2-pick-glow-gold 1.1s ease-in-out infinite;
}
#g2-chars-pick .g2-char-slot.clickable[data-logical="2"]:hover .g2-char-figure img {
  animation: g2-pick-glow-magenta 1.1s ease-in-out infinite;
}
.g2-char-slot.correct-pick .g2-char-figure img {
  filter: drop-shadow(0 0 16px rgba(22,163,74,0.6));
}
.g2-char-slot.wrong-pick .g2-char-figure img {
  filter: drop-shadow(0 0 16px rgba(220,38,38,0.6));
}
.g2-char-slot.reveal .g2-char-figure img {
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.12));
}

/* RESULT */
.g2-result-box {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 2.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  width: 100%;
}

.g2-result-icon { font-size: 3rem; }

.g2-result-box h3 {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.3px;
}

.fortune-card {
  background: linear-gradient(135deg, #FFFBEB, #FEF3C7);
  border: 2px solid #FCD34D;
  border-radius: var(--radius);
  padding: 1.2rem 1.25rem;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  box-sizing: border-box;
}
.fortune-cookie-img { min-height: 2.5rem; display: flex; align-items: center; justify-content: center; }
.fortune-cookie-img .g2-icon-fortune-cookie--fortune {
  width: 2.75rem;
  height: 2.75rem;
}
.fortune-text {
  font-size: clamp(0.72rem, 2.65vw, 0.9rem);
  font-weight: 600;
  color: #92400E;
  text-align: center;
  line-height: 1.5;
  font-style: italic;
  white-space: pre-line;
  word-break: keep-all;
  width: 100%;
  max-width: 100%;
  overflow-wrap: break-word;
}
.fortune-text.fortune-text--long {
  font-size: clamp(0.68rem, 2.35vw, 0.82rem);
  line-height: 1.45;
}

/* ════════════════════════════════════════
   GAME 3
════════════════════════════════════════ */
.g3-progress-track {
  height: 3px;
  background: var(--border);
  flex-shrink: 0;
}
#g3-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--blue), #818CF8);
  transition: width 0.5s ease;
}

.g3-timer-bar {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.45rem 1rem 0.4rem;
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.g3-timer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.g3-timer-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
}
.g3-chances-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
}
.g3-chances-label {
  flex-shrink: 0;
}
.g3-chances-slots {
  display: inline-flex;
  align-items: center;
  gap: 0.12rem;
  letter-spacing: 0.02em;
}
.g3-chance {
  font-size: 0.95rem;
  line-height: 1;
}
.g3-chance--on {
  color: #e11d48;
}
.g3-chance--off {
  color: var(--border);
}
.g3-chances-count {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.g3-chances-count strong {
  color: #e11d48;
}
.g3-chances-bar--warn .g3-chances-count strong,
.g3-chances-bar--warn .g3-chance--on {
  color: #ea580c;
}
.g3-timer-display {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  margin-left: 0.35rem;
}
.g3-timer-bar--warn .g3-timer-display {
  color: #ea580c;
}
.g3-timer-track {
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.g3-timer-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #16a34a, #86efac);
  transition: width 0.2s linear;
}
.g3-timer-bar--warn .g3-timer-fill {
  background: linear-gradient(90deg, #c2410c, #fb923c);
}

.g3-timeup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 120;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}
.g3-timeup-overlay--open {
  display: flex;
}
.g3-timeup-card {
  max-width: 22rem;
  width: 100%;
  padding: 1.35rem 1.5rem 1.5rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-md);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.g3-timeup-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
}
.g3-timeup-sub {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-dim);
}
.g3-timeup-card .main-btn {
  margin-top: 0.25rem;
}

.g3-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 0.8rem;
  padding: 0.8rem 1rem 0;
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.g3-zoom-hint {
  flex-shrink: 0;
  margin: 0;
  padding: 0.4rem 1rem 0.35rem;
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.45;
}
.g3-zoom-hint strong { color: var(--text); font-weight: 800; }
.g3-zoom-hint .g3-cal-link {
  color: var(--blue);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.g3-img-box--hit-target {
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35), var(--shadow-sm);
}

.g3-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  overflow: hidden;
}

.g3-panel-label {
  flex-shrink: 0;
  align-self: center;
  padding: 0.22rem 0.55rem;
  border: 1.5px solid #111;
  border-radius: 4px;
  background: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  color: #111;
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-align: center;
}

#game3.view.active {
  overflow: hidden;
}

.g3-img-box {
  flex: 1;
  position: relative;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #111;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.g3-img-box.g3-img-box--zoom {
  touch-action: none;
}

.g3-img-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform-origin: center center;
  will-change: transform;
}

#g3-left-box:hover,
#g3-right-box:hover { box-shadow: 0 0 0 2px var(--blue), var(--shadow-sm); cursor: crosshair; }

.g3-img-box img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  image-rendering: pixelated;
  pointer-events: none;
}

#g3-canvas-left,
#g3-canvas-right {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 2;
  cursor: crosshair;
  pointer-events: auto;
  touch-action: none;
}

.g3-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.35rem;
  font-weight: 900;
  color: #111;
  letter-spacing: 0.12em;
  line-height: 1;
}

.g3-nav-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.g3-bottom-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.8rem;
  padding: 0.65rem max(1rem, env(safe-area-inset-left, 0px)) max(0.65rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-right, 0px));
  background: var(--surface);
  border-top: 1.5px solid var(--border);
}

.g3-diff-row {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  flex-wrap: wrap;
}

.diff-chip {
  font-size: 0.73rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
  transition: all 0.3s;
}
.diff-chip.found  { background: var(--green-lt); border-color: var(--green); color: var(--green); }
.diff-chip.hinted { background: var(--blue-lt);  border-color: var(--blue); color: var(--blue); }

/* ════════════════════════════════════════
   TOAST
════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  max-width: calc(100vw - 2rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  background: #1F2937;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.65rem 1.4rem;
  border-radius: 999px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  white-space: pre-line;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err  { background: var(--red); }
.toast.ok   { background: var(--green); }

/* ════════════════════════════════════════
   엔딩 모달
════════════════════════════════════════ */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── 엔딩 모달: 전체화면 검은 배경 + 이미지 풀스크린 + 글 플로팅 카드 ── */
.ending-modal {
  position: fixed;
  inset: 0;
  z-index: 10050;
  background: #000;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease, visibility 0.28s;
}
.ending-modal.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

/* 배경 클릭 레이어 */
.ending-modal__backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* 이미지 스테이지: 상단 60% 영역, 하단은 텍스트 카드용 */
.ending-img-stage {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 38%;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ending-modal__img {
  display: block;
  max-width: 95%;
  max-height: 95%;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* 닫기 버튼: 화면 우상단 고정 */
.ending-modal__close {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top, 0px));
  right: max(1rem, env(safe-area-inset-right, 0px));
  z-index: 10;
  width: 2.4rem;
  height: 2.4rem;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}
.ending-modal__close:hover {
  background: rgba(255, 255, 255, 0.32);
}

/* ── 글 카드: 하단 가로 리본 (얼굴 안 가림) ── */
.ending-modal:not(.is-open) .ending-text-card {
  opacity: 0;
  transform: translateX(-50%) translateY(18px) scale(0.96);
  filter: blur(4px);
  pointer-events: none;
}
.ending-modal.is-open .ending-text-card {
  pointer-events: auto;
}

.ending-modal.is-open:not(.ending-modal--text-wait) .ending-text-card {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
  filter: none;
}

.ending-modal.is-open:not(.ending-modal--text-wait) .ending-scroll-stage {
  opacity: 1;
  visibility: visible;
}

/* 대기 중: 스크롤 글만 숨김 — 공유·다시 하기·확인은 즉시 */
.ending-modal.is-open.ending-modal--text-wait .ending-scroll-stage,
.ending-modal.is-open.ending-modal--text-wait .ending-fade-top,
.ending-modal.is-open.ending-modal--text-wait .ending-fade-bot {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
}

.ending-modal.is-open.ending-modal--text-wait .ending-text-card {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto;
  animation: endingActionsBarIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  transform: translateX(-50%) translateY(0);
  filter: none;
  max-height: none;
}

.ending-modal.is-open.ending-modal--text-wait .ending-actions {
  pointer-events: auto;
}

@keyframes endingActionsBarIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes endingCardRise {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(32px) scale(0.94);
    filter: blur(5px);
  }
  55% {
    opacity: 1;
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
    filter: blur(0);
  }
}

.ending-text-card {
  position: fixed;
  z-index: 8;
  bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: min(94vw, 900px);
  height: auto;
  max-height: min(42vh, 340px);
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  pointer-events: auto;
}

.parchment-panel--ending {
  color: var(--parchment-ink, #3d2e1a);
}

/* 위아래 페이드 (낮은 리본에 맞춤) */
.ending-fade-top,
.ending-fade-bot {
  position: absolute;
  left: 0; right: 0;
  height: 2rem;
  pointer-events: none;
  z-index: 3;
}
.ending-fade-top {
  top: 0;
  background: linear-gradient(to bottom, #f4e4bc 0%, transparent 100%);
}
.ending-fade-bot {
  bottom: 3.35rem;
  background: linear-gradient(to top, #e6d2a6 0%, transparent 100%);
}
.ending-modal.is-open:has(.ending-share-sheet--open) .ending-fade-bot {
  bottom: calc(3.35rem + 3.45rem);
}

.ending-scroll-stage {
  flex: 1 1 auto;
  min-height: 80px;
  position: relative;
  overflow: hidden;
  z-index: 2;
}

.ending-scroll-text {
  padding: 0.85rem 1.25rem 0.55rem;
  text-align: center;
  will-change: transform;
  font-weight: 600;
  position: relative;
  z-index: 2;
}

.ending-scroll-deco {
  font-size: 1.2rem;
  font-weight: 800;
  margin: 0 0 0.45rem;
  color: #8b6914;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
  letter-spacing: 0.1em;
  opacity: 1;
}
.ending-scroll-deco--sm {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.35em;
  margin: 0.25rem 0 0.55rem;
  color: #6b5424;
  text-shadow: none;
  opacity: 0.95;
}
.ending-scroll-deco--fin {
  margin-top: 0.85rem;
}

.ending-title {
  font-weight: 900;
  font-size: 1.06rem;
  margin-bottom: 0.45rem;
  color: #2f2414;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
  line-height: 1.45;
}
.ending-dialogue {
  margin: 0 0 0.45rem;
  padding: 0.5rem 0.65rem;
  border-left: 3px solid #8b6914;
  background: rgba(139, 98, 48, 0.1);
  border-radius: 0;
  font-weight: 800;
  font-size: 0.95rem;
  color: #3d2e1a;
  text-align: left;
  line-height: 1.65;
  text-shadow: none;
}
.ending-coda {
  font-size: 0.88rem;
  font-weight: 700;
  color: #5c4a32;
  line-height: 1.7;
  text-shadow: none;
}

.ending-actions {
  flex: 0 0 auto;
  flex-shrink: 0;
  display: flex;
  gap: 0.55rem;
  padding: 0.5rem 0.75rem;
  border-top: 2px solid rgba(139, 98, 48, 0.35);
  background: rgba(230, 210, 166, 0.65);
  position: relative;
  z-index: 12;
  pointer-events: auto;
}
.ending-btn {
  flex: 1;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  padding: 0.58rem 0;
  border-radius: 2px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.ending-btn:active { transform: scale(0.97); }
.ending-btn--share {
  background: rgba(244, 228, 188, 0.9);
  border: 2px solid #8b6914;
  color: #3d2e1a;
}
.ending-btn--share:hover {
  background: #faf0d4;
  border-color: #6b5424;
}
.ending-btn--retry {
  background: #16a34a;
  border: 2px solid #15803d;
  color: #fff;
  box-shadow: none;
}
.ending-btn--retry:hover {
  filter: brightness(1.06);
}
.ending-btn--confirm {
  background: #3d2e1a;
  border: 2px solid #2f2414;
  color: #faf0d4;
  box-shadow: none;
}
.ending-btn--confirm:hover {
  filter: brightness(1.08);
}

/* 공유·확인 버튼 위 빈 띠 — 아이콘 4개 가로 배치 */
.ending-share-rail {
  flex: 0 0 auto;
  flex-shrink: 0;
  display: none;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.62rem;
  width: 100%;
  min-height: 3.35rem;
  padding: 0.42rem 0.75rem 0.38rem;
  box-sizing: border-box;
  position: relative;
  z-index: 12;
  pointer-events: auto;
  background: rgba(228, 208, 168, 0.5);
  border-top: 1px solid rgba(139, 98, 48, 0.28);
}
.ending-share-rail.ending-share-sheet--open {
  display: flex;
}
.ending-share-rail[hidden] {
  display: none !important;
}
.ending-share-sheet__btn {
  flex: 0 0 auto;
  width: 2.65rem;
  height: 2.65rem;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(61, 46, 26, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(61, 46, 26, 0.2);
  transition: transform 0.08s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.ending-share-sheet__btn:active {
  transform: scale(0.96);
}
.ending-share-sheet__btn svg {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
  pointer-events: none;
}
.ending-share-sheet__btn--link {
  background: #faf0d4;
  color: #3d2e1a;
}
.ending-share-sheet__btn--kakao {
  background: #fee500;
  color: #191600;
  border-color: rgba(25, 22, 0, 0.15);
}
.ending-share-sheet__btn--instagram {
  background: linear-gradient(135deg, #f9ce34 0%, #ee2a7b 52%, #6228d7 100%);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}
.ending-share-sheet__btn--x {
  background: #0f1419;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.share-toast {
  position: fixed;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(120%);
  z-index: 10100;
  max-width: min(92vw, 22rem);
  padding: 0.72rem 1rem;
  border-radius: 8px;
  background: rgba(15, 20, 35, 0.92);
  color: #f4f6ff;
  font-family: var(--font);
  font-size: 0.82rem;
  line-height: 1.45;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.28s ease, opacity 0.28s ease;
}
.share-toast--show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ════════════════════════════════════════
   SCROLLBAR
════════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ════════════════════════════════════════
   RESPONSIVE · 모바일 / 좁은 화면
════════════════════════════════════════ */
@media (max-width: 700px) {
  @keyframes g2-shell-hop-pop {
    0%   { transform: translateX(-50%) translateY(0); }
    42%  { transform: translateX(-50%) translateY(-88px); }
    100% { transform: translateX(-50%) translateY(0); }
  }

  .hub-grid {
    flex-direction: column;
    overflow: visible;
    padding: 1rem max(1rem, env(safe-area-inset-right, 0px)) max(1rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
  }

  #hub.hub--8bit .hub-grid {
    flex: 0 0 auto;
    overflow: visible;
  }
  .hub-title { font-size: 1.35rem; }
  .game-card {
    flex: none;
    width: 100%;
    max-width: 420px;
    margin-inline: auto;
    padding: 1.15rem;
    min-height: 44px;
  }

  #hub.hub--8bit .hub-intro {
    flex-wrap: wrap;
    padding:
      calc(env(safe-area-inset-top, 0px) + 0.75rem)
      max(1rem, env(safe-area-inset-right, 0px))
      1rem
      max(1rem, env(safe-area-inset-left, 0px));
  }
  #hub.hub--8bit .hub-bot-img { width: 56px; }

  #hub.hub--8bit .hub-footer-legal {
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.65rem;
  }
  #hub.hub--8bit .hub-footer-line {
    display: block;
  }

  .g1-info-bar {
    flex-wrap: nowrap;
    gap: 0.4rem;
  }
  .g1-info-copy {
    gap: 0.5rem;
  }
  .g1-thumb {
    width: min(34vw, 140px);
    height: min(34vw, 140px);
  }
  .g1-target-card--thumb {
    padding: 0.06rem 0.1rem;
  }
  .g1-target-card--label {
    padding: 0.75rem 1rem;
  }
  .g1-target-label {
    font-size: clamp(0.78rem, 3.4vw, 0.88rem);
  }
  .g1-hint-btn {
    min-width: 3.75rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.74rem;
    min-height: 0;
  }
  .g1-tries-badge { margin-left: auto; }

  .g2-chars:not(.g2-chars--shell) {
    flex-wrap: nowrap;
    gap: 0.5rem;
    justify-content: center;
    padding-inline: max(0.5rem, env(safe-area-inset-left, 0px)) max(0.5rem, env(safe-area-inset-right, 0px));
  }
  .g2-chars { min-height: 360px; }
  .g2-chars--shell { min-height: 400px; }
  .g2-chars--shell .g2-char-slot {
    min-width: 0;
    width: 33%;
    max-width: none;
  }
  .g2-char-figure img {
    width: min(58vw, 220px);
    height: auto;
    max-height: 72vh;
  }
  .g2-chars:not(.g2-chars--shell) .g2-pix-eat-wrap {
    --g2-eat-icon-size: 2.65rem;
  }
  .g2-chars--shell .g2-pix-eat-wrap {
    --g2-eat-icon-size: clamp(1.85rem, 7.5vw, 2.45rem);
  }
  .g2-result-box { padding: 1.5rem; }
  .g2-result-box .main-btn {
    width: 100%;
    max-width: 300px;
    min-height: 48px;
  }

  #game3.view.active {
    overflow: hidden;
  }

  #game3 .g3-layout {
    flex: 1;
    flex-direction: column;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    gap: 0;
    padding-bottom: 0.75rem;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  #game3 .g3-panel {
    flex: 0 0 auto;
    width: 100%;
  }

  #game3 .g3-panel[data-side="left"] {
    order: 1;
  }

  #game3 .g3-divider {
    order: 2;
    flex: 0 0 auto;
    width: 100%;
    justify-content: center;
    padding: 0.35rem 0;
    font-size: clamp(2.25rem, 12vw, 3.5rem);
    font-weight: 900;
    color: #111;
    letter-spacing: 0.14em;
  }

  #game3 .g3-panel[data-side="right"] {
    order: 3;
  }

  #game3 .g3-img-box {
    flex: 0 0 auto;
    width: 100%;
    min-height: min(52vh, 520px);
    max-height: none;
  }

  #game3 .g3-zoom-hint {
    font-size: 0.7rem;
    padding-bottom: 0.3rem;
  }

  #game3 .g3-panel-label {
    font-size: 0.66rem;
    padding: 0.2rem 0.5rem;
  }

  #game3 .topbar {
    align-items: center;
  }
  #game3 .topbar .topbar-title {
    flex: 1 1 100%;
    order: 10;
    text-align: center;
    font-size: 0.82rem;
  }
  #game3 .topbar .back-btn { order: 1; }
  #game3 .topbar .g3-nav-wrap {
    order: 2;
    flex: 1;
    justify-content: flex-end;
  }
  #game3 .topbar > .topbar-meta:last-of-type {
    order: 11;
    flex: 1 1 100%;
    text-align: center;
    font-size: 0.78rem;
  }

  /* ── 메이커 인트로 (모바일 ≤700px) ── */

  /* 하강 원오 박스: 세로로 작게 */
  .maker-plg-descent {
    width: clamp(120px, 38vw, 200px);
    height: clamp(148px, 48vw, 252px);
  }

  /* 대화창·초상화 묶음 */
  .maker-plg-inner {
    width: 100%;
    max-width: 100%;
    gap: 0.5rem;
  }

  /* 모바일: 세로 스택 — 초상화(위) + 대화창(아래), 그룹 중앙 */
  .maker-plg-stage {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
    margin-top: 0.5rem;
  }

  .maker-plg-stage--descent-portrait {
    width: 100%;
    max-width: 100%;
  }
  .maker-plg-stage--descent-portrait .maker-plg-portrait-wrap--descent,
  .maker-plg-stage--descent-portrait .maker-plg-portrait-wrap--kid-final {
    align-self: center;
    margin-inline: auto;
  }
  .maker-plg-stage--descent-portrait .maker-plg-portrait-wrap--descent .maker-plg-portrait,
  .maker-plg-stage--descent-portrait .maker-plg-portrait-wrap--kid-final .maker-plg-portrait {
    max-height: min(36vh, 180px);
  }

  /* 초상화를 대화창 위로 */
  .maker-plg-portrait-wrap {
    order: -1;
    align-self: center;
  }

  .maker-plg-portrait-wrap--guardian {
    --guardian-frame: clamp(185px, 52vw, 264px);
    transform: none;
  }

  .maker-plg-portrait-wrap--guardian .maker-plg-portrait {
    object-position: center center;
  }

  /* 원오 세로 */
  .maker-plg-portrait-wrap:not(.maker-plg-portrait-wrap--guardian):not(.maker-plg-portrait-wrap--descent):not(.maker-plg-portrait-wrap--kid-final) {
    width: clamp(110px, 33vw, 163px);
    height: clamp(150px, 46.2vw, 231px);
  }

  /* 대화창: 그룹 너비에 맞춤, 하단 정렬 */
  .maker-plg-textbox {
    width: 100%;
    max-width: 100%;
    min-height: 5.5rem;
    align-self: stretch;
    padding: 0.7rem 0.85rem 0.75rem;
    font-size: clamp(0.8rem, 3.8vw, 0.94rem);
    line-height: 1.6;
  }

  .maker-plg-nav-btn {
    font-size: 0.58rem;
    padding: 0.26rem 0.42rem;
  }

  .maker-plg-start {
    min-height: 48px;
    font-size: 0.9rem;
    width: 100%;
  }

  .maker-plg-hint {
    font-size: clamp(0.72rem, 3.2vw, 0.84rem);
    line-height: 1.5;
  }

  /* ── 서울 메이어 메이커 (모바일) ── */
  #maker .topbar {
    align-items: center;
  }

  #maker .topbar .topbar-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: clamp(0.78rem, 3.4vw, 0.9rem);
  }

  #maker .maker-layout {
    padding: 0.35rem max(0.65rem, env(safe-area-inset-right, 0px))
      max(0.65rem, env(safe-area-inset-bottom, 0px))
      max(0.65rem, env(safe-area-inset-left, 0px));
  }

  .maker-play-fit {
    margin-top: -30px;
    max-height: calc(100dvh - 3rem);
    max-height: calc(100vh - 3rem);
  }

  .maker-brand {
    font-size: clamp(1rem, 4.5vw, 1.2rem);
    margin-bottom: 0.25rem;
  }

  .maker-hint {
    font-size: 0.78rem;
    margin-bottom: 0.65rem;
    padding: 0 0.15rem;
  }

  .maker-dress-zone {
    min-height: 0;
  }

  #maker .maker-character-panel {
    width: 100%;
  }

  #maker .maker-character-panel .maker-preview {
    width: min(100%, 92vw);
  }

  #maker .maker-character-panel .maker-preview.maker-preview--nukki-wear {
    width: min(100%, 96vw);
  }

  .maker-inv-section {
    width: 100%;
  }

  #maker .maker-inv-spacehint {
    flex-direction: column;
    gap: 0.35rem;
    font-size: clamp(0.72rem, 3.2vw, 0.82rem);
    opacity: 0.85;
    padding: 0.35rem 0.5rem 0.15rem;
  }

  #maker .maker-inv-spacehint .maker-key-btn {
    display: none;
  }

  #maker .maker-mobile-pick-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: min(100%, 640px);
    margin: 0.35rem auto 0;
    min-height: 56px;
    padding: 0.9rem 1.25rem;
    font-family: var(--font);
    font-size: clamp(1.05rem, 4.8vw, 1.2rem);
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #fff;
    background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
    border: 2px solid #b45309;
    border-radius: 14px;
    box-shadow: 0 4px 0 #92400e, 0 6px 16px rgba(180, 83, 9, 0.35);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }

  #maker .maker-mobile-pick-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #92400e, 0 3px 10px rgba(180, 83, 9, 0.3);
  }

  #maker .maker-action-bar #maker-check-btn {
    display: none !important;
  }

  .maker-inventory {
    width: 100%;
    min-width: 0;
  }

  .maker-inv-btn {
    width: 50px;
    height: 50px;
    min-width: 50px;
  }

  #maker .maker-character-panel .maker-equipped--compact {
    --maker-eq-side: clamp(26px, 7vw, 36px);
  }

  #maker .maker-character-panel .maker-eq-caption {
    font-size: 0.48rem;
  }

  .maker-spacebar-hint {
    font-size: 0.78rem;
    line-height: 1.45;
    padding: 0 0.15rem;
  }

  .maker-action-bar {
    width: 100%;
  }

  .maker-space-btn {
    width: 100%;
    min-height: 48px;
    font-size: 0.92rem;
  }

  .maker-play-again-btn {
    width: 100%;
    min-height: 52px;
    font-size: 1rem;
  }

  .ending-modal__close {
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1.25rem;
  }
}

@media (max-width: 480px) {
  body { font-size: 14px; }

  #hub.hub--8bit .hub-title { font-size: 1.15rem; }
  #hub.hub--8bit .hub-eyebrow { font-size: 0.65rem; }

  .g2-char-figure img {
    width: min(52vw, 200px);
    max-height: 68vh;
  }
  .g2-chars,
  .g2-chars--shell { min-height: 320px; }

  .g3-img-box { min-height: min(48vh, 440px); max-height: none; }

  .topbar-title { font-size: 0.78rem; }

  .maker-plg-textbox {
    min-height: 6.5rem;
    font-size: 0.8rem;
  }

  .maker-plg-title {
    letter-spacing: 0.18em;
    font-size: 0.65rem;
  }

  .maker-inv-label {
    width: 42px;
    min-width: 42px;
    font-size: 0.65rem;
  }

  #maker .maker-mobile-pick-btn {
    min-height: 52px;
    font-size: 1.08rem;
    border-radius: 12px;
  }

  .maker-inv-btn {
    width: 46px;
    height: 46px;
    min-width: 46px;
  }

  #maker .maker-nudge-btn {
    min-width: 2.35rem;
    height: 2.35rem;
    min-height: 44px;
  }

  .maker-lose-card {
    margin: 0 0.5rem;
    max-width: min(100%, 320px);
  }
}

@media (hover: none) and (pointer: coarse) {
  .game-card:hover { transform: none; }
  #hub.hub--8bit .game-card:hover {
    transform: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  }
  #hub.hub--8bit .game-card:active {
    transform: scale(0.99);
    opacity: 0.92;
  }

  .maker-inv-btn:hover {
    border-color: var(--border);
    background: #fff;
  }

  .maker-inv-btn.selected:hover {
    border-color: #f59e0b;
    background: #fef3c7;
  }

  #maker .maker-nudge-btn:hover {
    filter: none;
  }
}

/* 모바일: 하단 리본 */
@media (max-width: 480px) {
  .ending-text-card {
    width: calc(100vw - 1rem);
    max-height: min(44vh, 340px);
    bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
    border-radius: 0;
  }
  .ending-img-stage {
    bottom: 42%;
  }
  .ending-scroll-text { padding: 0.75rem 0.65rem 0.45rem; }
  .ending-fade-bot { bottom: 3.15rem; }
}
