:root {
  --bg: #08080c;
  --panel: #12121b;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --text: #f6f2e9;
  --muted: #918e9f;
  --pink: #ff3d5f;
  --orange: #ff7a18;
  --gold: #ffb703;
  --radius-lg: 24px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
}

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(880px 460px at 50% -180px, rgba(255, 61, 95, 0.3), transparent 72%),
    radial-gradient(720px 400px at 108% 4%, rgba(255, 122, 24, 0.13), transparent 70%),
    radial-gradient(600px 380px at -10% 24%, rgba(255, 183, 3, 0.07), transparent 70%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

a,
a:visited {
  color: #807f84;
}

a:hover,
a:active {
  color: #cccccc; /* 悬停/点击时也保持白色，可改成 #cccccc 做反馈 */
}

p,
h1,
h2 {
  margin: 0;
}

.app {
  width: 100%;
  max-width: 540px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 18px
    calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 46px;
  height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(135deg, #ff3d5f, #ff7a18 55%, #ffb703);
  color: #25060d;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 10px 24px rgba(255, 61, 95, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  transform: rotate(-4deg);
}

.brand-text h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1px;
}

.brand-text p {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.3px;
}

/* ---------- layout ---------- */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.pick-view {
  justify-content: center;
}

/* ---------- pick view ---------- */
.chars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.char {
  position: relative;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border-radius: 20px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 38%),
    linear-gradient(160deg, #1b1b27, #101018);
  font-size: clamp(30px, 9vw, 42px);
  font-weight: 800;
  color: #fff8e7;
  text-shadow: 0 2px 14px rgba(255, 183, 3, 0.22);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.char::after {
  content: "";
  position: absolute;
  left: 26%;
  right: 26%;
  bottom: 11px;
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--pink), var(--gold));
  opacity: 0.5;
}

.char:nth-child(2)::after {
  background: linear-gradient(90deg, #ff6fa5, var(--orange));
}

.char:nth-child(3)::after {
  background: linear-gradient(90deg, var(--orange), var(--gold));
}

.char:nth-child(4)::after {
  background: linear-gradient(90deg, var(--gold), var(--pink));
}

.char.pop {
  animation: tile-pop 0.38s cubic-bezier(0.22, 1.2, 0.36, 1) both;
}

@keyframes tile-pop {
  0% {
    transform: scale(0.84) rotate(-4deg);
    opacity: 0.3;
  }
  60% {
    transform: scale(1.05) rotate(1deg);
  }
  100% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

.reroll {
  align-self: center;
  margin-top: -6px;
  padding: 7px 16px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.5px;
  background: rgba(255, 255, 255, 0.02);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.reroll:hover {
  color: var(--text);
  border-color: rgba(255, 183, 3, 0.5);
}

.reroll:active {
  transform: scale(0.96);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 4px;
}

.section-head h2 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #d9d3c6;
}

.section-head span {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.4px;
}

/* ---------- formats ---------- */
.formats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  transition: opacity 0.2s;
}

.formats.is-busy {
  opacity: 0.45;
  pointer-events: none;
}

.fmt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  min-height: 74px;
  padding: 13px 15px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(165deg, #16161f, #111119);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  text-align: left;
  transition: transform 0.12s ease, border-color 0.2s, background 0.2s;
}

.fmt:hover {
  border-color: rgba(255, 183, 3, 0.38);
  background: linear-gradient(165deg, #1c1c27, #12121a);
}

.fmt:active {
  transform: scale(0.97);
}

.fmt:last-child {
  grid-column: 1 / -1;
}

.fmt-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
  letter-spacing: 0.5px;
  color: #8e8a9d;
}

.fmt-preview {
  font-size: clamp(18px, 5.1vw, 22px);
  font-weight: 700;
  line-height: 1.25;
  color: #fff6e6;
  word-break: break-all;
}

.fmt-preview.small {
  font-size: clamp(14px, 3.9vw, 16.5px);
}

/* ---------- crazy button ---------- */
.crazy-btn {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  margin-top: 2px;
  padding: 17px 20px 18px;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  color: #2a0710;
  background: linear-gradient(100deg, #ff2e57 0%, #ff7a18 55%, #ffb703 100%);
  box-shadow: 0 16px 34px rgba(255, 61, 95, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.14s ease, filter 0.2s;
}

.crazy-btn > span {
  position: relative;
  z-index: 1;
}

.crazy-title {
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 2px;
}

.crazy-sub {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  opacity: 0.78;
}

.crazy-btn::after {
  content: "";
  position: absolute;
  inset: -40% -20%;
  z-index: 0;
  background: linear-gradient(
    115deg,
    transparent 38%,
    rgba(255, 255, 255, 0.5) 50%,
    transparent 62%
  );
  transform: translateX(-110%) rotate(4deg);
  animation: shine 3.6s ease-in-out infinite;
}

@keyframes shine {
  0%,
  55% {
    transform: translateX(-110%) rotate(4deg);
  }
  85%,
  100% {
    transform: translateX(110%) rotate(4deg);
  }
}

.crazy-btn:hover {
  filter: brightness(1.05);
}

.crazy-btn:active {
  transform: scale(0.985);
}

.tip {
  margin-top: -2px;
  font-size: 11.5px;
  line-height: 1.6;
  letter-spacing: 0.3px;
  text-align: center;
  color: #77738a;
}

/* ---------- result view ---------- */
.result-view {
  gap: 14px;
  justify-content: center;
}

.result-card {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: clamp(230px, 36vh, 340px);
  padding: 22px 20px 24px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 183, 3, 0.16);
  background:
    radial-gradient(520px 220px at 20% -40px, rgba(255, 61, 95, 0.14), transparent 70%),
    linear-gradient(165deg, #191924, #0e0e15 80%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
  animation: card-rise 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes card-rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.result-card::after {
  content: "";
  position: absolute;
  right: -90px;
  bottom: -110px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 122, 24, 0.16), transparent 70%);
  pointer-events: none;
}

.result-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.result-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid rgba(255, 183, 3, 0.22);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--gold);
  background: rgba(255, 183, 3, 0.1);
}

