.bp-shell {
  --bp-cell: 40px;
  --bp-ink: #16202a;
  --bp-deep: #1b2733;
  --bp-deep2: #25374a;
  --bp-rim: rgba(255, 255, 255, 0.1);
  max-width: 760px;
  margin: 0 auto;
  padding: 0 14px 26px;
  color: var(--cg-ink);
  font-family: Inter, Arial, sans-serif;
}

.cg-shell-game .cg-stage-main #game-root > .bp-shell {
  max-width: min(100%, 760px) !important;
}

.bp-topbar,
.bp-statline,
.bp-actions,
.bp-below {
  display: flex;
  align-items: center;
}

.bp-topbar {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.bp-statline,
.bp-actions {
  gap: 8px;
  flex-wrap: wrap;
}

.bp-stat,
.bp-hud-card {
  min-width: 74px;
  padding: 7px 11px;
  border: 1px solid var(--cg-line);
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #f4f6f2);
  box-shadow: 0 6px 16px rgba(24, 34, 30, 0.08);
}

.bp-stat span,
.bp-hud-card span {
  display: block;
  color: var(--cg-muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.bp-stat strong,
.bp-hud-card strong {
  display: block;
  margin-top: 2px;
  font-size: 19px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.bp-btn,
.bp-close {
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--cg-line);
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #f2f4f0);
  color: var(--cg-ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(24, 34, 30, 0.08);
  transition: transform 120ms ease, border-color 120ms ease;
}

.bp-btn:hover,
.bp-close:hover {
  transform: translateY(-1px);
  border-color: var(--cg-teal);
}

.bp-btn:focus-visible,
.bp-close:focus-visible,
.bp-grid:focus-visible,
.bp-seg-btn:focus-visible {
  outline: 3px solid rgba(49, 95, 157, 0.4);
  outline-offset: 2px;
}

.bp-icon {
  display: inline-grid;
  padding: 0;
  place-items: center;
}

.bp-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bp-icon.is-off {
  color: var(--cg-red);
}

.bp-primary {
  border-color: transparent;
  background: linear-gradient(180deg, #17907f, #0f6f63);
  color: #fff;
}

.bp-stage {
  position: relative;
}

.bp-hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 560px);
  margin: 0 auto 10px;
}

.bp-hud-card {
  position: relative;
  overflow: hidden;
  text-align: left;
}

.bp-hud-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--cg-teal);
  content: "";
}

.bp-hud-combo::before {
  background: var(--cg-amber);
}

.bp-hud-lines::before {
  background: var(--cg-green);
}

.bp-hud-pieces::before {
  background: var(--cg-blue);
}

.bp-hud-score strong {
  font-size: 24px;
}

.bp-well {
  position: relative;
  width: min(100%, 560px, 68vh);
  margin: 0 auto;
  aspect-ratio: 1;
  border: 1px solid #16222c;
  border-radius: 16px;
  background:
    radial-gradient(120% 90% at 50% -18%, rgba(96, 205, 190, 0.34), transparent 60%),
    linear-gradient(180deg, var(--bp-deep2) 0%, var(--bp-deep) 62%, #141d26 100%);
  box-shadow: var(--cg-shadow), inset 0 1px 0 var(--bp-rim);
  touch-action: none;
  user-select: none;
  overflow: hidden;
}

.bp-well::after {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  box-shadow: inset 0 0 60px rgba(6, 12, 18, 0.55);
  content: "";
  pointer-events: none;
}

.bp-grid {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 2px;
  padding: 5px;
}

.bp-cell {
  position: relative;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.045);
}

.bp-cell.bp-on {
  border-radius: 6px;
  background-image: linear-gradient(155deg, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0.06) 38%, rgba(0, 0, 0, 0.2) 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.42),
    inset 0 -3px 0 rgba(0, 0, 0, 0.22),
    0 3px 6px rgba(4, 10, 16, 0.35);
}

.bp-cell.bp-fall {
  animation: bp-fall 300ms cubic-bezier(0.3, 0.9, 0.3, 1) both;
}

@keyframes bp-fall {
  from {
    transform: translate(calc(var(--bp-shift, 0) * var(--bp-cell)), calc(var(--bp-drop, 0) * var(--bp-cell)));
  }
  to {
    transform: translate(0, 0);
  }
}

.bp-cell.bp-clear {
  animation: bp-clear 240ms ease-in both;
}

@keyframes bp-clear {
  0% {
    transform: scale(1);
    filter: brightness(1.9);
  }
  60% {
    transform: scale(0.72) rotate(6deg);
    filter: brightness(2.4) saturate(0.5);
  }
  100% {
    transform: scale(0);
    opacity: 0;
  }
}

