/* The workshop keeps the original palette and typography. */
:root {
  color-scheme: dark;
}
body.playing {
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}
body.playing .masthead {
  flex: 0 0 52px;
  height: 52px;
  width: 100%;
  padding: 0 20px;
}
body.playing .brand {
  font-size: 27px;
}
body.playing main {
  flex: 1;
  min-height: 0;
  width: 100%;
}
body.playing .site-footer {
  display: none;
}
body.playing #game {
  height: 100%;
  width: 100%;
  max-width: 1600px;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
body.playing button,
dialog button {
  min-height: 44px;
  font-size: 14px;
  padding: 9px 12px;
}
body.playing .match-top {
  margin: 0;
  gap: 16px;
  flex-shrink: 0;
}
body.playing .match-top > div:first-child {
  flex: 1;
  min-width: 0;
}
body.playing .match-top h1 {
  font-size: 30px;
}
body.playing .match-top .eyebrow {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
}
body.playing .match-top p {
  display: none;
}
body.playing .battle-bar {
  border: 0;
  background: transparent;
  padding: 0;
  gap: 8px;
}
body.playing .battle-bar > div {
  display: none;
}
body.playing #ready {
  font-size: 14px;
  white-space: nowrap;
}
body.playing .clock-wrap {
  gap: 0 10px;
}
body.playing .clock-wrap strong {
  font-size: 34px;
  line-height: 1;
}
body.playing .clock-wrap span {
  font-size: 12px;
}
body.playing #connection {
  font-size: 12px;
}
body.playing .mobile-credits {
  display: none;
}
body.playing .invite-bar {
  margin: 0;
  padding: 0 12px;
  gap: 8px;
  flex-shrink: 0;
  font-size: 14px;
}
body.playing .scoreboard {
  flex-shrink: 0;
  padding: 6px 16px;
  min-height: 65px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}
body.playing .player {
  min-width: 0;
}
body.playing .player span,
body.playing .player small,
body.playing .score-center span {
  font-size: 12px;
  line-height: 1.4;
}
body.playing .player b {
  font-size: 19px;
  margin: 0;
  line-height: 1.2;
}
body.playing .score-center strong {
  font-size: 26px;
  line-height: 1.1;
}
body.playing .arena-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 20px;
}
body.playing #tool-slot {
  min-height: 0;
}
body.playing .arena-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1px;
}
body.playing .board-shell {
  flex: none;
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  box-shadow: 0 0 0 1px var(--line);
}
body.playing #board {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  touch-action: none;
  border-radius: 0;
}
body.playing .workbench,
#tools-dialog .workbench {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
body.playing .workbench {
  height: 100%;
  overflow: auto;
}
.workbench .bench-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  gap: 8px;
}
.workbench .bench-heading h2 {
  font:
    600 26px "Barlow Condensed",
    Impact,
    sans-serif;
  margin: 0;
}
.workbench .bench-heading span {
  font-size: 14px;
  color: var(--blue);
}
body.playing .parts,
#tools-dialog .parts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
body.playing .parts button,
#tools-dialog .parts button {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  justify-content: center;
  padding: 8px;
  min-height: 74px;
  position: relative;
}
body.playing .parts button[data-kind="erase"],
#tools-dialog .parts button[data-kind="erase"] {
  grid-column: 1/-1;
  flex-direction: row;
  min-height: 44px;
  gap: 8px;
}
body.playing .parts b,
#tools-dialog .parts b {
  font-size: 14px;
}
body.playing .parts small,
#tools-dialog .parts small {
  display: none;
}
body.playing .parts i,
#tools-dialog .parts i {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 12px;
  font-style: normal;
  color: var(--muted);
}
body.playing .parts .part-icon,
#tools-dialog .parts .part-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}
body.playing .part-icon canvas,
#tools-dialog .part-icon canvas {
  width: 36px;
  height: 36px;
}
body.playing .facing,
#tools-dialog .facing {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 0;
}
body.playing .facing > span,
#tools-dialog .facing > span {
  font-size: 14px;
}
body.playing #directions,
#tools-dialog #directions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}
body.playing #directions button,
#tools-dialog #directions button {
  min-width: 44px;
  font-size: 20px;
  padding: 6px;
}
body.playing #turn,
#tools-dialog #turn {
  font-size: 14px;
  margin: 0;
}
body.playing .part-help,
#tools-dialog .part-help {
  font-size: 14px;
  line-height: 1.5;
  min-height: 0;
  margin: 0;
}
body.playing .bench-actions,
#tools-dialog .bench-actions {
  display: flex;
  gap: 6px;
}
.bench-actions button {
  flex: 1;
}
body.playing .keyboard,
#tools-dialog .keyboard {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}
body.playing .below-game {
  margin: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}
