:root {
  --sky: #50c7f6;
  --sky-deep: #1597ea;
  --ink: #123064;
  --cream: #fffdf2;
  --sun: #ffcb36;
  --orange: #ff8a20;
  --pink: #ff5f93;
  --green: #76cf4a;
  --tile-gap: clamp(7px, 2vw, 11px);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background:
    radial-gradient(circle at 50% -10%, #d8f6ff 0 18%, transparent 44%),
    linear-gradient(155deg, #087ed8, #54d0f4 48%, #d4f8f1);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button { font: inherit; }

.game-shell {
  position: relative;
  width: min(100%, 520px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 14%, rgba(255,255,255,.52), transparent 23%),
    linear-gradient(180deg, #35baf2 0%, #87ddf4 46%, #d9f5e5 100%);
  box-shadow: 0 0 70px rgba(4, 64, 124, .28);
}

.game-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .24;
  pointer-events: none;
  background-image: repeating-linear-gradient(112deg, transparent 0 42px, rgba(255,255,255,.28) 44px 47px, transparent 49px 100px);
  mask-image: linear-gradient(#000, transparent 64%);
}

.sky-decor span { position: absolute; pointer-events: none; }
.star { z-index: 0; color: #fff6a6; filter: drop-shadow(0 3px 0 rgba(26,100,157,.15)); animation: twinkle 2.4s ease-in-out infinite; }
.star-a { top: 9%; left: 5%; font-size: 24px; transform: rotate(-14deg); }
.star-b { top: 17%; right: 7%; font-size: 17px; animation-delay: -1.2s; }
.float-number { z-index: 0; font-weight: 1000; font-size: 50px; color: rgba(255,255,255,.28); -webkit-text-stroke: 2px rgba(20,109,181,.14); }
.n-one { top: 25%; left: -7px; transform: rotate(-18deg); }
.n-nine { top: 31%; right: -5px; transform: rotate(16deg); }
.cloud { width: 120px; height: 45px; border-radius: 60px; background: rgba(255,255,255,.58); filter: blur(.2px); }
.cloud::before, .cloud::after { content:""; position:absolute; background:inherit; border-radius:50%; }
.cloud::before { width: 54px; height:54px; left:18px; top:-22px; }
.cloud::after { width:72px; height:72px; right:7px; top:-36px; }
.cloud-a { top: 26%; left: -72px; }
.cloud-b { top: 41%; right: -88px; transform: scale(.85); }

.topbar, .score-card, .mission-row, .board-wrap, .instruction { position: relative; z-index: 2; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 100px; }
.title-wrap { text-align: center; transform: rotate(-1.5deg); }
.eyebrow { margin: 0 0 -2px; color: rgba(18,48,100,.68); font-size: 10px; font-weight: 900; letter-spacing: .19em; }
h1 { margin: 0; color: #fff; font-size: clamp(42px, 12vw, 62px); font-weight: 1000; line-height: 1; letter-spacing: -5px; text-shadow: 0 5px 0 #2077c2, 0 8px 16px rgba(0,72,142,.26); -webkit-text-stroke: 2px #1978c4; }
h1 span { color: #ffde35; font-size: 1.18em; text-shadow: 0 5px 0 #e88718, 0 8px 16px rgba(0,72,142,.26); -webkit-text-stroke-color: #f09a1d; }

.round-button {
  width: 44px; height: 44px; border: 0; border-radius: 16px; cursor: pointer;
  color: #176bb0; background: rgba(255,255,255,.74); box-shadow: 0 5px 0 rgba(20,111,177,.24), inset 0 1px 0 #fff;
  font-size: 20px; font-weight: 1000; transition: transform .16s, box-shadow .16s;
}
.round-button:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(20,111,177,.24); }

.score-card {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: 68px; padding: 8px 15px; border: 2px solid rgba(255,255,255,.7); border-radius: 24px;
  background: rgba(255,255,255,.78); box-shadow: 0 11px 0 rgba(28,114,169,.14), 0 16px 35px rgba(35,112,160,.12); backdrop-filter: blur(10px);
}
.score-block { display: flex; flex-direction: column; }
.score-block.align-right { align-items: flex-end; }
.score-block span { color: #6883a8; font-size: 11px; font-weight: 800; }
.score-block strong { font-size: 26px; line-height: 1.1; font-weight: 1000; letter-spacing: -1px; }
.level-badge { display:flex; align-items:center; gap:6px; padding: 7px 13px; color:#fff; border-radius: 15px; background:linear-gradient(145deg,#ffaf29,#ff7a1a); box-shadow:inset 0 2px 0 rgba(255,255,255,.46), 0 4px 0 #d76517; transform: rotate(-2deg); }
.level-badge span { font-size:9px; font-weight:900; letter-spacing:.09em; }
.level-badge strong { font-size:21px; }

.mission-row { display:grid; grid-template-columns:66px 1fr 62px; align-items:center; gap:10px; margin:18px 1px 13px; }
.remaining-badge { width:66px; height:48px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:1px; color:#fff; border-radius:18px; background:linear-gradient(145deg,#ff8e56,#ff5f73); box-shadow:0 5px 0 #d94c5d,inset 0 2px 0 rgba(255,255,255,.35); transform:rotate(-2deg); }
.remaining-badge strong { font-size:17px; line-height:1; text-shadow:0 2px 0 rgba(132,36,53,.2); font-variant-numeric:tabular-nums; }
.remaining-badge small { font-size:9px; font-weight:1000; }
.mission-copy span { display:block; margin-bottom:6px; color:#1c5a91; font-size:12px; font-weight:900; }
.progress-track { height:11px; padding:2px; border-radius:10px; background:rgba(255,255,255,.56); box-shadow:inset 0 2px 2px rgba(15,92,148,.12); overflow:hidden; }
.progress-track i { display:block; width:0; height:100%; border-radius:8px; background:linear-gradient(90deg,#ffce34,#ff8c25); transition:width .28s ease; }
.hint-button { height:42px; border:0; border-radius:15px; color:#185da1; background:#fff4a7; box-shadow:0 4px 0 #e5b93c; font-size:12px; font-weight:1000; cursor:pointer; }
.hint-button span { display:block; margin-bottom:-3px; color:#ff8f18; font-size:15px; }
.hint-button:active { transform:translateY(2px); box-shadow:0 2px 0 #e5b93c; }

.board-wrap { padding:10px 10px 32px; border-radius:24px 24px 34px 34px; background:linear-gradient(160deg,rgba(255,255,255,.43),rgba(78,170,204,.27)); border:2px solid rgba(255,255,255,.58); box-shadow:inset 0 2px 0 rgba(255,255,255,.5),0 14px 0 rgba(52,129,161,.16),0 22px 42px rgba(48,107,140,.13); }
.board { position:relative; display:grid; grid-template-columns:repeat(10,1fr); gap:3px; min-height:0; touch-action:none; cursor:crosshair; }
.tile {
  position:relative; aspect-ratio:1; display:grid; place-items:center; border:0; border-radius:6px; pointer-events:none;
  color:#27466d; background:linear-gradient(155deg,#fff,#f7fbff); box-shadow:0 2px 0 #b8d6df,inset 0 1px 0 #fff;
  font-size:clamp(12px,3.8vw,18px); font-weight:1000; transition:opacity .18s ease,transform .12s ease,background .12s ease;
  animation:tileIn .22s cubic-bezier(.2,.9,.25,1.25) both;
}
.tile::after { content:""; position:absolute; inset:2px; border-radius:4px; border:1px solid rgba(32,132,205,.15); pointer-events:none; }
.tile.is-selected { z-index:3; color:#7a3a00; background:linear-gradient(150deg,#ffe56b,#ffad35); box-shadow:0 0 0 2px #ff7a20,inset 0 1px 0 rgba(255,255,255,.7); transform:scale(1.05); }
.tile.is-hint { animation:hintPulse .62s ease-in-out 3; }
.tile.is-match { pointer-events:none; animation:matchOut .42s ease forwards; }
.tile.is-cleared { opacity:0; pointer-events:none; }
.tile.is-refresh { animation:refreshTile .38s cubic-bezier(.2,.9,.25,1.2) both; }
.tile.is-wrong { animation:wrong .3s ease; }
.tile[data-value="1"],.tile[data-value="9"] { --tile-accent:#69baf0; }
.tile[data-value="2"],.tile[data-value="8"] { --tile-accent:#ff9ab8; }
.tile[data-value="3"],.tile[data-value="7"] { --tile-accent:#9fd66b; }
.tile[data-value="4"],.tile[data-value="6"] { --tile-accent:#ffc65a; }
.tile[data-value="5"] { --tile-accent:#ad9bea; }
.selection-box { position:absolute; z-index:6; display:none; border:3px solid #ff7a20; border-radius:8px; background:rgba(255,190,48,.16); box-shadow:0 0 0 2px rgba(255,255,255,.72),0 4px 12px rgba(194,70,13,.22); pointer-events:none; }
.selection-box.is-visible { display:block; }
.selection-sum { position:absolute; z-index:7; display:none; min-width:42px; padding:4px 8px; border-radius:13px; color:#fff; background:#ff7922; box-shadow:0 3px 0 #c74c15; font-size:12px; font-weight:1000; text-align:center; pointer-events:none; transform:translate(-50%,-115%); }
.selection-sum.is-visible { display:block; }

.combo-bubble { position:absolute; z-index:7; left:50%; top:44%; min-width:110px; text-align:center; color:#fff; font-size:25px; font-weight:1000; text-shadow:0 3px 0 #d85623; transform:translate(-50%,-50%) scale(0); pointer-events:none; }
.combo-bubble.pop { animation:comboPop .72s ease both; }
.mascot { position:absolute; left:50%; bottom:-19px; width:76px; height:43px; transform:translateX(-50%); }
.ear { position:absolute; top:9px; width:28px; height:25px; background:#e97845; border:4px solid #91432f; transform:rotate(35deg); border-radius:7px; }
.ear-left { left:1px; } .ear-right { right:1px; transform:rotate(-35deg); }
.face { position:absolute; left:10px; width:56px; height:44px; display:flex; justify-content:center; gap:16px; padding-top:16px; border:4px solid #91432f; border-radius:42% 42% 48% 48%; background:#ef8a51; }
.face i { width:5px; height:7px; border-radius:50%; background:#44251f; }
.face b { position:absolute; top:22px; font-size:9px; color:#7e3d2c; }
.instruction { margin:21px 0 0; text-align:center; color:#3e7391; font-size:12px; font-weight:800; }
.instruction span { color:#175994; }
.instruction b { display:inline-grid; place-items:center; width:27px; height:27px; margin-left:3px; border-radius:9px; color:#fff; background:#ff8c24; box-shadow:0 3px 0 #d66117; font-size:15px; transform:rotate(3deg); }

.modal { position:fixed; z-index:30; inset:0; display:grid; place-items:center; padding:24px; background:rgba(4,40,79,.48); backdrop-filter:blur(9px); opacity:0; pointer-events:none; transition:opacity .24s ease; }
.modal.is-open { opacity:1; pointer-events:auto; }
.modal-card { width:min(calc(100vw - 40px),410px); padding:30px 25px 24px; text-align:center; border:3px solid rgba(255,255,255,.88); border-radius:34px; background:linear-gradient(160deg,#ffffff,#eefaff); box-shadow:0 14px 0 rgba(12,78,131,.28),0 30px 65px rgba(2,33,70,.32); transform:translateY(18px) scale(.96); transition:transform .3s cubic-bezier(.2,.9,.25,1.15); }
.modal.is-open .modal-card { transform:none; }
.modal-card h2 { margin:5px 0 12px; color:#164d87; font-size:27px; line-height:1.2; }
.modal-card p { margin:0 auto 18px; max-width:330px; color:#66809d; font-size:14px; line-height:1.75; }
.modal-kicker { margin:0 !important; color:#f78b22 !important; font-size:10px !important; font-weight:1000; letter-spacing:.16em; }
.mini-cards { display:flex; align-items:center; justify-content:center; gap:5px; margin:-55px auto 18px; }
.mini-cards i { display:grid; place-items:center; width:45px; height:52px; border-radius:14px; color:#164b82; background:#fff; box-shadow:0 5px 0 #b5d4e3,0 7px 16px rgba(24,80,115,.2); font-size:22px; font-weight:1000; font-style:normal; transform:rotate(-7deg); }
.mini-cards i:nth-child(even) { width:24px; box-shadow:none; color:#ff8b21; background:transparent; transform:none; }
.mini-cards i:nth-child(3) { transform:rotate(5deg); }
.mini-cards i:last-child { width:55px; color:#fff; background:linear-gradient(150deg,#ffb62e,#ff7621); box-shadow:0 5px 0 #d65a18; transform:rotate(-2deg); }
.primary-button { width:100%; min-height:56px; border:0; border-radius:19px; color:#fff; cursor:pointer; background:linear-gradient(120deg,#ffad26,#ff721c); box-shadow:0 6px 0 #d85a18,0 11px 20px rgba(226,93,27,.24); font-size:18px; font-weight:1000; letter-spacing:.03em; }
.primary-button:active { transform:translateY(3px); box-shadow:0 3px 0 #d85a18; }
.modal-card small { display:block; margin-top:15px; color:#93a6b7; font-size:10px; }
.compact-card { max-width:360px; }
.text-button { margin-top:15px; border:0; color:#66829e; background:transparent; cursor:pointer; font-size:13px; font-weight:800; }
.result-score { margin:16px 0; padding:14px; border-radius:20px; background:#eef8fb; }
.result-score span { display:block; color:#7b93a8; font-size:11px; font-weight:800; }
.result-score strong { display:block; color:#ff7f20; font-size:38px; line-height:1.1; }
.toast { position:fixed; z-index:50; left:50%; bottom:max(25px,env(safe-area-inset-bottom)); padding:11px 18px; border-radius:20px; color:#fff; background:rgba(14,48,84,.88); box-shadow:0 8px 24px rgba(0,31,65,.22); font-size:12px; font-weight:800; transform:translate(-50%,25px); opacity:0; pointer-events:none; transition:.25s ease; }
.toast.show { opacity:1; transform:translate(-50%,0); }

@keyframes tileIn { from { opacity:0; transform:translateY(-20px) scale(.75) rotate(-5deg); } }
@keyframes matchOut { 45% { transform:scale(1.18) rotate(6deg); filter:brightness(1.2); } to { opacity:0; transform:translateY(-20px) scale(.2) rotate(-16deg); } }
@keyframes wrong { 25% { transform:translateX(-5px); } 75% { transform:translateX(5px); } }
@keyframes refreshTile { from { opacity:0; transform:scale(.72) rotate(-7deg); } to { opacity:1; } }
@keyframes hintPulse { 50% { transform:translateY(-6px) scale(1.06); box-shadow:0 7px 0 #55a9cf,0 0 0 5px rgba(255,255,255,.75); } }
@keyframes comboPop { 0% { opacity:0; transform:translate(-50%,-50%) scale(.2) rotate(-8deg); } 30% { opacity:1; transform:translate(-50%,-80%) scale(1.2) rotate(3deg); } 75% { opacity:1; transform:translate(-50%,-105%) scale(1); } 100% { opacity:0; transform:translate(-50%,-135%) scale(.8); } }
@keyframes twinkle { 50% { transform:scale(.65) rotate(18deg); opacity:.55; } }

@media (min-width: 560px) {
  body { padding:20px 0; }
  .game-shell { min-height:calc(100vh - 40px); border-radius:42px; }
}

@media (max-height: 760px) {
  .topbar { min-height:84px; }
  .mission-row { margin:12px 1px 9px; }
  .board { min-height:290px; }
  .board-wrap { padding-top:11px; }
}

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