:root {
  --bg: #fff7fb;
  --bg-2: #f6efff;
  --card: rgba(255, 255, 255, 0.86);
  --text: #33243b;
  --muted: #8a718f;
  --pink: #ff7fa8;
  --pink-deep: #e84f86;
  --purple: #b99af5;
  --purple-soft: #efe6ff;
  --line: rgba(130, 87, 148, 0.16);
  --shadow: 0 18px 50px rgba(126, 84, 142, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  background: var(--bg) url("./assets/bg-cat-v5.jpg") center center / cover no-repeat fixed;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
}

.view {
  display: none;
  min-height: calc(100vh - 42px);
}

.view.active {
  display: flex;
  flex-direction: column;
}

.brand-block {
  padding-top: 12vh;
  text-align: center;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: 40px;
  line-height: 1.05;
  font-weight: 900;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.18;
  font-weight: 900;
}

.subtext {
  width: min(100%, 320px);
  margin-right: auto;
  margin-left: auto;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.unlock-card,
.result-card {
  width: 100%;
  margin-top: 34px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.unlock-card label {
  display: block;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 800;
}

.unlock-card input {
  width: 100%;
  height: 54px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  outline: 0;
  color: var(--text);
  background: #fff;
  font-size: 16px;
}

.unlock-card input:focus {
  border-color: rgba(232, 79, 134, 0.5);
  box-shadow: 0 0 0 4px rgba(255, 127, 168, 0.14);
}

.unlock-card button,
.result-actions button {
  width: 100%;
  height: 54px;
  margin-top: 14px;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, #ff82a7, #ee5075);
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(232, 79, 134, 0.24);
}

.error-text {
  min-height: 20px;
  margin: 10px 0 0;
  color: #d7426f;
  font-size: 13px;
}

.watermark {
  margin: auto 0 0;
  padding-top: 24px;
  color: rgba(51, 36, 59, 0.42);
  text-align: center;
  font-size: 12px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 14px;
  padding: 16px 0 20px;
  text-align: center;
}

.topbar.compact {
  align-items: center;
  justify-content: center;
  position: relative;
}

.topbar.compact .ghost-btn {
  position: absolute;
  left: 0;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.category-card {
  min-height: 132px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--text);
  text-align: left;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 32px rgba(126, 84, 142, 0.11);
}

.category-title-img {
  display: block;
  width: auto;
  max-width: 100%;
  height: 19px;
  margin-bottom: 12px;
  object-fit: contain;
  object-position: left center;
}

.category-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.category-card.all {
  border-color: rgba(238, 80, 117, 0.2);
  background: linear-gradient(135deg, #ff82a7, #ee5075);
  box-shadow: 0 14px 34px rgba(238, 80, 117, 0.22);
}

.category-card.all span {
  color: rgba(255, 255, 255, 0.86);
}

.page-note {
  margin: 16px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.ghost-btn,
.soft-btn {
  min-width: 72px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  font-weight: 800;
}

.lottery-wrap {
  position: relative;
  width: min(100%, 430px);
  aspect-ratio: 1;
  margin: 14px auto 0;
  padding: 10px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow);
}

.lottery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 9px;
  width: 100%;
  height: 100%;
}

.lottery-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(185, 154, 245, 0.18);
  border-radius: 20px;
  color: #57415e;
  text-align: center;
  background: linear-gradient(180deg, #fff, #fff8fb);
  font-size: clamp(13px, 3.4vw, 17px);
  font-weight: 900;
  line-height: 1.22;
  word-break: keep-all;
  box-shadow: 0 10px 18px rgba(126, 84, 142, 0.08);
  transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

.lottery-cell.active {
  color: #fff;
  background: linear-gradient(135deg, #ff82a7, #ee5075);
  transform: scale(1.04);
  box-shadow: 0 12px 26px rgba(232, 79, 134, 0.28);
}

.lottery-cell.center-cell {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.lottery-grid.gathering .lottery-cell:not(.center-cell),
.lottery-grid.mixing .lottery-cell:not(.center-cell),
.lottery-grid.returning .lottery-cell:not(.center-cell) {
  position: relative;
  z-index: 4;
}

.lottery-grid.gathering .lottery-cell:not(.center-cell) {
  transition: transform 0.42s ease-in, opacity 0.42s ease-in;
  transform: translate(var(--gather-x), var(--gather-y)) scale(0.72);
  opacity: 0.78;
}

.lottery-grid.mixing .lottery-cell:not(.center-cell) {
  animation: shuffleGather 0.34s ease-in-out infinite;
}

.lottery-grid.returning .lottery-cell:not(.center-cell) {
  animation: flyHome 0.65s cubic-bezier(0.18, 0.9, 0.25, 1) both;
}

@keyframes shuffleGather {
  0% {
    transform: translate(var(--gather-x), var(--gather-y)) rotate(-8deg) scale(0.74);
  }
  50% {
    transform: translate(calc(var(--gather-x) + var(--mix-x)), calc(var(--gather-y) + var(--mix-y))) rotate(10deg) scale(0.82);
  }
  100% {
    transform: translate(var(--gather-x), var(--gather-y)) rotate(-4deg) scale(0.74);
  }
}

@keyframes flyHome {
  0% {
    opacity: 0.86;
    transform: translate(var(--gather-x), var(--gather-y)) rotate(-6deg) scale(0.76);
  }
  72% {
    opacity: 1;
    transform: translate(0, 0) rotate(1deg) scale(1.04);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}

.start-button {
  position: absolute;
  inset: 50% auto auto 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 30%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #ff82a7, #ee5075);
  box-shadow: 0 14px 34px rgba(167, 106, 198, 0.38);
}

.start-button img {
  display: block;
  width: 50%;
  height: auto;
  object-fit: contain;
}

.start-button:disabled {
  opacity: 0.74;
}

.draw-actions {
  display: flex;
  justify-content: center;
  padding-top: 48px;
}

.result-card {
  position: relative;
  overflow: hidden;
  min-height: 380px;
  margin-top: 12px;
  padding: 26px 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 247, 251, 0.94)),
    radial-gradient(circle at 84% 12%, rgba(185, 154, 245, 0.3), transparent 24%);
}

.result-card h3 {
  margin-bottom: 18px;
  font-size: 40px;
  line-height: 1.08;
  font-weight: 1000;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.result-meta span {
  padding: 8px 10px;
  border-radius: 999px;
  color: #6d5276;
  background: var(--purple-soft);
  font-size: 12px;
  font-weight: 800;
}

.result-tip {
  color: #6d5276;
  font-size: 15px;
  line-height: 1.7;
}

.result-mark {
  position: absolute;
  right: 18px;
  bottom: 16px;
  margin: 0;
  color: rgba(51, 36, 59, 0.38);
  font-size: 12px;
}

.result-actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.result-actions .soft-btn {
  margin-top: 0;
  color: var(--text);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: none;
}

@media (max-width: 370px) {
  .app-shell {
    padding-inline: 12px;
  }

  h1 {
    font-size: 34px;
  }

  .category-card {
    min-height: 122px;
    padding: 14px;
  }

  .category-title-img {
    height: 18px;
  }

  .lottery-wrap {
    padding: 8px;
  }

  .lottery-grid {
    gap: 7px;
  }
}
