.bp-shell {
  --bp-deep: #142238;
  --bp-night: #1d3150;
  --bp-cream: #fffaf0;
  --bp-paper: #f3ead7;
  --bp-zero: #0f7d78;
  --bp-one: #c86224;
  --bp-gold: #f0b54e;
  --bp-soft: rgba(20, 34, 56, 0.1);
  width: min(92vw, 720px);
  max-width: 100%;
  margin: 0 auto;
  color: var(--cg-ink);
}

.cg-stage-main #game-root > .bp-shell {
  width: min(92vw, 720px);
  max-width: 720px;
}

.bp-chrome {
  min-height: 60px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bp-stats,
.bp-actions,
.bp-toggle-group,
.bp-result-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bp-stats {
  min-width: 0;
}

.bp-stat {
  min-width: 76px;
  padding: 6px 11px;
  border: 1px solid var(--cg-line);
  border-radius: 14px;
  background: var(--cg-panel);
  box-shadow: 0 4px 12px rgba(20, 34, 56, 0.06);
}

.bp-stat span,
.bp-result-stats span {
  display: block;
  color: var(--cg-muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.bp-stat strong {
  display: block;
  margin-top: 1px;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bp-actions {
  flex: 0 0 auto;
}

.bp-action,
.bp-icon,
.bp-primary,
.bp-secondary,
.bp-toggle,
.bp-close {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.bp-action,
.bp-icon {
  border: 1px solid var(--cg-line);
  border-radius: 13px;
  background: var(--cg-panel);
  color: var(--bp-deep);
  font-weight: 900;
  box-shadow: 0 4px 12px rgba(20, 34, 56, 0.07);
}

.bp-action {
  padding: 0 11px;
  font-size: 12px;
}

.bp-icon {
  width: 46px;
  height: 46px;
  padding: 0;
  font-size: 19px;
}

.bp-action:disabled {
  cursor: default;
  opacity: 0.42;
  box-shadow: none;
}

.bp-action:not(:disabled):hover,
.bp-icon:hover,
.bp-toggle:hover {
  border-color: var(--cg-blue);
}

.bp-action:focus-visible,
.bp-icon:focus-visible,
.bp-primary:focus-visible,
.bp-secondary:focus-visible,
.bp-toggle:focus-visible,
.bp-close:focus-visible {
  outline: 3px solid var(--cg-amber);
  outline-offset: 2px;
}

.bp-board-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: clamp(8px, 1.6vw, 14px);
  overflow: hidden;
  border: 1px solid rgba(20, 34, 56, 0.28);
  border-radius: 28px;
  background:
    radial-gradient(circle at 18% 8%, rgba(240, 181, 78, 0.2), transparent 25%),
    radial-gradient(circle at 88% 92%, rgba(15, 125, 120, 0.23), transparent 28%),
    linear-gradient(145deg, #1d3150, #101c31 68%, #162b43);
  box-shadow: var(--cg-shadow);
}

.bp-board {
  --bp-gap: clamp(2px, 0.55vw, 6px);
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: repeat(var(--bp-size), minmax(0, 1fr));
  gap: var(--bp-gap);
  border-radius: 18px;
  outline: none;
}

.bp-board:focus-visible {
  box-shadow: 0 0 0 4px rgba(240, 181, 78, 0.62);
}

.bp-row {
  display: grid;
  grid-template-columns: repeat(var(--bp-size), minmax(0, 1fr));
  gap: var(--bp-gap);
}

.bp-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(20, 34, 56, 0.12);
  border-radius: clamp(5px, 1.1vw, 12px);
  background: var(--bp-cream);
  color: var(--bp-deep);
  font: inherit;
  font-size: clamp(18px, 4.2vw, 38px);
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: inset 0 -2px 0 rgba(20, 34, 56, 0.08);
  transition: background 80ms ease, color 80ms ease, transform 80ms ease, box-shadow 80ms ease;
}

.bp-cell:hover {
  background: #fffdf7;
  transform: translateY(-1px);
}

.bp-cell.bp-zero {
  background: #d8efea;
  color: var(--bp-zero);
}

.bp-cell.bp-one {
  background: #fae3cf;
  color: var(--bp-one);
}

.bp-cell.bp-given {
  border-color: rgba(20, 34, 56, 0.26);
  background: var(--bp-paper);
  box-shadow: inset 0 0 0 1px rgba(20, 34, 56, 0.08), inset 0 -3px 0 rgba(20, 34, 56, 0.12);
}

.bp-cell.bp-given::after {
  content: "";
  position: absolute;
  top: 12%;
  right: 12%;
  width: clamp(3px, 0.55vw, 6px);
  height: clamp(3px, 0.55vw, 6px);
  border-radius: 50%;
  background: var(--bp-deep);
  opacity: 0.34;
}

.bp-cell.bp-selected {
  z-index: 1;
  outline: 3px solid var(--cg-blue);
  outline-offset: -3px;
  box-shadow: 0 0 0 3px rgba(49, 95, 157, 0.18);
}

.bp-cell.bp-conflict {
  border-color: #8e1f25;
  outline: 2px solid #d53d43;
  outline-offset: -2px;
  background: #b82e35;
  color: #fff;
}

.bp-cell.bp-conflict.bp-selected {
  outline: 3px solid #ffd37c;
  outline-offset: -3px;
}

.bp-result {
  position: absolute;
  inset: 0;
  z-index: 5;
  padding: clamp(22px, 5vw, 52px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 0%, rgba(240, 181, 78, 0.18), transparent 42%),
    linear-gradient(145deg, rgba(16, 28, 49, 0.98), rgba(29, 49, 80, 0.97));
  color: #fff;
}

.bp-result[hidden],
.bp-modal[hidden] {
  display: none;
}

.bp-kicker {
  color: #8be1cf;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.bp-result > strong {
  margin-top: 8px;
  font-size: clamp(32px, 7vw, 60px);
  line-height: 1.02;
}

.bp-result > p {
  max-width: 420px;
  margin: 14px 0 20px;
  color: rgba(255, 255, 255, 0.72);
  font-size: clamp(14px, 2.4vw, 18px);
  line-height: 1.45;
}

.bp-result-stats {
  width: min(100%, 440px);
  margin-bottom: 22px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.bp-result-stats div {
  padding: 11px 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
}

.bp-result-stats span {
  color: rgba(255, 255, 255, 0.58);
}

.bp-result-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.bp-primary,
.bp-secondary {
  padding: 0 18px;
  border-radius: 14px;
  font-weight: 900;
}

.bp-primary {
  background: var(--bp-gold);
  color: #2c2112;
  box-shadow: 0 6px 0 #a96e22;
}

.bp-secondary {
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.bp-below {
  min-height: 106px;
  padding: 12px 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.bp-toggle {
  padding: 0 13px;
  border: 1px solid var(--cg-line);
  border-radius: 13px;
  background: var(--cg-panel);
  color: var(--cg-ink);
  font-size: 13px;
  font-weight: 800;
}

.bp-toggle.bp-active {
  border-color: var(--bp-deep);
  background: var(--bp-deep);
  color: #fff;
}

.bp-size {
  min-width: 58px;
}

.bp-copy {
  flex-basis: 100%;
  color: var(--cg-muted);
  font-size: 12px;
  text-align: center;
}

.bp-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  padding: 18px;
  display: grid;
  place-items: center;
  background: rgba(9, 16, 28, 0.76);
}

.bp-modal-card {
  position: relative;
  width: min(100%, 540px);
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  padding: 30px;
  border: 1px solid var(--cg-line);
  border-radius: 24px;
  background: var(--cg-panel);
  color: var(--cg-ink);
  box-shadow: var(--cg-shadow);
}

.bp-modal-card h2 {
  margin: 8px 52px 14px 0;
  font-size: clamp(25px, 5vw, 32px);
}

.bp-modal-card p {
  margin: 11px 0;
  color: var(--cg-muted);
  line-height: 1.55;
}

.bp-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 13px;
  background: var(--cg-bg);
  color: var(--cg-ink);
  font-size: 25px;
}

@media (max-width: 600px) {
  .bp-shell {
    width: 100%;
  }

  .cg-stage-main #game-root > .bp-shell {
    width: 100%;
    max-width: 100%;
  }

  .bp-chrome {
    min-height: 55px;
    margin-bottom: 8px;
  }

  .bp-stats {
    flex: 1;
    gap: 5px;
  }

  .bp-stat {
    flex: 1;
    min-width: 0;
    padding: 6px 7px;
    border-radius: 12px;
  }

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

  .bp-actions {
    gap: 3px;
  }

  .bp-action {
    padding: 0 8px;
    font-size: 11px;
  }

  .bp-icon {
    width: 44px;
    height: 44px;
  }

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

  .bp-board-wrap {
    padding: 7px;
  }

  .bp-board {
    --bp-gap: 2px;
    border-radius: 14px;
  }

  .bp-cell {
    border-radius: 5px;
  }

  .bp-below {
    min-height: 108px;
    padding-top: 8px;
    gap: 6px;
  }

  .bp-toggle {
    padding: 0 9px;
    font-size: 12px;
  }

  .bp-result {
    padding: 18px;
  }

  .bp-result > p {
    margin: 10px 0 16px;
  }

  .bp-result-stats {
    margin-bottom: 16px;
  }

  .bp-primary,
  .bp-secondary {
    padding: 0 12px;
    font-size: 13px;
  }
}

@media (max-width: 380px) {
  .bp-stat span {
    font-size: 9px;
  }

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

  .bp-action {
    padding: 0 6px;
    font-size: 10px;
  }

  .bp-copy {
    font-size: 11px;
  }
}

@media (max-height: 700px) {
  .bp-chrome {
    min-height: 46px;
    margin-bottom: 4px;
  }

  .bp-board-wrap {
    width: min(100%, calc(100vh - 106px));
    padding: 2px;
    margin: 0 auto;
  }

  .bp-board {
    --bp-gap: 1px;
  }

  .bp-below {
    min-height: 46px;
    padding: 3px 0 0;
  }

  .bp-copy {
    display: none;
  }

  .bp-result {
    padding: 10px;
  }

  .bp-result > strong {
    margin-top: 3px;
    font-size: 24px;
  }

  .bp-result > p {
    display: none;
  }

  .bp-result-stats {
    margin: 8px 0;
  }

  .bp-result-stats div {
    padding: 5px 4px;
  }

  .bp-result-stats strong {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bp-cell {
    transition: none;
  }
}
