:root {
  --bg-grad-1: #fff6e9;
  --bg-grad-2: #e9f7ff;
  --card-bg: #ffffff;
  --ink: #2c2a4a;
  --ink-soft: #646284;
  --primary: #ff6b8b;
  --primary-dark: #e84e71;
  --secondary: #5c7cfa;
  --mint: #2ec4b6;
  --gold: #ffbe0b;
  --border: #eceaf6;
  --shadow-sm: 0 4px 12px rgba(44, 42, 74, 0.08);
  --shadow-md: 0 10px 28px rgba(44, 42, 74, 0.12);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-display: 'Jua', 'Noto Sans KR', sans-serif;
  --font-body: 'Noto Sans KR', sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background: radial-gradient(circle at top left, var(--bg-grad-1), var(--bg-grad-2) 60%, #f3ecff 100%);
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* ==================== TOAST ==================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #2c2a4a;
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.05rem;
  padding: 12px 24px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  z-index: 10000;
  animation: toastPop 0.25s ease;
}

@keyframes toastPop {
  from { transform: translate(-50%, 16px) scale(0.95); opacity: 0; }
  to { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

/* ==================== BUTTONS ==================== */
.btn {
  border: none;
  border-radius: 16px;
  padding: 11px 20px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:active {
  transform: translateY(2px) scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #ff7aa2, #ff5c8a);
  color: #fff;
  box-shadow: 0 5px 0 #d93c69, 0 8px 18px rgba(255, 92, 138, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.04);
}

.btn-xl {
  font-size: 1.25rem;
  padding: 15px 32px;
  border-radius: 20px;
}

.btn-save {
  background: linear-gradient(135deg, #2ec4b6, #20a4f3);
  color: #fff;
  box-shadow: 0 4px 0 #1982c4, 0 8px 16px rgba(32, 164, 243, 0.3);
  white-space: nowrap;
}

.btn-gold {
  background: linear-gradient(135deg, #ffd166, #ff9f1c);
  color: #3a2200;
  box-shadow: 0 4px 0 #d97706;
}

.btn-soft {
  background: #f1effb;
  color: var(--ink);
}

.btn-soft:hover {
  background: #e5e1f7;
}

.btn-danger {
  background: #ffe3e8;
  color: #d62849;
}

.btn-tiny {
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink-soft);
  padding: 6px 12px;
  font-size: 0.9rem;
  border-radius: 10px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: #f8f7ff;
}

.link-btn {
  background: none;
  border: none;
  color: var(--secondary);
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  font-family: var(--font-body);
}

/* ==================== LOGIN SCREEN ==================== */
.login-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 20px 60px;
  text-align: center;
}

.brand-hero {
  margin-bottom: 32px;
}

.brand-badge {
  display: inline-block;
  background: #fff;
  color: var(--primary-dark);
  font-family: var(--font-display);
  padding: 7px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  font-size: 1rem;
}

.brand-title {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 5vw, 3.2rem);
  margin: 0 0 10px;
  color: var(--ink);
  text-shadow: 0 4px 0 rgba(255, 255, 255, 0.9);
}

.brand-subtitle {
  margin: 0;
  font-size: 1.05rem;
  color: var(--ink-soft);
}

.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px;
  margin: 28px 0 34px;
}

.player-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 22px 16px;
  box-shadow: var(--shadow-sm);
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  position: relative;
}

.player-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.player-card-lock {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 1rem;
}

.player-avatar-circle {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.1);
}

.player-card-name {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin-bottom: 6px;
}

.player-card-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--ink-soft);
  font-weight: 700;
}

