/* =============================================================
   Nocturne Chess — component styles.
   Every color here traces to a token in globals.css (see style.md).
   Mobile-first; widened at 768px and 1024px.
   ============================================================= */

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------- Header ---------------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--space-md) var(--space-gutter);
}

.brand {
  font-family: var(--font-display);
  font-size: var(--text-headline-md);
  line-height: var(--leading-headline-md);
  letter-spacing: var(--tracking-headline);
  color: var(--foreground);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.2em;
  min-height: var(--tap-min);
}

.brand em {
  font-style: italic;
  color: var(--muted-foreground);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  height: 24px;
  padding: 0 10px;
  border: var(--border-hairline);
  border-radius: var(--radius-full);
  background: var(--card);
  color: var(--muted-foreground);
  font-family: var(--font-ui);
  font-size: var(--text-eyebrow);
  font-weight: var(--weight-medium);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge[data-state="connected"] {
  color: var(--foreground);
}

/* Connection state reads from the label + wifi-off icon, not color
   (the badge keeps the pack's muted treatment on every state). */

.icon-14 { width: 14px; height: 14px; flex: none; }
.icon-16 { width: 16px; height: 16px; flex: none; }
.icon-20 { width: 20px; height: 20px; flex: none; }

/* ---------------- Buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  height: var(--control-height);
  padding: 0 18px;
  border-radius: var(--radius-full);
  font-family: var(--font-ui);
  font-size: var(--text-label-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-label-sm);
  letter-spacing: var(--tracking-label);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: var(--elevation-glow);
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border: var(--border-primary);
  box-shadow: var(--elevation-inset-highlight);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: var(--elevation-glow);
}

/* The primary fill equals the ring color, so a border swap is invisible;
   the doctrine (UX_GUIDE-desktop §13/§14) requires a real outline here. */
.btn-primary:focus-visible {
  outline: 1px solid var(--ring);
  outline-offset: 2px;
  box-shadow: var(--elevation-inset-highlight);
}

.btn-secondary {
  background: transparent;
  color: var(--secondary-foreground);
  border: var(--border-hairline);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--secondary);
  border: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--muted-foreground);
  border: 1px solid transparent;
  padding: 0 14px;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--foreground);
  background: var(--card);
}

.btn-destructive {
  background: transparent;
  color: var(--destructive);
  border: var(--border-destructive);
}

.btn-destructive:hover:not(:disabled) {
  background: var(--card);
}

.btn-destructive-solid {
  background: var(--destructive);
  color: var(--destructive-foreground);
  border: var(--border-destructive);
}

.btn-destructive-solid:hover:not(:disabled) {
  box-shadow: var(--elevation-glow);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--icon-button);
  height: var(--icon-button);
  flex: none;
  background: transparent;
  color: var(--muted-foreground);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.btn-icon:hover {
  color: var(--foreground);
  background: var(--card);
}

.btn-icon:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: var(--elevation-glow);
}

/* ---------------- Inputs ---------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.field-label {
  font-size: var(--text-label-sm);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-label);
  color: var(--muted-foreground);
}

.input {
  height: var(--control-height);
  padding: 0 14px;
  border: 1px solid var(--input);
  border-radius: var(--radius-sm);
  background: var(--muted);
  color: var(--foreground);
  font-family: var(--font-ui);
  font-size: var(--text-input);
  line-height: 1.4;
  width: 100%;
}

.input::placeholder {
  color: var(--muted-foreground);
}

.input:hover {
  border-color: var(--color-border-strong);
}

.input:focus,
.input:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: var(--elevation-glow);
}

.input-editor {
  font-size: var(--text-input-editor);
}

.input-code {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.field-error {
  margin: 0;
  font-size: var(--text-body-sm);
  line-height: var(--leading-body-sm);
  color: var(--destructive);
}

/* ---------------- Cards ---------------- */

.card {
  background: var(--card);
  border: var(--border-hairline);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
}

.eyebrow {
  margin: 0;
  font-size: var(--text-eyebrow);
  line-height: var(--leading-eyebrow);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--muted-foreground);
}

/* ---------------- Views ---------------- */

main {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-gutter) var(--space-3xl);
}

.view[hidden] {
  display: none;
}

/* ---------------- Lobby ---------------- */

.lobby {
  max-width: var(--container-narrow);
  margin: 0 auto;
  padding-top: var(--space-3xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.lobby-hero {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  font-size: var(--text-headline-lg);
  line-height: var(--leading-headline-lg);
  letter-spacing: var(--tracking-headline);
  text-wrap: balance;
}

.lobby-hero em {
  font-style: italic;
}

.lobby-sub {
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--text-body-md);
  line-height: var(--leading-body-md);
  text-wrap: pretty;
}

.lobby-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  margin-top: var(--space-lg);
}

