:root {
  --bg: #fff6e7;
  --ink: #24314f;
  --muted: rgba(36, 49, 79, 0.52);
  --orange: #ff7f2a;
  --pink: #ff5ca8;
  --sky: #47b8ff;
  --mint: #32d39a;
  --yellow: #ffd84d;
  --violet: #806bff;
  --danger: #ff6f7b;
  --white: #fffdf8;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 216, 77, 0.18), transparent 18%),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  padding: 18px 16px 28px;
  overflow: hidden;
}

.dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 127, 42, 0.16) 1.2px, transparent 1.2px);
  background-size: 20px 20px;
  opacity: 0.55;
  pointer-events: none;
}

.shape {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.shape-a {
  top: 32px;
  left: -40px;
  width: 160px;
  height: 160px;
  background: rgba(255, 92, 168, 0.18);
}

.shape-b {
  top: 90px;
  right: -48px;
  width: 190px;
  height: 190px;
  background: rgba(71, 184, 255, 0.16);
}

.shape-c {
  bottom: 120px;
  left: 50%;
  width: 260px;
  height: 120px;
  transform: translateX(-50%) rotate(-8deg);
  background: rgba(255, 216, 77, 0.22);
}

.topbar,
.hud,
.record-line,
.result-metrics,
.result-actions,
.sheet-head,
.range-row {
  display: flex;
  align-items: center;
}

.topbar {
  position: relative;
  z-index: 2;
  justify-content: space-between;
  max-width: 940px;
  margin: 0 auto 8px;
}

.topbar.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.screen {
  position: relative;
  z-index: 1;
  display: none;
  max-width: 940px;
  margin: 0 auto;
}

.screen.active {
  display: block;
}

.circle-button {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--white);
  color: var(--ink);
  font-size: 1.2rem;
  box-shadow: 0 10px 0 rgba(36, 49, 79, 0.08);
}

.circle-button.small {
  width: 42px;
  height: 42px;
  box-shadow: none;
}

.start-screen {
  padding-top: 20px;
  text-align: center;
}

.mini-tag {
  display: inline-block;
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-weight: 700;
}

h1 {
  margin: 22px 0 0;
  font-size: clamp(3rem, 10vw, 6rem);
  line-height: 0.9;
  letter-spacing: -0.06em;
}

.hero-row {
  margin-top: 28px;
}

.hero-burst {
  display: inline-block;
  margin-top: 18px;
  padding: 16px 24px;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--ink);
  font-size: clamp(1.2rem, 4vw, 2rem);
  font-weight: 900;
  transform: rotate(-5deg);
}

.start-button,
.ghost-button,
.save-button,
.mode-option,
.toggle-pill,
.key {
  transition: transform 140ms ease;
}

.start-button,
.save-button {
  min-height: 78px;
  padding: 0 34px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff9551, var(--orange));
  color: #fff;
  font-size: 1.55rem;
  font-weight: 900;
  box-shadow: 0 14px 0 rgba(204, 90, 24, 0.26);
}

.start-button.small {
  min-height: 64px;
  font-size: 1.25rem;
}

