:root {
  --bg: #f5f5f0;
  --bg-panel: #fffef8;
  --bg-panel-strong: #f6f2e8;
  --ink: #1d1f24;
  --ink-muted: #535865;
  --line: #d6d2c6;
  --accent: #c44f29;
  --accent-strong: #8f3418;
  --ok: #2c8d5e;
  --warn: #ae6f13;
  --error: #b22626;
  --radius: 14px;
  --shadow: 0 10px 26px rgba(24, 23, 20, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 15% 20%, #ece4cf 0%, transparent 40%),
    radial-gradient(circle at 90% 10%, #f2dfcd 0%, transparent 32%),
    var(--bg);
  min-height: 100vh;
}

.ambient-gradient {
  position: fixed;
  inset: 0;
  background: linear-gradient(120deg, rgba(196, 79, 41, 0.11), transparent 35%, rgba(44, 141, 94, 0.06) 65%, transparent 90%);
  pointer-events: none;
}

.shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 28px 16px 36px;
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-size: 12px;
}

h1 {
  margin: 2px 0 0;
  font-size: 34px;
  line-height: 1.05;
}

h2 {
  margin: 0;
  font-size: 24px;
}

h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.session-pill {
  appearance: none;
  background: var(--bg-panel-strong);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  cursor: pointer;
  text-align: left;
}

.session-pill:hover {
  transform: none;
  background: #f2ebdc;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  padding: 20px;
}

.auth-card {
  max-width: 560px;
}

.muted {
  color: var(--ink-muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 14px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}

textarea {
  resize: vertical;
}

button {
  border: 1px solid var(--accent-strong);
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  border-radius: 999px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: #fff;
}

.tab.tab-logout {
  margin-left: auto;
  border-color: #d89f8d;
  background: #fff8f6;
  color: #8f3418;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 760px;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #ece8dc;
  vertical-align: top;
}

th {
  font-size: 13px;
  color: var(--ink-muted);
  background: #f9f5ea;
}

tbody tr:hover {
  background: #fffcf3;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row.is-selected {
  background: #f3efe2;
}

.mono {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  border: 1px solid transparent;
  text-transform: capitalize;
}

.status-queued {
  background: #fcf3dc;
  color: #855c11;
  border-color: #efd8a2;
}

.status-running,
.status-in_progress {
  background: #dff3e6;
  color: #256146;
  border-color: #afddbe;
}

.status-completed {
  background: #d6f0e2;
  color: #215c43;
  border-color: #9fd0b7;
}

.status-failed {
  background: #fde6e3;
  color: #8f2c22;
  border-color: #f4b7ae;
}

.status-stopping,
.status-stopped,
.status-terminated {
  background: #eceaf0;
  color: #51515f;
  border-color: #cecbda;
}

.action-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.rollout-detail-card {
  margin-top: 14px;
}

.rollout-detail-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(300px, 500px) 1fr;
  gap: 12px;
}

.position-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(300px, 500px) 1fr;
  gap: 12px;
}

.position-form {
  display: grid;
  gap: 10px;
  margin: 8px 0 14px;
}

.position-board-toolbar {
  margin: 6px 0 10px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.position-board-toolbar-left,
.position-board-toolbar-right {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.position-board-toolbar-right {
  margin-left: auto;
  justify-content: flex-end;
}

.position-inline-field {
  display: grid;
  gap: 4px;
  font-size: 12px;
  min-width: 0;
}

#position-game-mode {
  min-width: 100px;
}

#position-match-length,
#position-score-player,
#position-score-computer {
  min-width: 78px;
}

.position-score-label {
  margin-bottom: 12px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.position-score-separator {
  margin-bottom: 12px;
  font-size: 14px;
}

.position-board-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-start;
}

.position-reset-button {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 8px;
}

#position-id-input {
  min-height: 118px;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
}

#position-id-summary {
  margin-top: 8px;
}

.rollout-board-host {
  width: 100%;
  max-width: 520px;
}