.lobby-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.card-heading {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  font-size: var(--text-headline-md);
  line-height: var(--leading-headline-md);
  letter-spacing: var(--tracking-headline);
}

.lobby-card .btn {
  margin-top: var(--space-xs);
  align-self: flex-start;
}

@media (min-width: 768px) {
  .lobby {
    padding-top: var(--space-section);
  }
  .lobby-hero {
    font-size: var(--text-display-lg);
    line-height: var(--leading-display-lg);
    letter-spacing: var(--tracking-display);
  }
  .lobby-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-xl);
  }
}

/* ---------------- Waiting ---------------- */

.wait {
  max-width: var(--container-narrow);
  margin: 0 auto;
  padding-top: var(--space-3xl);
}

/* Atmosphere Card — Penumbra's signature surface, used once here for the
   game's hero moment (ported from penumbra/css/system.css). The medallion is
   a decorative backdrop; the form sits above it at z-index 1. */
.wait-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-3xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--elevation-inset-highlight);
  overflow: hidden;
  isolation: isolate;
}

.wait-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.05) 0%, transparent 45%),
    radial-gradient(circle at 75% 80%, rgba(255, 255, 255, 0.04) 0%, transparent 50%);
  z-index: 0;
  pointer-events: none;
}

.wait-card > * {
  position: relative;
  z-index: 1;
}

.atmosphere-medallion {
  position: absolute;
  top: -72px;
  right: -72px;
  width: 240px;
  height: 240px;
  z-index: 0;
  pointer-events: none;
  border-radius: var(--radius-full);
  background-image: radial-gradient(circle, rgba(244, 244, 245, 0.85) 1px, transparent 1.4px);
  background-size: 10px 10px;
  background-position: center;
  -webkit-mask-image: radial-gradient(circle, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.85) 35%, rgba(0, 0, 0, 0.25) 70%, transparent 100%);
  mask-image: radial-gradient(circle, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.85) 35%, rgba(0, 0, 0, 0.25) 70%, transparent 100%);
  opacity: 0.5;
}

.wait-heading {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  font-size: var(--text-headline-md);
  line-height: var(--leading-headline-md);
}

.ellipsis::after {
  content: "…";
}

.wait-copy {
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--text-body-md);
  line-height: var(--leading-body-md);
}

.share-row {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

.share-input {
  font-family: var(--font-mono);
  font-size: var(--text-input);
  flex: 1;
  min-width: 0;
}

.wait-code {
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--text-body-sm);
}

.code-chip {
  font-family: var(--font-mono);
  font-size: var(--text-mono-sm);
  color: var(--foreground);
  background: var(--muted);
  border: var(--border-hairline);
  border-radius: var(--radius-xs);
  padding: 2px 6px;
  letter-spacing: 0.12em;
}

.copy-ack {
  margin: 0;
  font-size: var(--text-body-sm);
  color: var(--color-success);
}

.wait-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-sm);
}

/* ---------------- Game layout ---------------- */

.game {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  padding-top: var(--space-md);
}

.board-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-width: 0;
}

.side-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  min-width: 0;
}

@media (min-width: 1024px) {
  .game {
    display: grid;
    grid-template-columns: minmax(0, var(--board-max)) minmax(0, var(--sidebar-width));
    gap: var(--space-xl);
    justify-content: center;
    align-items: start;
  }
}

/* ---------------- Player bars ---------------- */

.player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  background: var(--card);
  border: var(--border-hairline);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  min-height: var(--player-bar-min);
}

.player-bar.active {
  border: 1px solid var(--color-border-strong);
}

.player-main {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
  flex-wrap: wrap;
}

.player-name {
  font-size: var(--text-title-md);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-title);
  line-height: var(--leading-title-md);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.to-move-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-eyebrow);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--muted-foreground);
  white-space: nowrap;
}

.to-move-tag .dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--primary);
}

.check-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-eyebrow);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--destructive);
  white-space: nowrap;
}

.offline-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-eyebrow);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--muted-foreground);
  white-space: nowrap;
}

.player-side-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex: none;
}

.captures {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  /* Light tray so the black pieces (#08080A) read at 11.6:1; white pieces
     keep their outline. A dark tray hid the black glyphs entirely. */
  background: var(--board-light);
  border-radius: var(--radius-xs);
  padding: var(--space-xs) var(--space-sm);
  min-height: 24px;
}

.captures:empty {
  display: none;
}

.captures svg {
  width: 16px;
  height: 16px;
}

.material-count {
  font-family: var(--font-mono);
  font-size: var(--text-mono-sm);
  color: var(--board-coord-on-light);
}

