:root {
  color-scheme: dark;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #080735;
}

button { font: inherit; }

.game-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: min(100vw, 540px);
  height: 100svh;
  min-height: 560px;
  margin: 0 auto;
  padding: calc(10px + var(--safe-top)) 14px calc(8px + var(--safe-bottom));
  overflow: hidden;
  isolation: isolate;
  background: #15106b url("assets/ui/game_bg.webp") center / cover no-repeat;
  box-shadow: 0 0 80px #000a;
}

.home-screen { position: absolute; inset: 0; z-index: 25; display: grid; place-items: center; overflow: hidden; padding: calc(28px + var(--safe-top)) 24px calc(22px + var(--safe-bottom)); color: white; background: radial-gradient(circle at 50% 18%, #263dc5 0, #151160 31%, transparent 54%), radial-gradient(circle at 10% 75%, #932a9c66, transparent 36%), linear-gradient(165deg, #080d35, #0d0736 72%, #16072d); transition: opacity 220ms ease, transform 220ms ease; }
.home-screen.is-hidden { opacity: 0; pointer-events: none; transform: scale(1.03); }
.home-screen::before { content: ""; position: absolute; inset: -45px; opacity: .65; background-image: radial-gradient(circle, #fff 0 1px, transparent 1.4px); background-size: 39px 39px; mask-image: linear-gradient(#fff, transparent 84%); animation: home-stars 22s linear infinite; }
.home-orbit { position: absolute; border: 1px solid #73ebff2e; border-radius: 50%; transform: rotate(-18deg); transform-origin: center; }
.orbit-one { width: 390px; height: 170px; top: 120px; animation: orbit-drift 12s ease-in-out infinite alternate; }
.orbit-two { width: 520px; height: 230px; top: 90px; border-color: #e871ff22; animation: orbit-drift-two 16s ease-in-out infinite alternate; }
.home-floating-tiles { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.float-tile { position: absolute; display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid #ffffff42; border-radius: 12px; color: #fff; font: 900 16px/1 system-ui, sans-serif; box-shadow: inset 0 1px #ffffff4d, 0 8px 20px #0007; opacity: .72; font-style: normal; }
.tile-two { left: 8%; top: 27%; background: linear-gradient(145deg, #57e792, #20ae65); animation: tile-float 5.5s ease-in-out infinite; }
.tile-four { right: 7%; top: 30%; color: #211600; background: linear-gradient(145deg, #ffe66a, #e9b91c); animation: tile-float 6.4s ease-in-out -1.7s infinite; }
.tile-eight { left: 13%; top: 66%; background: linear-gradient(145deg, #ffaa4a, #e76522); animation: tile-float 7s ease-in-out -3s infinite; }
.tile-sixteen { right: 9%; top: 69%; background: linear-gradient(145deg, #ff6a67, #d83d49); animation: tile-float 5.8s ease-in-out -2.2s infinite; }
.home-content { position: relative; z-index: 1; width: min(100%, 410px); text-align: center; }
.home-kicker { margin: 0 0 7px; color: #76efff; font-size: 10px; font-weight: 900; letter-spacing: .23em; }
.home-logo { margin: 0; color: #fff; font: 950 clamp(34px, 10vw, 49px)/.88 system-ui, sans-serif; letter-spacing: -.07em; text-shadow: 0 5px 22px #07103f, 0 0 20px #608eff55; }
.home-logo span { display: block; color: #fff48d; font-size: .55em; letter-spacing: .18em; }
.home-tagline { margin: 12px 0 22px; color: #c4ccef; font-size: 13px; }
.home-feature { display: flex; align-items: center; gap: 14px; width: min(100%, 340px); margin: 0 auto 19px; padding: 11px; border: 1px solid #9deaff30; border-radius: 20px; color: white; background: #d9f7ff0c; box-shadow: inset 0 1px #ffffff12, 0 14px 35px #03041d66; backdrop-filter: blur(12px); text-align: left; cursor: pointer; }
.home-feature:active { transform: scale(.985); background: #d9f7ff15; }
.home-feature-arrow { margin-left: auto; padding-right: 3px; color: #6feaff; font-size: 27px; font-weight: 300; }
.home-feature-art { flex: 0 0 76px; height: 76px; padding: 3px; border-radius: 18px; background: linear-gradient(145deg, #fff382, #65e6ff, #a76cff); box-shadow: 0 0 18px #65e6ff38; animation: reward-glow 3.2s ease-in-out infinite; }
.home-feature-art img { width: 100%; height: 100%; border-radius: 14px; object-fit: cover; }
.home-progress-copy { display: flex; flex-direction: column; min-width: 0; }
.home-progress-copy > span { color: #7de9f5; font-size: 8px; font-weight: 900; letter-spacing: .13em; }
.home-progress-copy strong { margin: 2px 0; font-size: 24px; }
.home-progress-copy strong b { color: #fff17b; }
.home-progress-copy small { color: #bac4e4; font-size: 10px; }
.home-collection-progress { width: 100%; height: 4px; margin-top: 7px; overflow: hidden; border-radius: 5px; background: #050a27a8; }
.home-collection-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #4ce8e7, #fff17b); box-shadow: 0 0 8px #54eaff; transition: width 500ms ease; }
.home-play { position: relative; display: grid; grid-template-columns: 45px 1fr; grid-template-rows: 1fr 1fr; width: min(100%, 340px); min-height: 70px; margin: 0 auto 12px; padding: 10px 22px; overflow: hidden; border: 0; border-radius: 22px; color: #fff; background: linear-gradient(135deg, #14d9e9, #3178ee); box-shadow: inset 0 2px #ffffff5c, 0 10px 28px #087be06b; cursor: pointer; text-align: left; }
.home-play::after { content: ""; position: absolute; top: -50%; bottom: -50%; left: -38%; width: 22%; background: linear-gradient(90deg, transparent, #ffffff55, transparent); transform: skewX(-18deg); animation: button-shine 3.8s ease-in-out infinite; }
.home-play span { grid-row: 1 / 3; align-self: center; font-size: 24px; animation: play-nudge 2.4s ease-in-out infinite; }
.home-play b { align-self: end; font-size: 21px; }
.home-play small { color: #dffcff; font-size: 10px; }
.home-play:active { transform: scale(.98); }
.home-utility { position: absolute; z-index: 7; top: calc(14px + var(--safe-top)); right: 14px; display: flex; gap: 8px; }
.home-utility button { display: grid; grid-template-rows: 26px auto; place-items: center; width: 57px; height: 52px; padding: 6px 3px 5px; border: 1px solid #bcecff4a; border-radius: 14px; color: #e8fcff; background: #142053b8; box-shadow: inset 0 1px #ffffff25, 0 7px 18px #02031d66; backdrop-filter: blur(12px); cursor: pointer; }
.home-utility button b { color: #b9c9e9; font-size: 8px; line-height: 1; letter-spacing: .02em; }
.settings-symbol { color: #8df4ff; font-size: 23px; line-height: 1; }
.sound-symbol { position: relative; width: 25px; height: 23px; }
.sound-symbol::before { content: ""; position: absolute; left: 1px; top: 7px; width: 13px; height: 11px; background: #8df4ff; clip-path: polygon(0 28%, 35% 28%, 100% 0, 100% 100%, 35% 72%, 0 72%); }
.sound-symbol::after { content: ""; position: absolute; right: 0; top: 4px; width: 9px; height: 15px; border-right: 2px solid #8df4ff; border-radius: 50%; }
.home-utility button.is-muted .sound-symbol::after { right: 3px; top: 3px; width: 2px; height: 19px; border: 0; border-radius: 0; background: #ff879a; transform: rotate(-42deg); }
.home-utility button:active { transform: scale(.93); background: #6beeff20; }
.home-settings-panel { position: absolute; z-index: 5; left: 50%; bottom: 17px; width: min(calc(100% - 10px), 354px); padding: 16px; border: 1px solid #a7eaff38; border-radius: 22px; background: #0b1238f5; box-shadow: 0 20px 55px #020316d9, inset 0 1px #ffffff1a; backdrop-filter: blur(18px); transform: translateX(-50%); transition: opacity 160ms ease, transform 160ms ease; }
.home-settings-panel.is-hidden { opacity: 0; pointer-events: none; transform: translate(-50%, 12px); }
.home-settings-head { display: flex; align-items: center; justify-content: space-between; padding: 1px 5px 12px; color: #eef9ff; font-size: 18px; }
.home-settings-head button { width: 36px; height: 36px; border: 0; border-radius: 11px; color: #b9c6df; background: #ffffff0d; font-size: 23px; cursor: pointer; }
.home-settings-panel > button { display: grid; grid-template-columns: 46px 1fr; grid-template-rows: 1fr 1fr; width: 100%; min-height: 68px; padding: 10px 9px; border: 0; border-top: 1px solid #bdeaff16; color: #eaf7ff; background: transparent; cursor: pointer; text-align: left; }
.home-settings-panel > button span { grid-row: 1 / 3; align-self: center; color: #64e8f5; font-size: 24px; text-align: center; }
.home-settings-panel > button b { align-self: end; font-size: 15px; line-height: 1.25; }
.home-settings-panel > button small { align-self: start; margin-top: 2px; color: #9ca9c6; font-size: 12px; line-height: 1.25; }
.home-settings-panel > button:hover { background: #ffffff08; }
.home-settings-panel > button.danger span, .home-settings-panel > button.danger b { color: #ff9aa9; }
.home-tip { max-width: 290px; margin: 19px auto 0; color: #929cc6; font-size: 10px; line-height: 1.4; }

@keyframes home-stars { to { transform: translate3d(39px, 39px, 0); } }
@keyframes orbit-drift { to { transform: rotate(-12deg) translateY(7px) scale(1.04); } }
@keyframes orbit-drift-two { to { transform: rotate(-23deg) translateY(-8px) scale(.97); } }
@keyframes tile-float { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-13px) rotate(4deg); } }
@keyframes reward-glow { 50% { box-shadow: 0 0 25px #65e6ff69; } }
@keyframes button-shine { 0%, 62% { left: -38%; } 88%, 100% { left: 120%; } }
@keyframes play-nudge { 0%, 70%, 100% { transform: translateX(0); } 82% { transform: translateX(4px); } }

@media (prefers-reduced-motion: reduce) {
  .home-screen::before, .home-orbit, .float-tile, .home-feature-art, .home-play::after, .home-play span { animation: none !important; }
}

.game-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, #10095e66, transparent 34%, #08052fa8 100%);
}

.topbar, .hud { position: relative; z-index: 2; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
}

.eyebrow {
  margin: 0 0 1px;
  color: #83f6ff;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .18em;
  text-shadow: 0 2px 4px #000a;
}

h1 {
  margin: 0;
  font-size: clamp(25px, 6vw, 34px);
  line-height: 1;
  color: white;
  text-shadow: 0 3px 0 #362188, 0 5px 12px #0009;
}

.top-actions { display: flex; gap: 7px; }

.image-button {
  width: 49px;
  height: 49px;
  padding: 0;
  border: 0;
  background: center / contain no-repeat;
  filter: drop-shadow(0 4px 4px #05022f99);
  cursor: pointer;
  transition: transform 100ms ease, filter 100ms ease;
}

.image-button:active { transform: scale(.9); filter: brightness(1.15); }

.hud {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 8px;
  height: 126px;
}

.goal-card, .score-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 24px 10px;
  background: center / 100% 100% no-repeat;
  filter: drop-shadow(0 5px 5px #08032b99);
}

.goal-card { background-image: url("assets/ui/goal_frame.webp"); }
.score-card { background-image: url("assets/ui/score_frame.webp"); padding-top: 10px; }
.hud-stats { display: grid; grid-template-rows: 72px 51px; min-width: 0; }
.hud-stats .goal-card { padding: 13px 22px 7px; }
.hud-stats .goal-card strong { font-size: 25px; }
.mini-stats { display: grid; grid-template-columns: 1.15fr .85fr; gap: 5px; min-width: 0; }
.mini-stats .score-card { padding: 8px 16px 5px; }
.mini-stats .score-card strong { font-size: 18px; }
.mini-stats .best-value { font-size: 7px; }
.moves-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid #58e7ff88;
  border-radius: 15px;
  background: linear-gradient(180deg, #2236a9e8, #111361ed);
  box-shadow: inset 0 1px #ffffff4f, 0 4px 8px #05012d88;
}
.moves-card strong { color: white; font-size: 19px; line-height: 1; text-shadow: 0 2px #16094f; }
.moves-card > span:last-child { color: #9cb6f4; font-size: 6px; font-weight: 900; }
.hud-label { color: #9ef7ff; font-size: 10px; font-weight: 900; letter-spacing: .14em; }
.goal-card strong { color: #fff7af; font-size: 31px; line-height: 1; text-shadow: 0 3px 0 #8d3a00; }
.score-card strong { color: white; font-size: 25px; line-height: 1.05; text-shadow: 0 2px 0 #27105e; }
.best-value { color: #ffd56a; font-size: 9px; font-weight: 900; }

.goal-meter {
  width: 66%;
  height: 5px;
  margin-top: 4px;
  overflow: hidden;
  border-radius: 8px;
  background: #050b41;
}

.goal-meter i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #19dfff, #fff573);
  box-shadow: 0 0 7px #3ef5ff;
  transition: width 350ms ease;
}

.reveal-card {
  position: relative;
  overflow: hidden;
  border: 4px solid #ffd95c;
  border-radius: 19px;
  background: #120a4e;
  box-shadow: inset 0 0 0 2px #7e49e6, 0 6px 14px #05012699;
  padding: 0;
  cursor: pointer;
}
.reveal-card img { width: 100%; height: 100%; display: block; object-fit: cover; }
.collection-caption { position: absolute; left: 6px; top: 6px; z-index: 2; padding: 3px 6px; border-radius: 8px; color: #e8fbff; background: #071126d9; font: 800 8px/1 system-ui, sans-serif; letter-spacing: .08em; }
.reveal-grid { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 2px; padding: 3px; }
.reveal-grid i {
  background: linear-gradient(145deg, #251361, #0c092f);
  box-shadow: inset 0 0 0 1px #6f4a9166;
  transition: opacity 350ms ease, transform 350ms cubic-bezier(.2, 1.5, .4, 1);
}
.reveal-grid i.is-revealed { opacity: 0; transform: scale(.25) rotate(12deg); }
.reveal-progress { position: absolute; left: 8px; right: 8px; bottom: 7px; height: 7px; overflow: hidden; border: 2px solid #8d56c8; border-radius: 8px; background: #160626; }
.reveal-progress i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #45f09a, #fff25f); box-shadow: 0 0 8px #60ffb2; transition: width 350ms ease; }
.reveal-card > span { position: absolute; right: 7px; top: 6px; padding: 2px 5px; border-radius: 7px; color: white; background: #10072dbd; font-size: 8px; font-weight: 900; }
.reveal-card:active { transform: scale(.96); }

.board-wrap {
  position: relative;
  min-height: 0;
  margin: 12px 0 2px;
  border-radius: 26px;
  touch-action: none;
  user-select: none;
}

#gameCanvas { width: 100%; height: 100%; display: block; touch-action: none; }

.chain-preview {
  position: absolute;
  left: 50%;
  top: 10px;
  min-width: 176px;
  padding: 6px 14px;
  border: 2px solid #ffffff33;
  border-radius: 999px;
  color: #e9faff;
  background: #10074cba;
  font-size: 11px;
  font-weight: 900;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
  box-shadow: 0 4px 12px #0005;
  opacity: 0;
  transition: opacity 120ms ease, transform 120ms ease;
}

.chain-preview.is-active { opacity: 1; color: #fff6a8; transform: translateX(-50%) scale(1.06); }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #08042ccc;
  backdrop-filter: blur(7px);
  transition: opacity 180ms ease;
}

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

.result-card {
  position: relative;
  width: min(100%, 390px);
  padding: 82px 28px 28px;
  border: 4px solid #ffc936;
  border-radius: 30px;
  background: radial-gradient(circle at 50% 0, #274dcc, #1b0b67 58%, #0a073e);
  box-shadow: inset 0 0 0 3px #ffef8a55, 0 18px 55px #000b;
  text-align: center;
  transform: scale(1);
  transition: transform 220ms cubic-bezier(.2, 1.4, .4, 1);
}

.is-hidden .result-card { transform: scale(.72); }
.result-ribbon { position: absolute; left: 4%; right: 4%; top: -48px; height: 125px; background: url("assets/ui/complete_ribbon.webp") center / contain no-repeat; }
.result-kicker { margin: 0; color: #7ff7ff; font-size: 11px; font-weight: 900; letter-spacing: .17em; }
.result-card h2 { margin: 4px 0 8px; color: white; font-size: 30px; text-shadow: 0 3px 0 #6a2586; }
.result-card > p:not(.result-kicker) { min-height: 40px; margin: 0 0 13px; color: #dbe7ff; font-size: 14px; line-height: 1.35; }
.result-stats { display: flex; justify-content: center; gap: 28px; margin-bottom: 12px; color: #85efff; font-size: 10px; font-weight: 900; }
.result-stats b { display: block; color: white; font-size: 22px; }

.primary-action, .secondary-action {
  display: block;
  width: 100%;
  color: white;
  font-weight: 900;
  cursor: pointer;
}

.primary-action { height: 56px; border: 0; border-radius: 17px; background: linear-gradient(135deg, #44e2ea, #3a98f3); box-shadow: inset 0 1px #ffffff70, 0 9px 24px #168bc34d; font-size: 17px; text-shadow: none; }
.secondary-action { width: max-content; height: auto; margin: 10px auto 0; padding: 7px 12px; border: 0; color: #92a1bf; background: transparent; font-size: 11px; text-decoration: underline; text-underline-offset: 3px; text-shadow: none; }
.primary-action:active, .secondary-action:active { transform: scale(.96); }
.home-action { display: none; width: 100%; min-height: 40px; margin: 5px 0; border: 1px solid #ffffff25; border-radius: 13px; color: #dbe8ff; background: #ffffff0b; font: 800 13px/1 system-ui, sans-serif; cursor: pointer; }
.overlay.game-over-mode .secondary-action { display: none; }

.completed-art-wrap {
  position: relative;
  width: 124px;
  height: 124px;
  margin: 0 auto 12px;
  padding: 4px;
  border: 3px solid #ffe271;
  border-radius: 20px;
  background: #13094c;
  box-shadow: 0 8px 20px #0007, 0 0 22px #55e8ff55;
}
.completed-art-wrap.is-hidden { display: none; }
.completed-art-wrap img { width: 100%; height: 100%; display: block; border-radius: 14px; object-fit: cover; cursor: pointer; }
.completed-art-wrap span { position: absolute; left: 50%; bottom: -8px; width: max-content; padding: 4px 9px; border-radius: 10px; color: #3c205d; background: #fff16e; font-size: 9px; font-weight: 900; transform: translateX(-50%); }

.collection-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: calc(18px + var(--safe-top)) 17px calc(18px + var(--safe-bottom));
  background: #070326e8;
  backdrop-filter: blur(8px);
  transition: opacity 180ms ease;
}
.collection-overlay.is-hidden { opacity: 0; pointer-events: none; }
.collection-panel {
  width: min(100%, 430px);
  max-height: 94%;
  padding: 22px 16px 17px;
  overflow: hidden;
  border: 3px solid #f7ce55;
  border-radius: 27px;
  background: radial-gradient(circle at 50% 0, #293cc2, #16095e 55%, #090438);
  box-shadow: inset 0 0 0 2px #7cefff33, 0 20px 50px #000a;
  text-align: center;
}
.collection-kicker { margin: 0; color: #68edff; font-size: 10px; font-weight: 900; letter-spacing: .16em; }
.collection-panel h2 { margin: 2px 0 2px; color: white; font-size: 28px; text-shadow: 0 3px #4c2187; }
.collection-panel > p:not(.collection-kicker) { margin: 0 0 12px; color: #cdd8ff; font-size: 11px; font-weight: 700; }
.collection-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-height: min(59vh, 500px);
  padding: 3px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.collection-item { position: relative; aspect-ratio: 1; overflow: hidden; border: 2px solid #ffe676; border-radius: 14px; background: #0b0632; box-shadow: 0 4px 8px #0007; }
.collection-item img { width: 100%; height: 100%; display: block; object-fit: cover; }
.collection-item span { position: absolute; left: 4px; top: 4px; display: grid; place-items: center; min-width: 23px; height: 20px; padding: 0 4px; border-radius: 7px; color: white; background: #12082ed6; font-size: 9px; font-weight: 900; }
.collection-item.is-locked { border-color: #594985; }
.collection-item.is-locked img { filter: brightness(.12) saturate(0); }
.collection-item.is-locked::after { content: "?"; position: absolute; inset: 0; display: grid; place-items: center; color: #8d80ba; font-size: 28px; font-weight: 900; }
.collection-close { width: min(100%, 240px); height: 45px; margin-top: 15px; border: 1px solid #76e8f268; border-radius: 14px; color: #c8f8ff; background: #55dce913; box-shadow: inset 0 1px #ffffff13; font-size: 13px; font-weight: 800; text-shadow: none; cursor: pointer; }
.collection-close:hover { border-color: #76e8f2a8; background: #55dce920; }
.collection-close:active { transform: scale(.97); }

.toast {
  position: absolute;
  z-index: 12;
  left: 50%;
  top: 42%;
  color: white;
  font-size: 30px;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 3px 0 #4d1b83, 0 7px 17px #000c;
  transform: translate(-50%, 16px) scale(.7);
}

.toast.show { animation: toast-pop 700ms ease-out; }
@keyframes toast-pop { 20% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -42px) scale(1); } }

.tutorial {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: calc(18px + var(--safe-top)) 20px calc(22px + var(--safe-bottom));
  background: radial-gradient(circle at 50% 48%, #2d218ddf, #09052df5 68%);
  backdrop-filter: blur(9px);
  transition: opacity 180ms ease;
}

.tutorial.is-hidden { opacity: 0; pointer-events: none; }
.tutorial-topline { display: grid; grid-template-columns: 70px 1fr 70px; align-items: center; }
.tutorial-skip { justify-self: start; padding: 8px 2px; border: 0; color: #b8c7ef; background: transparent; font-size: 13px; font-weight: 900; cursor: pointer; }
#tutorialCount { justify-self: end; color: #91eaff; font-size: 12px; font-weight: 900; }
.tutorial-steps { display: flex; justify-content: center; gap: 7px; }
.tutorial-steps i { width: 8px; height: 8px; border-radius: 10px; background: #ffffff33; transition: width 180ms ease, background 180ms ease; }
.tutorial-steps i.is-current { width: 25px; background: #4deaff; box-shadow: 0 0 9px #4deaff; }

.tutorial-content { align-self: center; text-align: center; }
.tutorial-kicker { margin: 0 0 4px; color: #5aeeff; font-size: 11px; font-weight: 900; letter-spacing: .17em; }
.tutorial-content h2 { margin: 0; color: white; font-size: clamp(27px, 8vw, 40px); line-height: 1.08; text-shadow: 0 3px 0 #4b228b; }
.tutorial-content > p:not(.tutorial-kicker) { margin: 8px 0 16px; color: #dbe7ff; font-size: 14px; font-weight: 700; }

.tutorial-demo {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 400px);
  height: 285px;
  margin: 0 auto 16px;
  overflow: hidden;
  border: 3px solid #6c5fe8;
  border-radius: 30px;
  background: radial-gradient(circle, #2d2591, #100848 72%);
  box-shadow: inset 0 0 34px #24cfff22, 0 15px 35px #02011788;
}

.demo-goal {
  position: absolute;
  top: 15px;
  left: 50%;
  display: flex;
  flex-direction: column;
  width: 72px;
  height: 61px;
  align-items: center;
  justify-content: center;
  background: url("assets/ui/score_frame.webp") center / 100% 100% no-repeat;
}

.demo-goal small { color: #9beaff; font-size: 8px; font-weight: 900; }
.demo-goal b { color: white; font-size: 22px; line-height: 1; }
.demo-row { display: flex; align-items: center; gap: 13px; margin-top: 42px; }
.demo-tile, .demo-result {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border: 3px solid #ffffff99;
  border-radius: 21px;
  color: white;
  font-size: 34px;
  font-weight: 900;
  box-shadow: inset 0 8px #ffffff2e, 0 8px 0 #06669f, 0 13px 20px #0007;
}
.value-2 { background: linear-gradient(#3de8ff, #0784ce); }
.demo-link { color: #8cf5ff; font-size: 28px; font-weight: 900; }
.demo-result { display: none; background: linear-gradient(#74f7a5, #11a866); box-shadow: inset 0 8px #ffffff2e, 0 8px 0 #087445, 0 13px 20px #0007; }

.tutorial-hand {
  position: absolute;
  left: calc(50% - 112px);
  top: 119px;
  width: 112px;
  height: 122px;
  background: url("assets/ui/tutorial_hand.webp") center / contain no-repeat;
  filter: drop-shadow(0 5px 8px #0008);
  animation: tutorial-drag 1.6s ease-in-out infinite;
}

@keyframes tutorial-drag {
  0%, 18% { transform: translateX(0) scale(.88); }
  60%, 82% { transform: translateX(101px) scale(.96); }
  100% { transform: translateX(0) scale(.88); }
}

.tutorial-demo.step-two .demo-link { display: none; }
.tutorial-demo.step-two .demo-tile:nth-child(3) { animation: merge-right 1.6s ease-in-out infinite; }
.tutorial-demo.step-two .demo-tile:first-child { animation: merge-left 1.6s ease-in-out infinite; }
.tutorial-demo.step-two .demo-result { display: grid; animation: result-pop 1.6s ease-in-out infinite; }
.tutorial-demo.step-two .tutorial-hand { display: none; }
@keyframes merge-left { 0%, 18% { transform: translateX(0); opacity: 1; } 55%, 100% { transform: translateX(48px) scale(.4); opacity: 0; } }
@keyframes merge-right { 0%, 18% { transform: translateX(0); opacity: 1; } 55%, 100% { transform: translateX(-48px) scale(.4); opacity: 0; } }
@keyframes result-pop { 0%, 47% { transform: scale(0); opacity: 0; } 65%, 100% { transform: scale(1); opacity: 1; } }

.tutorial-demo.step-three .demo-row { gap: 7px; }
.tutorial-demo.step-three .demo-link { display: none; }
.tutorial-demo.step-three .demo-tile, .tutorial-demo.step-three .demo-result { display: grid; width: 57px; height: 57px; border-radius: 16px; font-size: 23px; }
.tutorial-demo.step-three .demo-tile:nth-child(3) { background: linear-gradient(#ffe55b, #e99f12); }
.tutorial-demo.step-three .demo-tile:nth-child(3) { font-size: 0; }
.tutorial-demo.step-three .demo-tile:nth-child(3)::after { content: "4"; font-size: 23px; }
.tutorial-demo.step-three .demo-result { background: linear-gradient(#ff6cb2, #c82999); font-size: 0; }
.tutorial-demo.step-three .demo-result::after { content: "8"; font-size: 23px; }
.tutorial-demo.step-three .tutorial-hand { left: calc(50% - 125px); top: 130px; width: 86px; height: 94px; animation-name: tutorial-chain; }
@keyframes tutorial-chain { 0%, 15% { transform: translateX(0); } 75%, 90% { transform: translateX(180px); } 100% { transform: translateX(0); } }

.tutorial-tip { display: flex; align-items: center; justify-content: center; gap: 8px; color: #dbe7ff; font-size: 12px; font-weight: 700; }
.tutorial-tip b { padding: 4px 7px; border-radius: 7px; color: #1f1254; background: #fff078; font-size: 9px; }
.tutorial-next {
  justify-self: center;
  width: min(100%, 340px);
  height: 56px;
  border: 0;
  border-radius: 17px;
  color: white;
  background: linear-gradient(135deg, #44e2ea, #3a98f3);
  box-shadow: inset 0 1px #ffffff70, 0 9px 24px #168bc34d;
  font-size: 17px;
  font-weight: 900;
  text-shadow: none;
  cursor: pointer;
  transition: transform 100ms ease, filter 100ms ease;
}
.tutorial-next:hover { filter: brightness(1.06); }
.tutorial-next:active { transform: scale(.96); }

@media (min-aspect-ratio: 3/4) {
  .game-shell { width: min(100vw, 470px); }
  .topbar { min-height: 52px; }
  .hud { height: 112px; grid-template-columns: 103px 1fr; }
  .hud-stats { grid-template-rows: 64px 45px; }
  .image-button { width: 43px; height: 43px; }
}

@media (max-height: 650px) {
  .game-shell { padding-top: 5px; }
  .topbar { min-height: 47px; }
  .hud { height: 104px; grid-template-columns: 96px 1fr; }
  .hud-stats { grid-template-rows: 59px 42px; }
  .goal-card strong { font-size: 25px; }
  .score-card strong { font-size: 21px; }
  .tutorial-demo { height: 230px; margin-bottom: 8px; }
  .tutorial-content > p:not(.tutorial-kicker) { margin: 4px 0 7px; }
}

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

/* Sleek space UI — one quiet visual language for every gameplay control. */
.game-shell {
  background-color: #070a22;
  background-position: center;
}

.game-shell::before {
  background:
    linear-gradient(180deg, #06091bd9 0%, #090d27bd 33%, #080b22e8 100%),
    radial-gradient(circle at 50% 28%, #334ac733, transparent 46%);
}

.topbar { min-height: 58px; }
.eyebrow { color: #6ee7ef; text-shadow: none; opacity: .82; }
h1 { font-size: clamp(24px, 5.7vw, 31px); font-weight: 800; text-shadow: none; letter-spacing: -.03em; }
.top-actions { gap: 6px; }

.image-button {
  position: relative;
  width: 39px;
  height: 39px;
  overflow: hidden;
  border: 1px solid #b9e7ff2e;
  border-radius: 13px;
  color: #eefaff;
  background: #dbeeff12 !important;
  box-shadow: inset 0 1px #ffffff18, 0 5px 14px #00000029;
  filter: none;
  backdrop-filter: blur(12px);
}

.image-button::before {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 800 19px/1 system-ui, sans-serif;
}
.pause-button::before {
  content: "";
  width: 13px;
  height: 17px;
  margin: auto;
  background: linear-gradient(90deg, #eefaff 0 35%, transparent 35% 65%, #eefaff 65%);
}
.image-button:active { background: #67dff52c !important; }

.hud {
  grid-template-columns: 106px 1fr;
  height: 116px;
  gap: 8px;
}

.reveal-card {
  border: 1px solid #9eeeff42;
  border-radius: 17px;
  background: #0b102bc7;
  box-shadow: inset 0 1px #ffffff1a, 0 7px 18px #00000038;
  backdrop-filter: blur(14px);
}
.reveal-grid { gap: 1px; padding: 2px; }
.reveal-grid i { background: linear-gradient(145deg, #171c3df7, #0a0e27f7); box-shadow: inset 0 0 0 1px #9addec12; }
.reveal-progress { left: 7px; right: 7px; bottom: 6px; height: 5px; border: 0; background: #030615b8; }
.reveal-progress i { background: linear-gradient(90deg, #43e3c2, #7bcaf8); box-shadow: none; }
.reveal-card > span { color: #c8f6ff; background: #070b20b8; font-weight: 700; }

.hud-stats { grid-template-rows: 67px 46px; gap: 4px; }
.goal-card, .score-card, .moves-card {
  border: 1px solid #b9e7ff26;
  border-radius: 15px;
  background: #dbeeff10;
  box-shadow: inset 0 1px #ffffff16, 0 5px 14px #00000024;
  filter: none;
  backdrop-filter: blur(12px);
}
.hud-stats .goal-card { padding: 7px 18px 6px; }
.hud-label { color: #7edce8; font-size: 9px; font-weight: 700; letter-spacing: .14em; }
.hud-stats .goal-card strong { color: #fff; font-size: 29px; text-shadow: none; letter-spacing: -.03em; }
.goal-meter { width: 70%; height: 3px; margin-top: 3px; background: #0306178f; }
.goal-meter i { background: linear-gradient(90deg, #48e0bd, #73c8ff); box-shadow: none; }
.mini-stats { gap: 4px; }
.mini-stats .score-card { padding: 5px 12px 3px; }
.mini-stats .score-card strong, .moves-card strong { color: #fff; font-size: 17px; text-shadow: none; }
.mini-stats .best-value, .moves-card > span:last-child { color: #8f9fc8; }

.board-wrap { margin-top: 12px; }
.chain-preview {
  top: 7px;
  min-width: 166px;
  padding: 5px 12px;
  border: 1px solid #c7edff22;
  color: #c9d6f2;
  background: #090e27c7;
  box-shadow: 0 5px 16px #0003;
  font-weight: 700;
  backdrop-filter: blur(10px);
}

.result-card, .collection-panel {
  border: 1px solid #bcecff35;
  background: linear-gradient(180deg, #17204bea, #090d27f7);
  box-shadow: inset 0 1px #ffffff1f, 0 20px 50px #0009;
}
.collection-item { border: 1px solid #a9e6f055; box-shadow: 0 4px 10px #0004; }
.collection-item.is-locked { border-color: #7180a62e; }

/* Pause has its own restrained hierarchy; reward decoration stays exclusive to wins. */
.overlay.pause-mode {
  background: #02040fb5;
  backdrop-filter: blur(10px) saturate(.72);
}
.overlay.pause-mode .result-card {
  width: min(100%, 330px);
  padding: 28px 22px 19px;
  border: 1px solid #74dff34a;
  border-radius: 24px;
  background: linear-gradient(180deg, #151d3df2, #090d24f5);
  box-shadow: inset 0 1px #ffffff1c, 0 24px 70px #000b, 0 0 32px #3bdaf218;
}
.overlay.pause-mode .result-ribbon { display: none; }
.overlay.pause-mode .result-kicker {
  color: #5ce2e8;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .2em;
}
.overlay.pause-mode .result-card h2 {
  margin: 7px 0 5px;
  color: #f5fbff;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.03em;
  text-shadow: none;
}
.overlay.pause-mode .result-card > p:not(.result-kicker) {
  min-height: 0;
  margin: 0 0 17px;
  color: #8894af;
  font-size: 13px;
}
.overlay.pause-mode .result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin-bottom: 16px;
  padding: 10px 0;
  border-top: 1px solid #b9e7ff18;
  border-bottom: 1px solid #b9e7ff18;
  color: #7895af;
}
.overlay.pause-mode .result-stats span {
  padding: 2px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.overlay.pause-mode .result-stats span + span { border-left: 1px solid #b9e7ff1b; }
.overlay.pause-mode .result-stats b {
  margin-top: 2px;
  color: #f4fbff;
  font-size: 20px;
  font-weight: 750;
}
.overlay.pause-mode .primary-action,
.overlay.pause-mode .secondary-action {
  height: 53px;
  border-radius: 15px;
  background-image: none;
  box-shadow: none;
  text-shadow: none;
  font-size: 15px;
  letter-spacing: .01em;
}
.overlay.pause-mode .primary-action {
  color: #061421;
  background: linear-gradient(135deg, #51e3ea, #57baf4);
  box-shadow: 0 8px 22px #31badb2e;
}
.overlay.pause-mode .secondary-action {
  width: 100%;
  height: 47px;
  margin-top: 9px;
  border: 1px solid #a884eb72;
  color: #cbbaf5;
  background: #9b6be810;
}
.overlay.pause-mode .home-action {
  display: block;
  min-height: 30px;
  margin: 8px 0 0;
  border: 0;
  border-radius: 8px;
  color: #8190ae;
  background: transparent;
  font-size: 11px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.overlay.pause-mode .home-action:hover { color: #b9c8e5; background: #ffffff08; }
.overlay.pause-mode .primary-action:hover { filter: brightness(1.06); }
.overlay.pause-mode .secondary-action:hover { border-color: #bca2f0a6; background: #9b6be819; }

@media (min-aspect-ratio: 3/4) {
  .hud { height: 108px; grid-template-columns: 98px 1fr; }
  .hud-stats { grid-template-rows: 62px 43px; }
}

@media (max-height: 650px) {
  .hud { height: 100px; grid-template-columns: 91px 1fr; }
  .hud-stats { grid-template-rows: 56px 41px; }
}