.empty-players-box {
  grid-column: 1 / -1;
  background: rgba(255, 255, 255, 0.8);
  border: 3px dashed #d5d0ee;
  border-radius: var(--radius-lg);
  padding: 36px 20px;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

/* ==================== TOP BAR ==================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--border);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mini {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--primary-dark);
}

.player-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f6f4ff;
  border: 2px solid #e4defc;
  border-radius: 999px;
  padding: 5px 14px 5px 8px;
  font-weight: 700;
}

.pill-avatar {
  font-size: 1.3rem;
}

.pill-stars {
  background: #fff3c4;
  color: #b45309;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.88rem;
}

.main-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-btn {
  border: 2px solid transparent;
  background: transparent;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--ink-soft);
  padding: 9px 15px;
  border-radius: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.nav-btn:hover {
  background: #f5f3ff;
  color: var(--ink);
}

.nav-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 107, 139, 0.35);
}

.badge-mini {
  background: rgba(255, 255, 255, 0.25);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.8rem;
}

.nav-btn:not(.active) .badge-mini {
  background: #eceaf6;
  color: var(--ink);
}

/* ==================== GAME MAIN ==================== */
.game-main {
  max-width: 1260px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.studio-layout {
  display: grid;
  grid-template-columns: minmax(340px, 470px) 1fr;
  gap: 20px;
  align-items: start;
}

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

/* ==================== MISSION BANNER ==================== */
.mission-banner {
  background: linear-gradient(135deg, #fff6d6, #ffe5ec);
  border: 3px solid #ffd166;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.mission-banner-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.mission-banner-checks {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.86rem;
  font-weight: 700;
}

.check-pill {
  background: rgba(255, 255, 255, 0.85);
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--ink-soft);
}

.check-pill.done {
  background: #d8f8e8;
  color: #0b7a4b;
}

.mission-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==================== STAGE CARD ==================== */
.stage-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-md);
  border: 2px solid var(--border);
}

.stage-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 12px;
}

.tool-chip {
  border: 2px solid #eceaf6;
  background: #faf9ff;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.95rem;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.tool-chip:hover {
  background: #efeafd;
  transform: translateY(-2px);
}

.figure-stage {
  width: 100%;
  aspect-ratio: 1 / 1.05;
  border-radius: 20px;
  overflow: hidden;
  border: 3px solid #f0eef9;
  background: #eef6ff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.figure-stage svg {
  width: 100%;
  height: 100%;
  display: block;
}

.figure-stage.pop-anim svg .figure-root {
  animation: figurePop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: 200px 250px;
}

.figure-stage.dance-anim svg .figure-root {
  animation: figureDance 0.9s ease-in-out;
  transform-origin: 200px 270px;
}

@keyframes figurePop {
  0% { transform: scale(0.92); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes figureDance {
  0% { transform: translateY(0) rotate(0deg); }
  20% { transform: translateY(-18px) rotate(-6deg); }
  45% { transform: translateY(0) rotate(6deg); }
  70% { transform: translateY(-14px) rotate(-4deg); }
  100% { transform: translateY(0) rotate(0deg); }
}

.save-bar {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.save-bar input {
  flex: 1;
  border: 2px solid #e2dff2;
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 1rem;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--ink);
  outline: none;
}

.save-bar input:focus {
  border-color: var(--mint);
}

.editing-indicator {
  margin-top: 10px;
  font-size: 0.88rem;
  color: var(--ink-soft);
  background: #f5f3ff;
  padding: 8px 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==================== CUSTOMIZER WORKBENCH ==================== */
.customizer-column {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 2px solid var(--border);
  overflow: hidden;
}

.preset-bar {
  padding: 12px 14px;
  background: linear-gradient(135deg, #fff4d6, #eef2ff);
  border-bottom: 2px solid var(--border);
}

.preset-bar-label {
  font-family: var(--font-display);
  font-size: 0.96rem;
  color: var(--ink);
  margin-bottom: 8px;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.preset-chip {
  border: 2px solid #dedbf4;
  background: #fff;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.92rem;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}

.preset-chip:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  background: #fff0f5;
}

.category-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 6px;
  padding: 12px;
  background: #f8f7ff;
  border-bottom: 2px solid var(--border);
}

.cat-tab {
  border: 2px solid transparent;
  background: #fff;
  border-radius: 14px;
  padding: 8px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-family: var(--font-display);
  font-size: 0.88rem;
  color: var(--ink-soft);
  transition: all 0.14s ease;
}

.cat-tab .cat-icon {
  font-size: 1.45rem;
}

.cat-tab:hover {
  border-color: #d7d0ff;
  color: var(--ink);
}

.cat-tab.active {
  background: linear-gradient(135deg, #6c63ff, #5c7cfa);
  color: #fff;
  box-shadow: 0 4px 10px rgba(92, 124, 250, 0.3);
}

.customizer-body {
  padding: 18px;
  min-height: 430px;
}

.option-group {
  margin-bottom: 20px;
}

.option-group:last-child {
  margin-bottom: 0;
}

.option-group-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin: 0 0 10px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  gap: 10px;
}

.option-card {
  border: 3px solid #eceaf6;
  background: #fcfcff;
  border-radius: 16px;
  padding: 12px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--ink);
  transition: all 0.14s ease;
}

.option-card .opt-emoji {
  font-size: 1.8rem;
  line-height: 1;
}

.option-card:hover {
  transform: translateY(-2px);
  border-color: #c7c0f6;
}

.option-card.selected {
  border-color: var(--primary);
  background: #fff0f5;
  box-shadow: 0 4px 12px rgba(255, 107, 139, 0.22);
}

.color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-swatch {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px #dedbf0, 0 3px 6px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: transform 0.14s ease;
}

.color-swatch:hover {
  transform: scale(1.12);
}

.color-swatch.selected {
  transform: scale(1.15);
  box-shadow: 0 0 0 3px var(--ink), 0 5px 12px rgba(0, 0, 0, 0.2);
}

/* ==================== SECTION HEADERS & GRIDS ==================== */
.section-header {
  text-align: center;
  margin-bottom: 24px;
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: 1.9rem;
  margin: 0 0 6px;
}

.section-header p {
  margin: 0;
  color: var(--ink-soft);
}

.missions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.mission-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 3px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mission-card.completed {
  border-color: #6ee7b7;
  background: #f4fff9;
}

.mission-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mission-icon {
  font-size: 2.2rem;
}

.mission-reward {
  background: #fff3c4;
  color: #b45309;
  font-family: var(--font-display);
  padding: 4px 12px;
  border-radius: 999px;
}

.mission-card h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin: 0;
}

.mission-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.94rem;
  line-height: 1.45;
  flex: 1;
}

.figures-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

.figure-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.15s ease;
}