.bp-cell.bp-lock {
  animation: bp-lock 200ms cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

@keyframes bp-lock {
  from {
    transform: scale(0.55);
    opacity: 0.4;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.bp-cell.bp-blocked {
  animation: bp-blocked 900ms ease-in-out infinite;
}

@keyframes bp-blocked {
  0%,
  100% {
    box-shadow:
      inset 0 2px 0 rgba(255, 255, 255, 0.3),
      0 0 0 2px rgba(189, 60, 55, 0.95);
  }
  50% {
    box-shadow:
      inset 0 2px 0 rgba(255, 255, 255, 0.3),
      0 0 14px 4px rgba(189, 60, 55, 0.85);
  }
}

.bp-k0 { background-color: #1d7f62; }
.bp-k1 { background-color: #127a89; }
.bp-k2 { background-color: #315f9d; }
.bp-k3 { background-color: #6b4fa0; }
.bp-k4 { background-color: #bd3c37; }
.bp-k5 { background-color: #c47a17; }
.bp-k6 { background-color: #2f7d4f; }
.bp-k7 { background-color: #b0497f; }

.bp-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.bp-blk {
  position: absolute;
  left: calc((var(--bp-ax) + var(--bx)) * var(--bp-cell));
  top: calc((var(--bp-ay) + var(--by)) * var(--bp-cell));
  width: var(--bp-cell);
  height: var(--bp-cell);
  margin: 1px;
  border-radius: 6px;
  background-image: linear-gradient(155deg, rgba(255, 255, 255, 0.46) 0%, rgba(255, 255, 255, 0.08) 36%, rgba(0, 0, 0, 0.22) 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.5),
    inset 0 -3px 0 rgba(0, 0, 0, 0.24),
    0 6px 12px rgba(3, 8, 14, 0.45);
}

.bp-ghost .bp-blk {
  box-shadow: none;
  background-image: none;
  opacity: 0.5;
  border: 2px solid #7ef0c0;
  background-color: rgba(46, 214, 154, 0.34);
}

.bp-ghost.bp-g-no .bp-blk {
  border-color: #ff8f8a;
  background-color: rgba(226, 74, 68, 0.34);
}

.bp-piece {
  z-index: 4;
  transition: transform 90ms linear;
}

.bp-piece.bp-grab {
  transition: none;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.5));
}

.bp-piece.bp-grab .bp-blk {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    inset 0 -3px 0 rgba(0, 0, 0, 0.26),
    0 10px 18px rgba(3, 8, 14, 0.5);
}

.bp-piece.bp-nope {
  animation: bp-nope 260ms ease both;
}

@keyframes bp-nope {
  0%,
  100% {
    transform: translate(var(--bp-nx, 0), var(--bp-ny, 0));
  }
  25% {
    transform: translate(calc(var(--bp-nx, 0px) - 7px), var(--bp-ny, 0px));
  }
  75% {
    transform: translate(calc(var(--bp-nx, 0px) + 7px), var(--bp-ny, 0px));
  }
}

.bp-fx {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.bp-spark {
  position: absolute;
  width: calc(var(--bp-cell) * 0.3);
  height: calc(var(--bp-cell) * 0.3);
  margin-left: calc(var(--bp-cell) * -0.15);
  margin-top: calc(var(--bp-cell) * -0.15);
  border-radius: 50%;
  background-image: linear-gradient(160deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0));
  animation: bp-spark 620ms ease-out var(--d, 0ms) both;
}

@keyframes bp-spark {
  0% {
    transform: translate(0, 0) scale(1.1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--sx), var(--sy)) scale(0.2);
    opacity: 0;
  }
}

.bp-pop {
  position: absolute;
  left: 50%;
  top: 22%;
  z-index: 6;
  padding: 7px 15px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(12, 20, 27, 0.86);
  color: #fff;
  font-size: 15px;
  font-weight: 850;
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  animation: bp-pop 700ms cubic-bezier(0.2, 1.4, 0.4, 1) both;
  pointer-events: none;
}

.bp-pop-big {
  background: linear-gradient(180deg, #f0a63a, #c47a17);
}

.bp-pop-good {
  background: rgba(12, 20, 27, 0.86);
}

.bp-pop-back {
  background: linear-gradient(180deg, #2a9d8f, #127a89);
}

@keyframes bp-pop {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(12px) scale(0.8);
  }
  22% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1.06);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-16px) scale(1);
  }
}

.bp-result {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 7;
  display: grid;
  gap: 8px;
  width: min(88%, 330px);
  padding: 18px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--cg-line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--cg-shadow);
  text-align: center;
  animation: bp-in 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
  backdrop-filter: blur(8px);
}

@keyframes bp-in {
  from {
    opacity: 0;
    transform: translate(-50%, -46%) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.bp-result > span {
  color: var(--cg-muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.bp-result > strong {
  font-size: 27px;
  line-height: 1.05;
}

.bp-result p {
  margin: 0;
  color: var(--cg-muted);
  font-size: 13px;
  line-height: 1.4;
}

.bp-final-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.bp-final-grid div {
  padding: 6px 2px;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  background: rgba(246, 247, 242, 0.9);
}

.bp-final-grid span {
  display: block;
  color: var(--cg-muted);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bp-final-grid strong {
  display: block;
  font-size: 15px;
}

.bp-result-actions {
  display: flex;
  gap: 8px;
}

.bp-result-actions .bp-btn {
  flex: 1 1 0;
}

.bp-below {
  justify-content: center;
  gap: 10px;
  width: min(100%, 560px);
  margin: 12px auto 0;
  flex-wrap: wrap;
}

.bp-tray {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 12px;
  border: 1px solid var(--cg-line);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--bp-deep2), var(--bp-deep));
  box-shadow: 0 8px 20px rgba(20, 30, 40, 0.22);
}

.bp-tray > span {
  color: #b8c6cf;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bp-tray-grid {
  position: relative;
  width: 46px;
  height: 44px;
}

.bp-seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--cg-line);
  border-radius: 12px;
  background: var(--cg-panel);
  box-shadow: 0 8px 20px rgba(24, 34, 30, 0.08);
}

.bp-seg-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--cg-muted);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.bp-seg-btn:hover {
  background: rgba(18, 122, 137, 0.1);
  color: var(--cg-ink);
}

.bp-seg-btn[aria-pressed="true"] {
  background: linear-gradient(180deg, #17907f, #0f6f63);
  color: #fff;
}

.bp-note {
  width: min(100%, 560px);
  margin: 10px auto 0;
  color: var(--cg-muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

.bp-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 28, 34, 0.42);
}

.bp-modal-card {
  position: relative;
  width: min(100%, 440px);
  padding: 22px;
  border: 1px solid var(--cg-line);
  border-radius: 14px;
  background: var(--cg-panel);
  color: var(--cg-ink);
  box-shadow: 0 24px 70px rgba(10, 20, 26, 0.3);
}

.bp-modal-card h2 {
  margin: 0 48px 12px 0;
  font-size: 24px;
  line-height: 1.1;
}

.bp-modal-card p {
  margin: 10px 0 0;
  color: var(--cg-muted);
  font-size: 14px;
  line-height: 1.45;
}

.bp-close {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

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

.bp-shake {
  animation: bp-shake 320ms ease both;
}

@keyframes bp-shake {
  0%,
  100% {
    transform: translate(0, 0);
  }
  20% {
    transform: translate(-6px, 3px);
  }
  45% {
    transform: translate(5px, -4px);
  }
  70% {
    transform: translate(-3px, -2px);
  }
}

@media (max-width: 560px) {
  .bp-shell {
    padding: 0 8px 20px;
  }

  .bp-topbar {
    gap: 8px;
  }

  .bp-stat {
    min-width: 68px;
    padding: 6px 9px;
  }

  .bp-stat strong {
    font-size: 17px;
  }

  .bp-hud {
    gap: 5px;
  }

  .bp-hud-card {
    padding: 6px 7px;
  }

  .bp-hud-card span {
    font-size: 9px;
  }

  .bp-hud-card strong,
  .bp-hud-score strong {
    font-size: 18px;
  }

  .bp-well {
    width: min(100%, 420px, 58vh);
  }

  .bp-below {
    gap: 8px;
  }

  .bp-seg {
    flex: 1 1 auto;
    justify-content: center;
  }

  .bp-seg-btn {
    flex: 1 1 0;
    padding: 0 8px;
    font-size: 13px;
  }

  .bp-tray {
    order: -1;
  }
}

.bp-shell {
  max-width: 820px;
}

.cg-shell-game .cg-stage-main #game-root > .bp-shell {
  max-width: min(100%, 820px) !important;
}

.bp-topbar {
  width: min(100%, 640px);
  margin: 0 auto 10px;
}

.bp-statline {
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
}

.bp-stat {
  position: relative;
  min-width: 0;
  padding: 6px 10px 8px;
  overflow: hidden;
}

.bp-stat::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--cg-teal);
  content: "";
}

.bp-hud-combo::before { background: var(--cg-amber); }
.bp-hud-lines::before { background: var(--cg-green); }
.bp-hud-best::before { background: var(--cg-blue); }

.bp-hud-score strong {
  min-width: 3.4ch;
  font-size: 20px;
}

.bp-goal {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.08);
}

.bp-goal b {
  display: block;
  width: 0;
  height: 100%;
  background: var(--cg-green);
  transition: width 300ms ease;
}

.bp-hot .bp-hud-combo strong {
  color: #c47a17;
  animation: bp-beat 700ms ease-in-out infinite;
}

@keyframes bp-beat {
  50% { transform: scale(1.25); }
}

.bp-well {
  width: min(100%, 640px, calc(100vh - 250px));
  min-width: 260px;
  border-radius: 18px;
  background:
    radial-gradient(120% 90% at 50% -18%, rgba(96, 205, 190, 0.3), transparent 60%),
    repeating-conic-gradient(rgba(255, 255, 255, 0.025) 0 25%, transparent 0 50%) 0 0 / calc(var(--bp-cell) * 2) calc(var(--bp-cell) * 2),
    linear-gradient(180deg, #23364a 0%, #172230 62%, #10171f 100%);
}

.bp-cell:not(.bp-on) {
  background: rgba(255, 255, 255, 0.045);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), inset 0 2px 5px rgba(0, 0, 0, 0.25);
}

.bp-cell.bp-on {
  background-image:
    linear-gradient(160deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.05) 42%, rgba(0, 0, 0, 0.28) 100%),
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.35), transparent 40%);
}

