:root {
  --bg: #e9e9e9;
  --card-red: #f02825;
  --brand-lime: #b8ef42;
  --chip: #f4f4f4;
  --ink: #0f1319;
  --muted: #9a9a9a;
  --outline: #101923;
  --radius: 18px;
  --shell-width: min(1280px, 96vw);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(circle at 50% 20%, #f1f1f1, #e6e6e6 55%, #dfdfdf);
  color: var(--ink);
  font-family: "Raleway", sans-serif;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.desktop-hearts {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.bg-heart {
  position: absolute;
  width: 140px;
  aspect-ratio: 1;
  background: url("./Heart.png") center / contain no-repeat;
  filter: blur(1px);
  animation: float 8s ease-in-out infinite;
}

.bg-heart::before,
.bg-heart::after {
  content: none;
}

.h1 { left: 5%; top: -1%; animation-delay: 0s; }
.h2 { left: 17%; top: 58%; animation-delay: .7s; }
.h3 { left: 76%; top: 18%; animation-delay: 1.2s; }
.h4 { left: 73%; top: 78%; animation-delay: .9s; }
.h5 { left: 25%; top: 28%; animation-delay: 1.8s; width: 105px; }
.h6 { left: 64%; top: 44%; animation-delay: 2.4s; width: 114px; }

@keyframes float {
  0%,
  100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-14px) scale(1.035); }
}

.app-shell {
  position: relative;
  width: var(--shell-width);
  margin: 10px auto;
  min-height: calc(100vh - 20px);
  border: none;
  border-radius: 14px;
  padding: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent;
}

.tg-start,
.editor {
  width: 100%;
  min-height: calc(100vh - 80px);
  transition: opacity .46s cubic-bezier(.22,.61,.36,1), transform .46s cubic-bezier(.22,.61,.36,1);
  opacity: 1;
  transform: translateY(0) scale(1);
}

.screen-enter {
  opacity: 0;
  transform: translateY(18px) scale(0.985);
}

.screen-exit {
  opacity: 0;
  transform: translateY(-14px) scale(0.985);
}

.tg-start {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 34px;
  text-align: center;
}

.tg-start h1 {
  margin: 0;
  font-size: clamp(34px, 4vw, 58px);
  max-width: 520px;
  line-height: 1.05;
}

.mark-lg {
  transform: scale(1.8);
}

.welcome-animation {
  width: min(290px, 60vw);
  max-width: 320px;
  aspect-ratio: 200 / 234.83;
  position: relative;
  margin: 8px auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 5;
}

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

.brand {
  height: 56px;
  width: 60px;
  border-radius: 0;
  background: url("./Logo.svg") center / contain no-repeat;
  color: transparent;
  font-size: 0;
  line-height: 0;
}

.brand::after {
  content: none;
}

.brand.mini {
  width: 40px;
  height: 38px;
  background-size: contain;
}

.brand.mini::after {
  content: none;
}

.btn-primary,
.btn-secondary {
  border: none;
  border-radius: 40px;
  height: 44px;
  padding: 0 26px;
  font: 600 17px/1 "Raleway", sans-serif;
  text-transform: lowercase;
  cursor: pointer;
}

.btn-primary {
  background: var(--brand-lime);
}

.btn-primary.large {
  height: 54px;
  padding: 0 34px;
  font-size: 21px;
}

.btn-secondary {
  background: var(--chip);
}

.btn-secondary.full {
  width: min(343px, 100%);
}

.editor {
  position: relative;
}

.bg-title {
  margin: -34px 0 0;
  font: 700 clamp(84px, 15vw, 172px)/0.83 "Raleway", sans-serif;
  color: #f2b8df;
  text-align: center;
  letter-spacing: -0.01em;
  user-select: none;
  position: relative;
  z-index: 2;
  transform: translateY(-24px);
}

.editor-core {
  margin: -100px auto 0;
  width: min(343px, 100%);
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
  position: relative;
  z-index: 4;
}

.card {
  width: 343px;
  max-width: 100%;
  height: 428px;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  background: var(--card-bg);
}

.card-overlay,
.card-custom-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.card-export-hitbox {
  display: none;
}

.card-base-bg {
  background: var(--card-bg);
}

.card-logo {
  display: none;
  position: absolute;
  left: 50%;
  top: calc(100% - 74px);
  transform: translateX(-50%);
  width: 40px;
  height: 38px;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  z-index: 4;
}

.card.preview.base .card-logo,
.card.preview.custom .card-logo {
  display: block;
}

.card.preview.custom .card-custom-layer {
  display: block;
}

.card.preview.base .card-custom-layer {
  display: none;
}

.custom-0 .card-custom-layer {
  background: url("./custom_1.png") center / cover no-repeat;
}

.custom-1 .card-custom-layer {
  background: url("./custom_2.png") center / cover no-repeat;
}

.custom-2 .card-custom-layer {
  background: url("./custom_3.png") center / cover no-repeat;
}

.custom-3 .card-custom-layer {
  background: url("./custom_4.png") center / cover no-repeat;
}

.custom-4 .card-custom-layer {
  background: url("./custom_5.png") center / cover no-repeat;
}

.custom-3 .card-custom-layer::before,
.custom-3 .card-custom-layer::after,
.custom-4 .card-custom-layer::before,
.custom-4 .card-custom-layer::after {
  content: none;
}

.message {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 304px;
  height: 128px;
  border: none;
  outline: none;
  resize: none;
  overflow: hidden;
  background: transparent;
  box-sizing: border-box;
  padding: 0;
  text-align: center;
  font: 800 21px/1.2 "REM", sans-serif;
  font-size: 21px;
  color: var(--text-color);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message::placeholder {
  color: color-mix(in srgb, var(--text-color) 60%, white 40%);
}

.card .brand.mini {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 22px;
}

.mode-switch {
  width: 100%;
  height: 44px;
  border-radius: 40px;
  background: var(--chip);
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.switch-btn {
  border: none;
  border-radius: 40px;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  font: 600 17px/1 "Raleway", sans-serif;
  cursor: pointer;
  color: var(--muted);
}

.switch-btn.active,
.switch-btn[aria-selected="true"] {
  background: var(--brand-lime);
  color: #0b0b0b;
}

.palette-grid {
  width: 100%;
  display: grid;
  gap: 12px;
}

.palette-row {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 12px;
}

.palette-row.palette-slider {
  width: 100%;
}

.palette-row .arrow {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid #9ba0a7;
  background: rgba(255, 255, 255, 0.5) url("./arrow.svg") center / 40px 40px no-repeat;
  color: transparent;
  font-size: 0;
  line-height: 0;
  cursor: pointer;
}

.palette-row .arrow-right {
  transform: rotate(180deg);
}

.swatches {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.swatch {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  position: relative;
}

.swatch.active::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 1.5px solid #8e939a;
  border-radius: 50%;
}

.custom-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 9px;
}

.custom-thumb {
  border: none;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  cursor: pointer;
  position: relative;
}

.custom-thumb.active::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1.6px solid #9ca0a8;
}

.custom-thumb.custom-0 { background: url("./custom-thumb_1.png") center / cover no-repeat; }
.custom-thumb.custom-1 { background: url("./custom-thumb_2.png") center / cover no-repeat; }
.custom-thumb.custom-2 { background: url("./custom-thumb_3.png") center / cover no-repeat; }
.custom-thumb.custom-3 { background: url("./custom-thumb_4.png") center / cover no-repeat; }
.custom-thumb.custom-4 { background: url("./custom-thumb_5.png") center / cover no-repeat; }

.phrases-wrap {
  width: 100%;
  position: relative;
}

.phrases-slider {
  position: relative;
  width: 100%;
  height: 170px;
  overflow: visible;
  padding: 4px 10px;
  box-sizing: border-box;
}

.phrase-slide {
  position: absolute;
  left: 10px;
  top: 0;
  width: calc(100% - 20px);
  height: 56px;
  border: 2px solid #eaeae9;
  border-radius: 25px;
  padding: 0 20px;
  background: #ffffff;
  font: 600 16px/1 "Raleway", sans-serif;
  text-align: center;
  color: #2f3338;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 5px 10px rgba(32, 28, 28, 0.2);
  cursor: pointer;
  transition: transform .28s cubic-bezier(.68,-0.55,.27,1.55), opacity .25s ease, box-shadow .25s ease;
}

.phrase-slide.stack-0 {
  z-index: 3;
  transform: translateY(0) scale(1);
}

.phrase-slide.stack-1 {
  z-index: 2;
  transform: translateY(38px) scale(.95);
}

.phrase-slide.stack-2 {
  z-index: 1;
  transform: translateY(74px) scale(.9);
}

.phrase-slide.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(100px) scale(.86);
}

