:root {
  --bg-a: #0b1220;
  --bg-b: #17233a;
  --card: rgba(255,255,255,.92);
  --ink: #111827;
  --muted: #64748b;
  --line: rgba(15,23,42,.12);
  --blue: #3b82f6;
  --mint: #14b8a6;
  --orange: #f97316;
  --pink: #ec4899;
  --purple: #8b5cf6;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 12%, rgba(20,184,166,.28), transparent 30%),
    radial-gradient(circle at 88% 18%, rgba(59,130,246,.28), transparent 28%),
    linear-gradient(135deg, var(--bg-a), var(--bg-b));
}

button, a { font: inherit; }

button { cursor: pointer; }

.block-shell {
  min-height: 100vh;
  padding: clamp(12px, 3vw, 32px);
  display: grid;
  place-items: center;
}

.block-card {
  width: min(1180px, 100%);
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 34px;
  background: linear-gradient(145deg, rgba(255,255,255,.96), rgba(236,243,255,.88));
  box-shadow: 0 28px 80px rgba(0,0,0,.32);
  overflow: hidden;
}

.block-header {
  padding: clamp(18px, 3vw, 34px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.nav-link {
  display: inline-flex;
  margin-bottom: 14px;
  color: #335c85;
  text-decoration: none;
  font-weight: 800;
}

.nav-link:hover { text-decoration: underline; }

.eyebrow {
  margin: 0 0 7px;
  color: #58708d;
  font-size: .7rem;
  font-weight: 900;
  letter-spacing: .12em;
}

h1, h2, p { margin-top: 0; }

.block-header h1 {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 5rem);
  line-height: .92;
  letter-spacing: -.065em;
}

.block-header h1 span { color: #2d70b7; }

.header-copy {
  max-width: 680px;
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 1rem;
}

.logo-chip {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  border-radius: 24px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 1000;
  letter-spacing: -.08em;
  background: linear-gradient(145deg, #0f172a, #315d88);
  box-shadow: 0 14px 30px rgba(15,23,42,.22);
}

.choose-screen { padding: clamp(18px, 3vw, 34px); }

.choose-copy {
  max-width: 620px;
  margin-bottom: 22px;
}

.choose-copy h2,
.board-topline h2,
.panel-heading h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  letter-spacing: -.04em;
}

.choose-copy p,
.panel-heading p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.mode-card {
  min-height: 230px;
  text-align: left;
  border: 1px solid rgba(15,23,42,.1);
  border-radius: 28px;
  padding: 24px;
  color: var(--ink);
  background: rgba(255,255,255,.78);
  box-shadow: 0 14px 28px rgba(15,23,42,.08);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.mode-card:hover,
.mode-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(45,112,183,.42);
  box-shadow: 0 18px 36px rgba(15,23,42,.14);
  outline: none;
}

.mode-size {
  display: inline-grid;
  place-items: center;
  min-width: 82px;
  height: 48px;
  margin-bottom: 20px;
  padding: 0 14px;
  border-radius: 16px;
  color: #fff;
  font-weight: 1000;
  font-size: 1.3rem;
  background: linear-gradient(145deg, #0f172a, #2563eb);
}

.mode-card strong,
.mode-card span:not(.mode-size),
.mode-card em { display: block; }

.mode-card strong {
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.mode-card span:not(.mode-size) {
  color: var(--muted);
  line-height: 1.45;
}

.mode-card em {
  margin-top: 18px;
  color: #315d88;
  font-style: normal;
  font-weight: 900;
}

.game-screen { padding: clamp(14px, 2.5vw, 26px); }

.is-hidden { display: none !important; }

.hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr)) minmax(220px, 2fr);
  gap: 12px;
  margin-bottom: 16px;
}

.hud-item,
.hud-status {
  min-height: 72px;
  padding: 13px 15px;
  border-radius: 20px;
  background: rgba(255,255,255,.75);
  border: 1px solid rgba(15,23,42,.08);
  box-shadow: 0 8px 18px rgba(15,23,42,.06);
}

.hud-item span {
  display: block;
  color: var(--muted);
  font-size: .73rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.hud-item strong {
  display: block;
  margin-top: 5px;
  font-size: 1.5rem;
  letter-spacing: -.04em;
}

.hud-status {
  display: flex;
  align-items: center;
  color: #38556f;
  line-height: 1.35;
  font-weight: 750;
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 18px;
  align-items: stretch;
}

.board-panel,
.piece-panel {
  border: 1px solid rgba(15,23,42,.1);
  border-radius: 28px;
  background: rgba(255,255,255,.72);
  box-shadow: 0 14px 28px rgba(15,23,42,.08);
}

.board-panel {
  padding: clamp(14px, 2vw, 22px);
}

.board-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.combo-pill {
  flex: 0 0 auto;
  padding: 9px 13px;
  border-radius: 999px;
  color: #fff;
  font-size: .85rem;
  font-weight: 900;
  background: #0f172a;
}

.board-wrap {
  position: relative;
  display: grid;
  place-items: center;
  padding: min(3vw, 22px);
  border-radius: 26px;
  background:
    radial-gradient(circle at 50% 50%, rgba(56,189,248,.13), transparent 45%),
    linear-gradient(145deg, #0f172a, #1d3a5c);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), inset 0 18px 40px rgba(255,255,255,.04);
  overflow: hidden;
}

.board {
  --size: 8;
  position: relative;
  z-index: 1;
  width: min(640px, calc(100vw - 54px));
  max-width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(var(--size), 1fr);
  grid-template-rows: repeat(var(--size), 1fr);
  gap: clamp(3px, .55vw, 7px);
  padding: clamp(6px, 1vw, 10px);
  border-radius: 22px;
  background: rgba(3,7,18,.55);
  box-shadow: 0 20px 40px rgba(0,0,0,.28);
  user-select: none;
  touch-action: manipulation;
}

.cell {
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: clamp(6px, 1.2vw, 11px);
  background: rgba(255,255,255,.095);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), inset 0 -10px 18px rgba(0,0,0,.07);
  transition: transform .12s ease, background .12s ease, box-shadow .12s ease, opacity .12s ease;
}

.cell.filled {
  transform: scale(.98);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.42), inset 0 -12px 20px rgba(0,0,0,.18), 0 6px 14px rgba(0,0,0,.15);
}

.cell.pop { animation: cellPop .22s ease; }
.cell.clearing { animation: clearCell .42s ease forwards; }
.cell.preview-ok { background: rgba(34,197,94,.42); transform: scale(.93); }
.cell.preview-bad { background: rgba(239,68,68,.35); transform: scale(.93); }
.cell.hint { animation: hintPulse .7s ease infinite alternate; }

.c1 { background: linear-gradient(145deg, #60a5fa, #2563eb) !important; }
.c2 { background: linear-gradient(145deg, #34d399, #0d9488) !important; }
.c3 { background: linear-gradient(145deg, #fb923c, #ea580c) !important; }
.c4 { background: linear-gradient(145deg, #f472b6, #db2777) !important; }
.c5 { background: linear-gradient(145deg, #a78bfa, #7c3aed) !important; }
.c6 { background: linear-gradient(145deg, #facc15, #ca8a04) !important; }
.c7 { background: linear-gradient(145deg, #f87171, #dc2626) !important; }
.c8 { background: linear-gradient(145deg, #67e8f9, #0891b2) !important; }

.float-layer {
  pointer-events: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 5;
}

.float-score {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-weight: 1000;
  font-size: clamp(1.3rem, 5vw, 3.8rem);
  text-shadow: 0 8px 24px rgba(0,0,0,.45);
  animation: floatScore 1s ease forwards;
}

.piece-panel {
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.panel-heading p { font-size: .92rem; }

.piece-tray {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.piece-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-height: 98px;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(15,23,42,.1);
  background: rgba(255,255,255,.82);
  box-shadow: 0 8px 18px rgba(15,23,42,.06);
  text-align: left;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease, opacity .14s ease;
}

.piece-card:hover,
.piece-card.is-selected {
  transform: translateY(-2px);
  border-color: rgba(45,112,183,.45);
  box-shadow: 0 14px 24px rgba(15,23,42,.12);
}

.piece-card.is-placed { opacity: .36; pointer-events: none; filter: grayscale(.8); }

.piece-name {
  min-width: 85px;
}

.piece-name strong { display: block; font-size: .95rem; }
.piece-name span { display: block; margin-top: 4px; color: var(--muted); font-size: .76rem; font-weight: 800; }

.mini-grid {
  --w: 5;
  --h: 5;
  display: grid;
  grid-template-columns: repeat(var(--w), 15px);
  grid-template-rows: repeat(var(--h), 15px);
  gap: 3px;
  padding: 8px;
  border-radius: 13px;
  background: rgba(15,23,42,.07);
}

.mini-cell {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  background: transparent;
}

.mini-cell.on { box-shadow: inset 0 1px 0 rgba(255,255,255,.36); }

.controls {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.controls .ghost { grid-column: 1 / -1; }

.primary,
.secondary,
.ghost {
  min-height: 46px;
  border-radius: 16px;
  border: 0;
  font-weight: 900;
  transition: transform .14s ease, filter .14s ease, background .14s ease;
}

.primary:hover,
.secondary:hover,
.ghost:hover { transform: translateY(-1px); }

.primary { color: #fff; background: linear-gradient(145deg, #0f172a, #2563eb); }
.secondary { color: #17233a; background: rgba(15,23,42,.08); }
.ghost { color: #315d88; background: transparent; border: 1px solid rgba(49,93,136,.22); }

.game-over {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2,6,23,.68);
  backdrop-filter: blur(9px);
}

.game-over-card {
  width: min(430px, 100%);
  padding: 26px;
  border-radius: 28px;
  background: rgba(255,255,255,.95);
  box-shadow: 0 28px 80px rgba(0,0,0,.35);
  text-align: center;
}

.game-over-card h2 {
  margin: 0;
  font-size: 2.2rem;
  letter-spacing: -.05em;
}

.game-over-card p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.5;
}

.final-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0;
}

.final-stats div {
  padding: 12px;
  border-radius: 18px;
  background: rgba(15,23,42,.07);
}

.final-stats span { display: block; color: var(--muted); font-size: .74rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.final-stats strong { display: block; margin-top: 5px; font-size: 1.5rem; }

.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@keyframes cellPop {
  0% { transform: scale(.72); opacity: .45; }
  70% { transform: scale(1.08); }
  100% { transform: scale(.98); opacity: 1; }
}

@keyframes clearCell {
  0% { transform: scale(.96) rotate(0); opacity: 1; }
  100% { transform: scale(.15) rotate(18deg); opacity: 0; }
}

@keyframes hintPulse {
  from { box-shadow: inset 0 0 0 2px rgba(255,255,255,.18), 0 0 0 rgba(34,197,94,0); }
  to { box-shadow: inset 0 0 0 2px rgba(255,255,255,.42), 0 0 18px rgba(34,197,94,.44); }
}

@keyframes floatScore {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(.86); }
  16% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -115%) scale(1.06); }
}

@media (max-width: 980px) {
  .hud { grid-template-columns: repeat(3, 1fr); }
  .hud-status { grid-column: 1 / -1; min-height: 56px; }
  .play-layout { grid-template-columns: 1fr; }
  .piece-panel { order: -1; }
  .piece-tray { grid-template-columns: repeat(3, 1fr); }
  .piece-card { min-height: 132px; flex-direction: column; align-items: flex-start; justify-content: space-between; }
  .mini-grid { grid-template-columns: repeat(var(--w), 13px); grid-template-rows: repeat(var(--h), 13px); }
  .mini-cell { width: 13px; height: 13px; }
}

@media (max-width: 650px) {
  .block-shell { padding: 10px; align-items: start; }
  .block-card { border-radius: 24px; }
  .block-header { padding: 18px; }
  .logo-chip { width: 52px; height: 52px; border-radius: 18px; font-size: .9rem; }
  .mode-grid { grid-template-columns: 1fr; }
  .hud { grid-template-columns: repeat(2, 1fr); }
  .hud-status { grid-column: 1 / -1; }
  .piece-tray { grid-template-columns: 1fr; }
  .piece-card { min-height: 86px; flex-direction: row; align-items: center; }
  .board-topline { align-items: flex-start; flex-direction: column; }
}

/* Mobile fullscreen upgrade */
.mobile-menu-button,
.mobile-game-menu { display: none; }

.mobile-menu-actions {
  display: grid;
  gap: 10px;
}

.mobile-exit-link {
  min-height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  text-decoration: none;
  font-weight: 900;
}

@media (max-width: 900px), (pointer: coarse) and (max-height: 620px) {
  html,
  body {
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body {
    position: fixed;
    inset: 0;
    background:
      radial-gradient(circle at 18% 8%, rgba(20,184,166,.22), transparent 34%),
      radial-gradient(circle at 86% 16%, rgba(59,130,246,.24), transparent 34%),
      linear-gradient(145deg, #07101f, #12213b 58%, #0b1220);
  }

  .block-shell {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 0;
    display: block;
    overflow: hidden;
  }

  .block-card {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    overflow: hidden;
  }

  .block-header {
    display: none;
  }

  .choose-screen {
    height: 100vh;
    height: 100dvh;
    padding: calc(16px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom));
    display: grid;
    align-content: center;
    gap: 14px;
    color: #fff;
    overflow: hidden;
  }

  .choose-copy {
    margin: 0;
    text-align: center;
  }

  .choose-copy h2 {
    color: #fff;
    font-size: clamp(1.55rem, 7vw, 2.45rem);
  }

  .choose-copy p,
  .choose-copy .eyebrow {
    color: rgba(255,255,255,.74);
  }

  .mode-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .mode-card {
    min-height: 0;
    padding: 16px;
    border-radius: 22px;
    background: rgba(255,255,255,.92);
    box-shadow: 0 20px 45px rgba(0,0,0,.24);
  }

  .mode-size {
    min-width: 72px;
    height: 42px;
    margin-bottom: 12px;
  }

  .game-screen {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    padding: calc(7px + env(safe-area-inset-top)) 8px calc(7px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 7px;
    overflow: hidden;
  }

  .game-screen.is-hidden {
    display: none !important;
  }

  .hud {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 6px;
    margin: 0;
    align-items: stretch;
  }

  .hud-item {
    min-height: 44px;
    padding: 6px 8px;
    border-radius: 14px;
    background: rgba(255,255,255,.92);
  }

  .hud-item span {
    font-size: .58rem;
    letter-spacing: .07em;
  }

  .hud-item strong {
    margin-top: 2px;
    font-size: clamp(.9rem, 4.4vw, 1.12rem);
    white-space: nowrap;
  }

  .hud-status {
    position: fixed;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
  }

  .mobile-menu-button {
    display: grid;
    place-items: center;
    min-width: 58px;
    min-height: 44px;
    border: 0;
    border-radius: 14px;
    color: #fff;
    font-weight: 1000;
    background: linear-gradient(145deg, #0f172a, #2563eb);
    box-shadow: 0 10px 22px rgba(0,0,0,.22);
  }

  .play-layout {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 7px;
    height: 100%;
    min-height: 0;
    align-items: stretch;
  }

  .board-panel,
  .piece-panel {
    border-radius: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
  }

  .board-panel {
    min-height: 0;
    padding: 0;
    display: grid;
  }

  .board-topline,
  .piece-panel .panel-heading,
  .controls {
    display: none;
  }

  .board-wrap {
    height: 100%;
    min-height: 0;
    padding: 5px;
    border-radius: 22px;
    background:
      radial-gradient(circle at 50% 48%, rgba(56,189,248,.16), transparent 52%),
      linear-gradient(145deg, rgba(15,23,42,.96), rgba(20,62,93,.96));
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.09), inset 0 18px 40px rgba(255,255,255,.04), 0 16px 42px rgba(0,0,0,.28);
  }

  .board {
    width: min(calc(100vw - 16px), calc(100dvh - 174px));
    max-width: 100%;
    max-height: 100%;
    gap: 2px;
    padding: 4px;
    border-radius: 18px;
    background: rgba(3,7,18,.58);
    box-shadow: 0 15px 34px rgba(0,0,0,.28);
  }

  .cell {
    border-radius: clamp(4px, 1.5vw, 8px);
  }

  .piece-panel {
    padding: 0;
    min-height: 0;
  }

  .piece-tray {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin: 0;
  }

  .piece-card {
    min-height: 74px;
    height: clamp(72px, 15dvh, 104px);
    padding: 5px;
    border-radius: 16px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: rgba(255,255,255,.92);
    touch-action: manipulation;
  }

  .piece-card:hover,
  .piece-card.is-selected {
    transform: translateY(-1px);
  }

  .piece-card.is-selected {
    border-color: rgba(96,165,250,.82);
    box-shadow: 0 0 0 2px rgba(96,165,250,.3), 0 12px 26px rgba(15,23,42,.18);
  }

  .piece-name {
    display: none;
  }

  .mini-grid {
    grid-template-columns: repeat(var(--w), clamp(9px, 2.85vw, 14px));
    grid-template-rows: repeat(var(--h), clamp(9px, 2.85vw, 14px));
    gap: 2px;
    padding: 6px;
    border-radius: 12px;
  }

  .mini-cell {
    width: clamp(9px, 2.85vw, 14px);
    height: clamp(9px, 2.85vw, 14px);
    border-radius: 3px;
  }

  .float-score {
    font-size: clamp(1.6rem, 12vw, 3.4rem);
  }

  .mobile-game-menu {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(2,6,23,.62);
    backdrop-filter: blur(10px);
  }

  .mobile-game-menu.is-hidden {
    display: none !important;
  }

  .mobile-game-menu-card {
    width: min(360px, 100%);
    padding: 20px;
    border-radius: 28px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 28px 80px rgba(0,0,0,.4);
  }

  .mobile-game-menu-card h2 {
    margin: 0 0 14px;
    font-size: 1.8rem;
    letter-spacing: -.05em;
  }

  .mobile-menu-actions {
    grid-template-columns: 1fr;
  }

  .game-over {
    padding: 14px;
  }

  .game-over-card {
    max-height: calc(100dvh - 28px);
    overflow: auto;
    padding: 20px;
    border-radius: 24px;
  }

  .game-over-card h2 {
    font-size: 1.8rem;
  }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 620px) {
  .game-screen {
    padding: calc(6px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
    grid-template-rows: auto minmax(0, 1fr);
  }

  .hud-item,
  .mobile-menu-button {
    min-height: 38px;
  }

  .play-layout {
    grid-template-columns: minmax(0, 1fr) clamp(148px, 25vw, 230px);
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
  }

  .board-wrap {
    border-radius: 20px;
  }

  .board {
    width: min(calc(100dvh - 60px), calc(100vw - 260px));
  }

  .piece-panel {
    display: grid;
    align-content: stretch;
  }

  .piece-tray {
    height: 100%;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(3, minmax(0, 1fr));
  }

  .piece-card {
    width: 100%;
    height: auto;
    min-height: 0;
  }

  .mini-grid {
    grid-template-columns: repeat(var(--w), clamp(8px, 1.6vw, 12px));
    grid-template-rows: repeat(var(--h), clamp(8px, 1.6vw, 12px));
  }

  .mini-cell {
    width: clamp(8px, 1.6vw, 12px);
    height: clamp(8px, 1.6vw, 12px);
  }
}


/* Drag-preview upgrade */
.board.is-drag-target {
  box-shadow: 0 20px 40px rgba(0,0,0,.28), 0 0 0 3px rgba(96,165,250,.25), 0 0 34px rgba(96,165,250,.18);
}

.cell.preview-block.preview-ok {
  opacity: .68;
  transform: scale(.9);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), inset 0 -12px 20px rgba(0,0,0,.18), 0 0 18px rgba(255,255,255,.16);
  animation: previewBreathe .5s ease infinite alternate;
}

.cell.preview-bad {
  background: rgba(239,68,68,.36) !important;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.16), inset 0 0 0 4px rgba(239,68,68,.36), 0 0 15px rgba(239,68,68,.3);
  transform: scale(.88);
}

.piece-card,
.piece-tray,
.board {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.piece-card.is-dragging-source {
  opacity: .38;
  transform: scale(.96);
  filter: saturate(.8);
}

.drag-piece-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9999;
  pointer-events: none;
  will-change: transform;
  filter: drop-shadow(0 22px 32px rgba(2,6,23,.34));
}

.drag-piece-ghost .mini-grid {
  grid-template-columns: repeat(var(--w), 20px);
  grid-template-rows: repeat(var(--h), 20px);
  gap: 4px;
  padding: 10px;
  border-radius: 17px;
  background: rgba(15,23,42,.24);
  backdrop-filter: blur(6px);
  box-shadow: 0 0 0 1px rgba(255,255,255,.18), 0 18px 38px rgba(0,0,0,.24);
}

.drag-piece-ghost .mini-cell {
  width: 20px;
  height: 20px;
  border-radius: 6px;
}

@keyframes previewBreathe {
  from { filter: brightness(1); }
  to { filter: brightness(1.12); }
}

@media (max-width: 900px), (pointer: coarse) and (max-height: 620px) {
  .piece-card {
    touch-action: none;
  }

  .drag-piece-ghost .mini-grid {
    grid-template-columns: repeat(var(--w), clamp(15px, 4.1vw, 20px));
    grid-template-rows: repeat(var(--h), clamp(15px, 4.1vw, 20px));
    gap: 3px;
    padding: 9px;
  }

  .drag-piece-ghost .mini-cell {
    width: clamp(15px, 4.1vw, 20px);
    height: clamp(15px, 4.1vw, 20px);
    border-radius: 5px;
  }

  .cell.preview-block.preview-ok {
    opacity: .74;
  }
}

/* iOS/Chrome mobile drag hardening */
.piece-card,
.piece-card *,
.mini-grid,
.mini-cell {
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
}

@media (max-width: 900px), (pointer: coarse) {
  .piece-tray,
  .piece-card,
  .piece-card *,
  .board,
  .cell {
    touch-action: none !important;
  }

  .drag-piece-ghost {
    z-index: 2147483647;
    opacity: .98;
  }

  .board.is-drag-target {
    outline: 3px solid rgba(96,165,250,.34);
    outline-offset: 3px;
  }
}


/* Mobile-safe board-slide placement mode */
@media (max-width: 900px), (pointer: coarse) {
  .board.is-board-touching {
    outline: 4px solid rgba(52, 211, 153, .34);
    outline-offset: 4px;
  }

  .piece-card.is-selected::after {
    content: "Slide on board";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    padding: 6px 8px;
    border-radius: 999px;
    background: rgba(34, 197, 94, .16);
    color: #047857;
    font-size: .66rem;
    font-weight: 1000;
    letter-spacing: .03em;
    text-transform: uppercase;
  }

  .drag-piece-ghost {
    transform-origin: center center;
  }
}