.bp-cell.bp-pre {
  animation: bp-pre 520ms ease-in-out infinite alternate;
}

@keyframes bp-pre {
  from { filter: brightness(1.1); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55), 0 0 6px rgba(255, 255, 255, 0.4); }
  to { filter: brightness(1.7); box-shadow: inset 0 0 0 2px #fff, 0 0 16px 2px rgba(255, 255, 255, 0.85); }
}

.bp-cell.bp-clear {
  animation: bp-clear2 380ms ease-in var(--cd, 0ms) both;
}

@keyframes bp-clear2 {
  0% { transform: scale(1); filter: brightness(1); }
  30% { transform: scale(1.12); filter: brightness(2.6) saturate(0.4); }
  100% { transform: scale(0); opacity: 0; filter: brightness(3); }
}

.bp-cell.bp-lock {
  animation: bp-lock2 260ms cubic-bezier(0.2, 1.6, 0.4, 1) both;
}

@keyframes bp-lock2 {
  0% { transform: scale(0.5); filter: brightness(2.2); }
  100% { transform: scale(1); filter: brightness(1); }
}

.bp-piece:not(.bp-grab) {
  animation: bp-idle 1.2s ease-in-out infinite;
}

@keyframes bp-idle {
  50% { filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.7)); }
}

