:root {
  --card-w: min(310px, 90vw, calc((100dvh - 205px) * 0.716));
  --card-radius: 16px;

  --bg: #171717;
  --surface: #201419;
  --surface2: #2b1b21;
  --text: #ffffff;
  --muted: #9a7d87;
  --accent: #9564A9;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}


body {
  font-family: 'Poppins', sans-serif;
  background:
    radial-gradient(ellipse 85% 55% at 82% 5%, rgba(100, 42, 128, 0.50) 0%, transparent 60%),
    radial-gradient(ellipse 65% 50% at 12% 95%, rgba(203, 32, 39, 0.32) 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 48% 48%, rgba(149, 100, 169, 0.10) 0%, transparent 65%),
    var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px 16px 24px;
  overflow-x: hidden;
}


.screen {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  animation: screenIn .35s ease;
}

.hidden {
  display: none !important;
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.logo {
  text-align: center;
}

.logo-title {
  font-family: 'Sancreek', cursive;
  font-size: 1.9rem;
  font-weight: 400;
  line-height: 1;
  background: linear-gradient(120deg, #9564A9 0%, #642A80 33%, #CB2027 66%, #EF586C 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-sub {
  font-family: 'Poppins', sans-serif;
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: .16em;
  text-transform: uppercase;
  margin-top: 4px;
}

.pull-box {
  background: var(--surface);
  border: 1px solid rgba(100, 42, 128, .30);
  border-radius: 20px;
  padding: 26px 22px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .55);
}

.pull-hint {
  font-size: .88rem;
  color: var(--muted);
  text-align: center;
}

.name-input {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid rgba(100, 42, 128, .38);
  border-radius: 12px;
  padding: 12px 16px;
  font-family: 'Poppins', sans-serif;
  font-size: 1.05rem;
  color: var(--text);
  outline: none;
  transition: border-color .2s;
  text-align: center;
}

.name-input::placeholder {
  color: var(--muted);
}

.name-input:focus {
  border-color: var(--accent);
}

.btn {
  font-family: 'Poppins', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
  border-radius: 13px;
  padding: 13px 16px;
  cursor: pointer;
  transition: transform .14s, box-shadow .14s;
  width: 100%;
  letter-spacing: .02em;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active {
  transform: scale(.965);
}

.btn-pull {
  background: linear-gradient(135deg, #9564A9, #642A80, #CB2027);
  color: #fff;
  box-shadow: 0 4px 22px rgba(100, 42, 128, .55);
  font-size: 1.2rem;
  padding: 16px;
}

.btn-pull:hover {
  box-shadow: 0 6px 28px rgba(100, 42, 128, .75);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1.5px solid rgba(100, 42, 128, .40);
}

.btn-secondary:hover {
  border-color: var(--accent);
}

.btn-share {
  background: linear-gradient(135deg, #51DDF4, #14B289);
  color: #171717;
  box-shadow: 0 4px 18px rgba(81, 221, 244, .30);
}

.btn-share:hover {
  box-shadow: 0 6px 24px rgba(81, 221, 244, .50);
  transform: translateY(-1px);
}

.btn-anim {
  background: linear-gradient(135deg, #FFD04E, #E57B2C);
  color: #171717;
  box-shadow: 0 4px 18px rgba(255, 208, 78, .30);
}

.btn-anim:hover {
  box-shadow: 0 6px 24px rgba(255, 208, 78, .50);
  transform: translateY(-1px);
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: var(--card-w);
}

.btn-row .btn-full {
  grid-column: 1 / -1;
}

#gacha-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(23, 23, 23, .97);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity .35s ease;
}

#gacha-overlay.fading {
  opacity: 0;
  pointer-events: none;
}

#spin-box {
  perspective: 700px;
}

#spin-card {
  width: var(--card-w);
  aspect-ratio: 63 / 88;
  border-radius: 14px;
  background: linear-gradient(148deg, #241228 0%, #171717 52%, #1e0e15 100%);
  border: 3px solid rgba(149, 100, 169, .50);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 32px rgba(100, 42, 128, .38), 0 20px 60px rgba(0, 0, 0, .85);
  overflow: hidden;
}

#spin-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(45deg, rgba(149, 100, 169, .08) 0, rgba(149, 100, 169, .08) 1px, transparent 1px, transparent 11px),
    repeating-linear-gradient(-45deg, rgba(149, 100, 169, .08) 0, rgba(149, 100, 169, .08) 1px, transparent 1px, transparent 11px);
}

#spin-card::after {
  content: '';
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(149, 100, 169, .22);
  border-radius: 9px;
  pointer-events: none;
}

.spin-inner {
  text-align: center;
  position: relative;
  z-index: 1;
}

.spin-logo {
  font-size: 2.2rem;
  color: rgba(149, 100, 169, .90);
  line-height: 1;
}

.spin-title {
  font-family: 'Sancreek', cursive;
  font-weight: 400;
  font-size: .9rem;
  color: rgba(255, 255, 255, .80);
  letter-spacing: .08em;
  margin-top: 5px;
}

.spin-sub {
  font-family: 'Poppins', sans-serif;
  font-size: .48rem;
  color: rgba(149, 100, 169, .65);
  letter-spacing: .16em;
  text-transform: uppercase;
  margin-top: 4px;
}

#rarity-flash {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

#rarity-flash.active {
  opacity: 1;
}

#toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(72px);
  background: var(--surface2);
  color: var(--text);
  border: 1px solid rgba(100, 42, 128, .45);
  border-radius: 12px;
  padding: 11px 20px;
  font-size: .9rem;
  z-index: 200;
  transition: transform .3s cubic-bezier(.34, 1.56, .64, 1);
  pointer-events: none;
  white-space: nowrap;
}

#toast.show {
  transform: translateX(-50%) translateY(0);
}

.pity-text {
  font-family: 'Poppins', sans-serif;
  font-size: 0.6rem;
  color: var(--muted);
  letter-spacing: .1em;
  text-align: center;
  margin-top: -4px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(23, 23, 23, .85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: screenIn .2s ease;
}

.modal-box {
  background: var(--surface);
  border: 1px solid rgba(100, 42, 128, .35);
  border-radius: 20px;
  padding: 28px 24px 22px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .7);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
  color: var(--text);
}

.modal-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-sub {
  display: block;
  font-family: 'Poppins', sans-serif;
  font-size: 0.52rem;
  opacity: .7;
  font-weight: 400;
  margin-top: 2px;
}

.modal-cancel {
  width: 100%;
}

.share-url-input {
  font-family: 'Poppins', sans-serif;
  font-size: 0.72rem;
  text-align: left;
  cursor: text;
  user-select: all;
}