.br-game {
  background: #29232c;
  color: #fbebd6;
  border: 1px solid #705456;
  border-radius: 12px;
  overflow: hidden;
}
.br-game header {
  padding: 14px 20px;
  background: linear-gradient(110deg, #48303c, #282635);
}
.br-game header small {
  color: #ffc181;
  font-weight: 700;
}
.br-game h2 {
  margin: 4px 0;
  font-size: clamp(20px, 3vw, 29px);
}
.br-game p {
  line-height: 1.4;
}
.br-hint {
  font-size: 0.92rem;
  margin: 3px 0;
}
.br-work {
  padding: clamp(8px, 1.6vw, 18px);
}
.br-board {
  position: relative;
  border: 1px solid #87605a;
  border-radius: 8px;
  overflow: hidden;
}
.br-board canvas {
  display: block;
  width: 100%;
  height: auto;
}
.br-places {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.br-places button {
  pointer-events: auto;
  position: absolute;
  transform: translate(-50%, -50%);
  width: clamp(29px, 5.4vw, 42px);
  aspect-ratio: 1;
  font: 700 clamp(15px, 2.5vw, 21px)/1 system-ui;
  color: #fff5da;
  background: #40303eed;
  border: 2px dashed #f7cb88;
  border-radius: 6px;
  padding: 0;
  touch-action: manipulation;
}
.br-places button[data-part='post'] {
  color: #ffd897;
}
.br-places button[data-part='rope'] {
  color: #b7f1ff;
  border-color: #8cddea;
}
.br-places button[aria-pressed='true'] {
  background: #29584e;
  border-style: solid;
  color: #b6ffe2;
}
.br-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 18px;
  align-items: center;
  margin-top: 13px;
}
.br-parts {
  font-weight: 700;
  color: #fff0bf;
}
.br-meter {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #decccc;
  font-size: 0.83rem;
}
.br-meter {
  --ink: #8bcda6;
  --load: 0%;
}
.br-meter[data-state='warning'] {
  --ink: #ffd270;
}
.br-meter[data-state='overload'],
.br-meter[data-state='gap'] {
  --ink: #ff9384;
  color: var(--ink);
  font-weight: 700;
}
.br-meter[data-state='gap'] .br-gauge {
  display: none;
}
.br-gauge {
  display: block;
  width: 76px;
  height: 9px;
  border: 1px solid #9b8077;
  background: #231e26;
}
.br-gauge i {
  display: block;
  width: var(--load);
  height: 100%;
  background: var(--ink);
}
.br-meter meter {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.br-board[data-phase='broken'] {
  border-color: #e68a76;
}
.br-status {
  margin: 2px 0;
  font-size: 0.91rem;
  color: #e3d5d6;
}
.br-go {
  padding: 10px 15px;
  min-height: 42px;
  border: 1px solid #ffc78a;
  background: #ffc78a;
  color: #382c32;
  border-radius: 7px;
  font-weight: 700;
}
.br-go:disabled {
  opacity: 0.7;
}
.br-places button:focus-visible {
  outline: 3px solid white;
  outline-offset: 1px;
}
@media (max-width: 660px) {
  .br-controls {
    grid-template-columns: 1fr;
  }
  .br-game header {
    padding: 11px;
  }
  .br-game h2 {
    font-size: 1.23rem;
  }
  .br-hint,
  .br-parts,
  .br-status {
    font-size: 0.83rem;
  }
  .br-go {
    justify-self: start;
  }
  .br-board {
    min-height: 164px;
  }
  .br-board canvas {
    height: 100%;
    min-height: 164px;
  }
}

/* Phone held sideways: the crossing fills the height, the task and parts sit beside it. */
@media (orientation: landscape) and (max-height: 540px) {
  .br-game {
    display: grid;
    grid-template-columns: auto minmax(180px, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: 10px;
    height: calc(100svh - 62px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
  .br-game > header { grid-column: 2; padding: 6px 8px; }
  .br-game > header h2 { font-size: 1rem; }
  .br-game .br-hint { font-size: 0.78rem; }
  .br-game .br-work { display: contents; }
  .br-game .br-board {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: start;
    margin: 6px 0 0 6px;
    width: min(calc(100vw - 260px - env(safe-area-inset-left) - env(safe-area-inset-right)),
      calc((100svh - 80px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 2.141));
    min-height: 0;
  }
  .br-game .br-board canvas { height: auto; min-height: 0; }
  .br-game .br-controls { grid-column: 2; grid-row: 2; align-content: start; min-height: 0; overflow-y: auto; grid-template-columns: minmax(0, 1fr); gap: 6px; margin: 0; padding: 0 8px 8px; }
  .br-game .br-controls > * { grid-column: 1; grid-row: auto; }
  .br-game .br-go { justify-self: stretch; order: -1; }
}