.bp-piece.bp-nope {
  animation: bp-nope 260ms ease both;
}

.bp-spark {
  width: calc(var(--bp-cell) * 0.34);
  height: calc(var(--bp-cell) * 0.34);
  margin-left: calc(var(--bp-cell) * -0.17);
  margin-top: calc(var(--bp-cell) * -0.17);
  background-image: linear-gradient(160deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0));
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
  animation: bp-spark2 900ms cubic-bezier(0.2, 0.7, 0.4, 1) var(--d, 0ms) both;
}

.bp-spark.bp-sq {
  border-radius: 3px;
}

@keyframes bp-spark2 {
  0% { transform: translate(0, 0) scale(1.2) rotate(0); opacity: 1; }
  100% { transform: translate(var(--sx), var(--sy)) scale(0.1) rotate(var(--r)); opacity: 0; }
}

.bp-pop {
  top: 40%;
  padding: 9px 20px;
  font-size: 22px;
}

.bp-tray {
  padding: 4px 12px;
  gap: 10px;
}

.bp-tray-grid {
  width: 64px;
  height: 52px;
}

.bp-pcs {
  color: var(--cg-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bp-pcs b {
  color: var(--cg-ink);
  font-size: 15px;
}

.bp-below {
  width: min(100%, 640px);
}

.bp-note {
  width: min(100%, 640px);
  margin-top: 8px;
}

@media (max-width: 560px) {
  .bp-shell {
    padding: 0 6px 16px;
  }

  .bp-topbar {
    gap: 6px;
  }

  .bp-stat {
    padding: 5px 7px 7px;
  }

  .bp-stat span {
    font-size: 8.5px;
    letter-spacing: 0.02em;
  }

  .bp-stat strong,
  .bp-hud-score strong {
    font-size: 16px;
  }

  .bp-actions {
    gap: 5px;
  }

  .bp-actions .bp-btn {
    min-width: 44px;
  }

  .bp-hud-best {
    display: none;
  }

  .bp-well {
    width: 100%;
    min-width: 0;
  }

  .bp-pcs {
    display: none;
  }

  .bp-tray {
    order: 0;
  }

  .bp-below {
    flex-wrap: wrap;
    gap: 6px;
  }

  .bp-tray {
    flex: 1 1 100%;
    justify-content: center;
  }

  .bp-seg {
    flex: 1 1 0;
    min-width: 0;
    padding: 2px;
  }

  .bp-seg-btn {
    padding: 0 4px;
    font-size: 12px;
  }
}