#rollout-detail-card table {
  min-width: 0;
}

.rollout-detail-card .btn-secondary {
  padding: 5px 8px;
  font-size: 11px;
}

.rollout-status-meta {
  margin-top: 4px;
  font-size: 11px;
}

#rollout-top-moves-body tr.is-selected {
  background: #f0fbf3;
}

#rollout-detail-text {
  margin-top: 12px;
}

.bgboard-root {
  width: 100%;
}

.bgboard-shell {
  display: grid;
  gap: 4px;
}

.bgboard-frame {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #fcf8ee;
  --bgboard-board-top: #f0e6d1;
  --bgboard-board-bottom: #e3d6bf;
  --bgboard-triangle-light: #c72e2e;
  --bgboard-triangle-dark: #3652a3;
  --bgboard-bar: rgba(51, 56, 69, 0.9);
  --bgboard-frame: rgba(56, 56, 56, 0.95);
  --bgboard-player-fill: #ffffff;
  --bgboard-player-stroke: rgba(46, 46, 46, 0.45);
  --bgboard-opponent-fill: rgba(31, 51, 117, 0.95);
  --bgboard-opponent-stroke: rgba(255, 255, 255, 0.55);
}

.bgboard-surface {
  position: relative;
  display: flex;
  flex-direction: column;
  aspect-ratio: 1.6 / 1;
  background: linear-gradient(180deg, var(--bgboard-board-top) 0%, var(--bgboard-board-bottom) 100%);
  border-top: 1px solid rgba(56, 56, 56, 0.35);
  border-bottom: 1px solid rgba(56, 56, 56, 0.35);
}

.bgboard-main {
  display: flex;
  align-items: stretch;
}

.bgboard-root.has-right-offtray .bgboard-surface {
  flex: 1;
  min-width: 0;
}

.bgboard-row {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr)) minmax(24px, 0.72fr) repeat(6, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
}

.bgboard-point,
.bgboard-bar {
  position: relative;
  min-height: 80px;
  overflow: hidden;
}

.bgboard-triangle {
  position: absolute;
  left: 6%;
  width: 88%;
}

.bgboard-point.is-top .bgboard-triangle {
  top: 0;
  height: 84%;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}

.bgboard-point.is-bottom .bgboard-triangle {
  bottom: 0;
  height: 84%;
  clip-path: polygon(50% 0, 0 100%, 100% 100%);
}

.bgboard-point.is-light .bgboard-triangle {
  background: var(--bgboard-triangle-light);
}

.bgboard-point.is-dark .bgboard-triangle {
  background: var(--bgboard-triangle-dark);
}

.bgboard-bar {
  background: var(--bgboard-bar);
  border-radius: 6px;
}

.bgboard-bar.is-top {
  border-bottom-left-radius: 2px;
  border-bottom-right-radius: 2px;
}

.bgboard-bar.is-bottom {
  border-top-left-radius: 2px;
  border-top-right-radius: 2px;
}

.bgboard-stack {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 92%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}

.bgboard-root.is-editable .bgboard-stack,
.bgboard-root.is-editable .bgboard-offpieces {
  pointer-events: auto;
}

.bgboard-point.is-top .bgboard-stack {
  top: 6px;
}

.bgboard-point.is-bottom .bgboard-stack {
  bottom: 6px;
}

.bgboard-bar.is-top .bgboard-stack {
  bottom: 6px;
}

.bgboard-bar.is-bottom .bgboard-stack {
  top: 6px;
}

.bgboard-checker {
  width: 82%;
  min-width: 12px;
  max-width: 28px;
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  border: 1px solid transparent;
  position: relative;
}

.bgboard-root.is-editable .bgboard-checker,
.bgboard-root.is-editable .bgboard-offpiece {
  cursor: grab;
  pointer-events: auto;
}

@media (hover: none) and (pointer: coarse) {
  .bgboard-root.is-editable .bgboard-checker,
  .bgboard-root.is-editable .bgboard-offpiece {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }
}

