:root {
  color-scheme: light;
  --ink: #26314d;
  --text: #3d4662;
  --muted: #7a83a2;
  --white: #fffdf8;
  --cream: #fff5cc;
  --pink: #ff73a8;
  --pink-dark: #e94f8e;
  --yellow: #ffd84d;
  --orange: #ff9c3f;
  --aqua: #58ddcf;
  --blue: #5794ff;
  --purple: #9b70ff;
  --green: #56d66f;
  --red: #ff6969;
  --shadow: 0 14px 0 rgba(79, 49, 91, 0.1), 0 24px 44px rgba(86, 55, 120, 0.16);
  --soft-shadow: 0 14px 32px rgba(83, 58, 112, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #ffcfdf;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: "Trebuchet MS", Nunito, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 255, 255, 0.95) 0 7%, transparent 8%),
    radial-gradient(circle at 84% 18%, rgba(255, 255, 255, 0.62) 0 5%, transparent 6%),
    radial-gradient(circle at 92% 68%, rgba(255, 255, 255, 0.52) 0 6%, transparent 7%),
    linear-gradient(160deg, #ffcfdf 0%, #ffe991 42%, #b7f5ec 100%);
  touch-action: manipulation;
}

.noscript-card {
  position: fixed;
  inset: 18px;
  z-index: 99;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 22px;
  border-radius: 28px;
  color: var(--ink);
  background: var(--white);
  box-shadow: var(--shadow);
  text-align: center;
  font-weight: 900;
}

.noscript-card p {
  margin: 0;
  color: var(--text);
}

button,
textarea {
  font: inherit;
}

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

button:focus-visible,
textarea:focus-visible {
  outline: 4px solid rgba(87, 148, 255, 0.35);
  outline-offset: 3px;
}

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

.game-shell {
  width: min(100%, 470px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hero {
  display: grid;
  gap: 10px;
}

.top-bar {
  min-height: 48px;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 10px;
}

.brand {
  display: grid;
  place-items: center;
  line-height: 0.95;
  text-align: center;
  color: #773158;
}

.brand span {
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.brand strong {
  font-size: clamp(2rem, 10vw, 3rem);
  font-weight: 1000;
  letter-spacing: 0;
}

.icon-button {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.76);
  box-shadow: 0 7px 0 rgba(84, 52, 97, 0.09), 0 12px 24px rgba(84, 52, 97, 0.12);
  font-size: 1.2rem;
  font-weight: 1000;
}

.score-card,
.frenzy-card,
.panel,
.modal-card {
  border: 3px solid rgba(255, 255, 255, 0.72);
  background: rgba(255, 253, 248, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.score-card {
  position: relative;
  overflow: hidden;
  padding: 15px;
  border-radius: 28px;
}

.score-card::after {
  content: "";
  position: absolute;
  inset: -60% auto auto -30%;
  width: 230px;
  height: 230px;
  border-radius: 50%;
  background: rgba(255, 216, 77, 0.4);
}

.world-pill,
.pill,
.kicker {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 1000;
  text-transform: uppercase;
}

.world-pill {
  position: relative;
  z-index: 1;
  padding: 0 12px;
  color: #7b3f00;
  background: #fff0a9;
}

.score-line {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.premium-line {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
  padding: 6px 10px;
  border-radius: 999px;
  color: #55336d;
  background: rgba(255, 255, 255, 0.62);
  font-size: 0.88rem;
  font-weight: 1000;
}

.gem-badge {
  display: inline-grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #e8ddff;
}

.candy-badge {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 19px;
  background: linear-gradient(145deg, #fff, #ffe0f0);
  box-shadow: inset 0 -5px 0 rgba(233, 79, 142, 0.12), 0 8px 16px rgba(233, 79, 142, 0.18);
  font-size: 2rem;
}

#candyCount {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: clamp(2.7rem, 15vw, 4.9rem);
  line-height: 0.95;
  font-weight: 1000;
  color: #4b2767;
}

#rateText {
  position: relative;
  z-index: 1;
  margin: 5px 0 12px;
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 900;
}

.level-row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}

#levelText {
  color: #6d3678;
  font-size: 0.86rem;
  font-weight: 1000;
}

.level-track,
.frenzy-track {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(84, 52, 97, 0.12);
  box-shadow: inset 0 2px 3px rgba(84, 52, 97, 0.12);
}

.level-track span,
.frenzy-track span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  transition: width 220ms ease;
}

.level-track span {
  background: linear-gradient(90deg, var(--pink), var(--yellow));
}

.play-area {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
  min-height: 330px;
  padding: 0 0 4px;
}

.frenzy-card {
  width: 100%;
  padding: 10px 12px;
  border-radius: 22px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.frenzy-card strong {
  display: block;
  color: #7d3278;
  font-size: 1.05rem;
}

.frenzy-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.frenzy-track span {
  background: linear-gradient(90deg, var(--aqua), var(--blue), var(--purple));
}

.tap-button {
  position: relative;
  width: min(78vw, 306px);
  aspect-ratio: 1;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 50%;
  color: white;
  background:
    radial-gradient(circle at 34% 22%, rgba(255, 255, 255, 0.9) 0 8%, transparent 17%),
    linear-gradient(145deg, #ff8eb8 0%, #ff5fa2 42%, #ff9a39 100%);
  box-shadow: 0 18px 0 #bd4a7d, 0 28px 46px rgba(189, 74, 125, 0.28);
  transform: translateY(0) scale(1);
  transition: transform 95ms ease, box-shadow 95ms ease, filter 130ms ease;
  user-select: none;
}

.tap-button::before {
  content: "";
  position: absolute;
  inset: -18px;
  border-radius: 50%;
  background: conic-gradient(from 120deg, rgba(255, 255, 255, 0.12), rgba(255, 216, 77, 0.42), rgba(88, 221, 207, 0.24), rgba(255, 255, 255, 0.12));
  animation: spin 8s linear infinite;
  z-index: -1;
}

.tap-button::after {
  content: "";
  position: absolute;
  inset: 17px;
  border: 3px dashed rgba(255, 255, 255, 0.48);
  border-radius: 50%;
}

.tap-button:active,
.tap-button.pop {
  transform: translateY(11px) scale(0.965);
  filter: saturate(1.12);
  box-shadow: 0 7px 0 #bd4a7d, 0 14px 24px rgba(189, 74, 125, 0.2);
}

.tap-face {
  font-size: clamp(4.2rem, 21vw, 6.5rem);
  filter: drop-shadow(0 5px 0 rgba(118, 49, 90, 0.16));
}

.tap-label {
  position: relative;
  z-index: 1;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  font-size: clamp(1.35rem, 7vw, 2rem);
  font-weight: 1000;
  text-shadow: 0 2px 0 rgba(129, 52, 87, 0.22);
}

.bonus-layer {
  position: absolute;
  inset: 52px 0 0;
  pointer-events: none;
  z-index: 4;
}

.bonus-bubble {
  position: absolute;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 20%, #fff 0 15%, #fff176 36%, #ff9c3f 100%);
  box-shadow: 0 10px 0 rgba(145, 86, 0, 0.18), 0 18px 26px rgba(255, 156, 63, 0.28);
  font-size: 2rem;
  pointer-events: auto;
  animation: bonusPop 950ms ease-in-out infinite alternate;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  padding: 8px;
  border-radius: 24px;
  background: rgba(255, 253, 248, 0.72);
  box-shadow: 0 10px 24px rgba(83, 58, 112, 0.12);
  backdrop-filter: blur(12px);
}

.tab {
  min-height: 47px;
  border-radius: 18px;
  color: #6c597a;
  background: transparent;
  font-size: 0.72rem;
  font-weight: 1000;
}

.tab.active {
  color: white;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  box-shadow: 0 7px 0 rgba(113, 57, 130, 0.24);
}

.panel {
  display: none;
  padding: 14px;
  border-radius: 28px;
}

.panel.active {
  display: block;
}

.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.kicker {
  color: var(--pink-dark);
  min-height: auto;
}

h2 {
  margin: 1px 0 0;
  color: #5c3274;
  font-size: 1.36rem;
  line-height: 1.1;
}

.pill,
.small-action {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  color: white;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  box-shadow: 0 7px 0 rgba(84, 52, 97, 0.14);
  font-size: 0.78rem;
  font-weight: 1000;
  white-space: nowrap;
}

.small-action {
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  color: #733900;
}

.card-list {
  display: grid;
  gap: 10px;
}

.shop-note {
  margin: -4px 0 12px;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 850;
  line-height: 1.35;
}

.monetization-status {
  margin: 10px 0 12px;
  padding: 10px 12px;
  border-radius: 18px;
  color: #744000;
  background: #fff0a9;
  font-size: 0.84rem;
  font-weight: 1000;
  line-height: 1.3;
}

.legal-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 18px;
  color: white;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  box-shadow: 0 7px 0 #8743a0;
  font-weight: 1000;
  text-decoration: none;
}

.upgrade-card,
.quest-card,
.trophy-card,
.offer-card,
.ad-card,
.skin-card {
  border-radius: 22px;
  background: var(--white);
  box-shadow: var(--soft-shadow);
  border: 2px solid rgba(255, 255, 255, 0.82);
}

.offer-card {
  padding: 13px;
  display: grid;
  gap: 9px;
}

.offer-top {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 10px;
}

.offer-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(145deg, #fff0a9, #ffe1ef);
  font-size: 1.8rem;
}

.offer-card h3,
.ad-card h3,
.skin-card strong {
  margin: 0 0 4px;
  color: #4d3465;
  font-size: 1rem;
}

.offer-card p,
.ad-card p,
.skin-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
  line-height: 1.28;
}

.price-pill {
  padding: 7px 10px;
  border-radius: 999px;
  color: #743500;
  background: #fff0a9;
  font-size: 0.78rem;
  font-weight: 1000;
  white-space: nowrap;
}

.offer-button,
.ad-card button,
.skin-card button,
.link-grid button {
  min-height: 46px;
  border-radius: 17px;
  color: white;
  background: linear-gradient(135deg, var(--pink), var(--orange));
  box-shadow: 0 7px 0 #ca4c75;
  font-weight: 1000;
}

.ad-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  padding: 13px;
}

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

.skin-card {
  padding: 12px;
  text-align: center;
}

.skin-preview {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 7px;
  border-radius: 21px;
  background: #fff0a9;
  font-size: 2rem;
}

.skin-card button {
  width: 100%;
  margin-top: 9px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  box-shadow: 0 7px 0 #4c61bc;
}

.upgrade-card {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  padding: 12px;
}

.upgrade-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 19px;
  background: linear-gradient(145deg, var(--cream), #ffe1ef);
  box-shadow: inset 0 -5px 0 rgba(233, 79, 142, 0.12);
  font-size: 1.9rem;
}

.upgrade-card h3,
.quest-card h3 {
  margin: 0 0 4px;
  color: #4d3465;
  font-size: 1rem;
  line-height: 1.12;
}

.upgrade-card p,
.quest-card p {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
  line-height: 1.26;
}

.buy-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.level-pill {
  padding: 7px 9px;
  border-radius: 999px;
  color: #71417b;
  background: #f2e8ff;
  font-size: 0.74rem;
  font-weight: 1000;
}

.buy-button,
.claim-button,
.prestige-button,
.settings-grid button,
.modal-card button {
  min-height: 50px;
  border-radius: 18px;
  color: white;
  background: linear-gradient(135deg, var(--green), #24b8a6);
  box-shadow: 0 7px 0 #159884;
  font-weight: 1000;
  transition: transform 100ms ease, box-shadow 100ms ease, opacity 120ms ease;
}

.buy-button {
  width: 100%;
}

.buy-button:active:not(:disabled),
.claim-button:active:not(:disabled),
.prestige-button:active:not(:disabled),
.settings-grid button:active,
.modal-card button:active,
.small-action:active,
.icon-button:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 rgba(84, 52, 97, 0.18);
}

button:disabled {
  color: #8d94aa;
  background: #edf0f6;
  box-shadow: inset 0 0 0 2px rgba(141, 148, 170, 0.12);
  cursor: not-allowed;
}

.quest-card {
  padding: 12px;
}

.progress-track {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #eee9f7;
  box-shadow: inset 0 2px 3px rgba(84, 52, 97, 0.1);
}

.progress-track span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pink), var(--yellow));
  transition: width 220ms ease;
}