.figure-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.figure-thumb {
  width: 100%;
  aspect-ratio: 1 / 1.05;
  border-radius: 16px;
  overflow: hidden;
  background: #f5f8ff;
}

.figure-thumb svg {
  width: 100%;
  height: 100%;
  display: block;
}

.figure-card-title {
  font-family: var(--font-display);
  font-size: 1.18rem;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.figure-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-weight: 700;
}

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

.figure-card-actions .btn {
  flex: 1;
  padding: 8px 10px;
  font-size: 0.9rem;
  border-radius: 12px;
}

.like-btn {
  border: 2px solid #ffd6e0;
  background: #fff5f8;
  color: #e63963;
  font-family: var(--font-display);
  font-size: 0.95rem;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.like-btn.liked {
  background: #ff5c8a;
  border-color: #ff5c8a;
  color: #fff;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  background: rgba(255, 255, 255, 0.85);
  border: 3px dashed #d8d3f2;
  border-radius: var(--radius-lg);
  padding: 48px 20px;
  color: var(--ink-soft);
}

.empty-state .empty-emoji {
  font-size: 3.2rem;
  margin-bottom: 10px;
}

/* ==================== MODALS ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(34, 30, 62, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  animation: modalPop 0.2s ease;
}

.modal-sm {
  max-width: 350px;
}

@keyframes modalPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #f8f7ff;
  border-bottom: 2px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.3rem;
}

.modal-close {
  border: none;
  background: #eceaf6;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
}

.modal-body {
  padding: 18px 20px;
}

.modal-footer {
  padding: 14px 20px;
  background: #faf9ff;
  border-top: 2px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.field-label {
  display: block;
  font-family: var(--font-display);
  font-size: 1.02rem;
  margin: 12px 0 6px;
}

.field-label:first-child {
  margin-top: 0;
}

.field-hint {
  margin: 6px 0 0;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.text-input {
  width: 100%;
  border: 2px solid #e2dff2;
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 1rem;
  font-family: var(--font-body);
  font-weight: 700;
  outline: none;
}

.text-input:focus {
  border-color: var(--primary);
}

.emoji-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.emoji-choice {
  font-size: 1.7rem;
  padding: 8px;
  border-radius: 14px;
  border: 3px solid #eceaf6;
  background: #faf9ff;
  cursor: pointer;
}

.emoji-choice.selected {
  border-color: var(--primary);
  background: #fff0f5;
}

.color-picker-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* PIN PAD */
.pin-subtitle {
  text-align: center;
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-weight: 700;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 18px;
}

.pin-dots span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid #d2cde8;
  background: #fff;
  transition: all 0.12s ease;
}

.pin-dots span.filled {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(1.15);
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.pin-key {
  border: 2px solid #eceaf6;
  background: #faf9ff;
  border-radius: 16px;
  padding: 14px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--ink);
  cursor: pointer;
}

.pin-key:active {
  background: #ffe3ec;
  transform: scale(0.95);
}

.pin-key-clear, .pin-key-back {
  font-size: 1rem;
  background: #f1effb;
}
