:root {
  color-scheme: dark;
  font-family: system-ui, "PingFang SC", sans-serif;
  color: #f9fbff;
  background: #23316f;
  --board-size: min(100%, 460px, 58svh);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100svh; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, .board:focus-visible { outline: 3px solid #f9d861; outline-offset: 4px; }
.game {
  min-height: 100svh;
  width: min(100%, 560px);
  margin-inline: auto;
  padding: max(13px, env(safe-area-inset-top)) 19px max(14px, env(safe-area-inset-bottom));
  background: #3e51ab;
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
}
.top { width: 100%; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
h1 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: .08em; }
.best { display: flex; align-items: center; gap: 6px; color: #ffe269; font-weight: 850; font-variant-numeric: tabular-nums; }
.best img { width: 27px; filter: sepia(1) saturate(5); }
.icon { justify-self: end; width: 46px; height: 46px; border: 0; background: transparent; border-radius: 12px; }
.icon:hover { background: #ffffff15; }
.icon img { width: 26px; display: block; margin: auto; }
.score-area { display: grid; justify-items: center; gap: 1px; padding: 12px 0 17px; }
.mode { color: #e5eaff; font-size: 13px; }
#score { font-size: clamp(40px, 8vw, 64px); line-height: 1.1; font-weight: 900; font-variant-numeric: tabular-nums; }
.board-wrap { position: relative; width: var(--board-size); }
.board {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template: repeat(8, 1fr) / repeat(8, 1fr);
  gap: 1px;
  padding: 2px;
  border: 2px solid #7284ce;
  border-radius: 7px;
  background: #303d77;
  box-shadow: 0 6px #263578;
  touch-action: none;
}
.cell { background: #1d2859; border-radius: 2px; min-width: 0; position: relative; }
.cell.preview { box-shadow: inset 0 0 0 2px #fbf6dc; background: #5768a3; }
.cell.preview.bad { box-shadow: inset 0 0 0 2px #ff9c9d; }
.cell.filled, .piece i, .cell.flash {
  background-color: var(--tile);
  background-image: url('assets/tile.png');
  background-size: 100% 100%;
  background-blend-mode: luminosity;
  border-radius: 3px;
}
.cell.flash { animation: clear .24s ease-out forwards; }
@keyframes clear { 40% { filter: brightness(2.2); } 100% { opacity: .1; transform: scale(.55); } }
.tray { width: var(--board-size); min-height: 110px; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; align-items: center; margin-top: 10px; }
.slot { display: grid; place-items: center; background: none; border: 1px solid transparent; border-radius: 10px; padding: 3px; min-height: 88px; touch-action: none; }
.slot[aria-pressed="true"] { background: #273a87; border-color: #a0aff0; }
.slot:disabled { cursor: default; }
.slot.dragging { opacity: .2; }
.piece { display: grid; grid-template: repeat(var(--rows), var(--unit)) / repeat(var(--cols), var(--unit)); gap: 1px; --unit: clamp(13px, 4.3vw, 23px); pointer-events: none; }
.piece i { grid-column: var(--x); grid-row: var(--y); }
.ghost { position: fixed; z-index: 3; display: none; opacity: .93; filter: drop-shadow(0 6px 6px #1119448c); }
.ghost.active { display: grid; }
.hint { color: #e5eaff; min-height: 20px; font-size: 13px; text-align: center; margin: 0; }
.burst { position: absolute; inset: 38% 0 auto; pointer-events: none; text-align: center; font-weight: 900; font-size: clamp(24px, 6vw, 42px); color: #fff2a1; }
.burst img { width: 105px; vertical-align: middle; margin-right: 5px; }
.burst.show { animation: pop .65s both; }
@keyframes pop { 0% { transform: scale(.75); opacity: 0; } 28% { transform: scale(1.1); opacity: 1; } 78% { opacity: 1; } 100% { transform: translateY(-18px); opacity: 0; } }
dialog { width: min(90vw, 345px); padding: 0; border: 1px solid #8598e4; border-radius: 18px; background: #283978; box-shadow: 0 12px 40px #0d153e99; }
dialog::backdrop { background: #11183fba; }
dialog form { display: grid; gap: 12px; padding: 24px; }
dialog h2, dialog p { margin: 0; }
dialog label { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
dialog [hidden], .slot[hidden] { display: none; }
dialog button { min-height: 46px; border: 1px solid #8194e0; border-radius: 10px; background: #3d51a3; }
dialog button.primary { background: #f8d35b; color: #182148; font-weight: 800; border-color: transparent; }
input { accent-color: #f8d35b; width: 22px; height: 22px; }
@media (min-width: 700px) { .game { border-inline: 1px solid #6475c4; } }
@media (max-height: 650px) { .score-area { padding: 5px 0 10px; } .tray { min-height: 82px; margin-top: 6px; } .slot { min-height: 73px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; } }

.modes { display: flex; gap: 8px; margin-top: 10px; }
.modes button, #level-picker button {
  min-height: 44px; padding: 0 16px; border: 1px solid #9faeed;
  border-radius: 9px; background: #344791;
}
.modes button[aria-pressed="true"] { color: #253477; background: #f8d35b; border-color: #f8d35b; font-weight: 800; }
#level-picker { display: flex; align-items: center; gap: 7px; margin-top: 8px; font-size: 13px; }
#level-picker[hidden] { display: none; }
#level-number { min-height: 44px; width: 78px; padding: 6px; border: 1px solid #9faeed; border-radius: 8px; background: #293b7c; color: white; font: inherit; }
dialog button.primary { grid-row: auto; }
@media (max-height: 650px) { :root { --board-size: min(100%, 460px, 50svh); } }

[hidden] { display: none !important; }
:root { font-family: "Arial Rounded MT Bold", system-ui, sans-serif; background: #182449; }
#app { position: relative; min-height: 100svh; }
.lobby, .game {
  width: min(100%, 540px);
  margin-inline: auto;
  min-height: 100svh;
  background-color: #414eae;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 45px, #17296314 45px 46px),
    repeating-linear-gradient(90deg, transparent 0 45px, #17296314 45px 46px),
    linear-gradient(180deg,#208bc1 0%,#4059b4 30%,#414eae 72%);
}
.lobby {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 19px;
  padding: 24px 26px 48px;
}
.brand { display: block; width: min(90%, 375px); height: auto; }
.lobby-best { display: flex; align-items: center; gap: 8px; color: #ffdc4b; font-size: 23px; font-weight: 900; text-shadow: 0 2px #614b30; }
.lobby-best img { width: 30px; filter: sepia(1) saturate(6); }
.lobby-actions { display: grid; gap: 12px; width: min(100%, 410px); }
.lobby-actions button { min-height: 80px; border-radius: 16px; transition: transform .12s ease, filter .12s ease; }
.lobby-actions button:hover { filter: brightness(1.07); }
.lobby-actions button:active { transform: translateY(3px); }
.classic-entry {
  aspect-ratio: 810 / 302; display: grid; grid-template-columns: 45% 55%; align-items: center;
  border: 2px solid #9ddbee; background: linear-gradient(#40a7e7,#2c6fc4);
  box-shadow: inset 0 -9px #20559a, 0 3px #28356e;
  font-size: clamp(26px, 7vw, 44px); font-weight: 900; font-style: italic;
  text-shadow: 0 3px #24609d;
}
.classic-art { display: grid; grid-template-columns: repeat(3,1fr); grid-template-rows: repeat(2,1fr); width: 70%; max-width: 116px; aspect-ratio: 3/2; margin: auto; transform: rotate(-11deg); gap: 1px; }
.classic-art i { background: #f0cd40 url('assets/tile.png') center/100% 100%; background-blend-mode: luminosity; }
.classic-art i:nth-child(1) { grid-column: 2; background-color: #ff7b47; }
.classic-art i:nth-child(2) { grid-area: 2/1; background-color: #f36b74; }
.classic-art i:nth-child(3) { grid-area: 2/2; background-color: #ffd34d; }
.classic-art i:nth-child(4) { grid-area: 2/3; background-color: #69df75; }
.adventure-entry { display: block; border: 0; padding: 0; background: transparent; }
.adventure-entry img { width: 100%; display: block; height: auto; }
.game { --board-size: min(100%, 470px, 58svh); padding-inline: clamp(12px,4vw,22px); }
.top { grid-template-columns: 1fr auto auto; }
.home-icon img { width: 22px; }
.best { text-shadow: 0 2px #65502e; font-size: clamp(17px, 4vw, 26px); }
.best img { width: clamp(24px, 7vw, 36px); }
.score-area { padding: 8px 0 17px; }
.game[data-mode="classic"] .mode { position: absolute; clip-path: inset(50%); }
#score { font-size: clamp(44px, 10vw, 65px); text-shadow: 0 3px #253f86; }
#goal { width: min(58vw, 210px); height: 9px; accent-color: #ffdb55; }
.board { border: 2px solid #293552; border-radius: 4px; background: #29335a; padding: 1px; box-shadow: 0 2px #566cc1; }
.cell { background: #20294e; border-radius: 1px; }
.cell.preview:not(.bad) { background: #52618c; box-shadow: inset 0 0 0 2px #e3e6f7; }
.cell.will-clear { filter: brightness(1.45); }
.tray { margin-top: 13px; }
.hint { opacity: .86; padding-top: 3px; }
#effects { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
#effects i { position: absolute; top: var(--y); left: var(--x); width: 7px; height: 7px; border-radius: 1px; background: var(--spark); animation: chip .4s ease-out forwards; }
@keyframes chip { to { transform: translate(var(--dx), -28px) rotate(100deg) scale(.25); opacity: 0; } }
.burst { z-index: 2; text-shadow: 0 3px #292d68; }
dialog { background: linear-gradient(#4e76d5,#344695); border: 2px solid #95b7f6; border-radius: 22px; }
dialog h2 { text-align: center; font-size: 29px; text-shadow: 0 2px #263578; }
dialog p { text-align: center; color: #f0f3ff; font-size: 14px; }
dialog label { min-height: 36px; }
dialog button.primary { background: linear-gradient(#a3ee4d,#58b621); border-color: #b6f47d; color: #173e0a; box-shadow: 0 3px #368315; }
#revive img { display: block; width: 84px; margin-inline: auto; }
dialog[data-result="win"] h2 { color: #ffe476; }
#level-picker { margin: 0; }
#level-picker input { width: 74px; }
@media (max-height: 640px) {
  .game { --board-size: min(100%, 440px, 56svh); }
  .lobby { gap: 12px; padding-bottom: 20px; }
  .brand { width: min(72%, 285px); }
}
.guided .cell:nth-child(n+6):nth-child(-n+8):not(.preview):not(.filled) { box-shadow: inset 0 0 0 1px #e5ce72; background-color: #35416a; }
.guided .slot:first-child { border-color: #f1d362; background-color: #263a80a8; }
#goal { appearance: none; border: 1px solid #242e60; border-radius: 9px; overflow: hidden; background: #222c56; }
#goal::-webkit-progress-bar { background: #222c56; }
#goal::-webkit-progress-value { background: #f5cf4c; border-radius: 8px; }
#goal::-moz-progress-bar { background: #f5cf4c; border-radius: 8px; }

#app:has(.edge-ad-bottom:not([hidden])) {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
}
#app:has(.edge-ad-bottom:not([hidden])) .game-viewport {
  flex: 1;
  min-height: 0;
  overflow: auto;
  container-type: size;
}
#app:has(.edge-ad-bottom:not([hidden])) :is(.game, .lobby) { min-height: 100%; }
#app:has(.edge-ad-bottom:not([hidden])) .game {
  --game-chrome: 338px;
  --board-size: min(100%, 470px, max(192px, calc(100cqh - var(--game-chrome))));
  padding-block: 20px;
}
@media (max-width: 600px) {
  #app:has(.edge-ad-bottom:not([hidden])) .game { --game-chrome: 292px; }
}
@media (max-height: 650px) {
  #app:has(.edge-ad-bottom:not([hidden])) .game { --game-chrome: 266px; }
  #app:has(.edge-ad-bottom:not([hidden])) .score-area { padding-block: 5px 10px; }
  #app:has(.edge-ad-bottom:not([hidden])) .tray { margin-top: 6px; }
}
.edge-ad {
  flex: none;
  width: min(100%, 540px);
  margin-inline: auto;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 6px env(safe-area-inset-right) 8px env(safe-area-inset-left);
  color: #e5eaff;
  background: #26356e;
  font-size: 11px;
  line-height: 14px;
  visibility: hidden;
  pointer-events: none;
}
.edge-ad-bottom { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
#app.native-anchor-available { margin-top: calc(0px - var(--native-anchor-inset, 0px)); }
#app.native-anchor-available .edge-ad-bottom {
  position: fixed;
  inset: auto 0 0;
  z-index: 4;
}
#app.native-anchor-available:has(.edge-ad-bottom:not([hidden])) {
  padding-bottom: calc(74px + max(8px, env(safe-area-inset-bottom)));
}
#app:not(.edge-ads-paused) .edge-ad[data-filled="true"] { visibility: visible; pointer-events: auto; }
.edge-ad > div { width: 320px; height: 50px; }
#ad-status:empty { position: absolute; }
#panel button:disabled { cursor: default; opacity: .65; }

body.entry-ad-open { overflow: hidden; }
.entry-ad {
  position: fixed;
  outline: none;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  color: #f5f5f5;
  background: rgb(20 21 23 / 88%);
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
}
.entry-ad-header {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  min-height: calc(64px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  font-size: 13px;
  line-height: 20px;
}
#entry-ad-close, #revive-ad-close {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: #f5f5f5;
  background: transparent;
}
#entry-ad-close:hover, #revive-ad-close:hover { color: #bfc0c3; }
#entry-ad-close:active, #revive-ad-close:active { transform: scale(.92); }
.entry-ad-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 16px 0 max(24px, env(safe-area-inset-bottom));
}
.entry-ad-placement {
  position: relative;
  flex: none;
  width: 300px;
  height: 250px;
  background: rgb(255 255 255 / 3%);
}
.entry-ad-placement:first-child { margin-top: auto; }
.entry-ad-placement:last-child { margin-bottom: auto; }
.entry-ad-placement > div { width: 300px; height: 250px; }
.entry-ad-placement::before {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: #c2c3c5;
  font-size: 13px;
}
.entry-ad-placement[data-state="loading"]::before { content: 'Loading advertisement…'; }
.entry-ad-placement[data-state="empty"]::before { content: 'No advertisement available'; }
.revive-ad-card { flex: none; display: grid; justify-items: center; gap: 20px; margin-block: auto; }
#revive-countdown { margin: 0; color: #ededee; font-size: 16px; line-height: 24px; font-variant-numeric: tabular-nums; }
