:root {
  --bg: #e9edf3;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --accent: #3b74e6;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", sans-serif;
}
body.app-booting .app {
  visibility: hidden;
}
.app { max-width: 760px; margin: 0 auto; padding: 16px 12px 16px; }
.topbar h1 { margin: 4px 0 14px; font-size: 56px; letter-spacing: -0.03em; line-height: 1.04; font-weight: 700; }
.topbar h1 span { color: var(--accent); }
.card {
  background: transparent;
  border: none;
  border-radius: 16px;
  padding: 0;
  display: grid;
  gap: 12px;
  box-shadow: none;
}
label { font-size: 13px; font-weight: 700; }
select, input[type='range'], input[type='color'], button, pre {
  width: 100%;
}
select, button {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  font-size: 14px;
}
button {
  background: linear-gradient(90deg, #0ea5e9, #2563eb);
  color: #fff;
  border: none;
  font-weight: 700;
}
.btn-secondary {
  background: #e2e8f0;
  color: #0f172a;
}
.step-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background: #f2f3f5;
  border-radius: 999px;
  padding: 4px;
}
.step-tab {
  padding: 13px 6px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #1e293b;
  font-size: 20px;
  font-weight: 700;
}
.step-tab.active {
  background: #dddddf;
  color: #343436;
}
.step-tab[disabled] {
  opacity: 0.3;
}
.preview-shell { display: grid; place-items: center; padding: 4px 0 8px; position: relative; min-height: 430px; }
.edit-fab {
  position: absolute;
  right: 0;
  top: 24px;
  width: 84px;
  height: 84px;
  border-radius: 999px;
  border: none;
  background: #f2f3f5;
  color: var(--accent);
  font-size: 38px;
  font-weight: 700;
  line-height: 1;
  display: grid;
  place-items: center;
}
.preview-circle {
  width: 390px;
  height: 390px;
  border-radius: 999px;
  background: #f6f7f8;
  border: 6px solid #b9bdc2;
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}
.preview-ring {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: var(--borderColor, #000);
  display: none;
  place-items: center;
}
.preview-fill {
  width: 94%;
  height: 94%;
  border-radius: 999px;
  background: var(--fillColor, #0073ff);
  display: grid;
  place-items: center;
}
.logo-wrap {
  width: 210px;
  height: 210px;
  touch-action: none;
  cursor: grab;
}
.logo-wrap.dragging { cursor: grabbing; }
.logo-svg {
  width: 100%;
  height: 100%;
  background: var(--logoColor, #fff);
  -webkit-mask-image: var(--logoMask);
  mask-image: var(--logoMask);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}
.preview-empty {
  position: absolute;
  color: #94a3b8;
  font-size: 20px;
  font-weight: 600;
}
.step-panel { display: none; }
.step-panel.active { display: grid; gap: 10px; }
.step-panel h2 { margin: 0; font-size: 50px; line-height: 1.07; letter-spacing: -0.03em; }
.accent-word { color: var(--accent); }
.upload-card {
  border: none;
  border-radius: 30px;
  padding: 42px 18px 34px;
  min-height: 420px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  background: #efeff1;
}
.upload-card.ready {
  background: #eaf3ff;
  box-shadow: inset 0 0 0 2px #3b74e6;
}
.upload-icon {
  width: 108px;
  height: 108px;
  border-radius: 28px;
  border: 2px solid #d6e3ff;
  background: linear-gradient(180deg, #edf3ff 0%, #e3ecff 100%);
  display: grid;
  place-items: center;
  line-height: 1;
  font-size: 54px;
  color: #2f76f6;
  font-weight: 800;
}
.upload-text { font-weight: 600; font-size: 22px; color: #34353a; letter-spacing: -0.01em; }
.upload-card input { display: none; }
.upload-status {
  margin: 0;
  min-height: 18px;
  color: #1d4ed8;
  font-weight: 700;
  font-size: 13px;
}
.hint { margin: 0; color: #81858a; font-size: 50px; line-height: 1.2; }
.hint.center { text-align: center; }
.text-link {
  background: none;
  border: none;
  color: var(--accent);
  text-align: center;
  padding: 0;
  font-weight: 700;
  font-size: 52px;
}
.contact-btn {
  width: auto;
  justify-self: center;
  padding: 16px 28px;
  border-radius: 24px;
  background: #dddddf;
  color: #3f3f46;
  font-size: 46px;
  border: none;
}
.error { margin: 0; min-height: 16px; color: #dc2626; font-size: 13px; }
.row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.color-editors {
  display: grid;
  gap: 12px;
  margin-top: 6px;
}
.color-editor {
  border: 1px solid #cdd3dd;
  border-radius: 16px;
  padding: 12px 14px;
  background: #f3f5f8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.color-editor-name {
  font-size: 18px;
  line-height: 1.1;
  color: #0f172a;
  font-weight: 700;
}
.color-editor input[type='color'] {
  width: 64px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  flex: 0 0 auto;
}
.color-editor input[type='color']::-webkit-color-swatch-wrapper {
  padding: 0;
}
.color-editor input[type='color']::-webkit-color-swatch {
  border: 2px solid #c4ccda;
  border-radius: 12px;
}
.color-editor input[type='color']::-moz-color-swatch {
  border: 2px solid #c4ccda;
  border-radius: 12px;
}
.palette-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.palette-chip {
  width: 84px;
  height: 84px;
  border: 4px solid #e5e7eb;
  border-radius: 999px;
  overflow: visible;
  justify-self: center;
  transform: none;
  padding: 0;
  display: grid;
  place-items: center;
}
.palette-chip.selected { outline: 5px solid var(--accent); border-color: #8db0f0; }
.palette-chip div { width: 48%; height: 48%; border-radius: 999px; border: 2px solid #ffffffcc; }
.hidden { display: none !important; }
.tier-cards {
  display: grid;
  gap: 10px;
}
.payment-methods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.payment-method-btn {
  border: 1px solid #c9d3e2;
  border-radius: 14px;
  background: #f8fafc;
  color: #1e293b;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.15;
  padding: 12px 10px;
}
.payment-method-btn.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px #60a5fa;
  background: #eef4ff;
}
.payment-note {
  margin: 0;
  color: #64748b;
  font-size: 15px;
  line-height: 1.2;
}
.payment-status {
  margin: 0;
  min-height: 20px;
  color: #1d4ed8;
  font-size: 14px;
  font-weight: 700;
}
.tier-card {
  border: 2px solid #e5e7eb;
  border-radius: 18px;
  background: #f4f5f7;
  color: #111827;
  padding: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 22px;
  font-weight: 700;
}
.tier-card.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px #60a5fa;
}
.example-block {
  display: grid;
  justify-items: center;
  gap: 6px;
}
.sticker-example-anim {
  width: 260px;
  height: 260px;
  border-radius: 18px;
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.sticker-example-anim svg {
  width: 100% !important;
  height: 100% !important;
}
.sticker-example-anim canvas {
  width: 100% !important;
  height: 100% !important;
}
.sticker-example-anim tgs-player {
  width: 100% !important;
  height: 100% !important;
  display: block;
}
.sticker-preview-gif {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.example-logo-overlay {
  position: absolute;
  left: 46%;
  top: 46%;
  transform: translate(calc(-50% + var(--overlayX, 0px)), calc(-50% + var(--overlayY, 0px))) rotate(-12deg) scale(var(--overlayScale, 1));
  min-width: 58px;
  min-height: 36px;
  border-radius: 6px;
  background: var(--overlayFill, #101010);
  color: #ffffff;
  border: 2px solid var(--overlayBorder, #1f2937);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
  padding: 3px 5px;
  box-shadow: 0 2px 4px #00000055;
}
.example-logo-overlay span {
  display: block;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.example-logo-mask {
  width: 42px;
  height: 26px;
  background: var(--overlayLogo, #ffffff);
  -webkit-mask-image: var(--overlayMask);
  mask-image: var(--overlayMask);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}
.fallback-card {
  border: 1px solid #cbd5e1;
  border-radius: 18px;
  background: #f8fafc;
}
.fallback-card-title {
  font-weight: 800;
  color: #334155;
}
.fallback-card-subtitle {
  font-size: 13px;
  color: #64748b;
}
.fallback-anim-shell {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  animation: fallback-bob 2.4s ease-in-out infinite;
}
.fallback-anim-ring {
  width: 84%;
  height: 84%;
  border-radius: 999px;
  background: var(--fallbackBorder, #000000);
  display: grid;
  place-items: center;
  box-shadow: 0 10px 20px #0f172a22;
}
.fallback-anim-fill {
  width: 92%;
  height: 92%;
  border-radius: 999px;
  background: var(--fallbackFill, #0073ff);
  display: grid;
  place-items: center;
}
.fallback-anim-logo-wrap {
  width: 54%;
  height: 54%;
  display: grid;
  place-items: center;
}
.fallback-anim-logo {
  width: 100%;
  height: 100%;
  background: var(--fallbackLogo, #ffffff);
  -webkit-mask-image: var(--fallbackMask);
  mask-image: var(--fallbackMask);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  animation: fallback-breathe 1.9s ease-in-out infinite;
}
@keyframes fallback-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
@keyframes fallback-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
.preview-circle.mini {
  width: 220px;
  height: 220px;
  border-width: 4px;
}
.preview-circle.mini .preview-ring { width: 100%; height: 100%; }
.preview-circle.mini .logo-wrap { width: 120px; height: 120px; }
input[type='text'] {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 18px;
  padding: 16px 18px;
  font-size: 28px;
  color: #111827;
  background: #f8fafc;
}
.characters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.characters-head h3 {
  margin: 0;
  font-size: 46px;
  color: #4b5563;
}
.select-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 8px 14px;
  background: #f8fafc;
  font-size: 14px;
  color: #374151;
}
.select-all input {
  width: 20px;
  height: 20px;
}
.character-grid {
  display: block;
}
.character-grid-inner {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.character-category .character-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.character-sections {
  display: grid;
  gap: 14px;
}
.character-category {
  display: grid;
  gap: 8px;
}
.character-category h4 {
  margin: 0;
  font-size: 18px;
  color: #6b7280;
  font-weight: 700;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.char-card {
  border: 2px solid #e5e7eb;
  border-radius: 18px;
  aspect-ratio: 1 / 1;
  background: #f3f4f6;
  display: grid;
  place-items: center;
  color: #334155;
  font-weight: 700;
  font-size: 14px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.char-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
  display: block;
}
.char-frame-fallback {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.tile-svg {
  width: 100%;
  height: 100%;
  display: block;
}
.tile-float {
  transform-origin: center;
}
.tile-mark-body {
  fill: var(--tileFill, #0073ff);
  stroke: var(--tileBorder, #000000);
  stroke-width: 4;
}
.tile-mark-shine {
  fill: var(--tileShine, #ffffff33);
}
.tile-mark-text {
  fill: var(--tileLogo, #ffffff);
  font-size: 11px;
  font-weight: 900;
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", sans-serif;
}
.tile-svg.playing .tile-float {
  animation: tile-pop 900ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.tile-svg.playing .tile-mark-shine {
  animation: tile-shine 900ms ease-in-out;
}
@keyframes tile-pop {
  0% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.09) rotate(-3deg); }
  55% { transform: scale(0.98) rotate(2deg); }
  100% { transform: scale(1) rotate(0deg); }
}
@keyframes tile-shine {
  0% { opacity: 0.45; }
  35% { opacity: 0.95; }
  100% { opacity: 0.45; }
}
.char-anim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  visibility: hidden;
}
.char-anim.playing {
  opacity: 1;
  visibility: visible;
}
.char-anim.pending {
  opacity: 0;
  visibility: hidden;
}
.char-anim svg {
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  display: block;
  overflow: hidden !important;
}
.char-card.selected {
  border-color: #1d4ed8;
  box-shadow: inset 0 0 0 1px #60a5fa;
}
.char-card .check {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #1d4ed8;
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  z-index: 5;
}
.char-card.selected .check { display: flex; }
.select-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #6b7280;
  font-size: 16px;
}
.text-link.small { font-size: 16px; }
.success-links {
  display: grid;
  gap: 8px;
}
.success-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.success-link-card {
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  padding: 10px;
  display: grid;
  gap: 4px;
}
.success-link-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.success-link-row a {
  color: #1d4ed8;
  font-weight: 700;
  text-decoration: none;
}
.actions { display: grid; grid-template-columns: 112px 1fr; gap: 8px; }
.actions.upload-mode { grid-template-columns: 1fr; }
.actions.wizard-mode { grid-template-columns: 0.34fr 1fr; gap: 14px; }
#next_btn.upload-cta {
  min-height: 86px;
  font-size: 48px;
  border-radius: 18px;
}
#next_btn.wizard-cta,
#back_btn.wizard-back {
  min-height: 86px;
  border-radius: 18px;
  font-size: clamp(28px, 5.2vw, 56px);
  font-weight: 700;
  line-height: 1;
}
.bottom-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, 100vw);
  bottom: 0;
  z-index: 40;
  background: #f0f1f3;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
}
.app {
  padding-bottom: calc(130px + env(safe-area-inset-bottom));
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 30;
}
.modal-card {
  width: min(520px, 100%);
  background: #f8fafc;
  border-radius: 18px;
  padding: 16px;
  display: grid;
  gap: 10px;
}
.modal-card h3 {
  margin: 0;
  font-size: 28px;
}
.modal-card p {
  margin: 0;
  color: #4b5563;
  font-size: 18px;
  line-height: 1.3;
}
.modal-actions {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
}
pre {
  margin: 0;
  background: #0b1020;
  color: #dbeafe;
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
  overflow: auto;
  min-height: 70px;
}
#result { display: none; }
#result.visible { display: block; }
@media (max-width: 460px) {
  .topbar h1 { font-size: 28px; }
  .step-tab { font-size: 12px; padding: 10px 2px; }
  .preview-shell { min-height: 260px; }
  .edit-fab { width: 44px; height: 44px; font-size: 18px; top: 8px; }
  .preview-circle { width: 200px; height: 200px; border-width: 4px; }
  .logo-wrap { width: 100px; height: 100px; }
  .step-panel h2 { font-size: 22px; }
  .hint { font-size: 14px; }
  .upload-card { min-height: 340px; padding: 34px 12px 24px; gap: 12px; border-radius: 24px; }
  .upload-text { font-size: 20px; }
  .upload-icon { width: 92px; height: 92px; font-size: 46px; border-width: 2px; border-radius: 24px; }
  .upload-status { font-size: 12px; }
  .contact-btn { font-size: 14px; padding: 10px 16px; }
  .text-link { font-size: 16px; }
  .palette-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
  .palette-chip { width: 44px; height: 44px; border-width: 2px; }
  .row { grid-template-columns: 1fr; }
  .color-editor { padding: 10px 12px; border-radius: 14px; }
  .color-editor-name { font-size: 16px; }
  .color-editor input[type='color'] { width: 56px; height: 40px; }
  .tier-card { font-size: 16px; padding: 14px; }
  input[type='text'] { font-size: 14px; padding: 12px; }
  .characters-head h3 { font-size: 20px; }
  .character-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .char-card { border-radius: 12px; font-size: 10px; }
  .preview-circle.mini { width: 180px; height: 180px; }
  .preview-circle.mini .logo-wrap { width: 92px; height: 92px; }
  .sticker-example-anim { width: 180px; height: 180px; }
}