.editor-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
.editor-controls #select.active {
  color: var(--amber);
  border-color: var(--amber);
  background: #e5bb6418;
}
.editor-controls .selection {
  width: auto;
  margin: 0;
}
.editor-controls button {
  white-space: nowrap;
}
body.playing .board-footer {
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  gap: 12px;
}
body.playing #board-hint {
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}
body.playing .board-badge {
  position: static;
  background: none;
  border: 0;
  padding: 0;
  font-size: 12px;
  color: var(--blue);
  white-space: nowrap;
}
#selection-toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
#selection-count {
  font-size: 14px;
  color: var(--amber);
  margin-right: 6px;
}
body.playing .result-banner {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: minmax(170px, 0.6fr) minmax(0, 2fr);
  gap: 3px 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 5px;
  background: #e5bb640b;
  padding: 8px 12px;
}
.result-banner[data-outcome="win"] {
  border-left-color: var(--blue);
}
.result-banner[data-outcome="loss"] {
  border-left-color: var(--coral);
}
.result-heading {
  grid-row: span 2;
}
.result-heading > span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.result-heading strong {
  font:
    600 26px/1.1 "Barlow Condensed",
    Impact,
    sans-serif;
}
.result-banner[data-outcome="win"] strong {
  color: var(--blue);
}
.result-banner[data-outcome="loss"] strong {
  color: var(--coral);
}
.result-banner p {
  margin: 0;
  font-size: 14px;
}
#result-detail {
  font-size: 12px;
  color: var(--muted);
}
body.playing #open-tools,
#close-tools {
  display: none;
}
#tools-dialog {
  width: 304px;
  max-width: calc(100% - 24px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: auto;
}
#tools-dialog .workbench {
  border: 0;
  border-radius: 0;
}
#tools-dialog #close-tools {
  display: block;
}
#presets-dialog {
  width: min(850px, calc(100% - 24px));
  max-width: 850px;
  max-height: calc(100dvh - 24px);
  padding: 22px;
  overflow: auto;
}
#presets-dialog .presets {
  margin: 0;
  border: 0;
  padding: 6px 0 0;
}
#presets-dialog .presets-header {
  padding-right: 24px;
}
#presets-dialog .presets-header h2 {
  font:
    600 28px "Barlow Condensed",
    Impact,
    sans-serif;
  margin: 0;
}
#presets-dialog .presets-header p,
.preset-card small {
  font-size: 12px;
}
#presets-dialog input {
  font-size: 16px;
}
#presets-dialog .presets-header {
  flex-wrap: wrap;
}
#presets-dialog .preset-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
#presets-dialog .preset-card {
  min-width: 0;
}
#presets-dialog .preset-card b {
  font-size: 14px;
}
.preset-card .delete-preset {
  min-width: 44px;
}
dialog {
  max-height: calc(100dvh - 24px);
  overflow: auto;
}
dialog .dialog-close {
  min-width: 44px;
  min-height: 44px;
}
#match-info {
  width: min(540px, calc(100% - 24px));
}
#info-summary {
  line-height: 1.6;
  font-size: 16px;
}
#info-result {
  font-size: 14px;
  line-height: 1.5;
}
#match-info .history {
  flex-wrap: wrap;
  margin: 14px 0;
}
#match-info .history span {
  font-size: 14px;
  padding: 6px 10px;
}
@media (max-width: 1020px), (max-height: 760px) {
  body.playing .arena-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  body.playing #tool-slot {
    display: none;
  }
  body.playing #open-tools {
    display: block;
  }
}
@media (max-width: 740px) {
  body.playing .masthead {
    height: 48px;
    flex-basis: 48px;
    padding: 0 10px;
  }
  body.playing .masthead .alpha,
  body.playing .masthead #help {
    display: none;
  }
  body.playing #game {
    padding: 8px 10px;
    gap: 8px;
  }
  body.playing .match-top {
    flex-wrap: wrap;
    gap: 6px 10px;
  }
  body.playing .match-top > div:first-child {
    flex-basis: calc(100% - 120px);
  }
  body.playing .match-top h1 {
    font-size: 25px;
  }
  body.playing .match-top .eyebrow {
    font-size: 12px;
  }
  body.playing .clock-wrap {
    order: 0;
  }
  body.playing .clock-wrap strong {
    font-size: 30px;
  }
  body.playing #connection {
    display: none;
  }
  body.playing .battle-bar {
    order: 1;
    width: 100%;
    justify-content: space-between;
  }
  body.playing #ready {
    flex: 1;
  }
  body.playing .scoreboard {
    padding: 6px 8px;
    gap: 8px;
  }
  body.playing .score-center span {
    display: none;
  }
  body.playing .score-center strong {
    font-size: 24px;
  }
  body.playing .player small {
    font-size: 12px;
  }
  body.playing .result-banner {
    grid-template-columns: 1fr;
    gap: 5px;
  }
  body.playing .result-heading {
    grid-row: auto;
  }
  body.playing #result-detail {
    display: none;
  }
  body.playing .board-footer,
  body.playing #win-guide,
  body.playing #leave {
    display: none;
  }
  body.playing .editor-controls button {
    padding: 9px 10px;
  }
  body.playing .invite-bar {
    font-size: 12px;
  }
}
@media (max-height: 520px) {
  body.playing .masthead {
    display: none;
  }
  body.playing #game {
    gap: 6px;
    padding: 6px 10px;
  }
  body.playing .match-top {
    flex-wrap: nowrap;
    gap: 8px;
  }
  body.playing .match-top > div:first-child {
    flex: 1;
    min-width: 0;
  }
  body.playing .match-top h1 {
    font-size: 24px;
  }
  body.playing .match-top .eyebrow,
  body.playing #connection {
    display: none;
  }
  body.playing .clock-wrap {
    flex: none;
  }
  body.playing .battle-bar {
    width: auto;
    flex: none;
    order: 0;
  }
  body.playing #ready {
    flex: none;
    max-width: 160px;
    white-space: normal;
  }
  body.playing .scoreboard,
  body.playing .board-footer {
    display: none;
  }
  body.playing .result-banner {
    grid-template-columns: 1fr;
    padding: 5px 10px;
  }
  body.playing .result-banner p,
  body.playing #result-detail,
  body.playing #result-scope {
    display: none;
  }
  body.playing .result-heading {
    grid-row: auto;
  }
  body.playing #win-guide,
  body.playing #leave {
    display: none;
  }
  #selection-toolbar button {
    padding: 9px;
  }
}
@media (max-width: 500px) and (max-height: 520px) {
  body.playing .match-top > div:first-child {
    display: none;
  }
  body.playing .match-top {
    justify-content: space-between;
  }
}
@media (hover: none) {
  button:hover:not(:disabled) {
    background: var(--panel);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Reserve the action row so the board never moves under a selection gesture. */
.selection-slot {
  height: 44px;
  flex: none;
}
#selection-toolbar {
  flex-wrap: nowrap;
  height: 44px;
}
#info-summary {
  white-space: pre-line;
}
@media (max-width: 740px) {
  #selection-count {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  #selection-toolbar button {
    padding: 9px 10px;
  }
}

