* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
:root {
  --bg:#0f1226; --bg2:#1a1f3d; --cell:#232a4d; --cell-border:#2c3560;
  --text:#eef1ff; --muted:#8b93c4; --accent:#ffd34d; --accent2:#6ee7a0;
}
html,body { height:100%; overflow:hidden; }
body {
  font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;
  background:radial-gradient(120% 100% at 50% 0%, #1c2247 0%, var(--bg) 60%);
  color:var(--text); touch-action:none; user-select:none; -webkit-user-select:none;
}
#app { height:100dvh; max-width:520px; margin:0 auto; display:flex; flex-direction:column; }
.screen { flex:1; display:flex; flex-direction:column; padding:16px; }
.hidden { display:none !important; }

/* MENU */
#menu { justify-content:center; align-items:center; gap:28px; }
.logo { text-align:center; }
.logo-grid { display:grid; grid-template-columns:repeat(3,22px); grid-template-rows:repeat(3,22px); gap:3px; justify-content:center; margin-bottom:14px; }
.logo-grid div { border-radius:5px; background:var(--cell); }
.logo h1 { font-size:44px; letter-spacing:2px; font-weight:900; }
.logo h1 span { color:var(--accent); }
.tagline { color:var(--muted); margin-top:6px; font-size:15px; }
.menu-buttons { width:100%; display:flex; flex-direction:column; gap:14px; }
.big-btn {
  border:none; border-radius:18px; padding:18px 20px; font-size:17px; font-weight:800;
  color:#14172e; cursor:pointer; display:flex; flex-direction:column; gap:4px; align-items:center;
  box-shadow:0 6px 0 rgba(0,0,0,.35); transition:transform .08s;
}
.big-btn:active { transform:translateY(3px); box-shadow:0 3px 0 rgba(0,0,0,.35); }
.big-btn.daily { background:linear-gradient(135deg,#ffd34d,#ff9a3d); }
.big-btn.classic { background:linear-gradient(135deg,#6ee7a0,#3ec6d8); }
.big-btn.ad-btn { background:linear-gradient(135deg,#c58bff,#7a5cff); color:#fff; }
.btn-title { font-size:19px; }
.btn-sub { font-size:13px; font-weight:600; opacity:.75; }
.menu-stats { display:flex; gap:36px; }
.stat { display:flex; flex-direction:column; align-items:center; }
.stat-num { font-size:26px; font-weight:900; color:var(--accent); }
.stat-label { font-size:12px; color:var(--muted); }
.banner-slot {
  width:320px; max-width:90%; height:50px; border:1px dashed #3a4270; border-radius:8px;
  display:flex; align-items:center; justify-content:center; color:#3a4270; font-size:12px;
}

/* GAME HUD */
.hud { display:flex; align-items:center; gap:12px; padding:4px 2px 12px; }
.hud-center { flex:1; text-align:center; }
.hud-label { font-size:11px; letter-spacing:3px; color:var(--muted); font-weight:700; }
.hud-score { font-size:38px; font-weight:900; line-height:1.05; }
.hud-sub { font-size:13px; color:var(--accent); font-weight:700; }
.icon-btn {
  width:46px; height:46px; border-radius:14px; border:none; background:var(--bg2);
  color:var(--text); font-size:20px; cursor:pointer; flex-shrink:0;
  box-shadow:0 3px 0 rgba(0,0,0,.35);
}
.icon-btn:active { transform:translateY(2px); box-shadow:none; }
.icon-btn.hint { background:#3a2f5e; }

/* BOARD */
#boardWrap { position:relative; display:flex; justify-content:center; }
#board {
  display:grid; grid-template-columns:repeat(8,1fr); grid-template-rows:repeat(8,1fr);
  gap:4px; background:var(--bg2); padding:8px; border-radius:14px;
  width:min(94vw - 32px, 480px); aspect-ratio:1; box-shadow:inset 0 2px 12px rgba(0,0,0,.4);
}
.cell { background:var(--cell); border-radius:5px; transition:background .1s; }
.cell.filled { box-shadow:inset 0 -3px 0 rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.18); }
.cell.ghost { opacity:.55; }
.cell.hint-flash { animation:hintFlash .5s ease-in-out 4; }
@keyframes hintFlash { 50% { filter:brightness(2); } }
.cell.clearing { animation:clearPop .35s ease-out forwards; }
@keyframes clearPop { 40% { transform:scale(1.15); filter:brightness(1.8); } 100% { transform:scale(0); opacity:0; } }
.combo-toast {
  position:absolute; top:38%; left:50%; transform:translate(-50%,-50%);
  font-size:30px; font-weight:900; color:var(--accent); text-shadow:0 3px 10px rgba(0,0,0,.6);
  pointer-events:none; animation:toastUp 1s ease-out forwards; white-space:nowrap;
}
@keyframes toastUp { 0% { opacity:0; transform:translate(-50%,-30%) scale(.6); } 25% { opacity:1; transform:translate(-50%,-50%) scale(1.15); } 75% { opacity:1; } 100% { opacity:0; transform:translate(-50%,-90%) scale(1); } }
.score-pop {
  position:absolute; font-weight:900; color:#fff; pointer-events:none; z-index:5;
  animation:popFade .8s ease-out forwards; text-shadow:0 2px 6px rgba(0,0,0,.5);
}
@keyframes popFade { 0% { opacity:0; transform:translateY(6px); } 25% { opacity:1; } 100% { opacity:0; transform:translateY(-26px); } }

/* TRAY */
#tray { flex:1; display:flex; align-items:center; justify-content:space-evenly; padding:10px 0 calc(8px + env(safe-area-inset-bottom)); min-height:110px; }
.piece { cursor:grab; touch-action:none; transition:opacity .2s; }
.piece.used { opacity:0; pointer-events:none; }
.piece.dragging { position:fixed; z-index:50; pointer-events:none; cursor:grabbing; }
.piece-grid { display:grid; gap:3px; }
.pcell { border-radius:4px; }
.pcell.on { box-shadow:inset 0 -2px 0 rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.18); }
.pcell.off { background:transparent; }
.shake { animation:shake .3s; }
@keyframes shake { 25% { transform:translateX(-5px); } 75% { transform:translateX(5px); } }

/* OVERLAYS */
.overlay { position:fixed; inset:0; background:rgba(8,10,24,.82); display:flex; align-items:center; justify-content:center; z-index:100; padding:20px; }
.overlay-card {
  background:var(--bg2); border-radius:22px; padding:28px 24px; width:100%; max-width:340px;
  text-align:center; display:flex; flex-direction:column; gap:14px; box-shadow:0 20px 60px rgba(0,0,0,.5);
}
.overlay-card h2 { font-size:28px; }
.overlay-card p { color:var(--muted); font-size:16px; }
.ov-streak { font-size:18px; font-weight:800; color:var(--accent); }
.overlay-buttons { display:flex; flex-direction:column; gap:10px; }
.text-btn { background:none; border:none; color:var(--muted); font-size:15px; padding:8px; cursor:pointer; }
.ad-card { align-items:center; }
.ad-spinner { width:46px; height:46px; border:4px solid #3a4270; border-top-color:var(--accent); border-radius:50%; animation:spin 1s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }
.ad-note { font-size:12px !important; }