.clock {
  font-family: var(--font-mono);
  font-size: var(--text-clock);
  font-weight: var(--weight-medium);
  line-height: var(--leading-clock);
  font-variant-numeric: tabular-nums;
  color: var(--muted-foreground);
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.clock.active {
  color: var(--foreground);
}

.clock .icon-16 {
  color: var(--muted-foreground);
}

/* ---------------- Board ---------------- */

.board-wrap {
  position: relative;
  width: 100%;
  max-width: var(--board-max);
  align-self: center;
}

@media (min-width: 1024px) {
  /* Keep the board + both player bars within the viewport height so the
     bottom bar and your clock never fall below the fold (W19). Budget:
     header (44 + 24) + page top (12) + 2 bars (2×56) + 3 gaps (3×12). */
  .board-wrap {
    max-width: min(
      var(--board-max),
      calc(100dvh - var(--tap-min) - 2 * var(--space-xl) - 2 * var(--player-bar-min) - 3 * var(--space-md))
    );
  }
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1;
  width: 100%;
  background: var(--card);
  border: var(--border-hairline);
  border-radius: var(--board-radius);
  overflow: hidden;
}

/* Full-bleed board below 768px so squares clear the 44px floor */
@media (max-width: 767px) {
  .board-wrap {
    width: 100vw;
    max-width: var(--board-max);
    margin-inline: calc(-1 * var(--space-gutter));
    align-self: center;
  }
  .board {
    border-left: none;
    border-right: none;
  }
}

.sq {
  position: relative;
  border: none;
  margin: 0;
  padding: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  cursor: default;
  background: var(--board-dark);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.sq.light {
  background: var(--board-light);
}

.sq.movable,
.sq.target {
  cursor: pointer;
}

@media (hover: hover) {
  .sq.movable {
    cursor: grab;
  }
  .sq.movable:hover .hover {
    background: var(--board-hover);
  }
}

.sq:focus {
  outline: none;
}

.sq:focus-visible {
  outline: none;
  z-index: 2;
}

/* Marker layers paint in DOM order, bottom to top:
   wash → hover → piece → target dot/circle → selection/focus ring → coords.
   Each is its own child so the ring never sits under a wash (style.md layer order). */
.sq .wash,
.sq .hover,
.sq .ring {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sq.last .wash {
  background: var(--board-last);
}

.sq.check .wash {
  background: var(--board-check);
}

.sq .piece {
  position: absolute;
  inset: 11%;
  pointer-events: none;
}

.sq .piece svg {
  display: block;
  width: 100%;
  height: 100%;
}

.sq.dragging .piece {
  opacity: 0.35;
}

.sq.target .marker {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sq.target .marker::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28%;
  height: 28%;
  transform: translate(-50%, -50%);
  border-radius: var(--radius-full);
  background: var(--board-target);
}

.sq.target.capture .marker::after {
  width: 100%;
  height: 100%;
  background: transparent;
  border: calc(var(--sq-size, 60px) * 0.1) solid var(--board-target);
  box-sizing: border-box;
  border-radius: var(--radius-full);
}

.sq.selected .ring {
  box-shadow: inset 0 0 0 3px var(--board-selected);
}

.sq:focus-visible .ring {
  box-shadow: inset 0 0 0 2px var(--board-focus), inset 0 0 0 4px var(--board-focus-inner);
}

/* Focus sits on top of selection when both apply. */
.sq.selected:focus-visible .ring {
  box-shadow: inset 0 0 0 3px var(--board-selected), inset 0 0 0 2px var(--board-focus),
    inset 0 0 0 4px var(--board-focus-inner);
}

.sq .coord {
  position: absolute;
  font-family: var(--font-ui);
  font-size: var(--text-label-sm);
  font-weight: var(--weight-medium);
  line-height: 1;
  pointer-events: none;
}

.sq .coord.file {
  right: var(--space-xs);
  bottom: var(--space-xs);
}

.sq .coord.rank {
  left: var(--space-xs);
  top: var(--space-xs);
}

.sq.light .coord { color: var(--board-coord-on-light); }
.sq:not(.light) .coord { color: var(--board-coord-on-dark); }
/* On a washed square (last move / check) the composite background darkens the
   square; a near-black coord clears AA on every wash+square combination. */
.sq.last .coord,
.sq.check .coord { color: var(--board-coord-on-wash); }

/* drag ghost */
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 50;
  width: var(--sq-size, 60px);
  height: var(--sq-size, 60px);
  transform: translate(-50%, -50%);
}

.drag-ghost svg {
  width: 100%;
  height: 100%;
  filter: var(--elevation-raised-drop);
}

/* move animation */
.anim-piece {
  position: absolute;
  pointer-events: none;
  z-index: 10;
  transition: transform var(--transition-slow);
}

/* ---------------- Promotion popover ---------------- */

.promo-popover {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: var(--popover);
  color: var(--popover-foreground);
  border: var(--border-hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--elevation-raised);
  overflow: hidden;
  z-index: 20;
}

.promo-popover[hidden] {
  display: none;
}

.promo-btn {
  border: none;
  background: transparent;
  width: var(--sq-size, 60px);
  height: var(--sq-size, 60px);
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding: 8%;
  cursor: pointer;
}

.promo-btn:hover {
  background: var(--accent);
}

.promo-btn:focus-visible {
  outline: 1px solid var(--ring);
  outline-offset: -2px;
}

.promo-btn svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------------- Game-over banner ---------------- */

.gameover {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92%, 420px);
  background: var(--popover);
  color: var(--popover-foreground);
  border: var(--border-hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--elevation-raised);
  padding: var(--space-2xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  z-index: 30;
  text-align: left;
}

.gameover[hidden] {
  display: none;
}

.gameover-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  font-size: var(--text-headline-lg);
  line-height: var(--leading-headline-lg);
  letter-spacing: var(--tracking-headline);
  text-wrap: balance;
}

.gameover-reason {
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--text-body-md);
  line-height: var(--leading-body-md);
}

