:root {
  color-scheme: dark;
  font-family: Inter, system-ui, sans-serif;
  color: #fafaff;
  background: #0e1024;
  --lime: #ceff65;
  --muted: #aab2d1;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 70% 40% at 50% 0, #39306e, transparent 72%), #0e1024;
  overflow-x: hidden;
}
button {
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}
.app {
  width: min(100%, 480px);
  min-height: 100dvh;
  margin: auto;
  padding: max(18px, env(safe-area-inset-top)) 17px
    calc(85px + env(safe-area-inset-bottom));
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  margin-bottom: 16px;
}
.brand {
  border: 0;
  background: none;
  color: #fff;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
}
.brand b {
  color: var(--lime);
}
.logo {
  width: 27px;
  height: 27px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  transform: rotate(-8deg);
}
.logo i {
  background: linear-gradient(145deg, #fff, #a6e844 53%, #6eae24);
  border-radius: 4px;
  box-shadow:
    inset 1px 1px #fff9,
    0 2px 5px #0005;
}
.logo i:nth-child(2) {
  background: linear-gradient(145deg, #ffb0d0, #ff5e91 55%, #bc2e5f);
}
.logo i:nth-child(3) {
  grid-column: 1/3;
  width: 12px;
  margin-left: 7px;
  background: linear-gradient(145deg, #aabaff, #727df5 55%, #444ab3);
}
.top-actions {
  display: flex;
  gap: 7px;
}
.round {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid #ffffff1f;
  background: #222643;
  color: #cbd0ed;
  font-size: 18px;
}
.round.on {
  color: #111a11;
  background: var(--lime);
  border-color: var(--lime);
}
.view {
  display: none;
}
.view.active {
  display: block;
  animation: view-in 0.22s ease-out;
}
@keyframes view-in {
  from {
    opacity: 0.4;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
  }
}
.mode-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 6px 1px 12px;
}
.mode-chip,
.streak-chip {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.7px;
}
.mode-chip {
  color: #191c31;
  background: var(--lime);
}
.streak-chip {
  color: #ffd1df;
  background: #ff719b20;
  border: 1px solid #ff79a040;
}
.streak-chip b {
  color: #fff;
}
.scorecard {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  padding: 17px 18px 16px;
  border-radius: 22px;
  background: linear-gradient(120deg, #25274c, #181b35 65%);
  border: 1px solid #ffffff18;
  box-shadow: 0 16px 36px #05071363;
}
.scorecard:after {
  content: "";
  position: absolute;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  right: -58px;
  top: -74px;
  background: #ccff6430;
}
.scorecard span,
.profile-hero span,
.section-intro > span,
.xp-card span {
  color: #abb3d8;
  font-size: 10px;
  letter-spacing: 1.5px;
  font-weight: 750;
}
.scorecard strong {
  display: block;
  position: relative;
  z-index: 1;
  margin: 1px 0 2px;
  font-size: 44px;
  letter-spacing: -2.5px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.scorecard small {
  display: block;
  position: relative;
  z-index: 1;
  font-size: 11px;
  color: #aeb6d5;
  max-width: 195px;
}
.best-score {
  text-align: right;
  padding-top: 2px;
}
.best-score strong {
  font-size: 25px;
  color: var(--lime);
  letter-spacing: -1px;
}
.best-score small {
  color: #8e96b9;
}
.board-wrap {
  position: relative;
  margin-top: 14px;
  padding: 8px;
  border-radius: 24px;
  background: linear-gradient(
    135deg,
    #33365d,
    #171a32 12%,
    #171a32 88%,
    #393860
  );
  box-shadow: 0 20px 48px #0406148c;
  isolation: isolate;
}
.board-wrap:before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 17px;
  background:
    radial-gradient(circle at 80% 10%, #4b4c7938, transparent 42%), #11142a;
}
#board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  touch-action: none;
}
.cell {
  aspect-ratio: 1;
  border: 0;
  border-radius: 7px;
  padding: 0;
  background: #272a48;
  box-shadow:
    inset 1px 1px #ffffff0c,
    inset -1px -2px #0708198c;
  transition: 0.1s;
  min-width: 0;
}
.cell.block,
.mini .block {
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--c), white 38%),
    var(--c) 45%,
    color-mix(in srgb, var(--c), black 24%)
  );
  box-shadow:
    inset 2px 2px #fff8,
    inset -3px -4px #0004,
    0 2px 5px #0004;
}
.cell.ghost {
  background: var(--c);
  opacity: 0.5;
  box-shadow: inset 0 0 0 2px #fff;
}
.cell.invalid {
  background: #ff4e7e;
  opacity: 0.55;
}
.cell.clear {
  animation: clear 0.3s forwards;
}
.cell.fall {
  animation: fall 0.27s cubic-bezier(0.2, 0.75, 0.4, 1);
}
@keyframes clear {
  45% {
    background: #fff;
    transform: scale(1.13);
  }
  to {
    transform: scale(0.25);
    opacity: 0;
  }
}
@keyframes fall {
  from {
    transform: translateY(var(--dy));
    opacity: 0.7;
  }
  to {
    transform: translateY(0);
  }
}
.tray-head {
  display: flex;
  justify-content: space-between;
  margin: 20px 3px 10px;
  color: #bdc4e5;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.4px;
}
.tray-head #hint {
  color: #8e97ba;
  font-weight: 500;
  letter-spacing: 0;
  font-size: 11px;
}
#tray {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}
.piece {
  height: 82px;
  border-radius: 17px;
  border: 1px solid #ffffff20;
  background: linear-gradient(145deg, #292d4d, #1d203d);
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: none;
  box-shadow:
    inset 0 1px #ffffff14,
    0 7px 15px #0003;
  transition: 0.15s;
}
.piece.selected {
  border-color: var(--lime);
  background: #3a4a35;
  box-shadow: 0 0 0 2px #ceff6538;
}
.piece.used {
  opacity: 0.25;
  border-style: dashed;
}
.piece.unfit {
  opacity: 0.42;
}
.mini {
  display: grid;
  gap: 3px;
  pointer-events: none;
}
.mini span {
  width: 18px;
  height: 18px;
  border-radius: 5px;
}
.mini .blank {
  visibility: hidden;
}
.game-tools {
  height: 37px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #a8b0cf;
  font-size: 11px;
}
.subtle {
  border: 0;
  background: none;
  color: #b9c2e5;
  padding: 5px 0;
  font-size: 11px;
}
.subtle:last-child {
  color: var(--lime);
}
#rankControls {
  height: auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 12px 14px 14px;
  padding: 0;
  align-items: stretch;
}
#rankControls .subtle {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #ffffff24;
  border-radius: 12px;
  background: #ffffff0d;
  color: #e7ebff;
  font-size: 13px;
  line-height: 1.2;
}
#rankControls .subtle:disabled {
  opacity: 0.42;
  cursor: default;
}
#rankStatus {
  margin: 2px 2px 0;
  color: #aab2d1;
  font-size: 12px;
  line-height: 1.4;
}
#toast {
  position: absolute;
  left: 0;
  right: 0;
  top: 39%;
  z-index: 4;
  text-align: center;
  color: #fff;
  font-size: 34px;
  font-weight: 950;
  letter-spacing: -1px;
  text-shadow: 0 3px 18px #060713;
  pointer-events: none;
  opacity: 0;
}
#toast.show {
  animation: toast 0.85s both;
}
@keyframes toast {
  0% {
    opacity: 0;
    transform: scale(0.75);
  }
  20%,
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-20px);
  }
}
#particles {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  overflow: hidden;
  pointer-events: none;
  z-index: 5;
}
.spark {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 3px;
  background: var(--c);
  box-shadow: 0 0 8px var(--c);
  animation: spark 0.65s ease-out forwards;
}
@keyframes spark {
  to {
    transform: translate(var(--dx), var(--dy)) rotate(140deg);
    opacity: 0;
  }
}
#drag {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 30;
  pointer-events: none;
  display: none;
  filter: drop-shadow(0 12px 10px #0008);
  opacity: 0.94;
}
.tabbar {
  position: fixed;
  z-index: 10;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 480px);
  padding: 8px 13px max(9px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: #171a33ed;
  backdrop-filter: blur(18px);
  border-top: 1px solid #ffffff1a;
}
.tab {
  display: grid;
  gap: 3px;
  place-items: center;
  border: 0;
  background: none;
  color: #8f98bd;
  font-size: 10px;
  padding: 3px;
}
.tab i {
  font-style: normal;
  font-size: 20px;
  line-height: 19px;
}
.tab.active {
  color: var(--lime);
}
.section-intro {
  padding: 15px 4px 19px;
}
.section-intro h1 {
  margin: 7px 0;
  font-size: 34px;
  line-height: 0.98;
  letter-spacing: -1.8px;
}
.section-intro p {
  margin: 0;
  color: #aab2d1;
  font-size: 14px;
  line-height: 1.4;
}
.section-intro p a {
  color: var(--lime);
}
.daily-card,
.leaderboard-card,
.xp-card {
  border: 1px solid #ffffff18;
  border-radius: 21px;
  background: linear-gradient(145deg, #282a51, #1a1c37);
  box-shadow: 0 12px 28px #0607174d;
}
.daily-card {
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.daily-orb {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: linear-gradient(145deg, #ffb15e, #ff668e);
  box-shadow: inset 2px 2px #fff7;
}
.daily-card b {
  display: block;
  font-size: 15px;
}
.daily-card small {
  display: block;
  color: #b0b9d8;
  margin-top: 4px;
  font-size: 11px;
}
.list-title {
  font-size: 11px;
  letter-spacing: 1.3px;
  color: #b7c0df;
  margin: 23px 3px 10px;
}
.mission-list,
.achievement-list {
  display: grid;
  gap: 8px;
}
.mission,
.achievement {
  display: flex;
  align-items: center;
  gap: 11px;
  border-radius: 16px;
  padding: 11px;
  background: #191c37;
  border: 1px solid #ffffff12;
}
.mission-icon,
.achievement-icon {
  width: 37px;
  height: 37px;
  flex: 0 0 37px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #ffffff0e;
  font-size: 18px;
}
.mission-body {
  flex: 1;
  min-width: 0;
}
.mission b,
.achievement b {
  font-size: 13px;
}
.mission small,
.achievement small {
  display: block;
  color: #a9b2d0;
  font-size: 10px;
  margin-top: 3px;
}
.mission-progress {
  width: 58px;
  height: 5px;
  border-radius: 9px;
  background: #3c4162;
  overflow: hidden;
}
.mission-progress i {
  display: block;
  height: 100%;
  background: var(--lime);
  border-radius: inherit;
}
.mission.done {
  border-color: #ceff6552;
}
.achievement.locked {
  opacity: 0.48;
  filter: saturate(0.2);
}
.podium {
  height: 150px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  padding: 12px;
}
.podium div {
  width: 76px;
  height: 70px;
  border-radius: 12px 12px 4px 4px;
  background: #8e91ae35;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
}
.podium .winner {
  height: 112px;
  background: linear-gradient(#d7ff6b70, #9abd3861);
}
.podium i {
  font-style: normal;
  font-size: 25px;
  font-weight: 900;
}
.podium span {
  font-size: 11px;
  color: #c7cde4;
}
.leaderboard-list {
  border-top: 1px solid #ffffff16;
  padding: 10px 14px 14px;
}
.empty-leaderboard {
  margin: 0;
  color: #aab2cf;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
}
.leader-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid #ffffff0d;
}
.leader-row b {
  width: 19px;
  color: #b5bfdf;
}
.leader-avatar {
  width: 29px;
  height: 29px;
  border-radius: 9px;
  background: #4a4e78;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 800;
}
.leader-row span {
  flex: 1;
  font-size: 13px;
}
.leader-row strong {
  font-size: 13px;
  color: var(--lime);
}
.profile-hero {
  padding: 20px 2px;
  display: flex;
  align-items: center;
  gap: 13px;
}
.profile-hero h1 {
  margin: 4px 0;
  font-size: 25px;
  letter-spacing: -1px;
}
.profile-hero p {
  margin: 0;
  color: #adb6d4;
  font-size: 12px;
}
.avatar {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 19px;
  color: #152014;
  font-weight: 950;
  background: linear-gradient(145deg, #e2ff82, #8bce39);
}
.xp-card {
  padding: 16px;
}
.xp-card > div:first-child {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.xp-card b {
  font-size: 12px;
}
.xp-track {
  height: 8px;
  border-radius: 9px;
  overflow: hidden;
  background: #10132b;
  margin-top: 11px;
}
.xp-track i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ceff65, #62e5bc);
  border-radius: inherit;
  transition: width 0.35s;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.stat-grid div {
  border: 1px solid #ffffff16;
  border-radius: 17px;
  background: #1a1d38;
  padding: 14px;
}
.stat-grid b {
  display: block;
  font-size: 25px;
  letter-spacing: -1px;
}
.stat-grid span {
  font-size: 10px;
  color: #aab2d1;
}
.playgames {
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #ffffff21;
  border-radius: 14px;
  background: #ffffff0c;
  color: #bbc4e2;
  font-size: 12px;
}
.danger-link {
  display: block;
  margin: 18px auto;
  border: 0;
  background: transparent;
  color: #ff93b4;
  font-size: 12px;
}
.modal-dismiss {
  position: absolute;
  right: 13px;
  top: 10px;
  border: 0;
  background: none;
  color: #aeb6d5;
  font-size: 25px;
}
dialog {
  position: relative;
  width: calc(100% - 34px);
  max-width: 380px;
  color: #f8f8ff;
  padding: 28px 22px 21px;
  border: 1px solid #ffffff28;
  border-radius: 24px;
  background: #202342;
  box-shadow: 0 25px 90px #0009;
}
dialog::backdrop {
  background: #07081ac4;
  backdrop-filter: blur(7px);
}
dialog h2 {
  font-size: 26px;
  line-height: 1.05;
  margin: 0 0 12px;
  letter-spacing: -1px;
}
dialog p {
  color: #bdc5e1;
  font-size: 14px;
  line-height: 1.45;
}
.final-score {
  font-size: 48px !important;
  font-weight: 900;
  color: var(--lime);
  margin: 3px 0 !important;
}
.primary,
.secondary {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 13px;
  margin-top: 8px;
  font-weight: 800;
  font-size: 14px;
}
.primary {
  color: #192311;
  background: var(--lime);
}
.secondary {
  color: #c5cce8;
  background: #ffffff11;
  border: 1px solid #ffffff24;
}
@media (min-width: 700px) {
  .app {
    padding-top: 30px;
  }
  .piece {
    height: 94px;
  }
}
@media (max-height: 720px) {
  .app {
    padding-top: 9px;
  }
  .topbar {
    margin-bottom: 5px;
  }
  .scorecard {
    padding: 12px 16px;
  }
  .scorecard strong {
    font-size: 35px;
  }
  .board-wrap {
    margin-top: 9px;
  }
  .piece {
    height: 67px;
  }
  .tray-head {
    margin-top: 11px;
  }
  .game-tools {
    height: 28px;
  }
}
@media (max-width: 430px) and (max-height: 760px) {
  .app {
    padding-bottom: calc(82px + env(safe-area-inset-bottom));
  }
  .piece {
    height: 56px;
  }
  .tray-head {
    margin-top: 8px;
  }
  .game-tools {
    min-height: 30px;
    height: auto;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation-duration: 0.01ms !important;
    transition: none !important;
  }
}

/* Keep the complete play loop above the persistent navigation on short phones and desktop windows. */
@media (max-height: 900px) {
  .app {
    padding-top: 9px;
    padding-bottom: 68px;
  }
  .topbar {
    margin-bottom: 4px;
  }
  .mode-line {
    margin: 3px 1px 6px;
  }
  .scorecard {
    padding: 10px 15px;
  }
  .scorecard strong {
    font-size: 32px;
  }
  .board-wrap {
    margin-top: 7px;
  }
  .tray-head {
    margin-top: 10px;
  }
  .piece {
    height: 62px;
  }
  .game-tools {
    height: 27px;
  }
  .tabbar {
    padding-top: 5px;
    padding-bottom: max(5px, env(safe-area-inset-bottom));
  }
}
@media (min-width: 700px) and (max-height: 900px) {
  .app {
    width: min(100%, 390px);
    padding-top: 10px;
  }
  .piece {
    height: 58px;
  }
}
@media (pointer: coarse) {
  .round {
    min-width: 40px;
    min-height: 40px;
  }
}
/* Must follow the general short-height rules: keep the whole play loop above nav. */
@media (max-width: 430px) and (max-height: 780px) {
  .app {
    padding-bottom: calc(82px + env(safe-area-inset-bottom));
  }
  .board-wrap,
  .tray-head,
  #tray,
  #gameView > .game-tools {
    width: min(100%, calc((100dvh - 390px) * 0.8));
    margin-left: auto;
    margin-right: auto;
  }
  .board-wrap {
    margin-top: 5px;
  }
  .tray-head {
    margin-top: 7px;
    margin-bottom: 6px;
  }
  .piece {
    height: 52px;
  }
  #gameView > .game-tools {
    min-height: 30px;
    height: auto;
  }
}