.bgboard-root.is-editable .bgboard-checker:active,
.bgboard-root.is-editable .bgboard-offpiece:active {
  cursor: grabbing;
}

.bgboard-drag-source-hidden {
  display: none !important;
}

.bgboard-checker.is-player {
  background: var(--bgboard-player-fill);
  border-color: var(--bgboard-player-stroke);
}

.bgboard-checker.is-opponent {
  background: var(--bgboard-opponent-fill);
  border-color: var(--bgboard-opponent-stroke);
}

.bgboard-checker-badge {
  position: absolute;
  inset: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  color: #1f1f25;
}

.bgboard-offtray {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  background: #f6f1e3;
}

.bgboard-offtray.is-top {
  border-bottom: 1px solid #ddd6c0;
}

.bgboard-offtray.is-bottom {
  border-top: 1px solid #ddd6c0;
}

.bgboard-offside {
  width: calc(var(--bgboard-checker-size, 24px) + 14px);
  display: flex;
  flex-direction: column;
  background: #f6f1e3;
  border-left: 1px solid #ddd6c0;
}

.bgboard-offslot {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 4px;
}

.bgboard-offslot.is-top {
  border-bottom: 1px solid #ddd6c0;
}

.bgboard-offslot .bgboard-offpieces {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

.bgboard-root.has-right-offtray .bgboard-offpiece {
  width: var(--bgboard-checker-size, 24px);
  height: var(--bgboard-offpiece-height, 7px);
  border-radius: 3px;
}

.bgboard-root.has-right-offtray .bgboard-offcount {
  display: none;
}

.bgboard-root.has-right-offtray .bgboard-offslot.is-top .bgboard-offpieces {
  margin-bottom: auto;
}

.bgboard-root.has-right-offtray .bgboard-offslot.is-bottom .bgboard-offpieces {
  margin-top: auto;
  flex-direction: column-reverse;
}

.bgboard-offpieces {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  min-height: 14px;
}

.bgboard-offpiece {
  width: 7px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid transparent;
}

.bgboard-offpiece.is-player {
  background: var(--bgboard-player-fill);
  border-color: var(--bgboard-player-stroke);
}

.bgboard-offpiece.is-opponent {
  background: var(--bgboard-opponent-fill);
  border-color: var(--bgboard-opponent-stroke);
}

.bgboard-point-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr)) minmax(24px, 0.72fr) repeat(6, minmax(0, 1fr));
  gap: 4px;
  padding: 0 4px;
}

.bgboard-root.has-right-offtray .bgboard-point-row {
  padding-right: 48px;
}

.bgboard-point-number {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  color: #5f6676;
  text-align: center;
}

.bgboard-pip-summary {
  margin: 2px 2px 0;
  font-size: 12px;
}

.bgboard-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.bgboard-arrow {
  fill: none;
  stroke: #24b457;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 2px rgba(17, 97, 47, 0.45));
}

.bgboard-arrowhead {
  fill: #24b457;
}

.bgboard-state-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.bgboard-dice-layer,
.bgboard-cube-layer {
  position: absolute;
  transform: translate(-50%, -50%);
}

.bgboard-dice-layer,
.bgboard-cube-layer {
  pointer-events: none;
}

.bgboard-cube-dropzone {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 10px;
  border: 1px dashed rgba(37, 153, 76, 0.45);
  background: rgba(49, 177, 88, 0.08);
  opacity: 0;
  pointer-events: none;
}

.bgboard-root.is-cube-dragging .bgboard-cube-dropzone {
  opacity: 1;
  pointer-events: auto;
}

.bgboard-dice-wrap {
  display: flex;
  gap: 6px;
}

.bgboard-dice-wrap.is-double {
  display: grid;
  grid-template-columns: repeat(2, auto);
}

.bgboard-die {
  position: relative;
  border-radius: 9px;
  border: 1px solid rgba(31, 36, 48, 0.28);
  box-shadow: 0 2px 8px rgba(20, 24, 36, 0.2);
  pointer-events: none;
}

