* { box-sizing: border-box; }
:root { color-scheme: dark; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; background: #251342; color: #fff8ff; }
html, body { margin: 0; width: 100%; min-height: 100%; }
body { min-height: 100dvh; background: radial-gradient(ellipse at 50% 42%, #512575 0, #351857 39%, #211039 78%, #180c2d 100%); overscroll-behavior: none; }
button { font: inherit; }
.game { position: relative; width: min(100%, 520px); min-height: 100dvh; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 17px max(20px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; overflow: hidden; }
.hud { width: 100%; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.score-box { min-width: 94px; padding: 9px 12px 8px; border: 1px solid rgba(255,255,255,.22); border-radius: 14px; background: linear-gradient(145deg, rgba(255,255,255,.2), rgba(255,255,255,.07)); box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 5px 15px rgba(13,4,29,.2); text-align: center; }
.score-box .label { display: block; color: #e4cfff; font-size: 11px; line-height: 1.2; }
.score-box strong { display: block; margin-top: 3px; color: #ffe286; font-size: 21px; line-height: 1.05; text-shadow: 0 2px 0 #b46a28, 0 0 10px rgba(255,224,134,.35); font-variant-numeric: tabular-nums; }
.moves { justify-self: end; }
.moves strong { color: #fff1c6; }
.brand { display: flex; align-items: center; gap: 5px; font-size: 15px; font-weight: 850; white-space: nowrap; color: #fff0c9; text-shadow: 0 2px 5px #160725; }
.brand-gem { color: #ffcb5c; font-size: 18px; }
.score-current { display: flex; align-items: baseline; gap: 8px; margin: 24px 0 13px; color: #e8d8ff; font-size: 13px; }
.score-current strong { color: #fff0a2; font-size: 30px; line-height: 1; text-shadow: 0 2px 0 #ac6d37, 0 0 14px rgba(255,224,126,.35); font-variant-numeric: tabular-nums; }
.board-wrap { position: relative; width: min(100%, 440px); aspect-ratio: 1; padding: 10px; border: 1px solid rgba(255,255,255,.34); border-radius: 23px; background: linear-gradient(145deg, rgba(255,255,255,.26), rgba(181,129,232,.1)); box-shadow: inset 0 2px 2px rgba(255,255,255,.3), inset 0 -9px 20px rgba(19,6,37,.25), 0 14px 35px rgba(11,4,24,.42), 0 0 25px rgba(214,155,255,.12); touch-action: none; }
.board { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); gap: clamp(3px, 1vw, 6px); padding: 5px; border-radius: 15px; background: rgba(34,13,55,.48); box-shadow: inset 0 2px 9px rgba(12,4,24,.48); }
.tile { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 10px; background: linear-gradient(145deg, rgba(255,255,255,.13), rgba(255,255,255,.035)); cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: none; transition: background .12s ease; }
.tile::before { content: ""; width: 78%; height: 78%; display: block; background: var(--gem); clip-path: var(--shape); border-radius: var(--round, 30%); filter: drop-shadow(0 3px 1px rgba(13,5,26,.36)) drop-shadow(0 0 7px color-mix(in srgb, var(--gem), transparent 48%)); box-shadow: inset 0 2px 4px rgba(255,255,255,.75); transition: transform .16s cubic-bezier(.2,.8,.3,1.25), filter .15s ease; }
.tile::after { content: ""; position: absolute; width: 28%; height: 13%; top: 17%; left: 21%; border-radius: 50%; background: rgba(255,255,255,.72); filter: blur(1px); transform: rotate(-35deg); pointer-events: none; }
.tile[data-type="0"] { --gem: #ff526d; --shape: circle; --round: 50%; }
.tile[data-type="1"] { --gem: #ff9d3f; --shape: inset(0 round 24%); --round: 24%; }
.tile[data-type="2"] { --gem: #ffd84c; --shape: polygon(50% 0, 96% 90%, 4% 90%); --round: 10%; }
.tile[data-type="3"] { --gem: #54df9b; --shape: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); --round: 12%; }
.tile[data-type="4"] { --gem: #54baff; --shape: polygon(50% 0, 61% 34%, 98% 35%, 69% 57%, 80% 95%, 50% 72%, 20% 95%, 31% 57%, 2% 35%, 39% 34%); --round: 10%; }
.tile[data-type="5"] { --gem: #ca83ff; --shape: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0 50%); --round: 12%; }
.tile.selected { z-index: 2; background: rgba(255,255,255,.25); box-shadow: inset 0 0 0 2px #fff5b3, 0 0 12px rgba(255,231,130,.48); }
.tile.selected::before { transform: translateY(-4px) scale(1.16); filter: drop-shadow(0 6px 4px rgba(13,5,26,.3)) drop-shadow(0 0 10px #fff2a5); }
.tile:focus-visible { outline: 2px solid #fff2a5; outline-offset: 1px; }
.tile.clearing::before { animation: burst .24s ease-in forwards; }
.tile.falling::before { animation: fall-in .28s cubic-bezier(.2,.72,.36,1.18); }
@keyframes burst { 0% { transform: scale(1); opacity: 1; } 55% { transform: scale(1.22) rotate(15deg); opacity: .85; } 100% { transform: scale(.08) rotate(75deg); opacity: 0; } }
@keyframes fall-in { 0% { transform: translateY(-32px) scale(.8); opacity: .2; } 72% { transform: translateY(3px) scale(1.04); opacity: 1; } 100% { transform: translateY(0) scale(1); } }
.combo { position: absolute; z-index: 4; inset: 0; display: grid; place-items: center; opacity: 0; pointer-events: none; color: #fff7bd; font-size: clamp(25px, 8vw, 42px); font-weight: 950; text-shadow: 0 3px 0 #bd652d, 0 0 22px #ffdf79; transform: scale(.7); }
.combo.show { animation: combo-pop .95s ease-out both; }
@keyframes combo-pop { 0% { opacity: 0; transform: scale(.55) rotate(-7deg); } 18% { opacity: 1; transform: scale(1.12) rotate(2deg); } 35% { transform: scale(1); } 78% { opacity: 1; } 100% { opacity: 0; transform: translateY(-18px) scale(.96); } }
.board-wrap.shake { animation: shake .26s ease-out; }
@keyframes shake { 15%, 45%, 75% { transform: translateX(-4px); } 30%, 60%, 90% { transform: translateX(4px); } }
.particles { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; pointer-events: none; }
.particle { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--particle); box-shadow: 0 0 9px var(--particle); animation: particle .45s ease-out forwards; }
@keyframes particle { to { transform: translate(var(--dx), var(--dy)) scale(.1); opacity: 0; } }
.restart { min-height: 46px; margin-top: 18px; padding: 0 20px; border: 1px solid rgba(255,255,255,.3); border-radius: 24px; color: #fff5d6; background: linear-gradient(180deg, #74409e, #542779); box-shadow: inset 0 1px 0 rgba(255,255,255,.24), 0 5px 12px rgba(12,4,24,.28); font-size: 14px; font-weight: 750; cursor: pointer; }
.restart span { margin-right: 5px; font-size: 18px; vertical-align: -1px; }
.restart:active, .dialog button:active { transform: translateY(1px) scale(.98); }
.overlay { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(16,7,29,.7); backdrop-filter: blur(5px); }
.overlay[hidden] { display: none; }
.dialog { width: min(100%, 330px); padding: 28px 24px 24px; border: 1px solid rgba(255,255,255,.3); border-radius: 22px; text-align: center; background: linear-gradient(150deg, #62358a, #32194f); box-shadow: 0 20px 55px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.25); }
.dialog-spark { color: #ffdc75; font-size: 32px; text-shadow: 0 0 15px #ffb957; }
.dialog h1 { margin: 5px 0 18px; font-size: 26px; }
.dialog p { margin: 8px 0; color: #e8d7f4; }
.dialog p strong { color: #ffe28c; font-size: 24px; }
.record-message { min-height: 20px; color: #ffe28c !important; font-size: 13px; }
.dialog button { min-height: 48px; width: 100%; margin-top: 14px; border: 0; border-radius: 25px; color: #4b245e; background: linear-gradient(180deg, #ffe993, #ffbc54); box-shadow: 0 4px 0 #cb813c; font-weight: 850; cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-height: 700px) { .game { padding-top: max(10px, env(safe-area-inset-top)); } .score-current { margin-top: 13px; margin-bottom: 9px; } .board-wrap { width: min(100%, calc(100dvh - 232px), 440px); } .restart { margin-top: 12px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
