:root {
  color-scheme: dark;
  font-family: "Avenir Next", "Nunito", "Trebuchet MS", system-ui, sans-serif;
  --ink: #ffffff;
  --muted: #c7d3ff;
  --panel: rgba(47, 49, 135, 0.72);
  --panel-strong: rgba(31, 32, 95, 0.92);
  --line: rgba(221, 231, 255, 0.24);
  --shadow: 0 1.6vh 4vh rgba(17, 15, 70, 0.42);
  --yellow: #ffd23f;
  --pink: #ff6f91;
  --blue: #29c2ff;
  --purple: #8b5cf6;
  --green: #54e397;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #5757db;
}

body {
  overscroll-behavior: none;
  touch-action: manipulation;
  color: var(--ink);
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
}

button:focus-visible {
  outline: 0.3rem solid rgba(255, 255, 255, 0.9);
  outline-offset: 0.2rem;
}

.app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  overflow: clip;
  isolation: isolate;
  background:
    radial-gradient(circle at 15% 8%, rgba(92, 224, 255, 0.35), transparent 31%),
    radial-gradient(circle at 84% 38%, rgba(201, 123, 255, 0.31), transparent 34%),
    linear-gradient(155deg, #626be8 0%, #4f4bc9 52%, #31329a 100%);
}

.ambient {
  position: absolute;
  width: 44vmin;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(6vmin);
  opacity: 0.38;
  pointer-events: none;
  z-index: -1;
}

.ambient-one {
  left: -14vmin;
  top: 24%;
  background: #35ddff;
}

.ambient-two {
  right: -10vmin;
  bottom: -8vmin;
  background: #b962ff;
}

.screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  opacity: 0;
  transform: translateY(2%);
  transition: opacity 0.28s ease, transform 0.28s ease;
  pointer-events: none;
}