.bgboard-die.is-player {
  background: #ffffff;
  border-color: rgba(31, 36, 48, 0.28);
}

.bgboard-die.is-player .bgboard-die-pip {
  background: rgba(0, 0, 0, 0.88);
}

.bgboard-die.is-opponent {
  background: #1f3375;
  border-color: rgba(255, 255, 255, 0.36);
}

.bgboard-die.is-opponent .bgboard-die-pip {
  background: #ffffff;
}

.bgboard-die.is-unknown {
  opacity: 0.72;
}

.bgboard-root.is-editable .bgboard-die.is-editable {
  cursor: pointer;
  pointer-events: auto;
}

.bgboard-die-pip {
  position: absolute;
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.bgboard-cube-face {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: #f4edd7;
  border: 1px solid rgba(76, 78, 88, 0.35);
  color: rgba(0, 0, 0, 0.9);
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  font-weight: 700;
  font-size: clamp(16px, 2.6vw, 34px);
  box-shadow: 0 2px 10px rgba(25, 28, 41, 0.2);
}

.bgboard-root.is-editable .bgboard-cube-face.is-editable {
  cursor: pointer;
  pointer-events: auto;
}

.bgboard-drop-target-active {
  box-shadow: inset 0 0 0 2px rgba(36, 180, 87, 0.9);
}

.bgboard-drag-ghost {
  contain: paint;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  position: relative;
  overflow: visible;
}

.bgboard-drag-ghost.is-touch-active {
  opacity: 0.96;
}

.bgboard-drag-ghost-checker {
  position: absolute;
  left: 0;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(20, 24, 36, 0.22);
}

.bgboard-drag-ghost-count {
  position: absolute;
  right: -8px;
  bottom: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 24, 36, 0.86);
  color: #f4f7ff;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.bgboard-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  background: rgba(255, 255, 255, 0.66);
  font-size: 13px;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  color: #384154;
  z-index: 3;
}

.inline-form {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: end;
  margin-top: 10px;
}

.inline-form button {
  align-self: end;
}

.accounts-create {
  margin: 12px 0;
}

.profile-card {
  margin-top: 12px;
}

.profile-form {
  margin-top: 8px;
}

#profile-tab-content .inline-form {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.spot-settings-card {
  margin: 12px 0 14px;
}

.spot-settings-form {
  margin-top: 10px;
}

#accounts-tab-content table {
  min-width: 980px;
}

.account-action-row {
  align-items: center;
}

.account-action-row .muted {
  font-size: 12px;
}

.password-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.password-reset-input {
  min-width: 170px;
  max-width: 220px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
}

.action-row button {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-secondary {
  background: #f7f4ea;
  border-color: #d4cbaf;
  color: #5a533f;
}

.btn-danger {
  background: #fff2ef;
  border-color: #d89f8d;
  color: #9c3a20;
}

.split-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.subcard {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

.help-content-host {
  line-height: 1.55;
}

.help-content-host h3 {
  margin: 0 0 8px;
}

.help-content-host p {
  margin: 0 0 10px;
}

.mono-block {
  margin: 10px 0 0;
  border: 1px solid #e6dfcc;
  border-radius: 10px;
  padding: 10px;
  background: #faf8f0;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.4;
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
}

.error {
  color: var(--error);
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .split-grid {
    grid-template-columns: 1fr;
  }

  .rollout-detail-grid {
    grid-template-columns: 1fr;
  }

  .position-grid {
    grid-template-columns: 1fr;
  }

  .position-board-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .position-board-toolbar-right {
    margin-left: 0;
    justify-content: flex-start;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  h1 {
    font-size: 30px;
  }

  .password-action {
    width: 100%;
  }

  .password-reset-input {
    flex: 1;
    max-width: 100%;
  }

  .bgboard-row {
    gap: 3px;
    padding: 3px;
  }

  .bgboard-point,
  .bgboard-bar {
    min-height: 58px;
  }
}