.result-chars {
  font-size: 11.5px;
  letter-spacing: 3px;
  color: var(--muted);
}

.result-text {
  position: relative;
  z-index: 1;
  margin: auto 0;
  font-size: clamp(27px, 7.6vw, 36px);
  font-weight: 800;
  line-height: 1.5;
  letter-spacing: 1px;
  overflow-wrap: break-word;
  word-break: break-word;
  background: linear-gradient(
    115deg,
    #fffdf6 0%,
    #ffe6a6 45%,
    #ffb0c3 78%,
    #fffdf6 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.result-text.long {
  font-size: clamp(18px, 5.2vw, 23px);
  line-height: 1.65;
  letter-spacing: 0.5px;
  background: none;
  color: #f7ecd8;
}

.result-text.scramble {
  background: none;
  color: #7f7a90;
  letter-spacing: 2px;
}

.result-text.reveal {
  animation: rise 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  .result-text {
    color: var(--text);
    background: none;
  }
}

/* ---------- result actions ---------- */
.result-actions {
  display: flex;
  gap: 10px;
}

.primary {
  flex: 1;
  padding: 15px 18px;
  border-radius: 16px;
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #210710;
  background: linear-gradient(100deg, #ffd166, #ffb703 45%, #ff8a3d);
  box-shadow: 0 12px 26px rgba(255, 183, 3, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.12s ease, filter 0.2s;
}

.primary:active {
  transform: scale(0.98);
}

.secondary {
  padding: 0 20px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: #e9e3d6;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.12s ease, border-color 0.2s;

}

.secondary:hover {
  border-color: rgba(255, 183, 3, 0.45);
}

.secondary:active {
  transform: scale(0.98);
}

.result-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.link {
  min-height: 40px;
  padding: 10px 4px;
  font-size: 12.5px;
  letter-spacing: 0.3px;
  color: var(--muted);
  transition: color 0.2s;
}

.link:hover {
  color: var(--gold);
}

/* ---------- footer & toast ---------- */
.foot {
  text-align: center;
  font-size: 10.5px;
  letter-spacing: 0.4px;
  color: #5b5768;
}



.toast {
  position: fixed;
  left: 50%;
  bottom: calc(74px + env(safe-area-inset-bottom));
  z-index: 50;
  width: max-content;
  max-width: calc(100vw - 40px);
  transform: translate(-50%, 16px);
  padding: 10px 18px;
  border-radius: 99px;
  background: #fdf7ea;
  color: #16121c;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-height: 700px) {
  .pick-view,
  .result-view {
    justify-content: flex-start;
  }

  .result-card {
    min-height: 240px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
