/* SnapEm web demo — Neon (default) theme tokens from lib/themes.dart */
@font-face { font-family: 'ArchivoBlack'; src: url('assets/fonts/ArchivoBlack.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'DMSans'; src: url('assets/fonts/DMSans.ttf') format('truetype'); font-weight: 100 1000; font-display: swap; }

html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: #21356E; }

.app {
  --s: 1;            /* chrome scale, set from JS (1 = the app's real sizes) */
  --bw: 300px;       /* board width, set from JS */
  --cr: 9px;         /* board cell radius, set from JS */
  --ink: #EEF1FF;
  --accent: #22D3EE;
  --accent-lt: #7FF0FF;
  position: relative; width: 100%; height: 100%; overflow: hidden;
  color: var(--ink);
  font-family: 'DMSans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-optical-sizing: auto;
  background: radial-gradient(125% 95% at 50% -5%, #3A5CB5 0%, #2A4790 45%, #21356E 100%);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
.app button {
  font: inherit; color: inherit; border: 0; background: none; padding: 0; margin: 0;
  cursor: pointer; -webkit-appearance: none; appearance: none; touch-action: manipulation;
}
.app button:focus { outline: none; }
.app button:focus-visible { outline: 2px solid var(--accent-lt); outline-offset: 2px; }
[hidden] { display: none !important; }
.paused *, .paused *::before, .paused *::after { animation-play-state: paused !important; }

.screen {
  position: absolute; inset: 0; box-sizing: border-box;
  padding: 10px 8px 8px; display: flex; flex-direction: column;
}

/* ---------- header (game.dart _Header) ---------- */
.hdr { display: flex; align-items: center; height: 40px; padding: 0 var(--hpad, 10px); flex: none; }
.hdr-title { min-width: 0; overflow: hidden; }
.tag { font-size: max(9px, calc(11px * var(--s))); font-weight: 500; letter-spacing: 1px; color: rgba(238,241,255,.5); white-space: nowrap; }
.tag .preview { color: rgba(238,241,255,.4); }
.narrow .tag .full { display: none; }
.lvl { font-size: max(14px, calc(20px * var(--s))); font-weight: 700; line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow { flex: 1 1 4px; min-width: 4px; }
.timer {
  display: flex; align-items: center; gap: 6px; flex: none;
  padding: calc(7px * var(--s)) min(14px, calc(14px * var(--s)), calc(var(--hpad, 10px) + 6px));
  border-radius: 14px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
  font-size: max(14px, calc(19px * var(--s))); font-weight: 700; letter-spacing: .5px; line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.timer svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.timer.low { color: #FF6B6B; background: rgba(255,107,107,.16); border-color: rgba(255,107,107,.4); }
.timer.low #time { display: inline-block; animation: lowPulse 1s ease-in-out infinite alternate; }
@keyframes lowPulse { to { transform: scale(1.09); } }
.app button.hbtn {
  width: 40px; height: 40px; flex: none; border-radius: 12px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center;
  transition: transform 90ms ease-out, background-color 90ms;
}
.app button.hbtn + button.hbtn { margin-left: 6px; }
.app button.hbtn:active { transform: scale(.93); background: rgba(255,255,255,.13); }
.hbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.hbtn polygon { fill: currentColor; }
#mute .snd-off { display: none; }
#mute[aria-pressed="true"] .snd-on { display: none; }
#mute[aria-pressed="true"] .snd-off { display: inline; }
#mute[aria-pressed="true"] { color: rgba(238,241,255,.6); }

/* ---------- board (widgets/board.dart) ---------- */
.mid { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding-top: 8px; }
.sp4 { flex: 4 1 0; } .sp1 { flex: 1 1 0; }
.board-wrap { position: relative; align-self: center; width: var(--bw); flex: none; }
.frame {
  box-sizing: border-box; width: 100%; padding: 8px; border-radius: 24px;
  background: linear-gradient(150deg, rgba(255,255,255,.12), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 18px 44px -10px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.2);
}
.well {
  padding: 6px; border-radius: 18px; background: rgba(0,0,0,.4);
  box-shadow: inset 0 3px 9px rgba(0,0,0,.4);
}
.grid { position: relative; }
#cells, #preview { position: absolute; inset: 0; }
#preview { pointer-events: none; }
#sparks { position: absolute; pointer-events: none; }
.cell, .pv { position: absolute; box-sizing: border-box; border-radius: var(--cr); }
.cell.slot {
  background:
    linear-gradient(180deg, rgba(0,0,0,.5) 0%, rgba(0,0,0,0) 55%, rgba(255,255,255,.05) 100%),
    rgba(255,255,255,.06);
}
/* glossBlock (widgets/gloss.dart): 155deg three-stop body + top-to-bottom glass overlay */
.gloss {
  background:
    linear-gradient(180deg, rgba(255,255,255,.82) 0%, rgba(255,255,255,.30) 6%, rgba(255,255,255,.06) 30%, rgba(255,255,255,0) 55%, rgba(0,0,0,.10) 85%, rgba(0,0,0,.26) 100%),
    linear-gradient(155deg, var(--c1) 0%, var(--c2) 46%, var(--c3) 100%);
  box-shadow: 0 3px 8px rgba(0,0,0,.42);
}
.gloss.locked {
  background:
    linear-gradient(180deg, rgba(255,255,255,.42) 0%, rgba(255,255,255,.16) 6%, rgba(255,255,255,.03) 30%, rgba(255,255,255,0) 55%, rgba(0,0,0,.12) 85%, rgba(0,0,0,.30) 100%),
    linear-gradient(155deg, var(--c1) 0%, var(--c2) 46%, var(--c3) 100%);
  box-shadow: 0 2px 5px rgba(0,0,0,.38);
}
.cell.pop { animation: pop 420ms linear; z-index: 1; }
@keyframes pop { 0% { transform: scale(.55); } 60% { transform: scale(1.14); } 100% { transform: scale(1); } }
.cell.hint { background: var(--hcA); border: 2px solid var(--hc); animation: hintPulse 1s linear infinite alternate; }
@keyframes hintPulse { from { box-shadow: 0 0 0 0 transparent; } to { box-shadow: 0 0 18px 5px var(--hcG); } }
.pv.ok { background: var(--pvA); border: 2px solid var(--pv); box-shadow: 0 0 13px var(--pvG); }
.pv.bad { background: rgba(255,255,255,.022); border: 2px solid #F43F5E; }

.toast {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%); z-index: 3;
  padding: 7px 16px; border-radius: 999px; white-space: nowrap; pointer-events: none;
  background: linear-gradient(150deg, #7FF0FF, #22D3EE); color: #06121A;
  box-shadow: 0 0 16px -2px rgba(34,211,238,.35);
  font-size: 14px; font-weight: 700; line-height: 1.3;
}
.toast.stuck {
  background: linear-gradient(150deg, #FF9A9A, #FF6B6B); color: #fff;
  box-shadow: 0 0 16px -2px rgba(255,107,107,.5);
  animation: shake 540ms linear;
}
@keyframes shake {
  0% { transform: translateX(-50%); }
  8.3% { transform: translateX(calc(-50% + 6.4px)); }
  25% { transform: translateX(calc(-50% - 5.2px)); }
  41.7% { transform: translateX(calc(-50% + 4.1px)); }
  58.3% { transform: translateX(calc(-50% - 2.9px)); }
  75% { transform: translateX(calc(-50% + 1.7px)); }
  91.7% { transform: translateX(calc(-50% - .6px)); }
  100% { transform: translateX(-50%); }
}
.flash {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3;
  padding: 10px 18px; border-radius: 999px; white-space: nowrap; pointer-events: none;
  background: rgba(8,11,24,.92); border: 1px solid rgba(255,255,255,.14);
  font-size: 14px; font-weight: 600; color: #EEF1FF; animation: fadeIn 220ms linear;
}
@keyframes fadeIn { from { opacity: 0; } }

/* ---------- tray (game.dart _Tray / _TrayPiece) ---------- */
.tray-sec { margin-top: calc(10px * var(--s)); flex: none; }
.tray-head {
  display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 3px;
  font-size: max(9px, calc(11px * var(--s))); font-weight: 500; letter-spacing: 1px; color: rgba(238,241,255,.45);
  white-space: nowrap;
}
.tray-head .left { font-size: max(10px, calc(12px * var(--s))); font-weight: 700; letter-spacing: 0; color: var(--accent); }
.tray {
  position: relative; height: calc(106px * var(--s)); border-radius: 18px; overflow: hidden;
  background: rgba(0,0,0,.28); border: 1px solid rgba(255,255,255,.07);
}
.tray-scroll { position: absolute; inset: 0; overflow: hidden; display: flex; align-items: center; }
.tray-row { display: flex; align-items: center; flex: none; padding: 0 12px; }
.tray-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: rgba(238,241,255,.5);
}
.fade { position: absolute; top: 0; bottom: 0; width: 26px; pointer-events: none; }
.fade-l { left: 0; background: linear-gradient(90deg, rgba(0,0,0,.26), rgba(0,0,0,0)); }
.fade-r { right: 0; background: linear-gradient(270deg, rgba(0,0,0,.26), rgba(0,0,0,0)); }
.app button.chip {
  flex: none; box-sizing: border-box; margin: 0 calc(3.5px * var(--s));
  padding: calc(6px * var(--s)); min-width: 40px; min-height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 13px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.09);
  transition: transform 140ms, opacity 140ms, background-color 140ms, border-color 140ms, box-shadow 140ms;
  touch-action: none; cursor: grab;
}
.app button.chip.sel { transform: scale(1.07); background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.4); box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.app button.chip.hinted { transform: scale(1.07); background: rgba(250,204,21,.16); border-color: rgba(250,204,21,.6); box-shadow: 0 0 16px 2px rgba(250,204,21,.55); }
.app button.chip.dragged { opacity: .25; }
.pgrid { position: relative; pointer-events: none; }
.tc { position: absolute; border-radius: calc(4px * var(--s)); }

/* ---------- controls (game.dart _CtrlButton) ---------- */
.controls { display: flex; gap: calc(7px * var(--s)); margin-top: calc(10px * var(--s)); flex: none; }
.app button.ctrl {
  flex: 1 1 0; min-width: 0; height: max(44px, calc(70px * var(--s)));
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(4px * var(--s));
  border-radius: 16px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.13);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.16);
  font-size: max(9px, calc(10.5px * var(--s))); font-weight: 600; letter-spacing: .2px; line-height: 1.2;
  transition: transform 90ms ease-out, background-color 90ms, opacity 120ms;
}
.app button.ctrl:active:not(:disabled) { transform: scale(.93); background: rgba(255,255,255,.13); }
.app button.ctrl:disabled { opacity: .4; cursor: default; }
.app button.ctrl.hl:not(:disabled) {
  color: #FF6B6B; background: rgba(255,107,107,.16); border: 1.4px solid rgba(255,107,107,.6);
  box-shadow: 0 0 14px -2px rgba(255,107,107,.45);
}
.ctrl .ico { display: block; width: max(18px, calc(25px * var(--s))); height: max(18px, calc(25px * var(--s))); }
.ctrl .ico svg { display: block; width: 100%; height: 100%; }

/* ---------- floating drag piece ---------- */
#ghost { position: absolute; left: 0; top: 0; z-index: 20; pointer-events: none; display: none; will-change: transform; }
#ghost .gc { position: absolute; border-radius: var(--cr); }

/* ---------- overlays (widgets/overlays.dart _CompleteOverlay / _GameOverOverlay) ---------- */
.ov {
  position: absolute; inset: 0; z-index: 30; box-sizing: border-box;
  background: rgba(8,11,24,.82); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  display: flex; align-items: center; justify-content: center;
  padding: 0 calc(30px * var(--s)); animation: fadeIn 180ms linear;
}
.ov-inner { position: relative; width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; }
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: 0; border-radius: 2px; animation: fall linear both; }
@keyframes fall {
  0% { transform: translateY(-30px) rotate(0deg); opacity: 1; }
  99% { opacity: 1; }
  100% { transform: translateY(var(--fall)) rotate(680deg); opacity: 0; }
}
.stars { display: flex; align-items: center; gap: 8px; }
.star { display: inline-block; animation: starIn 400ms cubic-bezier(.2,1.3,.4,1) both; }
.star:nth-child(2) { animation-delay: 120ms; } .star:nth-child(3) { animation-delay: 240ms; }
.star span { display: block; font-size: calc(40px * var(--s)); line-height: 1.2; color: rgba(255,255,255,.15); }
.star.on span { color: #FACC15; text-shadow: 0 0 18px rgba(250,204,21,.7); }
.star:nth-child(2) span { transform: translateY(-8px) scale(1.15); }
@keyframes starIn { from { transform: scale(0); opacity: 0; } }
.ov-title {
  margin-top: 4px; font-family: 'ArchivoBlack', 'Arial Black', Impact, sans-serif; font-weight: 400;
  font-size: calc(42px * var(--s)); line-height: 1.15; letter-spacing: -.02em; white-space: nowrap;
  background: linear-gradient(90deg, #fff, #7FE9FF); -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
}
.ov-title.plain { background: none; color: #EEF1FF; -webkit-text-fill-color: #EEF1FF; font-size: calc(34px * var(--s)); }
.ov-emoji { font-size: calc(54px * var(--s)); line-height: 1.15; }
.stats { display: flex; gap: 12px; width: 100%; margin-top: calc(16px * var(--s)); }
.stat {
  flex: 1 1 0; padding: calc(16px * var(--s)) 8px; border-radius: 18px; text-align: center;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
}
.stat b { display: block; font-size: calc(24px * var(--s)); font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { display: block; margin-top: 3px; font-size: max(9px, calc(11px * var(--s))); font-weight: 500; letter-spacing: .5px; color: rgba(238,241,255,.5); text-transform: uppercase; }
.bonus {
  margin-top: 10px; padding: 8px 18px; border-radius: 999px; text-align: center;
  background: linear-gradient(150deg, #FFE27A, #FF9D54); color: #06121A;
  font-size: max(11px, calc(13px * var(--s))); font-weight: 700; line-height: 1.3;
}
.app button.cta {
  position: relative; width: 100%; height: max(46px, calc(58px * var(--s))); margin-top: 10px;
  border-radius: 18px; border: 1px solid rgba(255,255,255,.45); color: #06121A;
  background:
    linear-gradient(180deg, rgba(255,255,255,.42) 0%, rgba(255,255,255,0) 46%, rgba(0,0,0,.06) 100%),
    linear-gradient(145deg, #91F2FF, #2DD5EF);
  box-shadow: 0 14px 34px -14px rgba(34,211,238,.4);
  font-size: max(15px, calc(18px * var(--s))); font-weight: 700;
  transition: transform 90ms ease-out;
}
.app button.ghostbtn {
  width: 100%; height: max(44px, calc(52px * var(--s))); margin-top: 8px; border-radius: 16px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14); color: #EEF1FF;
  font-size: 14px; font-weight: 600; transition: transform 90ms ease-out;
}
.app button.cta:active, .app button.ghostbtn:active { transform: scale(.97); }

@media (prefers-reduced-motion: reduce) {
  .cell.pop, .star, .toast.stuck, .ov, .flash, .timer.low #time { animation: none !important; }
  .cell.hint { animation: none; box-shadow: 0 0 12px 3px var(--hcG); }
  .confetti { display: none; }
  .app button.chip, .app button.ctrl, .app button.hbtn { transition: none; }
}