.screen.is-active {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.screen[hidden] {
  display: none;
}

.home-screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: clamp(0.65rem, 1.6vh, 1.3rem);
  padding:
    max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(0.75rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
}

.home-topbar,
.page-header,
.game-hud {
  position: relative;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.profile-chip,
.icon-button,
.round-button,
.header-total {
  border: 0.12rem solid rgba(255, 255, 255, 0.26);
  background: rgba(40, 43, 127, 0.56);
  box-shadow: inset 0 0.08rem 0.1rem rgba(255, 255, 255, 0.2), var(--shadow);
  backdrop-filter: blur(1rem);
}

.profile-chip {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: min(14rem, 58vw);
  padding: 0.48rem 1rem 0.48rem 0.48rem;
  border-radius: 3rem;
  text-align: left;
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 2.8rem;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(145deg, #4bd5ff, #7b5cff);
  box-shadow: inset 0 0 0 0.18rem rgba(255, 255, 255, 0.3);
  font-size: 1.05rem;
  font-weight: 1000;
  background-size: cover;
  background-position: center;
}

.profile-avatar.has-image {
  color: transparent;
}

.profile-chip b,
.profile-chip small {
  display: block;
  line-height: 1.05;
}

.profile-chip b {
  font-size: 0.9rem;
  letter-spacing: 0.06em;
}

.profile-chip small {
  margin-top: 0.25rem;
  color: #ffe784;
  font-size: 0.68rem;
  font-weight: 900;
}

.icon-button,
.round-button {
  display: grid;
  place-items: center;
  width: clamp(2.8rem, 7.2vmin, 4.2rem);
  aspect-ratio: 1;
  padding: 0;
  border-radius: 50%;
  font-size: clamp(1.35rem, 3.5vmin, 2.2rem);
  font-weight: 900;
}

.home-hero {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.mini-well {
  position: absolute;
  top: 4%;
  left: 50%;
  width: clamp(10rem, 36vmin, 23rem);
  aspect-ratio: 1.35;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(20, 24, 83, 0.9) 0 32%, rgba(58, 61, 164, 0.88) 34% 47%, rgba(188, 204, 255, 0.5) 49% 52%, transparent 54%);
  filter: drop-shadow(0 2.1vh 1.9vh rgba(24, 20, 92, 0.36));
  opacity: 0.78;
}

.mini-well span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 17%;
  height: 27%;
  margin: -13.5% -8.5%;
  border-radius: 24%;
  background: linear-gradient(160deg, #6de2ff, #158fe9);
  box-shadow: inset 0 0.22rem 0.18rem rgba(255, 255, 255, 0.34), 0 0.5rem 0.7rem rgba(14, 19, 91, 0.34);
  transform: rotate(calc(var(--i) * 60deg)) translateY(-125%) rotate(calc(var(--i) * -60deg));
}

.mini-well span:nth-child(1) { --i: 0; background: linear-gradient(160deg, #ff7e9f, #dc3e78); }
.mini-well span:nth-child(2) { --i: 1; background: linear-gradient(160deg, #ffd94d, #f49a18); }
.mini-well span:nth-child(3) { --i: 2; }
.mini-well span:nth-child(4) { --i: 3; background: linear-gradient(160deg, #9d78ff, #6437c9); }
.mini-well span:nth-child(5) { --i: 4; background: linear-gradient(160deg, #55eca3, #12ad75); }
.mini-well span:nth-child(6) { --i: 5; background: linear-gradient(160deg, #ffd94d, #f49a18); }

.brand-mark {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.24rem;
  width: clamp(3.7rem, 9vmin, 6.4rem);
  margin-top: clamp(3.6rem, 12vh, 8rem);
  filter: drop-shadow(0 0.65rem 0.55rem rgba(15, 19, 96, 0.38));
}

.brand-mark i {
  aspect-ratio: 1;
  border-radius: 28%;
  background: linear-gradient(145deg, #66e5ff, #198cfa);
  box-shadow: inset 0 0.18rem 0.18rem rgba(255, 255, 255, 0.4);
}

.brand-mark i:nth-child(2) { background: linear-gradient(145deg, #ffdd52, #ff9b1e); }
.brand-mark i:nth-child(3) { background: linear-gradient(145deg, #ff8ca7, #ea4774); }
.brand-mark i:nth-child(4) { background: linear-gradient(145deg, #a383ff, #6f42e3); }

.home-hero h1 {
  position: relative;
  z-index: 1;
  margin: clamp(0.6rem, 1.8vh, 1.2rem) 0 0;
  font-size: clamp(2rem, 8vmin, 5.5rem);
  line-height: 0.9;
  letter-spacing: -0.045em;
  text-shadow: 0 0.45rem 0.1rem rgba(43, 35, 141, 0.35);
}

.home-hero p {
  position: relative;
  z-index: 1;
  max-width: 34rem;
  margin: 0.65rem 1rem 1rem;
  color: var(--muted);
  font-size: clamp(0.82rem, 2.2vmin, 1.25rem);
  font-weight: 700;
}

.hero-button,
.primary-button {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-width: min(22rem, 68vw);
  padding: clamp(0.85rem, 2vh, 1.25rem) 2rem;
  border-radius: 4rem;
  background: linear-gradient(180deg, #ffe15c, #ffad23);
  box-shadow: inset 0 0.18rem 0.12rem rgba(255, 255, 255, 0.72), 0 0.52rem 0 #de7e1d, 0 1rem 2rem rgba(33, 21, 103, 0.42);
  color: #573526;
  font-size: clamp(1.1rem, 3.2vmin, 1.8rem);
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-shadow: 0 0.08rem rgba(255, 255, 255, 0.45);
}

.hero-button:active,
.primary-button:active,
.control-button:active {
  transform: translateY(0.2rem);
  filter: brightness(0.97);
}

.hero-button b {
  font-size: 0.8em;
}

.hero-button small {
  display: block;
  margin-top: 0.12rem;
  font-size: clamp(0.5rem, 1.55vmin, 0.72rem);
  letter-spacing: 0.08em;
  opacity: 0.78;
}

.home-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(0.65rem, 2vw, 1rem);
  width: min(48rem, 100%);
  margin-inline: auto;
}

.feature-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  padding: clamp(0.72rem, 1.6vh, 1rem);
  border: 0.12rem solid rgba(255, 255, 255, 0.22);
  border-radius: 1.25rem;
  background: linear-gradient(145deg, rgba(62, 64, 161, 0.8), rgba(38, 39, 119, 0.74));
  box-shadow: inset 0 0.12rem 0.12rem rgba(255, 255, 255, 0.16), var(--shadow);
  text-align: left;
}

.feature-icon {
  display: grid;
  place-items: center;
  width: clamp(2.6rem, 7vmin, 4.3rem);
  aspect-ratio: 1;
  border-radius: 35%;
  background: linear-gradient(150deg, #67e4ff, #178fea);
  box-shadow: inset 0 0.18rem 0.18rem rgba(255, 255, 255, 0.36), 0 0.45rem 0.6rem rgba(18, 18, 75, 0.3);
  font-size: clamp(1.15rem, 3.4vmin, 2rem);
}

.medals-card .feature-icon {
  background: linear-gradient(150deg, #ffe15a, #f08c1e);
}

.feature-card b,
.feature-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feature-card b {
  font-size: clamp(0.76rem, 2.1vmin, 1.1rem);
  letter-spacing: 0.04em;
}

.feature-card small {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: clamp(0.62rem, 1.7vmin, 0.9rem);
  font-weight: 800;
}

.feature-card > i {
  font-size: 1.8rem;
  font-style: normal;
  opacity: 0.72;
}

.bottom-nav {
  position: relative;
  z-index: 9;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(34rem, 100%);
  margin-inline: auto;
  padding: 0.35rem;
  border: 0.1rem solid rgba(255, 255, 255, 0.18);
  border-radius: 1.35rem;
  background: rgba(36, 37, 111, 0.66);
  box-shadow: inset 0 0.1rem rgba(255, 255, 255, 0.15), var(--shadow);
  backdrop-filter: blur(1.2rem);
}

.bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: clamp(3.1rem, 7vh, 4rem);
  border-radius: 1rem;
  background: transparent;
  color: #aab9ef;
}

.bottom-nav button.is-current {
  color: #fff;
  background: rgba(122, 121, 244, 0.62);
  box-shadow: inset 0 0.12rem rgba(255, 255, 255, 0.2);
}

.bottom-nav span {
  font-size: clamp(1.1rem, 3vmin, 1.55rem);
  line-height: 1;
}

.bottom-nav b {
  font-size: clamp(0.54rem, 1.5vmin, 0.74rem);
  letter-spacing: 0.05em;
}

.panel-screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(0.8rem, 2vh, 1.5rem);
  padding:
    max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(0.75rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
}

.page-header {
  justify-content: flex-start;
}

.page-header > div {
  min-width: 0;
  flex: 1;
}

.page-header h2 {
  margin: 0;
  font-size: clamp(1.25rem, 4vmin, 2.5rem);
  line-height: 1;
  letter-spacing: 0.025em;
}

.page-header p {
  margin: 0.38rem 0 0;
  color: var(--muted);
  font-size: clamp(0.68rem, 1.8vmin, 1rem);
  font-weight: 700;
}

.back-button {
  flex: 0 0 auto;
  font-size: clamp(2rem, 5vmin, 3rem);
  line-height: 0.8;
}

.header-total {
  flex: 0 0 auto;
  padding: 0.58rem 0.82rem;
  border-radius: 2rem;
  color: #ffe57c;
  font-size: clamp(0.72rem, 2vmin, 1rem);
  font-weight: 1000;
}

.level-grid,
.medal-grid {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  padding: 0.25rem 0.1rem 1.3rem;
}

.level-grid::-webkit-scrollbar,
.medal-grid::-webkit-scrollbar {
  display: none;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
  gap: clamp(0.65rem, 2.1vw, 1rem);
}

.level-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: clamp(6.6rem, 17vh, 9rem);
  padding: 0.8rem 0.45rem;
  overflow: hidden;
  border: 0.12rem solid rgba(255, 255, 255, 0.24);
  border-radius: 1.15rem;
  background: linear-gradient(145deg, rgba(82, 87, 194, 0.88), rgba(41, 42, 127, 0.82));
  box-shadow: inset 0 0.16rem 0.14rem rgba(255, 255, 255, 0.18), 0 0.72rem 1.5rem rgba(23, 20, 88, 0.26);
}

.level-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(98, 227, 255, 0.23), transparent 55%);
  pointer-events: none;
}

.level-number {
  position: relative;
  font-size: clamp(1.45rem, 5vmin, 2.6rem);
  line-height: 1;
}

.level-card small {
  position: relative;
  margin-top: 0.36rem;
  color: var(--muted);
  font-size: clamp(0.54rem, 1.5vmin, 0.78rem);
  font-weight: 800;
}

.level-stars {
  position: relative;
  margin-top: 0.55rem;
  color: rgba(255, 255, 255, 0.2);
  letter-spacing: 0.08em;
  font-size: clamp(0.76rem, 2.4vmin, 1.15rem);
}

.level-stars .filled {
  color: #ffe36c;
  text-shadow: 0 0.2rem rgba(96, 53, 12, 0.4);
}

.level-card.is-next {
  border-color: rgba(255, 226, 100, 0.72);
  background: linear-gradient(145deg, rgba(120, 96, 209, 0.95), rgba(62, 47, 148, 0.9));
  box-shadow: inset 0 0.18rem rgba(255, 255, 255, 0.2), 0 0 1.2rem rgba(255, 216, 69, 0.2), var(--shadow);
}

.level-card.is-locked {
  filter: saturate(0.34);
  opacity: 0.58;
}

.level-lock {
  position: absolute;
  right: 0.55rem;
  top: 0.5rem;
  font-size: 0.9rem;
}

.medal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: clamp(0.75rem, 2.3vw, 1.2rem);
}

.medal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: clamp(9rem, 23vh, 13rem);
  padding: 1rem;
  border: 0.12rem solid rgba(255, 255, 255, 0.23);
  border-radius: 1.35rem;
  background: linear-gradient(145deg, rgba(60, 65, 161, 0.88), rgba(34, 35, 108, 0.82));
  box-shadow: inset 0 0.16rem rgba(255, 255, 255, 0.16), var(--shadow);
  text-align: center;
}

.medal-card.is-earned {
  border-color: rgba(255, 222, 95, 0.66);
  background: linear-gradient(150deg, rgba(106, 81, 186, 0.96), rgba(46, 42, 132, 0.9));
}

.medal-icon {
  display: grid;
  place-items: center;
  width: clamp(3.7rem, 11vmin, 6rem);
  aspect-ratio: 1;
  border: 0.28rem solid rgba(255, 240, 170, 0.35);
  border-radius: 50%;
  background: linear-gradient(145deg, #ffe65b, #e98a18);
  box-shadow: inset 0 0.25rem 0.25rem rgba(255, 255, 255, 0.45), 0 0.65rem 1rem rgba(28, 19, 84, 0.38);
  color: #764b22;
  font-size: clamp(1.65rem, 5vmin, 2.8rem);
  filter: grayscale(0.85);
  opacity: 0.55;
}

.medal-card.is-earned .medal-icon {
  filter: none;
  opacity: 1;
}

.medal-card b {
  margin-top: 0.75rem;
  font-size: clamp(0.72rem, 2vmin, 1.05rem);
  letter-spacing: 0.04em;
}

.medal-card small {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: clamp(0.6rem, 1.65vmin, 0.85rem);
  font-weight: 800;
}

.medal-progress {
  width: 84%;
  height: 0.38rem;
  margin-top: 0.65rem;
  overflow: hidden;
  border-radius: 1rem;
  background: rgba(18, 21, 77, 0.72);
}

.medal-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #39d7ff, #ffe05b);
}

.settings-screen {
  grid-template-rows: auto minmax(0, auto) 1fr;
}

.compact-header {
  min-height: 3.5rem;
}

.settings-card {
  width: min(40rem, 100%);
  margin: min(7vh, 4rem) auto 0;
  padding: 0.55rem;
  border: 0.12rem solid rgba(255, 255, 255, 0.23);
  border-radius: 1.5rem;
  background: rgba(38, 40, 121, 0.66);
  box-shadow: var(--shadow);
  backdrop-filter: blur(1rem);
}

.setting-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: clamp(4.2rem, 10vh, 5.6rem);
  padding: 0.65rem 0.8rem;
  border-radius: 1.05rem;
  background: transparent;
  text-align: left;
}

.setting-row + .setting-row {
  border-top: 0.08rem solid rgba(255, 255, 255, 0.12);
  border-radius: 0;
}

.setting-icon {
  display: grid;
  place-items: center;
  width: 2.7rem;
  aspect-ratio: 1;
  border-radius: 0.82rem;
  background: linear-gradient(145deg, #6cddff, #5471ef);
  font-size: 1.25rem;
  font-weight: 1000;
}

.setting-row b {
  font-size: clamp(0.83rem, 2.4vmin, 1.15rem);
}

.setting-row em {
  min-width: 2.2rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 900;
  text-align: right;
}

.toggle {
  position: relative;
  width: 3.15rem;
  height: 1.75rem;
  border-radius: 2rem;
  background: #2d2f85;
  box-shadow: inset 0 0.18rem 0.35rem rgba(20, 21, 73, 0.48);
}

.toggle::after {
  content: "";
  position: absolute;
  left: 0.2rem;
  top: 0.2rem;
  width: 1.35rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #dce6ff;
  box-shadow: 0 0.15rem 0.35rem rgba(19, 17, 70, 0.5);
  transition: transform 0.2s ease;
}

.setting-row.is-on .toggle {
  background: linear-gradient(90deg, #26ccba, #4ce084);
}

.setting-row.is-on .toggle::after {
  transform: translateX(1.4rem);
  background: white;
}

.shape-gallery {
  align-self: end;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(0.6rem, 2vw, 1.4rem);
  padding-bottom: min(7vh, 4rem);
  opacity: 0.58;
}

.shape-gallery span {
  display: grid;
  place-items: center;
  width: clamp(3.2rem, 10vmin, 5.2rem);
  aspect-ratio: 1;
  border-radius: 1rem;
  background: linear-gradient(145deg, #5bceff, #276fe3);
  box-shadow: inset 0 0.18rem rgba(255, 255, 255, 0.35), 0 0.6rem 1rem rgba(22, 18, 86, 0.35);
  font-size: clamp(1.25rem, 4vmin, 2rem);
  font-weight: 1000;
}

.shape-gallery span:nth-child(2) { background: linear-gradient(145deg, #ffe052, #f2951d); }
.shape-gallery span:nth-child(3) { background: linear-gradient(145deg, #ff83a1, #e74576); }
.shape-gallery span:nth-child(4) { background: linear-gradient(145deg, #a579ff, #6a3edb); }
.shape-gallery span:nth-child(5) { background: linear-gradient(145deg, #5ee8a3, #12a975); }

.game-screen {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(213, 222, 255, 0.62), transparent 54%),
    radial-gradient(circle at 8% 72%, rgba(139, 184, 255, 0.38), transparent 35%),
    radial-gradient(circle at 94% 68%, rgba(150, 150, 255, 0.34), transparent 36%),
    linear-gradient(180deg, #95abff 0%, #8399f6 35%, #778bef 70%, #7184e9 100%);
  touch-action: none;
  isolation: isolate;
}

.game-screen::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(255, 255, 255, 0.1), transparent 58%),
    linear-gradient(90deg, rgba(82, 99, 207, 0.12), transparent 15%, transparent 85%, rgba(82, 99, 207, 0.12));
  content: "";
  pointer-events: none;
}

#gameCanvas {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  touch-action: none;
}

.game-hud {
  position: absolute;
  z-index: 10;
  left: max(3.4vw, env(safe-area-inset-left));
  right: max(3.4vw, env(safe-area-inset-right));
  top: max(2.4vh, env(safe-area-inset-top));
  display: grid;
  grid-template-columns: 15vw minmax(0, 1fr) 20vw;
  align-items: start;
  gap: 1.8vw;
  pointer-events: none;
}

.game-hud button,
.game-hud .next-card {
  pointer-events: auto;
}

.hud-control {
  display: grid;
  width: 12.5vw;
  aspect-ratio: 1;
  place-items: center;
  padding: 0;
  border: 0.34vw solid rgba(218, 229, 255, 0.48);
  border-radius: 50%;
  background: linear-gradient(155deg, rgba(105, 126, 220, 0.78), rgba(58, 70, 160, 0.72));
  box-shadow: inset 0 0.32vw rgba(255, 255, 255, 0.32), 0 0.55vw 0 rgba(72, 83, 177, 0.72), 0 1.8vw 4.2vw rgba(52, 58, 145, 0.28);
  backdrop-filter: blur(0.8rem);
}

.pause-glyph {
  display: flex;
  align-items: center;
  gap: 1.25vw;
}

.pause-glyph i {
  display: block;
  width: 1.35vw;
  min-width: 0.34rem;
  height: 5.2vw;
  max-height: 2.1rem;
  border-radius: 0.8vw;
  background: white;
  box-shadow: 0 0.25vw 0.45vw rgba(46, 52, 140, 0.35);
}

.mission {
  min-width: 0;
  padding-top: 0.25vh;
  text-align: center;
  text-shadow: 0 0.22rem 0.34rem rgba(43, 36, 132, 0.32);
}

.level-label {
  margin: 0;
  font-size: clamp(1.55rem, 6.1vw, 3.15rem);
  font-weight: 1000;
  line-height: 1;
  letter-spacing: 0.035em;
}

.mission-objective {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 1.3vw;
  margin: 0.8vh 0 0;
  color: white;
  font-size: clamp(0.72rem, 3.15vw, 1.45rem);
  font-weight: 1000;
  letter-spacing: 0.045em;
}

.mission-objective span {
  color: rgba(236, 241, 255, 0.9);
  font-size: 0.78em;
}

.mission-objective i {
  color: rgba(238, 242, 255, 0.76);
  font-style: normal;
}

.progress-track {
  box-sizing: border-box;
  width: 92%;
  height: clamp(0.62rem, 1.55vh, 0.95rem);
  margin: 1.1vh auto 0;
  padding: 0.18vw;
  border: 0.32vw solid rgba(215, 226, 255, 0.53);
  border-radius: 99rem;
  background: rgba(50, 63, 155, 0.66);
  box-shadow: inset 0 0.3vw 0.75vw rgba(29, 37, 111, 0.42), 0 0.28vw rgba(255, 255, 255, 0.18);
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffd13e, #ffaf29);
  box-shadow: 0 0 0.5rem rgba(255, 211, 70, 0.65);
  transition: width 0.28s ease;
}

.next-card {
  box-sizing: border-box;
  width: 20vw;
  aspect-ratio: 1 / 0.92;
  justify-self: end;
  padding: 1.2vw 1vw 0.7vw;
  border: 0.34vw solid rgba(218, 228, 255, 0.48);
  border-radius: 4vw;
  background: linear-gradient(155deg, rgba(94, 111, 204, 0.66), rgba(56, 67, 156, 0.58));
  box-shadow: inset 0 0.32vw rgba(255, 255, 255, 0.25), 0 0.55vw 0 rgba(72, 83, 177, 0.55), 0 1.8vw 4vw rgba(52, 58, 145, 0.24);
  backdrop-filter: blur(0.8rem);
  text-align: center;
}

.next-card p {
  margin: 0;
  font-size: clamp(0.58rem, 2.8vw, 1.2rem);
  font-weight: 1000;
  letter-spacing: 0.06em;
}

.next-piece {
  display: grid;
  grid-template-columns: repeat(var(--piece-columns, 4), var(--preview-cell, 3.2vmin));
  grid-template-rows: repeat(var(--piece-rows, 2), var(--preview-cell, 3.2vmin));
  gap: 0.45vw;
  width: 100%;
  height: 8.2vmin;
  margin: 0.8vw auto 0;
  place-content: center;
}

.next-piece i {
  position: relative;
  width: var(--preview-cell, 3.2vmin);
  min-width: 0;
  aspect-ratio: 1;
  border-radius: 24%;
  background: linear-gradient(145deg, color-mix(in srgb, var(--piece-color) 72%, white), var(--piece-color));
  box-shadow: inset 0 0.12rem rgba(255, 255, 255, 0.54), 0 0.2rem 0.35rem rgba(15, 23, 85, 0.35);
}

.landing-guide {
  position: absolute;
  z-index: 2;
  top: 19vh;
  left: 50%;
  display: flex;
  width: 15.5vw;
  height: 9vh;
  justify-content: space-between;
  filter: drop-shadow(0 0.2vw 0.3vw rgba(55, 65, 153, 0.3));
  transform: translateX(-50%);
  pointer-events: none;
}

.landing-guide i {
  display: block;
  height: 100%;
  border-left: 0.38vw dashed rgba(255, 255, 255, 0.92);
}

.danger-badge {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 15vh;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  border: 0.1rem solid rgba(255, 255, 255, 0.25);
  border-radius: 2rem;
  background: rgba(192, 46, 86, 0.82);
  box-shadow: 0 0.5rem 1rem rgba(71, 17, 70, 0.3);
  transform: translate(-50%, -0.4rem);
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s linear 0.2s, opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.danger-badge.is-visible {
  visibility: visible;
  opacity: 1;
  transform: translate(-50%, 0);
  transition-delay: 0s;
}

.danger-badge span {
  display: grid;
  place-items: center;
  width: 1.35rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #ffe55f;
  color: #8d3454;
  font-weight: 1000;
}

.danger-badge b {
  font-size: clamp(0.56rem, 1.6vmin, 0.8rem);
}

.combo-toast {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 20%;
  color: #ffe45f;
  font-size: clamp(1.25rem, 5vmin, 2.8rem);
  font-weight: 1000;
  text-shadow: 0 0.28rem 0 #9b4f2d, 0 0 1rem rgba(255, 223, 75, 0.7);
  transform: translate(-50%, 0.8rem) scale(0.8);
  opacity: 0;
  pointer-events: none;
}

.combo-toast.is-visible {
  animation: combo-pop 1s ease both;
}

@keyframes combo-pop {
  0% { opacity: 0; transform: translate(-50%, 0.8rem) scale(0.72); }
  18%, 68% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -0.7rem) scale(1.08); }
}

.game-controls {
  position: absolute;
  z-index: 10;
  left: max(5vw, env(safe-area-inset-left));
  right: max(5vw, env(safe-area-inset-right));
  bottom: max(3.4vh, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 17vw minmax(0, 1fr) 17vw;
  align-items: end;
  gap: 2.6vw;
  pointer-events: none;
}

.round-control {
  box-sizing: border-box;
  display: grid;
  width: 16.5vw;
  aspect-ratio: 1;
  place-items: center;
  padding: 0;
  border: 0.34vw solid rgba(219, 229, 255, 0.46);
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.2), transparent 34%),
    linear-gradient(155deg, rgba(102, 122, 216, 0.9), rgba(55, 66, 157, 0.86));
  box-shadow: inset 0 0.45vw rgba(255, 255, 255, 0.38), inset 0 -0.6vw 1.2vw rgba(30, 35, 122, 0.22), 0 0.65vw 0 rgba(66, 76, 166, 0.62), 0 2vw 4.5vw rgba(43, 47, 125, 0.3);
  backdrop-filter: blur(0.75rem);
  pointer-events: auto;
}

.round-control:active {
  transform: translateY(0.7vw) scale(0.97);
  box-shadow: inset 0 0.35vw rgba(255, 255, 255, 0.3), 0 0.18vw 0 rgba(66, 76, 166, 0.62), 0 1vw 2.5vw rgba(43, 47, 125, 0.26);
}

.rotate-icon {
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0.4vw 0.5vw rgba(43, 49, 133, 0.35);
  transform: translateY(-0.2vh);
}

.drop-control {
  justify-self: end;
}

.drop-chevron {
  display: flex;
  flex-direction: column;
  gap: 1.2vw;
  transform: translateY(0.2vh);
}

.drop-chevron i {
  display: block;
  width: 4.6vw;
  aspect-ratio: 1;
  border-right: 1.4vw solid white;
  border-bottom: 1.4vw solid white;
  border-radius: 0.35vw;
  transform: rotate(45deg);
}

.swipe-guide {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4vh;
  padding-bottom: 0.5vh;
  color: white;
  text-align: center;
  pointer-events: none;
}

.swipe-guide div {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2.5vw;
  width: 100%;
}

.swipe-guide i {
  font-size: clamp(1.6rem, 6.8vw, 3.3rem);
  font-style: normal;
  font-weight: 1000;
  text-shadow: 0 0.35vw 0.45vw rgba(42, 48, 133, 0.34);
}

.swipe-guide span {
  font-size: clamp(2.2rem, 9vw, 4.3rem);
  filter: drop-shadow(0 0.24rem 0.2rem rgba(34, 29, 112, 0.42));
  transform: translateY(0.5vh);
}

.swipe-guide b {
  font-size: clamp(0.72rem, 3.35vw, 1.45rem);
  letter-spacing: 0.025em;
  text-shadow: 0 0.15rem 0.18rem rgba(35, 27, 111, 0.55);
}

.dialog {
  position: absolute;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(21, 20, 73, 0.62);
  backdrop-filter: blur(0.8rem);
}

.dialog[hidden] {
  display: none;
}

.dialog-card {
  width: min(30rem, 91vw);
  max-height: 90vh;
  max-height: 90dvh;
  overflow: auto;
  padding: clamp(1.35rem, 4vmin, 2.3rem);
  border: 0.13rem solid rgba(255, 255, 255, 0.31);
  border-radius: clamp(1.5rem, 5vmin, 2.35rem);
  background: linear-gradient(155deg, rgba(81, 83, 190, 0.98), rgba(36, 35, 112, 0.98));
  box-shadow: inset 0 0.18rem rgba(255, 255, 255, 0.2), 0 2rem 5rem rgba(16, 12, 62, 0.55);
  text-align: center;
}

.dialog-eyebrow {
  margin: 0;
  color: #aeeaff;
  font-size: 0.68rem;
  font-weight: 1000;
  letter-spacing: 0.12em;
}

.dialog-card h2 {
  margin: 0.55rem 0 0;
  font-size: clamp(1.75rem, 7vmin, 3.4rem);
  line-height: 0.95;
}

.dialog-card > p:not(.dialog-eyebrow, .dialog-score) {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.star-row {
  min-height: 2.5rem;
  margin-top: 0.65rem;
  color: #ffe052;
  font-size: clamp(1.8rem, 7vmin, 3.4rem);
  letter-spacing: 0.05em;
  text-shadow: 0 0.22rem 0 #aa5e28, 0 0 1rem rgba(255, 226, 77, 0.44);
}

.dialog-score {
  margin: 0.6rem 0 1.1rem;
  font-size: clamp(0.85rem, 2.5vmin, 1.15rem);
  font-weight: 1000;
}

.dialog-actions {
  display: grid;
  gap: 0.85rem;
}

.dialog-actions .primary-button {
  min-width: 0;
  width: 100%;
}

.secondary-button {
  padding: 0.78rem 1rem;
  border: 0.1rem solid rgba(255, 255, 255, 0.24);
  border-radius: 2rem;
  background: rgba(28, 29, 92, 0.55);
  color: #dce4ff;
  font-size: 0.86rem;
  font-weight: 1000;
  letter-spacing: 0.05em;
}

.loading {
  position: absolute;
  z-index: 70;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: linear-gradient(155deg, #6069e2, #3939a7);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading span {
  width: 4.2rem;
  aspect-ratio: 1;
  border: 0.45rem solid rgba(255, 255, 255, 0.24);
  border-top-color: #ffe15a;
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
}

.loading b {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

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

.sr-only {
  position: absolute;
  width: 0.08rem;
  height: 0.08rem;
  padding: 0;
  margin: -0.08rem;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-aspect-ratio: 1 / 1) {
  .home-screen {
    grid-template-columns: minmax(0, 1.35fr) minmax(18rem, 0.65fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .home-topbar {
    grid-column: 1 / -1;
  }

  .home-hero {
    grid-column: 1;
    grid-row: 2 / 4;
  }

  .home-cards {
    grid-column: 2;
    grid-row: 2;
    grid-template-columns: 1fr;
    align-self: end;
  }

  .home-screen > .bottom-nav {
    grid-column: 2;
    grid-row: 3;
    width: 100%;
  }

  .mini-well {
    top: -5%;
  }

  .brand-mark {
    margin-top: 3vh;
  }

  .level-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .medal-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .level-card {
    min-height: clamp(5.2rem, 22vh, 8rem);
  }

  .medal-card {
    min-height: clamp(7.2rem, 31vh, 11rem);
  }

  .settings-screen {
    grid-template-columns: minmax(18rem, 0.7fr) minmax(20rem, 1fr);
    grid-template-rows: auto 1fr;
  }

  .settings-screen .page-header {
    grid-column: 1 / -1;
  }

  .settings-card {
    align-self: center;
    margin: 0 auto;
  }

  .shape-gallery {
    align-self: center;
    flex-wrap: wrap;
    max-width: 30rem;
    padding: 0;
  }

  .game-hud {
    left: max(2vw, env(safe-area-inset-left));
    right: max(2vw, env(safe-area-inset-right));
    top: max(2vh, env(safe-area-inset-top));
    width: auto;
    grid-template-columns: 9vw minmax(0, 1fr) 12vw;
  }

  .hud-control {
    width: 8vw;
  }

  .pause-glyph i {
    width: 0.8vw;
    height: 3vw;
  }

  .level-label {
    font-size: clamp(1.35rem, 4.4vh, 2.4rem);
  }

  .next-card {
    position: static;
    width: 11vw;
    border-radius: 2vw;
  }

  .game-controls {
    left: max(25vw, env(safe-area-inset-left));
    right: max(25vw, env(safe-area-inset-right));
    width: auto;
    grid-template-columns: 9vw minmax(0, 1fr) 9vw;
  }

  .round-control {
    width: 8.5vw;
  }

  .landing-guide {
    top: 20vh;
    width: 10vw;
    height: 12vh;
  }
}

@media (max-height: 34rem) {
  .home-hero p {
    display: none;
  }

  .brand-mark {
    width: 3.2rem;
  }

  .home-hero h1 {
    font-size: 2.25rem;
  }

  .feature-card {
    padding-block: 0.5rem;
  }
}

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