:root {
  --bg: #0f1224;
  --text: #eef0ff;
  --muted: #a3a8c9;
  --line: #2b3157;
  --header-h: 48px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a {
  color: #ffd166;
}

button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

[hidden] {
  display: none !important;
}

svg {
  display: block;
  width: 100%;
  height: 100%;
}

.page {
  padding: 12px 10px 40px;
}

/* ---------- Themes ---------- */

.game-root,
.theme-classic {
  /* classic */
  --panel: #171b36;
  --panel-2: #20264a;
  --edge: #323a6e;
  --ink: #eef0ff;
  --ink-muted: #a3a8c9;
  --accent: #ffd166;
  --accent-2: #ef8354;
  --good: #06d6a0;
  --bad: #ff5d73;
  --tile-a: #fff6e0;
  --tile-b: #f3dfb4;
  --tile-edge: #c9a664;
  --tile-ink: #2a2140;
  --tile-made-a: #ffe3a3;
  --tile-made-b: #f7c56b;
  --op-a: #5b6cff;
  --op-b: #3f4bd1;
  --bg-a: #1a1f40;
  --bg-b: #10132a;
  --pattern: radial-gradient(circle at 20% 10%, #ffffff0a 0 1.5px, transparent 2px) 0 0 / 26px 26px;
  --tile-font: 800;
  --tile-radius: 16px;
  --on-accent: #2a2140;
  --tile-shadow: 0 5px 0 var(--tile-edge), 0 10px 18px #0006;
}

.theme-chalk {
  --panel: #1f3a2e;
  --panel-2: #274a3a;
  --edge: #3f6b55;
  --accent: #f6f1d5;
  --accent-2: #f4a6a6;
  --good: #b6f09c;
  --tile-a: #33554a;
  --tile-b: #2b4a40;
  --tile-edge: #1a2f28;
  --tile-ink: #fbfbf0;
  --tile-made-a: #4a6f5e;
  --tile-made-b: #3b5e4e;
  --op-a: #e8e4c9;
  --op-b: #bdb89a;
  --bg-a: #22453a;
  --bg-b: #172e27;
  --pattern: repeating-linear-gradient(-20deg, #ffffff05 0 2px, transparent 2px 9px);
  --on-accent: #1f3a2e;
  --tile-font: 700;
}
.theme-chalk .op {
  color: #1f3a2e;
}
.theme-chalk .tile {
  border: 2px dashed #ffffff40;
}

.theme-ocean {
  --panel: #0c2f47;
  --panel-2: #0f3d5c;
  --edge: #1d5b85;
  --accent: #7ee3ff;
  --accent-2: #ffb86b;
  --good: #7dffc4;
  --tile-a: #e6fbff;
  --tile-b: #a9e7f6;
  --tile-edge: #3a8fb5;
  --tile-ink: #07314a;
  --tile-made-a: #b9f5e0;
  --tile-made-b: #6fdcc0;
  --op-a: #1fb3d6;
  --op-b: #11799a;
  --bg-a: #0c3350;
  --bg-b: #061b2c;
  --pattern: radial-gradient(ellipse at 50% 120%, #7ee3ff14 0 30%, transparent 31%) 0 0 / 60px 30px;
}

.theme-neon {
  --panel: #120b24;
  --panel-2: #1b1036;
  --edge: #3c1f73;
  --accent: #39ff9f;
  --accent-2: #ff3fd4;
  --good: #39ff9f;
  --tile-a: #1a0f33;
  --tile-b: #140a28;
  --tile-edge: #ff3fd4;
  --tile-ink: #7df9ff;
  --tile-made-a: #251146;
  --tile-made-b: #1c0c38;
  --op-a: #ff3fd4;
  --op-b: #a3198a;
  --bg-a: #150b2c;
  --bg-b: #07040f;
  --pattern: linear-gradient(#ff3fd40d 1px, transparent 1px) 0 0 / 22px 22px, linear-gradient(90deg, #7df9ff0d 1px, transparent 1px) 0 0 / 22px 22px;
  --tile-shadow: 0 0 0 2px var(--tile-edge), 0 0 18px #ff3fd466, inset 0 0 14px #7df9ff22;
  --on-accent: #120b24;
}
.theme-neon .tile .v {
  text-shadow: 0 0 10px currentColor;
}

.theme-candy {
  --panel: #3b1740;
  --panel-2: #4d1f54;
  --edge: #7a3584;
  --accent: #ffd6f5;
  --accent-2: #ffe066;
  --good: #9bffb0;
  --tile-a: #ffc2e2;
  --tile-b: #ff8fc8;
  --tile-edge: #d45796;
  --tile-ink: #5a0f3f;
  --tile-made-a: #c8f7ff;
  --tile-made-b: #84e3ff;
  --op-a: #ff6fb5;
  --op-b: #d43d8b;
  --bg-a: #4a1a52;
  --bg-b: #26092b;
  --pattern: repeating-linear-gradient(45deg, #ffffff08 0 10px, transparent 10px 20px);
  --tile-radius: 22px;
}

.theme-walnut {
  --panel: #2c1c12;
  --panel-2: #3a2618;
  --edge: #5c3d25;
  --accent: #f2c38b;
  --accent-2: #d9814a;
  --good: #b8e07a;
  --tile-a: #d9a066;
  --tile-b: #b8773f;
  --tile-edge: #6e4322;
  --tile-ink: #2a160a;
  --tile-made-a: #f0c690;
  --tile-made-b: #cf9458;
  --op-a: #8a5a33;
  --op-b: #5e3a1e;
  --bg-a: #3a2618;
  --bg-b: #1c110a;
  --pattern: repeating-linear-gradient(92deg, #ffffff06 0 3px, transparent 3px 11px, #00000010 11px 13px, transparent 13px 23px);
  --tile-radius: 10px;
}
.theme-walnut .tile {
  background-image: repeating-linear-gradient(88deg, #0000 0 6px, #5a320f1c 6px 8px, #0000 8px 15px), linear-gradient(160deg, var(--tile-a), var(--tile-b));
}

.theme-gilded {
  --panel: #1b1710;
  --panel-2: #262015;
  --edge: #5a4a24;
  --accent: #ffd86b;
  --accent-2: #fff3c4;
  --good: #ffe08a;
  --tile-a: #fff0b8;
  --tile-b: #d9a82e;
  --tile-edge: #8a6412;
  --tile-ink: #3a2a05;
  --tile-made-a: #fffbe8;
  --tile-made-b: #f0cf6a;
  --op-a: #2c2415;
  --op-b: #16110a;
  --bg-a: #231d12;
  --bg-b: #0e0b06;
  --pattern: radial-gradient(circle at 50% 50%, #ffd86b10 0 1px, transparent 1.5px) 0 0 / 14px 14px;
}
.theme-gilded .op {
  color: #ffd86b;
  box-shadow: 0 0 0 2px #ffd86b88, 0 4px 0 #000;
}
.theme-gilded .tile::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(115deg, transparent 30%, #ffffff66 45%, transparent 60%);
  background-size: 250% 100%;
  animation: shine 3.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes shine {
  0% {
    background-position: 120% 0;
  }
  60%,
  100% {
    background-position: -120% 0;
  }
}

/* ---------- Layout ---------- */

.game-root {
  position: relative;
  margin: 0 auto;
  max-width: 540px;
  min-height: 560px;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--edge);
  background: var(--pattern), linear-gradient(180deg, var(--bg-a), var(--bg-b));
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  padding: 14px 14px 16px;
}

.screen {
  position: relative;
  z-index: 1;
}

.fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.icon-btn {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  border: 1px solid var(--edge);
  background: var(--panel);
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  padding: 9px;
  color: var(--ink);
}

.icon-btn:hover {
  background: var(--panel-2);
}

/* ---------- Home ---------- */

.home-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.icon-row {
  display: flex;
  gap: 8px;
}

.logo {
  display: flex;
  gap: 5px;
}

.logo span {
  width: 38px;
  height: 44px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 26px;
  border-radius: 10px;
  color: var(--tile-ink);
  background: linear-gradient(160deg, var(--tile-a), var(--tile-b));
  box-shadow: 0 4px 0 var(--tile-edge), 0 8px 14px #0005;
  animation: bob 3s ease-in-out infinite;
}
.logo span:nth-child(2) {
  animation-delay: 0.12s;
}
.logo span:nth-child(3) {
  animation-delay: 0.24s;
  background: linear-gradient(160deg, var(--tile-made-a), var(--tile-made-b));
}
.logo span:nth-child(4) {
  animation-delay: 0.36s;
}
.logo span:nth-child(5) {
  animation-delay: 0.48s;
}
.logo span:nth-child(6) {
  animation-delay: 0.6s;
  background: linear-gradient(160deg, var(--op-a), var(--op-b));
  color: #fff;
}
@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

.level-card {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 16px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.lv-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lv-badge {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  font-weight: 900;
  font-size: 20px;
  line-height: 1;
  color: var(--tile-ink);
  background: radial-gradient(circle at 35% 30%, var(--tile-a), var(--accent));
  box-shadow: 0 0 0 3px var(--panel-2), 0 0 0 5px var(--accent);
}

.lv-badge small {
  font-size: 9px;
  letter-spacing: 1px;
  opacity: 0.8;
}

.lv-main {
  flex: 1;
  min-width: 0;
}

.lv-text {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.lv-next {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar {
  height: 10px;
  border-radius: 6px;
  background: var(--panel-2);
  overflow: hidden;
  box-shadow: inset 0 1px 3px #0006;
}

.bar-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 1.1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.streak {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 48px;
  color: var(--ink-muted);
}

.streak .flame {
  width: 26px;
  height: 26px;
  opacity: 0.45;
}

.streak.live .flame {
  color: #ff8a3d;
  opacity: 1;
  filter: drop-shadow(0 0 6px #ff8a3d88);
  animation: flicker 1.6s ease-in-out infinite;
}

.streak b {
  font-size: 16px;
  color: var(--ink);
  line-height: 1.1;
}

.frzs {
  display: flex;
  gap: 2px;
  margin-top: 2px;
}

.frz {
  width: 12px;
  height: 12px;
  opacity: 0.25;
}

.frz.on {
  opacity: 1;
  color: #8fd8ff;
}

@keyframes flicker {
  0%,
  100% {
    transform: scale(1) rotate(-2deg);
  }
  50% {
    transform: scale(1.08) rotate(2deg);
  }
}

.mode-cards {
  display: grid;
  gap: 10px;
}

.mode-card {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: 1px solid var(--edge);
  border-radius: 16px;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--panel-2), var(--panel));
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 4px 0 #0005;
}

.mode-card:hover {
  transform: translateY(-1px);
}

.mode-card:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0005;
}

.mode-card.daily {
  border-color: var(--accent);
  box-shadow: 0 4px 0 #0005, 0 0 0 1px var(--accent), 0 0 24px color-mix(in srgb, var(--accent) 25%, transparent);
  padding: 16px 14px;
}

.mc-ico {
  width: 42px;
  height: 42px;
  flex: none;
  padding: 9px;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--op-a), var(--op-b));
  color: #fff;
}

.daily .mc-ico {
  background: linear-gradient(160deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
}

.rush .mc-ico {
  background: linear-gradient(160deg, #ffcf5c, #ff8a3d);
  color: #3b1d00;
}

.mc-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.mc-title {
  font-weight: 800;
  font-size: 18px;
}

.daily .mc-title {
  font-size: 21px;
}

.small {
  font-size: 13px;
  color: var(--ink-muted);
}

.small b {
  color: var(--ink);
}

.freeze-prog {
  font-size: 12px;
}

.cta {
  flex: none;
  font-weight: 800;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  align-self: center;
}

.mode-card .mc-body .cta {
  align-self: flex-start;
  margin-top: 4px;
}

.stars {
  display: flex;
  gap: 2px;
}

.st {
  width: 22px;
  height: 22px;
  color: #ffffff26;
  display: inline-block;
}

.st.on {
  color: #ffd23f;
  filter: drop-shadow(0 0 4px #ffd23f88);
}

.missions {
  margin-top: 12px;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 16px;
  padding: 10px 12px;
  font-size: 14px;
}

.ms-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.ms {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.ms .ck {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid var(--edge);
  flex: none;
  padding: 1px;
}

.ms.done .ck {
  background: var(--good);
  border-color: var(--good);
  color: #062b1f;
}

.ms.done span:nth-child(2) {
  text-decoration: line-through;
  color: var(--ink-muted);
}

.ms .xp,
.xp {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.home-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: 14px;
  border: 1px solid var(--edge);
  background: var(--panel);
  font-size: 12px;
  font-weight: 600;
}

.nav-btn .ico {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.net-note {
  margin: 12px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-muted);
}

/* ---------- Play ---------- */

.play-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.play-title {
  flex: 1;
  font-weight: 800;
  font-size: 18px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.play-title .sub {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.clock {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 18px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--edge);
  min-width: 64px;
  text-align: center;
}

.clock.low {
  color: #fff;
  background: var(--bad);
  animation: pulse 0.5s ease-in-out infinite alternate;
}

@keyframes pulse {
  to {
    transform: scale(1.06);
  }
}

.rush-bar {
  margin-top: 10px;
}

.rush-time {
  height: 8px;
  border-radius: 6px;
  background: var(--panel-2);
  overflow: hidden;
}

.rush-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffcf5c, #ff8a3d);
  transition: width 0.2s linear;
}

.rush-fill.low {
  background: linear-gradient(90deg, var(--bad), #ff8a3d);
}

.rush-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  font-weight: 800;
}

.rush-stats .pts {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.rush-stats .pts::after {
  content: ' pts';
  font-size: 12px;
  color: var(--ink-muted);
}

.rush-stats .combo {
  display: flex;
  align-items: center;
  gap: 2px;
  color: #ff8a3d;
}

.rush-stats .combo .flame {
  width: 20px;
  height: 20px;
}

.rush-stats .combo.hot {
  animation: flicker 0.8s ease-in-out infinite;
  color: #ffcf5c;
}

.rush-stats .nth {
  margin-left: auto;
  font-size: 13px;
  color: var(--ink-muted);
}

.banner {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent-2) 22%, var(--panel));
  border: 1px solid var(--accent-2);
  font-size: 14px;
  text-align: center;
}

.target-wrap {
  text-align: center;
  margin: 12px 0 10px;
}

.target {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 30px 8px;
  border-radius: 18px;
  background: var(--panel);
  border: 2px solid var(--edge);
  box-shadow: inset 0 2px 10px #0005;
  min-width: 190px;
}

.target .label {
  font-size: 11px;
  letter-spacing: 3px;
  font-weight: 800;
  color: var(--ink-muted);
}

.target .num {
  font-size: 58px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-shadow: 0 3px 0 #0006;
  letter-spacing: 2px;
}

.target.golden {
  border-color: #ffd23f;
  background: radial-gradient(ellipse at 50% 0%, #ffd23f33, var(--panel) 70%);
  box-shadow: 0 0 26px #ffd23f55, inset 0 2px 10px #0005;
}

.target.golden .num {
  color: #ffd23f;
  text-shadow: 0 0 14px #ffd23faa, 0 3px 0 #0006;
}

.target.golden .label {
  color: #ffd23f;
}

.target.pop {
  animation: tpop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1);
}

@keyframes tpop {
  from {
    transform: scale(0.7);
    opacity: 0.2;
  }
}

.meta-line {
  margin-top: 8px;
  font-size: 14px;
  color: var(--ink-muted);
  min-height: 20px;
}

.meta-line b {
  color: var(--ink);
}
.meta-line .good {
  color: var(--good);
}
.meta-line .ok {
  color: var(--accent);
}

.board {
  --gap: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gap);
  margin: 6px auto 0;
  max-width: 420px;
}

.board[data-n='7'] {
  max-width: 500px;
  --gap: 8px;
}

.slot {
  width: calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols));
  aspect-ratio: 5 / 4;
  max-height: 104px;
}

.board[data-n='4'] .slot {
  aspect-ratio: 2 / 1;
}

.slot.empty {
  border-radius: var(--tile-radius);
  border: 2px dashed color-mix(in srgb, var(--ink-muted) 25%, transparent);
}

.tile {
  position: relative;
  width: 100%;
  height: calc(100% - 5px);
  border: 0;
  border-radius: var(--tile-radius);
  background: linear-gradient(160deg, var(--tile-a), var(--tile-b));
  color: var(--tile-ink);
  box-shadow: var(--tile-shadow);
  display: grid;
  place-items: center;
  padding: 0;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.tile .v {
  font-weight: var(--tile-font);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.tile.d1 .v,
.tile.d2 .v {
  font-size: clamp(28px, 9vw, 40px);
}
.tile.d3 .v {
  font-size: clamp(26px, 8vw, 36px);
}
.tile.d4 .v {
  font-size: clamp(22px, 6.5vw, 30px);
}
.tile.d5 .v {
  font-size: clamp(18px, 5.2vw, 25px);
}

.tile.made {
  background: linear-gradient(160deg, var(--tile-made-a), var(--tile-made-b));
}

.tile .from {
  position: absolute;
  bottom: 5px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.6;
}

.tile:hover {
  transform: translateY(-1px);
}

.tile:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--tile-edge), 0 4px 8px #0006;
}

.tile.sel {
  transform: translateY(-4px) scale(1.04);
  box-shadow: 0 0 0 3px var(--accent), 0 0 0 6px color-mix(in srgb, var(--accent) 35%, transparent), 0 9px 0 var(--tile-edge), 0 14px 22px #0008;
}

.tile.near {
  box-shadow: var(--tile-shadow), 0 0 16px color-mix(in srgb, var(--good) 70%, transparent);
}

.tile.hit {
  background: linear-gradient(160deg, #d9fff0, var(--good));
  color: #043b2a;
  box-shadow: 0 5px 0 #03966f, 0 0 30px var(--good);
  animation: hit 0.9s ease-in-out infinite alternate;
}

@keyframes hit {
  to {
    transform: scale(1.06);
  }
}

.tile.bonus {
  background: linear-gradient(160deg, #fff4c2, #ffcf5c);
  color: #4a3000;
  box-shadow: 0 5px 0 #b8860b, 0 0 18px #ffcf5c88;
}

.tile .ribbon {
  position: absolute;
  top: -7px;
  right: -6px;
  font-size: 11px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 8px;
  background: #ff5d73;
  color: #fff;
  box-shadow: 0 2px 0 #0005;
}

.tile.pop {
  animation: pop 0.38s cubic-bezier(0.3, 1.8, 0.5, 1);
}

@keyframes pop {
  from {
    transform: scale(0.55);
  }
}

.tile.ghost {
  position: absolute;
  z-index: 4;
  pointer-events: none;
}

.shake {
  animation: shake 0.35s ease;
}

@keyframes shake {
  20% {
    transform: translateX(-7px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(2px);
  }
}

.shake-screen .screen {
  animation: sshake 0.3s ease;
}

@keyframes sshake {
  25% {
    transform: translate(3px, -2px);
  }
  50% {
    transform: translate(-3px, 2px);
  }
  75% {
    transform: translate(2px, 1px);
  }
}

.ops {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 16px 0 4px;
}

.op {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  background: linear-gradient(160deg, var(--op-a), var(--op-b));
  box-shadow: 0 4px 0 #0007, inset 0 2px 0 #ffffff33;
  transition: transform 0.1s ease;
  display: grid;
  place-items: center;
  padding: 0 0 3px;
}

.op:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #0007;
}

.op.sel {
  transform: translateY(-3px) scale(1.08);
  background: linear-gradient(160deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  box-shadow: 0 0 0 3px #fff, 0 6px 0 #0007, 0 0 20px var(--accent);
}

.msg {
  min-height: 24px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  margin: 6px 0;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.msg.show {
  opacity: 1;
}

.msg.bad {
  color: var(--bad);
}

.msg.near {
  color: var(--good);
}

.msg.gold {
  color: #ffd23f;
}

.msg.info {
  color: var(--ink-muted);
}

.actions {
  display: flex;
  gap: 10px;
}

.act {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid var(--edge);
  background: var(--panel);
  font-weight: 700;
  font-size: 15px;
}

.act .ico {
  width: 18px;
  height: 18px;
}

.act:disabled {
  opacity: 0.45;
}

.act.primary {
  flex: 1.4;
  background: linear-gradient(160deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  border: 0;
  box-shadow: 0 4px 0 #0006;
  font-weight: 800;
}

.act.primary.armed {
  background: linear-gradient(160deg, #ff8fa0, var(--bad));
  color: #fff;
  box-shadow: 0 4px 0 #0006, 0 0 0 3px #ff5d7355;
}

.log {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 0;
  margin: 12px 0 0;
  min-height: 26px;
}

.log li {
  font-size: 13px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--edge);
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.log li b {
  color: var(--ink);
}

/* ---------- Overlay / modals ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.overlay.dim {
  background: rgba(8, 10, 22, 0.78);
  background: color-mix(in srgb, var(--bg-b) 82%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.modal {
  width: 100%;
  max-width: 460px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--edge);
  border-radius: 20px;
  padding: 18px 16px;
  box-shadow: 0 20px 50px #000a;
  animation: rise 0.3s cubic-bezier(0.2, 1.3, 0.5, 1);
  margin: auto 0;
}

@keyframes rise {
  from {
    transform: translateY(24px) scale(0.96);
    opacity: 0;
  }
}

.modal h2 {
  margin: 2px 0 8px;
  font-size: 26px;
  text-align: center;
}

.r-kicker {
  text-align: center;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 700;
}

.big-stars {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 4px 0 12px;
}

.big-stars .st {
  width: 46px;
  height: 46px;
}

.big-stars .st.in {
  animation: starin 0.45s cubic-bezier(0.3, 1.8, 0.5, 1);
}

@keyframes starin {
  from {
    transform: scale(0.2) rotate(-40deg);
  }
}

.pts-big {
  font-size: 46px !important;
  color: var(--accent);
}

.pts-big small {
  font-size: 16px;
  color: var(--ink-muted);
}

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

.r-stats.four {
  grid-template-columns: repeat(4, 1fr);
}

.cell {
  background: var(--bg-b);
  border-radius: 12px;
  padding: 8px 4px;
  text-align: center;
}

.cell .v {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.cell .l {
  font-size: 11px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.versus {
  text-align: center;
  font-weight: 800;
  padding: 8px;
  border-radius: 12px;
  margin: 8px 0;
}

.versus.win {
  background: color-mix(in srgb, var(--good) 20%, transparent);
  color: var(--good);
}

.versus.lose {
  background: color-mix(in srgb, var(--bad) 18%, transparent);
  color: var(--bad);
}

.versus.tie {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
}

.rank-box {
  text-align: center;
  font-size: 14px;
  padding: 8px;
  border-radius: 12px;
  background: var(--bg-b);
  color: var(--ink-muted);
  margin: 8px 0;
}

.rank-box b {
  color: var(--accent);
}

.progress-block {
  margin: 10px 0;
}

.xp-gain {
  font-weight: 800;
  color: var(--accent);
  text-align: center;
  margin-bottom: 6px;
}

.unlock {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--bg-b);
}

.unlock svg {
  width: 20px;
  height: 20px;
  flex: none;
  color: var(--accent);
}

.r-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.btn {
  flex: 1 1 120px;
  min-height: 46px;
  border-radius: 14px;
  border: 1px solid var(--edge);
  background: var(--panel);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn.primary {
  background: linear-gradient(160deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  border: 0;
  box-shadow: 0 4px 0 #0006;
  font-weight: 800;
}

.r-lower {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--ink-muted);
}

.link-btn {
  background: none;
  border: 0;
  color: var(--accent);
  font-weight: 700;
  padding: 6px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.solution {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-b);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.next-in b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.p-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.p-head h2 {
  margin: 0;
  text-align: left;
}

.panel h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--ink-muted);
  margin: 16px 0 8px;
}

.muted {
  color: var(--ink-muted);
}

.help ol {
  padding-left: 20px;
  line-height: 1.55;
  margin: 0 0 10px;
}

.help li {
  margin-bottom: 6px;
}

.help .st {
  width: 16px;
  height: 16px;
  vertical-align: -2px;
}

.help .btn {
  width: 100%;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.tab {
  flex: 1;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--edge);
  background: var(--bg-b);
  font-weight: 700;
  color: var(--ink-muted);
}

.tab.active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--ink-muted);
}

.name-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--edge);
  background: var(--bg-b);
  color: var(--ink);
  user-select: text;
  -webkit-user-select: text;
}

.lb-me {
  padding: 8px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-b));
  margin-bottom: 8px;
  font-size: 14px;
}

.lb-me b {
  color: var(--accent);
}

.lb-me .st {
  width: 16px;
  height: 16px;
  display: inline-block;
  vertical-align: -3px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-bottom: 1px solid var(--edge);
  font-size: 14px;
}

.lb-row.me {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 8px;
}

.lb-row .rk {
  width: 26px;
  text-align: right;
  font-weight: 800;
  color: var(--ink-muted);
}

.lb-row .nm {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-row .vl {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lb-row .st {
  width: 14px;
  height: 14px;
}

.lb-row .t {
  font-size: 13px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.freeze-line {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--ink-muted);
  margin-top: 8px;
}

.freeze-line svg {
  width: 18px;
  height: 18px;
  flex: none;
  color: #8fd8ff;
}

.cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.cal-h {
  text-align: center;
  font-size: 11px;
  color: var(--ink-muted);
}

.cal-d {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-b);
  color: var(--ink-muted);
  padding: 20%;
}

.cal-d svg {
  color: #8fd8ff;
}

.cal-d.future {
  opacity: 0.3;
}

.cal-d.s0 {
  background: #5a5f86;
  color: #fff;
}
.cal-d.s1 {
  background: #8a6f3a;
  color: #fff;
}
.cal-d.s2 {
  background: #c79a2e;
  color: #1a1200;
}
.cal-d.s3 {
  background: var(--good);
  color: #062b1f;
}

.cal-d.frozen {
  background: #1d4260;
}

.cal-d.today {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.hist {
  display: grid;
  gap: 4px;
}

.h-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.h-l {
  width: 72px;
  text-align: right;
  color: var(--ink-muted);
  flex: none;
}

.h-bar {
  background: var(--edge);
  color: #fff;
  font-weight: 700;
  text-align: right;
  padding: 2px 6px;
  border-radius: 4px;
  min-width: 22px;
}

.h-bar.hl {
  background: var(--good);
  color: #062b1f;
}

.themes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.themes > p {
  grid-column: 1 / -1;
}

.theme-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: 14px;
  border: 2px solid var(--edge);
  background: var(--pattern), linear-gradient(180deg, var(--bg-a), var(--bg-b));
  color: var(--ink);
}

.theme-card.current {
  border-color: var(--accent);
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 40%, transparent);
}

.theme-card.locked {
  opacity: 0.55;
  filter: saturate(0.5);
}

.theme-card .sw {
  display: flex;
  gap: 6px;
}

.tile.mini {
  width: 44px;
  height: 38px;
  border-radius: calc(var(--tile-radius) * 0.6);
  box-shadow: 0 3px 0 var(--tile-edge);
}

.theme-neon .tile.mini {
  box-shadow: 0 0 0 2px var(--tile-edge), 0 0 10px #ff3fd466;
}

.tile.mini .v {
  font-size: 18px !important;
}

.theme-card .tn {
  font-weight: 800;
}

.theme-card .tl {
  font-size: 12px;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.theme-card .tl svg {
  width: 12px;
  height: 12px;
}

.achs {
  display: grid;
  gap: 6px;
}

.ach {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--bg-b);
  opacity: 0.6;
}

.ach.got {
  opacity: 1;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.ach .medal {
  width: 30px;
  height: 30px;
  flex: none;
  color: var(--ink-muted);
}

.ach.got .medal {
  color: var(--accent);
}

.ach .ad {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.ach small {
  color: var(--ink-muted);
}

.copy-src {
  position: fixed;
  left: -9999px;
  top: 0;
}

/* ---------- Page (SEO) ---------- */

.ad-slot {
  max-width: 970px;
  margin: 12px auto 0;
  min-height: 0;
}

.ad-slot[data-filled='true'] {
  min-height: 90px;
}

.about {
  max-width: 720px;
  margin: 28px auto 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 15px;
}

.about h1,
.about h2 {
  color: var(--text);
}

kbd {
  background: #1d2244;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  font-family: inherit;
}

/* ---------- Small screens ---------- */

@media (max-width: 420px) {
  .page {
    padding: 6px 6px 32px;
  }
  .game-root {
    padding: 10px 10px 14px;
    border-radius: 16px;
  }
  .logo span {
    width: 32px;
    height: 38px;
    font-size: 22px;
  }
  .op {
    width: 56px;
    height: 56px;
  }
  .ops {
    gap: 12px;
  }
  .target .num {
    font-size: 52px;
  }
  .modal {
    padding: 16px 12px;
  }
}

@media (max-width: 340px) {
  .logo span {
    width: 27px;
    height: 34px;
    font-size: 19px;
  }
}

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