.ghost-button {
  min-height: 64px;
  padding: 0 24px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.start-button:hover,
.ghost-button:hover,
.save-button:hover,
.mode-option:hover,
.toggle-pill:hover,
.key:hover,
.circle-button:hover {
  transform: translateY(-2px);
}

.record-line {
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 22px;
  color: var(--muted);
  font-weight: 700;
}

.record-line strong {
  color: var(--ink);
  font-size: 1.15rem;
}

.home-achievement-peek {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.peek-pill,
.result-pill,
.achievement-count,
.hud-item,
.feedback-text {
  border-radius: 999px;
}

.peek-pill {
  padding: 10px 14px;
  background: #fff;
  font-weight: 800;
}

.game-screen {
  padding-top: 10px;
}

.hud {
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.hud-item {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.58);
  color: rgba(36, 49, 79, 0.48);
  font-size: 0.95rem;
  font-weight: 700;
}

.hud-exit {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: rgba(36, 49, 79, 0.72);
  font-size: 0.92rem;
  font-weight: 800;
}

.question-area {
  padding: 28px 0 24px;
  text-align: center;
}

.question-text {
  font-size: clamp(4rem, 13vw, 8rem);
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: -0.08em;
}

.answer-text {
  margin-top: 20px;
  font-size: clamp(3rem, 11vw, 5.4rem);
  font-weight: 900;
  color: var(--violet);
}

.feedback-text {
  display: inline-block;
  min-width: 112px;
  margin-top: 14px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-weight: 800;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.key {
  min-height: 78px;
  border-radius: 28px;
  background: #fff;
  color: var(--ink);
  font-size: 1.8rem;
  font-weight: 900;
  box-shadow: 0 10px 0 rgba(36, 49, 79, 0.06);
}

.key-faint {
  color: rgba(36, 49, 79, 0.48);
}

.key-submit {
  background: linear-gradient(180deg, #ffdd6b, #ffc62a);
}

.key-wide {
  grid-column: span 4;
}

.result-screen {
  padding-top: 24px;
  text-align: center;
}

.result-topline {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 999px;
  background: #fff;
  color: var(--orange);
  font-weight: 900;
}

.result-screen h2 {
  margin: 14px 0 18px;
  font-size: clamp(2.2rem, 7vw, 4rem);
  line-height: 0.95;
}

.result-metrics {
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
}

.result-metrics > div {
  min-width: 142px;
  padding: 14px 16px;
  border-radius: 28px;
  background: #fff;
}

.result-metrics span,
.field span,
.achievement-card p,
.mode-block p,
.settings-group p {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.result-metrics strong {
  display: block;
  margin-top: 6px;
  font-size: 1.7rem;
}

.result-achievements {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.result-pill {
  padding: 10px 14px;
  background: #fff;
  font-weight: 800;
}

.result-actions {
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  background: rgba(36, 49, 79, 0.16);
  backdrop-filter: blur(6px);
}

.modal-backdrop.hidden {
  display: none;
}

.sheet {
  width: min(92vw, 560px);
  max-height: min(88vh, 900px);
  padding: 22px;
  border-radius: 34px;
  background: var(--white);
  box-shadow: 0 28px 80px rgba(36, 49, 79, 0.14);
  overflow: auto;
}

.wide-sheet {
  width: min(94vw, 880px);
}

.sheet-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.sheet-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sheet-head h3 {
  margin: 0;
  font-size: 1.7rem;
}

.ghost-mini {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: #f4efe6;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 800;
}

.mode-block + .mode-block,
.settings-group + .settings-group {
  margin-top: 18px;
}

.mode-level {
  display: none;
}

.mode-level.active {
  display: block;
}

.mode-grid,
.toggle-grid,
.achievement-list {
  display: grid;
  gap: 12px;
}

.mode-grid,
.toggle-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
}

.single-grid {
  grid-template-columns: 1fr;
}

.mode-option {
  min-height: 84px;
  border-radius: 30px;
  color: #fff;
  font-size: 1.35rem;
  font-weight: 900;
}

.mode-option.orange {
  background: var(--orange);
}

.mode-option.pink {
  background: var(--pink);
}

.mode-option.sky {
  background: var(--sky);
}

.mode-option.mint {
  background: var(--mint);
}

.mode-option.violet {
  background: var(--violet);
}

.toggle-pill {
  position: relative;
  min-height: 72px;
  display: grid;
  place-items: center;
  border-radius: 26px;
  background: #f4efe6;
  color: var(--ink);
  font-weight: 900;
}

.toggle-pill input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.toggle-pill.is-on {
  background: var(--yellow);
}

.range-row {
  gap: 12px;
  margin-top: 10px;
}

.field {
  flex: 1;
}

.field input {
  width: 100%;
  margin-top: 8px;
  min-height: 58px;
  padding: 0 16px;
  border: 0;
  border-radius: 22px;
  background: #f4efe6;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 800;
}

.save-button {
  width: 100%;
  margin-top: 22px;
}

.achievement-list {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 16px;
}

.achievement-card {
  min-height: 164px;
  padding: 16px 14px 14px;
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #fff9ef;
  box-shadow: inset 0 0 0 1px rgba(36, 49, 79, 0.06);
}

.achievement-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.achievement-icon {
  font-size: 2.2rem;
}

.achievement-card h4 {
  margin: 10px 0 4px;
  font-size: 1rem;
  line-height: 1.1;
}

.achievement-count {
  display: inline-block;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.82);
  font-weight: 900;
}

.achievement-card.is-locked {
  opacity: 0.62;
}

.achievement-card.is-earned {
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.42),
    0 14px 26px rgba(36, 49, 79, 0.08);
}

.rarity-common {
  background: linear-gradient(180deg, #fff8ef, #fff0cc);
}

.rarity-common .achievement-count {
  color: #b97c16;
}

.rarity-uncommon {
  background: linear-gradient(180deg, #f4ffef, #def7c9);
}

.rarity-uncommon .achievement-count {
  color: #2a9a66;
}

.rarity-rare {
  background: linear-gradient(180deg, #eef8ff, #d9eeff);
}

.rarity-rare .achievement-count {
  color: #2d86df;
}

.rarity-epic {
  background: linear-gradient(180deg, #f7f0ff, #e5d8ff);
}

.rarity-epic .achievement-count {
  color: #7352d8;
}

.rarity-legendary {
  background: linear-gradient(135deg, #fff4bf, #ffd870 52%, #ffb24d);
}

.rarity-legendary .achievement-count {
  color: #b75b00;
}

.floating-text-layer,
.particle-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  overflow: hidden;
}

.floating-badge {
  position: absolute;
  left: 50%;
  top: 28%;
  transform: translate(-50%, 0);
  padding: 14px 18px;
  border-radius: 999px;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 900;
  animation: float-up 950ms ease forwards;
}

.particle {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  animation: burst 900ms ease-out forwards;
}

.question-area.flash-good {
  animation: pulse-good 280ms ease;
}

.question-area.flash-bad {
  animation: pulse-bad 280ms ease;
}

@keyframes float-up {
  0% {
    opacity: 0;
    transform: translate(-50%, 12px) scale(0.84);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -46px) scale(1.04);
  }
}

@keyframes burst {
  from {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  to {
    transform: translate(var(--x), var(--y)) scale(0.2);
    opacity: 0;
  }
}

@keyframes pulse-good {
  50% {
    transform: scale(1.02);
  }
}

@keyframes pulse-bad {
  50% {
    transform: scale(0.985);
  }
}

@media (max-width: 720px) {
  .question-text {
    font-size: 3.5rem;
  }

  .answer-text {
    font-size: 2.9rem;
  }

  .mode-grid,
  .toggle-grid {
    grid-template-columns: 1fr;
  }

  .range-row,
  .result-actions {
    flex-direction: column;
  }

  .sheet {
    max-height: 90vh;
  }

  .key {
    min-height: 68px;
    font-size: 1.55rem;
  }

  .record-line {
    gap: 10px;
    font-size: 0.95rem;
  }
}