.gameover-rematch {
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--text-body-sm);
}

.gameover-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-md);
  margin-top: var(--space-sm);
}

/* ---------------- Side panels ---------------- */

.panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.offer-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.offer-text {
  margin: 0;
  font-size: var(--text-body-md);
  line-height: var(--leading-body-md);
}

.offer-actions {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.move-list {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  column-gap: var(--space-md);
  row-gap: var(--space-xs);
  font-family: var(--font-mono);
  font-size: var(--text-move);
  line-height: var(--leading-move);
  max-height: 240px;
  overflow-y: auto;
  align-content: start;
}

.move-list:empty::before {
  content: "No moves yet.";
  grid-column: 1 / -1;
  font-family: var(--font-ui);
  font-size: var(--text-body-sm);
  color: var(--color-on-surface-faint);
}

.move-num {
  color: var(--color-on-surface-faint);
  padding: var(--space-xs) 0;
}

.move-san {
  color: var(--muted-foreground);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-xs);
}

.move-san.latest {
  background: var(--accent);
  color: var(--foreground);
  font-weight: var(--weight-medium);
}

/* ---------------- Chat ---------------- */

.chat-log {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-height: 200px;
  min-height: 48px;
  overflow-y: auto;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.chat-sender {
  font-size: var(--text-label-sm);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-label);
  color: var(--muted-foreground);
}

.chat-text {
  font-size: var(--text-body-md);
  line-height: var(--leading-body-md);
  overflow-wrap: anywhere;
}

.chat-log:empty::before {
  content: "No messages yet.";
  font-size: var(--text-body-sm);
  color: var(--color-on-surface-faint);
}

.chat-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.chat-input {
  flex: 1;
  min-width: 0;
  font-size: var(--text-input);
}

.chat-send {
  border: var(--border-hairline);
}

.chat-error,
.controls-reason {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.chat-error .btn,
.chat-error .btn-ghost {
  min-height: var(--control-height);
}

/* ---------------- Controls ---------------- */

/* Resign (destructive) sits on its own row, after a full-width divider,
   never adjacent to the routine Offer-draw control (both guides §1). */
.game-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.controls-row {
  display: flex;
  justify-content: flex-end;
}

.controls-divider {
  width: 100%;
  height: 1px;
  margin: 0;
  border: 0;
  background: var(--border);
}

.controls-reason {
  text-align: right;
}

/* ---------------- Dialogs ---------------- */

.dialog {
  background: var(--popover);
  color: var(--popover-foreground);
  border: var(--border-hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--elevation-raised);
  padding: var(--space-2xl);
  max-width: 400px;
  width: calc(100% - 2 * var(--space-gutter));
}

.dialog::backdrop {
  /* --background at 60% — ::backdrop cannot read custom properties in all engines,
     so the composited value is spelled out; it derives from --background #08080A. */
  background: rgba(8, 8, 10, 0.6);
}

.dialog-title {
  margin: 0 0 var(--space-sm);
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  font-size: var(--text-headline-md);
  line-height: var(--leading-headline-md);
}

.dialog-copy {
  margin: 0 0 var(--space-xl);
  color: var(--muted-foreground);
  font-size: var(--text-body-md);
  line-height: var(--leading-body-md);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md);
  margin: 0;
}

.sq.lift .piece {
  inset: 9%;
}

.sq.target.lean .marker::after {
  width: 34%;
  height: 34%;
}

.sq.target.capture.lean .marker::after {
  width: 100%;
  height: 100%;
  border-width: calc(var(--sq-size, 60px) * 0.125);
}

.promo-btn.lean {
  padding: 6%;
}
