:root{
  --bg1:#0b1020; --bg2:#101a3a;
  --card: rgba(255,255,255,.08);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.65);
  --accent: #6ee7ff;
  --accent2:#a78bfa;
  --good:#34d399;
  --shadow: 0 18px 55px rgba(0,0,0,.45);
  --radius: 22px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  color:var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background:
    radial-gradient(900px 560px at 20% 15%, rgba(110,231,255,.18), transparent 55%),
    radial-gradient(700px 480px at 85% 25%, rgba(167,139,250,.18), transparent 55%),
    linear-gradient(160deg, var(--bg1), var(--bg2));
  -webkit-font-smoothing: antialiased;
  overflow-x:hidden;
}

.wrap{
  min-height: 100svh;
  display:flex;
  justify-content:center;
  padding: 14px 14px calc(96px + var(--safe-bottom));
}

.panel{
  width: min(520px, 100%);
  background: linear-gradient(180deg, var(--card), rgba(255,255,255,.05));
  border: 1px solid rgba(255,255,255,.10);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  overflow:hidden;
}

.header{ padding: 16px 16px 10px; }

.badge{
  display:inline-flex; gap:8px; align-items:center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(110,231,255,.12);
  border: 1px solid rgba(110,231,255,.22);
  font-size: 13px;
}
.dot{
  width:10px; height:10px; border-radius:999px;
  background: var(--good);
  box-shadow: 0 0 18px rgba(52,211,153,.7);
}

h1{
  margin: 12px 0 8px;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.sub{
  margin:0 0 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.stats{
  display:flex;
  gap:10px;
  padding: 0 16px 12px;
}
.stat{
  flex:1;
  display:flex; flex-direction:column; gap:4px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  min-width: 0;
}
.stat small{color:var(--muted); font-size:12px}
.stat b{font-size:15px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}

.game{ padding: 0 16px 16px; }

.grid{
  width:100%;
  aspect-ratio: 1 / 1;
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 12px;
  border-radius: 22px;
  background: rgba(0,0,0,.22);
  border: 1px solid rgba(255,255,255,.10);
  position:relative;
}

.cell{
  position:relative;
  display:grid;
  place-items:center;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.06));
  border: 1px solid rgba(255,255,255,.12);
  overflow:hidden;
  user-select:none;
  transform: translateZ(0);
}
.cell::after{
  content:"";
  position:absolute; inset:-2px;
  background:
    radial-gradient(220px 160px at 30% 20%, rgba(110,231,255,.14), transparent 55%),
    radial-gradient(220px 160px at 70% 70%, rgba(167,139,250,.12), transparent 55%);
  opacity:.65;
  pointer-events:none;
}

.fruit{
  position:relative;
  z-index:2;
  font-size: clamp(34px, 9vw, 58px);
  filter: drop-shadow(0 12px 22px rgba(0,0,0,.35));
  transition: transform .25s ease, opacity .25s ease;
}

.spinning .fruit{ animation: wiggle .18s infinite linear; }
@keyframes wiggle{
  0%{transform: translateY(0) rotate(0deg) scale(1)}
  25%{transform: translateY(-2px) rotate(-3deg) scale(1.02)}
  50%{transform: translateY(0) rotate(0deg) scale(1)}
  75%{transform: translateY(2px) rotate(3deg) scale(1.02)}
  100%{transform: translateY(0) rotate(0deg) scale(1)}
}

.midRow{ box-shadow: 0 0 0 2px rgba(110,231,255,.12) inset; }

.boom .fruit{ animation: pop .55s ease forwards; }
@keyframes pop{
  0%{transform: scale(1); opacity:1}
  35%{transform: scale(1.35) rotate(4deg); opacity:1}
  100%{transform: scale(.35) rotate(-6deg); opacity:0}
}

.particle{
  position:absolute;
  left:50%; top:50%;
  width: 8px; height: 8px;
  border-radius: 999px;
  transform: translate(-50%,-50%);
  opacity: .95;
  animation: blast .6s ease-out forwards;
  z-index:3;
}
@keyframes blast{
  0%{ transform: translate(-50%,-50%) scale(1); opacity:1 }
  100%{ transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.2); opacity:0 }
}

/* Sticky bottom bar */
.bottomBar{
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 12px 14px calc(12px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(10,14,30,0), rgba(10,14,30,.75) 35%, rgba(10,14,30,.92));
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255,255,255,.08);
  display:flex;
  justify-content:center;
  z-index: 50;
}
.btn{
  width: min(520px, calc(100% - 0px));
  border:0;
  cursor:pointer;
  color: rgba(0,0,0,.92);
  font-weight: 900;
  letter-spacing: .02em;
  padding: 15px 16px;
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
  transition: transform .12s ease, filter .12s ease, opacity .2s ease;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn:active{ transform: translateY(1px) scale(.99); }
.btn[disabled]{ opacity:.55; cursor:not-allowed; transform:none; }

/* Modal */
.modal{
  position:fixed; inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  padding:16px;
  background: rgba(0,0,0,.58);
  backdrop-filter: blur(7px);
  z-index: 999;
}
.modal.show{ display:flex; }
.modalCard{
  width: min(520px, 100%);
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,.12);
  background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.06));
  box-shadow: 0 22px 70px rgba(0,0,0,.55);
  padding: 16px;
}
.modalCard h2{ margin: 4px 0 8px; font-size: 20px; letter-spacing:-.02em; }
.modalCard p{ margin:0 0 14px; color: var(--muted); line-height:1.5; font-size: 14px; }
.modalActions{ display:flex; gap:10px; flex-wrap:wrap; }