.phrase-slide.active {
  border-color: #d8d8d8;
}

.phrases-wrap.expanded .phrases-slider {
  height: 330px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 10px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.phrases-wrap.expanded .phrases-slider::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.phrases-wrap.expanded .phrase-slide {
  position: relative;
  left: auto;
  width: calc(100% - 20px);
  transform: none !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 10px;
}

.phrases-wrap.expanded .phrase-slide:last-child {
  margin-bottom: 0;
}

.phrases-toggle-wrap {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.phrases-dots {
  display: none;
}

.phrases-toggle-btn {
  position: relative;
  padding: 10px 40px 10px 28px;
  background: #fff;
  border-radius: 20px;
  border: 0;
  box-shadow: 0 3px 3.5px rgba(119, 113, 113, 0.5);
  font: 700 14px/1 "Raleway", sans-serif;
  text-transform: lowercase;
  cursor: pointer;
  transition: all 0.2s ease;
}

.phrases-toggle-btn:hover {
  transform: translateY(-1px);
}

.phrases-toggle-btn::after {
  position: absolute;
  content: "";
  border-top: 2px solid #000;
  border-left: 2px solid #000;
  width: 7px;
  height: 7px;
  right: 20px;
  top: 12px;
  transform: rotate(225deg);
  transition: all .2s linear;
}

.phrases-wrap.expanded .phrases-toggle-btn::after {
  transform: rotate(45deg);
  top: 16px;
}

@media (max-width: 980px) {
  .desktop-hearts { display: none; }
  .app-shell {
    width: 100%;
    border-radius: 52px;
    border-width: 0;
    margin: 0;
    min-height: 100vh;
    padding: 14px 12px 20px;
  }

  .topbar { display: none; }

  .bg-title {
    display: none;
  }

  .editor-core {
    margin-top: -5px;
  }

  .card {
    background: var(--card-bg);
  }

  .card-export-hitbox {
    display: block;
    position: absolute;
    top: 12px;
    right: 12px;
    width: 120px;
    height: 44px;
    border: none;
    padding: 0;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    border-radius: 40px;
    background: var(--brand-lime);
    color: #0b0b0b;
    font: 600 16px/1 "Raleway", sans-serif;
    text-transform: lowercase;
    cursor: pointer;
    z-index: 5;
  }

  .palette-row {
    grid-template-columns: 42px 1fr 42px;
  }

  .custom-grid {
    gap: 12px;
  }

  .phrases-slider {
    display: flex;
    gap: 10px;
    height: auto;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    scrollbar-width: none;
  }

  .phrases-slider::-webkit-scrollbar {
    display: none;
  }

  .phrase-slide {
    position: relative;
    left: auto;
    flex: 0 0 100%;
    height: 44px;
    border: none;
    border-radius: 40px;
    padding: 0 24px;
    background: var(--chip);
    font: 600 17px/1 "Raleway", sans-serif;
    box-shadow: none;
    transform: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    margin: 0 !important;
    scroll-snap-align: center;
  }

  .phrases-toggle-wrap {
    display: none;
  }

  .phrases-dots {
    width: 96px;
    margin: 10px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
  }

  .phrase-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: 0;
    background: #ffffff;
    padding: 0;
  }

  .phrase-dot.active {
    background: #969696;
  }
}

@media (max-width: 420px) {
  .app-shell {
    border-width: 0;
    border-radius: 46px;
  }

  .editor-core {
    margin-top: -9px;
    gap: 20px;
  }

  .card {
    width: calc(100vw - 58px);
    height: calc((100vw - 58px) * 1.25);
  }

  .message {
    width: calc(100% - 36px);
  }

  .custom-thumb {
    width: 52px;
    height: 52px;
  }
}