.quest-footer {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
}

.quest-reward {
  color: #7c3d00;
  font-size: 0.82rem;
  font-weight: 1000;
}

.claim-button {
  min-height: 42px;
  padding: 0 12px;
}

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

.trophy-card {
  min-height: 126px;
  padding: 12px;
  text-align: center;
  opacity: 0.55;
  filter: grayscale(0.4);
}

.trophy-card.unlocked {
  opacity: 1;
  filter: none;
}

.trophy-card strong {
  display: block;
  margin: 5px 0;
  color: #55336d;
  font-size: 0.94rem;
}

.trophy-card span {
  font-size: 2rem;
}

.trophy-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.prestige-button {
  width: 100%;
  margin-top: 12px;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  box-shadow: 0 7px 0 #8743a0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.toggles-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.toggles-grid label,
.volume-grid label {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 17px;
  color: #55336d;
  background: rgba(255, 255, 255, 0.74);
  font-size: 0.86rem;
  font-weight: 1000;
}

.toggles-grid input {
  width: 22px;
  height: 22px;
  accent-color: var(--pink);
}

.volume-grid {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.volume-grid label {
  justify-content: space-between;
}

.volume-grid input {
  width: 46%;
  accent-color: var(--purple);
}

.link-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.link-grid button {
  background: linear-gradient(135deg, var(--blue), var(--purple));
  box-shadow: 0 7px 0 #4c61bc;
  font-size: 0.82rem;
}

.version-line {
  margin: 12px 0 0;
  text-align: center;
  color: var(--muted);
  font-weight: 900;
}

.settings-grid button {
  min-height: 48px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  box-shadow: 0 7px 0 #4c61bc;
  font-size: 0.86rem;
}

.save-status {
  margin: 12px 0 8px;
  color: var(--muted);
  font-weight: 850;
  text-align: center;
}

.save-box {
  width: 100%;
  min-height: 105px;
  resize: vertical;
  border: 3px solid #ffe1ef;
  border-radius: 20px;
  padding: 12px;
  color: var(--text);
  background: white;
  font-size: 0.86rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(92, 50, 116, 0.28);
  backdrop-filter: blur(8px);
}

.modal.active {
  display: flex;
}

.modal-card {
  width: min(100%, 390px);
  padding: 22px;
  border-radius: 30px;
  text-align: center;
}

.modal-icon {
  display: inline-grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin-bottom: 8px;
  border-radius: 26px;
  background: #fff0a9;
  font-size: 2.8rem;
}

.modal-card p {
  color: var(--text);
  font-weight: 850;
  line-height: 1.45;
}

.modal-card button {
  width: 100%;
  background: linear-gradient(135deg, var(--pink), var(--orange));
  box-shadow: 0 7px 0 #ca4c75;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 40;
  width: min(calc(100% - 28px), 420px);
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 18px;
  color: white;
  background: linear-gradient(135deg, #653180, #ef5d9f);
  box-shadow: 0 14px 34px rgba(84, 52, 97, 0.25);
  font-weight: 1000;
  text-align: center;
  transform: translate(-50%, 120%);
  opacity: 0;
  pointer-events: none;
  transition: transform 180ms ease, opacity 180ms ease;
}

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

.float-text,
.spark {
  position: absolute;
  left: 50%;
  top: 48%;
  pointer-events: none;
  z-index: 8;
}

.float-text {
  color: #ff7a25;
  font-size: 1.75rem;
  font-weight: 1000;
  text-shadow: 0 3px 0 white;
  animation: floatUp 720ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.spark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--spark-color);
  animation: spark 540ms ease-out forwards;
}

.pop-in {
  animation: cardPop 240ms ease both;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes bonusPop {
  from {
    transform: translateY(0) rotate(-4deg) scale(1);
  }
  to {
    transform: translateY(-8px) rotate(5deg) scale(1.05);
  }
}

@keyframes floatUp {
  from {
    transform: translate(-50%, 10px) scale(0.82);
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  to {
    transform: translate(-50%, -86px) scale(1.12);
    opacity: 0;
  }
}

@keyframes spark {
  from {
    transform: translate(-50%, -50%) rotate(var(--angle)) translateX(0) scale(1);
    opacity: 1;
  }
  to {
    transform: translate(-50%, -50%) rotate(var(--angle)) translateX(var(--distance)) scale(0);
    opacity: 0;
  }
}

@keyframes cardPop {
  from {
    transform: translateY(8px) scale(0.96);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@media (min-width: 430px) {
  .game-shell {
    padding-left: 18px;
    padding-right: 18px;
  }
}

@media (max-width: 370px) {
  .game-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .tab {
    min-height: 43px;
    font-size: 0.64rem;
  }

  .tap-button {
    width: min(76vw, 280px);
  }
}

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

body.reduced-effects *,
body.reduced-effects *::before,
body.reduced-effects *::after {
  animation-duration: 1ms !important;
  transition-duration: 1ms !important;
}

body.battery-saver .spark,
body.battery-saver .float-text,
body.battery-saver .bonus-bubble::after {
  display: none;
}