/* The same context row shows a hint or selection actions, without moving the grid. */
.selection-slot {
  display: flex;
  align-items: center;
  justify-content: center;
}
.selection-slot:has(#selection-toolbar:not([hidden])) .board-footer {
  display: none;
}
@media (max-width: 740px) {
  body.playing .match-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }
  body.playing .match-top .clock-wrap {
    display: flex;
    flex-direction: column;
    gap: 1px;
    grid-column: 2;
    grid-row: 1;
  }
  body.playing .match-top .battle-bar {
    grid-column: 1/-1;
  }
}
@media (max-height: 520px) {
  body.playing .match-top {
    display: flex;
  }
  body.playing .match-top .clock-wrap {
    flex-direction: row;
    gap: 6px;
    align-items: center;
  }
}

/* Keep help and facing labels readable inside the mobile parts drawer. */
#tools-dialog .workbench {
  flex-wrap: nowrap;
}
#tools-dialog .part-help,
#tools-dialog .keyboard,
#tools-dialog .facing > span {
  display: block;
}
#tools-dialog .facing {
  align-items: stretch;
}
#tools-dialog .bench-actions {
  margin: 0;
}
.toast {
  font-size: 14px;
  pointer-events: none;
}
.entry button,
.join button {
  min-height: 44px;
  font-size: 14px;
}

/* Give tests and live clashes their board space back; editing resumes in Build. */
body.playing
  #game.previewing
  .editor-controls
  :is(#open-tools, #select, #open-presets) {
  display: none;
}
@media (max-width: 740px), (max-height: 520px) {
  #game.previewing .selection-slot,
  #game:is(
      [data-phase="countdown"],
      [data-phase="fight"],
      [data-phase="review"],
      [data-phase="finished"]
    )
    .selection-slot {
    display: none;
  }
}
@media (max-width: 1020px), (max-height: 760px) {
  body.playing .mobile-credits {
    display: inline-block;
    color: var(--blue);
    font-size: 14px;
    margin-left: 8px;
  }
  body.playing .match-top .eyebrow {
    display: inline;
  }
}
@media (max-height: 520px) {
  body.playing .match-top .eyebrow,
  body.playing .mobile-credits {
    display: none;
  }
}

#tools-dialog .parts i {
  display: inline;
}
body.playing .toast {
  bottom: 118px;
}
@media (max-width: 740px) {
  #selection-toolbar button {
    padding: 9px 6px;
    min-width: 44px;
  }
}
