.bw-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px 22px;
  color: var(--cg-ink);
  font-family: Inter, Arial, sans-serif;
  --bw-wood: #d8a464;
  --bw-glow: #ffc46b;
  --bw-ice: #6fc6ff;
  --bw-deep: #0a0f19;
}

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

.bw-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: nowrap;
}

.bw-statline,
.bw-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-wrap: nowrap;
}

.bw-statline {
  flex: 1 1 auto;
}

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

.bw-stat {
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  background: linear-gradient(160deg, #1b2334, #101724);
  box-shadow: 0 6px 14px rgba(6, 10, 18, 0.28);
}

.bw-stat span {
  display: block;
  color: #8d9cb4;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.bw-stat strong {
  display: block;
  margin-top: 2px;
  color: #f4f7ff;
  font-size: 19px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.bw-btn,
.bw-close {
  min-height: 44px;
  min-width: 44px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: linear-gradient(165deg, #233049, #141c2c);
  color: #eaf1ff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(6, 10, 18, 0.28);
  transition: transform 120ms ease, border-color 120ms ease, background 160ms ease;
}

.bw-btn {
  padding: 0 14px;
}

.bw-btn:hover,
.bw-close:hover {
  transform: translateY(-1px);
  border-color: var(--bw-ice);
}

.bw-btn:focus-visible,
.bw-close:focus-visible,
.bw-canvas:focus-visible,
.bw-range:focus-visible,
.bw-seg-btn:focus-visible {
  outline: 3px solid rgba(111, 198, 255, 0.5);
  outline-offset: 2px;
}

.bw-icon {
  display: inline-grid;
  place-items: center;
  padding: 0;
  font-size: 19px;
  line-height: 1;
}

.bw-primary {
  border-color: transparent;
  background: linear-gradient(165deg, #2f8f5e, #1c6b45);
  color: #fff;
}

.bw-board {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr)) minmax(0, 1.5fr);
  gap: 3px;
  margin-bottom: 8px;
  padding: 4px;
  border-radius: 12px;
  background: #1b2334;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 20px rgba(6, 10, 18, 0.28);
}

.bw-box {
  position: relative;
  display: grid;
  grid-template-rows: 15px 20px 1fr;
  min-width: 0;
  min-height: 62px;
  overflow: hidden;
  border-radius: 7px;
  background: #f6f1e4;
  color: #1a2233;
}

.bw-box-tenth {
  background: #fbefd2;
}

.bw-box-active {
  background: #dff3ff;
  box-shadow: inset 0 0 0 2px #1f8fd6;
}

.bw-fnum {
  display: block;
  padding-top: 2px;
  background: rgba(26, 34, 51, 0.1);
  color: #4a5670;
  font-size: 10px;
  font-weight: 800;
  line-height: 13px;
  text-align: center;
}

.bw-marks {
  display: flex;
  justify-content: flex-end;
  border-bottom: 1px solid rgba(26, 34, 51, 0.16);
}

.bw-m {
  display: block;
  flex: 0 0 auto;
  min-width: 17px;
  height: 20px;
  border-left: 1px solid rgba(26, 34, 51, 0.16);
  color: #1a2233;
  font-size: 14px;
  font-weight: 900;
  font-style: normal;
  line-height: 20px;
  text-align: center;
}

.bw-m-x {
  color: #c4322c;
}

.bw-run {
  display: grid;
  place-items: center;
  color: #0f1626;
  font-size: 17px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.bw-play {
  display: grid;
  gap: 10px;
}

.bw-side {
  min-width: 0;
}

.bw-stage {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #070b12;
  box-shadow: 0 14px 34px rgba(6, 10, 18, 0.42);
}

.bw-canvas {
  display: block;
  width: 100%;
  height: clamp(380px, 62vh, 620px);
  touch-action: none;
}

.bw-banner {
  position: absolute;
  left: 50%;
  top: 26%;
  transform: translate(-50%, -50%) scale(0.7);
  padding: 10px 22px;
  border-radius: 12px;
  background: rgba(9, 13, 21, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: clamp(22px, 5.4vw, 40px);
  font-weight: 900;
  letter-spacing: 0.04em;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
}

.bw-banner-strike,
.bw-banner-spare {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  animation: bw-pop 420ms cubic-bezier(0.2, 1.5, 0.4, 1);
}

.bw-banner-strike {
  color: #fff2cf;
  border-color: rgba(255, 196, 107, 0.75);
  box-shadow: 0 0 46px rgba(255, 180, 80, 0.5);
}

.bw-banner-spare {
  color: #d8f4ff;
  border-color: rgba(111, 198, 255, 0.7);
  box-shadow: 0 0 40px rgba(90, 180, 255, 0.45);
}

.bw-banner-gutter {
  color: #ffd0d0;
  border-color: rgba(214, 74, 74, 0.7);
}

.bw-banner-normal {
  color: #eef3ff;
}

.bw-result {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  text-align: center;
  background: rgba(7, 11, 18, 0.86);
  backdrop-filter: blur(4px);
  animation: bw-fade 240ms ease;
}

.bw-result span {
  color: var(--bw-glow);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.bw-result strong {
  color: #fff;
  font-size: clamp(38px, 11vw, 62px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.bw-result p {
  margin: 0;
  max-width: 34ch;
  color: #9fb0c8;
  font-size: 13px;
  line-height: 1.45;
}

.bw-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 2px;
  width: min(100%, 420px);
}

.bw-cell {
  padding: 4px 2px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
}

.bw-cell span {
  display: block;
  color: #7c8aa1;
  font-size: 9px;
  font-weight: 800;
}

.bw-cell strong {
  font-size: 12px;
  line-height: 1.2;
}

.bw-result-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.bw-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.bw-meter {
  position: relative;
  grid-column: 1 / -1;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #16202f, #0d1420);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.bw-meter-fill {
  height: 100%;
  width: 72%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3aa5ff 0%, #57d0a0 46%, var(--bw-glow) 78%, #ff6a4d 100%);
  transition: width 60ms linear;
}

.bw-meter-sweet {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 84%;
  width: 2px;
  background: rgba(255, 255, 255, 0.75);
}

.bw-ctl {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 6px 10px 2px;
  border-radius: 11px;
  background: linear-gradient(165deg, #1a2233, #101725);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.bw-ctl label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  color: #8d9cb4;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bw-ctl label b {
  color: #f2f6ff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: none;
  font-variant-numeric: tabular-nums;
}

.bw-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.bw-range::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: #26324a;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.bw-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 30px;
  margin-top: -12px;
  border-radius: 7px;
  background: linear-gradient(170deg, #fdfdff, #b9c6dd);
  border: 1px solid rgba(9, 13, 21, 0.6);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
}

.bw-range::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: #26324a;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.bw-range::-moz-range-thumb {
  width: 20px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(170deg, #fdfdff, #b9c6dd);
  border: 1px solid rgba(9, 13, 21, 0.6);
}


.bw-roll {
  grid-column: 1 / -1;
  min-height: 54px;
  border-color: rgba(255, 196, 107, 0.4);
  background: linear-gradient(165deg, #3b2a12, #1d1608);
  color: var(--bw-glow);
  font-size: 15px;
  letter-spacing: 0.04em;
  touch-action: none;
  user-select: none;
}

.bw-roll-on {
  border-color: var(--bw-glow);
  background: linear-gradient(165deg, #6b4a17, #33230a);
  color: #fff3d6;
  transform: translateY(1px);
}

.bw-below {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.bw-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: #101725;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.bw-seg-btn {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #9fb0c8;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.bw-seg-btn[aria-pressed="true"] {
  background: linear-gradient(165deg, #2c3a55, #1b2436);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(111, 198, 255, 0.35);
}

.bw-note {
  margin: 0;
  flex: 1 1 180px;
  color: var(--cg-muted);
  font-size: 12px;
  line-height: 1.4;
}

.bw-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(6, 9, 15, 0.72);
  backdrop-filter: blur(3px);
}

.bw-modal-card {
  position: relative;
  width: min(100%, 430px);
  max-height: 84vh;
  overflow: auto;
  padding: 20px;
  border-radius: 16px;
  background: linear-gradient(170deg, #1a2334, #0e141f);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 20px 50px rgba(4, 7, 12, 0.6);
}

.bw-modal-card h2 {
  margin: 0 46px 10px 0;
  color: #fff;
  font-size: 20px;
}

.bw-modal-card p {
  margin: 0 0 10px;
  color: #9fb0c8;
  font-size: 14px;
  line-height: 1.5;
}
.bw-modal-card b {
  color: #dce6f7;
}

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

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

@keyframes bw-pop {
  0% { transform: translate(-50%, -50%) scale(0.72); opacity: 0; }
  60% { transform: translate(-50%, -50%) scale(1.06); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}


@keyframes bw-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

  .bw-stat {
    padding: 5px 6px;
  }

  .bw-topbar,
  .bw-actions {
    gap: 4px;
  }

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

  .bw-controls {
    gap: 6px;
    margin-top: 8px;
  }

  .bw-ctl {
    padding: 5px 6px 0;
  }

  .bw-board {
    gap: 2px;
    padding: 3px;
  }

  .bw-box {
    min-height: 56px;
    grid-template-rows: 13px 18px 1fr;
  }

  .bw-fnum {
    font-size: 9px;
    line-height: 11px;
  }

  .bw-m {
    min-width: 12px;
    height: 18px;
    font-size: 12px;
    line-height: 18px;
  }

  .bw-run {
    font-size: 13px;
  }

  .bw-canvas {
    height: clamp(340px, calc(100svh - 455px), 560px);
  }
}

@media (min-width: 900px) {
  .bw-play {
    grid-template-columns: minmax(0, 1fr) 300px;
    align-items: start;
  }

  .bw-canvas {
    height: clamp(420px, calc(100svh - 300px), 640px);
  }

  .bw-controls {
    grid-template-columns: 1fr;
    margin-top: 0;
  }

  .bw-ctl {
    padding: 6px 12px 0;
  }

  .bw-below {
    flex-direction: column;
    align-items: stretch;
  }

  .bw-seg {
    align-self: flex-start;
  }
}

@media (pointer: coarse) {
  .bw-btn,
  .bw-close,
  .bw-seg-btn {
    min-height: 46px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bw-banner-strike,
  .bw-banner-spare,
  .bw-result {
    animation: none;
  }
}
