*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--stone);
  color: var(--sumi);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ten-blue) 70%, white);
  outline-offset: 3px;
}

.number {
  font-family: var(--font-number);
  font-variant-numeric: tabular-nums;
}

.tenbo-band {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: 6px;
  width: 100%;
}

.tenbo-band__gold {
  background: var(--ten-gold);
}

.tenbo-band__blue {
  background: var(--ten-blue);
}

.tenbo-band__sumi {
  background: var(--sumi);
}

.tenbo-band__red {
  background: var(--ten-red);
}

.app-shell {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  min-height: calc(100vh - 6px);
}

.left-rail {
  border-right: 1px solid var(--line);
  background: var(--card);
  padding: var(--space-6) var(--space-4);
}

.app-shell--home {
  grid-template-columns: 1fr;
}

.app-shell--home .left-rail {
  display: none;
}

.app-shell--home .page-header {
  max-width: 960px;
  margin-inline: auto;
}

.left-rail__brand {
  display: block;
  margin-bottom: var(--space-6);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  text-wrap: balance;
  text-decoration: none;
  cursor: pointer;
}

.left-rail__nav {
  display: grid;
  gap: var(--space-2);
}

.left-rail__link {
  border-left: 4px solid transparent;
  padding: var(--space-2) var(--space-3);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.left-rail__link.is-active {
  border-left-color: var(--ten-gold);
  background: color-mix(in srgb, var(--ten-gold) 13%, transparent);
  font-weight: 700;
}

.main-content {
  min-width: 0;
  padding: var(--space-8);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  border-bottom: 1px solid var(--line);
  padding-bottom: var(--space-5);
}

.breadcrumb {
  margin: 0 0 var(--space-1);
  color: color-mix(in srgb, var(--sumi) 70%, white);
  font-size: 12px;
  font-weight: 600;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: var(--font-display);
  line-height: 1.2;
}

h1 {
  margin-bottom: 0;
  font-size: 40px;
}

h2 {
  margin-bottom: var(--space-4);
  font-size: 28px;
}

.home-view {
  max-width: 960px;
  margin-inline: auto;
  padding-top: var(--space-8);
}

.home-tagline {
  font-size: 0.8125rem;
  color: var(--sumi);
  opacity: 0.6;
  margin: var(--space-2) 0 var(--space-6);
}

.home-hero {
  margin-bottom: var(--space-8);
}

.home-hero__tagline {
  font-size: 1rem;
  margin-bottom: var(--space-4);
  color: var(--sumi);
}

.home-hero__steps {
  counter-reset: step;
  display: flex;
  gap: var(--space-6);
  list-style: none;
  padding: 0;
  margin: 0;
  flex-wrap: wrap;
}

.home-hero__steps li {
  flex: 1;
  min-width: 180px;
  padding: var(--space-4);
  padding-top: var(--space-6);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.875rem;
  counter-increment: step;
  position: relative;
}

.home-hero__steps li::before {
  content: counter(step);
  position: absolute;
  top: var(--space-3);
  left: var(--space-4);
  font-family: var(--font-number);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--taku);
}

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

.create-panel {
  padding: var(--space-6);
}

.create-form {
  display: grid;
  /* 各フィールドに最低 200px を確保し、セグメント2択(例「トーナメント」)が
     折り返さずに収まるようにする。幅に応じて列数が自動で増減する。 */
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  align-items: end;
}

/* フィールドは行の上端で揃え、ラベルとコントロール上端を各行で一直線にする。
   align-items:end は送信ボタンを入力欄の下端に揃えるために残す。 */
.create-form > .field {
  align-self: start;
}

.mc-create-form-status {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: var(--space-2);
}

.field[hidden] {
  display: none;
}

.field:is(fieldset) {
  min-width: 0;
  border: 0;
  margin: 0;
  padding: 0;
}

/* legend は fieldset の grid に参加しないため gap が効かない。
   入力フィールドの label→control 間隔(8px)に合わせ、左端も他ラベルと揃える。 */
.field:is(fieldset) legend {
  margin-bottom: var(--space-2);
  padding: 0;
}

.field label,
.field legend {
  font-size: 14px;
  font-weight: 600;
  color: var(--sumi);
}

.field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--sumi);
  padding: 10px 12px;
}

.mc-required-mark {
  margin-left: 0.2em;
  color: #e53935;
  font-weight: 700;
}

.mc-form-legend {
  margin: 0;
  color: color-mix(in srgb, var(--sumi) 58%, white);
  font-size: 12px;
}

.mc-readonly-field__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--sumi);
}

.mc-readonly-field__value {
  color: color-mix(in srgb, var(--sumi) 76%, white);
}

.field textarea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--sumi);
  padding: 10px 12px;
  font-family: var(--font-number);
  line-height: 1.5;
}

.button {
  min-height: 44px;
  border: 1px solid var(--taku);
  border-radius: 6px;
  background: var(--taku);
  color: white;
  padding: 9px 16px;
  font-weight: 700;
  white-space: nowrap;
}

.button--ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--sumi);
}

.button--danger {
  border-color: var(--ten-red);
  background: transparent;
  color: var(--ten-red);
}

.tournament-list {
  display: grid;
  gap: var(--space-3);
  margin: var(--space-6) 0;
  padding: 0;
  list-style: none;
}

.tournament-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-4);
  align-items: center;
  overflow: hidden;
  padding: var(--space-4);
}

.tournament-card:hover {
  border-color: color-mix(in srgb, var(--taku) 60%, var(--line));
}

.tournament-card__open {
  display: grid;
  grid-template-columns: 5px minmax(0, 1fr) auto;
  gap: var(--space-4);
  align-items: center;
  width: 100%;
  min-height: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.tournament-card__open:hover,
.tournament-card__open:focus-visible {
  background: color-mix(in srgb, var(--stone) 40%, white);
}

.tournament-card__open::before {
  align-self: stretch;
  min-height: 44px;
  border-radius: 4px;
  background: var(--ten-gold);
  content: "";
}

.tournament-card__open::after {
  content: "›";
  align-self: center;
  padding-right: var(--space-1);
  color: color-mix(in srgb, var(--sumi) 45%, white);
  font-size: 24px;
  line-height: 1;
  transition: transform 0.15s ease, color 0.15s ease;
}

.tournament-card__open:hover::after,
.tournament-card__open:focus-visible::after {
  color: var(--taku);
  transform: translateX(2px);
}

@media (prefers-reduced-motion: reduce) {
  .tournament-card__open::after {
    transition: none;
  }
}

.tournament-card__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.3;
}

.tournament-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: var(--space-2) 0 0;
  color: color-mix(in srgb, var(--sumi) 70%, white);
  font-size: 14px;
}

.tournament-card__badge {
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 55%, white);
  color: color-mix(in srgb, var(--sumi) 72%, white);
  padding: 0 0.4em;
  font-size: 0.75em;
  font-weight: 700;
}

.tournament-card__delete {
  border-color: var(--line);
  opacity: 0.55;
}

.tournament-card__delete:hover,
.tournament-card__delete:focus-visible {
  border-color: var(--ten-red);
  opacity: 1;
}

.empty-state {
  margin-top: var(--space-4);
  padding: var(--space-4) var(--space-2);
}

.empty-state p {
  margin: 0;
  font-size: 14px;
  color: color-mix(in srgb, var(--sumi) 55%, transparent);
}

.tournament-view {
  display: grid;
  gap: var(--space-6);
  max-width: 1120px;
  padding-top: var(--space-8);
}

.tournament-toolbar {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
}

.import-panel,
.preview-panel {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-6);
}

.import-status {
  min-height: 24px;
  font-size: 14px;
  font-weight: 700;
}

/* 文言が無い(textContentが空)ときは枠ごと非表示にして余白を出さない。 */
.import-status:empty {
  display: none;
}

.import-status--error {
  color: var(--ten-red);
}

.import-status--info {
  color: var(--ten-blue);
}

.preview-panel__meta {
  margin-bottom: 0;
  color: color-mix(in srgb, var(--sumi) 68%, white);
  font-size: 14px;
}

.mc-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.mc-table-scroll:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ten-blue) 70%, white);
  outline-offset: 2px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: color-mix(in srgb, var(--stone) 70%, white);
  font-weight: 700;
}

.match-list-section {
  display: grid;
  gap: var(--space-4);
}

.match-list-table td:nth-child(2) {
  max-width: 420px;
}

.mc-match-row {
  cursor: pointer;
}

.mc-match-row:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ten-blue) 70%, white);
  outline-offset: -3px;
}

.mc-match-caret {
  display: inline-block;
  width: 1.25em;
  color: color-mix(in srgb, var(--sumi) 70%, white);
  font-family: var(--font-number);
}

.mc-match-detail-row td {
  background: color-mix(in srgb, var(--stone) 48%, white);
  padding: var(--space-3) var(--space-4);
}

.mc-match-detail-row .mc-table-scroll {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.mc-manual-result-section {
  display: grid;
  gap: var(--space-4);
  border-top: 1px solid var(--line);
  padding-top: var(--space-4);
}

.mc-manual-result-form {
  display: grid;
  gap: var(--space-4);
}

.mc-manual-entry-table input {
  width: 100%;
  min-width: 88px;
  box-sizing: border-box;
  /* 他のフォーム入力(.field input)と枠・角丸・余白を揃える(ブラウザ既定の見た目をやめる)。 */
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--sumi);
  padding: 8px 10px;
  font: inherit;
}

.mc-manual-entry-table td:nth-child(2) input {
  min-width: 160px;
}

.mc-tab-content {
  min-width: 0;
}

.mc-dashboard {
  display: grid;
  gap: var(--space-4);
}

.mc-bracket {
  display: grid;
  gap: var(--space-4);
}

.mc-bracket-panel {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-6);
}

.mc-bracket-scroll {
  padding-bottom: var(--space-2);
}

.mc-bracket-fit {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.mc-bracket-board {
  position: relative;
}

.mc-bracket-connectors {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: visible;
  pointer-events: none;
}

.mc-bracket-connectors polyline {
  fill: none;
  stroke: color-mix(in srgb, var(--taku) 42%, var(--line));
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mc-bracket-round-heading {
  position: absolute;
  top: 0;
  z-index: 2;
  overflow: hidden;
  margin: 0;
  color: color-mix(in srgb, var(--sumi) 74%, white);
  font-family: var(--font-display);
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mc-bracket-node {
  position: absolute;
  z-index: 1;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 4px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-left: 4px solid color-mix(in srgb, var(--ten-gold) 72%, var(--line));
  border-radius: 7px;
  background: color-mix(in srgb, var(--stone) 28%, white);
  padding: 6px 8px;
  font-size: 12px;
}

.mc-bracket-node__header {
  font-size: 12px;
}

.mc-bracket-node .mc-player-chip {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 0;
  padding: 1px 8px;
  font-size: 11px;
  line-height: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mc-bracket-node .mc-tag {
  padding: 0 5px;
  font-size: 10px;
}

.mc-bracket-node--complete {
  border-left-color: var(--taku);
  background: color-mix(in srgb, var(--taku) 6%, white);
}

.mc-bracket-node--bye {
  border-left-color: var(--ten-blue);
}

.mc-bracket-node__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-weight: 700;
}

.mc-bracket-node__badges {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: var(--space-1);
  justify-content: flex-end;
}

.mc-bracket-node__progress {
  font-size: 11px;
  font-weight: 700;
  color: color-mix(in srgb, var(--sumi) 62%, white);
}

.mc-bracket-entrants {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 2px;
  overflow: hidden;
}

.mc-bracket-chip--advancer {
  border-color: color-mix(in srgb, var(--taku) 55%, var(--line));
  background: color-mix(in srgb, var(--taku) 16%, white);
  color: var(--taku);
}

.mc-bracket-chip--pending {
  border-style: dashed;
  background: white;
  color: color-mix(in srgb, var(--sumi) 54%, white);
}

.mc-bracket-champion {
  margin: 0;
  border: 1px solid color-mix(in srgb, var(--ten-gold) 52%, var(--line));
  border-radius: 6px;
  background: color-mix(in srgb, var(--ten-gold) 13%, white);
  padding: var(--space-3) var(--space-4);
  font-weight: 800;
}

.mc-bracket-dashboard {
  display: grid;
  gap: var(--space-3);
}

.mc-bracket-placement-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.mc-bracket-placement-list li {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--stone) 42%, white);
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 700;
}

.mc-bracket-regenerate-form {
  display: grid;
  gap: var(--space-5);
}

.mc-bracket-standard-row {
  align-items: center;
}

.mc-bracket-standard-label {
  color: color-mix(in srgb, var(--sumi) 70%, white);
  font-weight: 600;
}

.mc-bracket-seed-details > summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.mc-bracket-seed-details[open] > summary {
  margin-bottom: var(--space-3);
}

.mc-bracket-seed-actions {
  margin-top: var(--space-3);
  flex-wrap: wrap;
}

.mc-bracket-seed-table input {
  width: 7em;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--sumi);
  padding: 8px 10px;
}

.mc-bracket-round-controls {
  display: grid;
  gap: var(--space-3);
}

.mc-bracket-round-controls h3,
.mc-bracket-regenerate-form h3 {
  margin: 0;
  font-size: 18px;
}

.mc-bracket-round-control {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 160px) minmax(120px, 160px);
  gap: var(--space-3);
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: var(--space-3);
}

.mc-bracket-round-control__name {
  align-self: center;
  font-weight: 700;
}

.mc-schedule {
  display: grid;
  gap: var(--space-4);
}

.mc-schedule-panel {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-6);
}

.mc-schedule-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 220px)) auto minmax(180px, 1fr);
  gap: var(--space-4);
  align-items: end;
}

.mc-schedule-summary {
  justify-self: end;
  color: color-mix(in srgb, var(--sumi) 68%, white);
  font-size: 14px;
  font-weight: 700;
}

.mc-schedule-table {
  min-width: 760px;
}

.mc-player-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid color-mix(in srgb, var(--taku) 24%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--taku) 7%, white);
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.mc-dashboard-meta {
  justify-self: end;
  color: color-mix(in srgb, var(--sumi) 68%, white);
  font-size: 14px;
  font-weight: 700;
}

.mc-warning {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  border: 1px solid color-mix(in srgb, var(--ten-red) 45%, var(--line));
  border-radius: 6px;
  background: color-mix(in srgb, var(--ten-red) 9%, white);
  padding: var(--space-3) var(--space-4);
  color: var(--sumi);
  font-weight: 700;
}

.mc-table-panel {
  overflow: hidden;
  padding: var(--space-6);
}

.mc-dashboard-table td:not(:first-child),
.mc-dashboard-table th:not(:first-child) {
  text-align: right;
}

.mc-standings-table td:nth-child(2),
.mc-standings-table th:nth-child(2) {
  text-align: left;
}

.mc-rank-number {
  font-family: var(--font-number);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.mc-rank-cell {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.mc-rank-marker {
  display: inline-block;
  flex: 0 0 6px;
  align-self: stretch;
  min-height: 24px;
  border-radius: 3px;
}

.mc-number-positive {
  color: var(--taku);
  font-weight: 700;
}

.mc-number-negative {
  color: var(--ten-red);
  font-weight: 700;
}

.mc-participants-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
  align-items: start;
}

.mc-participants-panel {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-6);
}

.mc-player-form {
  display: grid;
  gap: var(--space-3);
}

.mc-player-form {
  border-bottom: 1px solid var(--line);
  padding-bottom: var(--space-4);
}

.mc-player-table input {
  width: 100%;
  box-sizing: border-box;
}

.mc-player-table input.is-default {
  color: color-mix(in srgb, var(--sumi) 45%, var(--card));
}

.mc-player-table th:nth-child(3),
.mc-player-table td:nth-child(3) {
  max-width: 8em;
  text-align: right;
}

.mc-player-table td:nth-child(3) input {
  text-align: right;
}

.mc-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.mc-button-compact {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 13px;
}

.mc-select {
  width: 100%;
  /* テキスト入力(.field input)と高さ・余白・枠を揃え、独自キャレットに統一する。 */
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--sumi);
  padding: 10px 36px 10px 12px;
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
  background-color: white;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%2320231E' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
}

.mc-segmented {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  min-height: 44px;
}

.mc-segmented__option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-2);
  font-size: 14px;
  font-weight: 600;
  color: var(--sumi);
  cursor: pointer;
  border-left: 1px solid var(--line);
  text-align: center;
  line-height: 1.2;
  /* 各セグメントは等幅に縮められる。短いラベル(四麻/トーナメント等)は
     列幅が十分なので1行に収まり、長いラベル(都合の合う人で絞る等)は
     はみ出して切れる代わりに折り返す。 */
  min-width: 0;
}

label.mc-segmented__option:first-of-type {
  border-left: 0;
}

.mc-segmented__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mc-segmented__option:has(.mc-segmented__input:checked) {
  background: var(--taku);
  color: white;
}

.mc-segmented__option:has(.mc-segmented__input:focus-visible) {
  outline: 3px solid var(--ten-blue);
  outline-offset: -3px;
}

.mc-segmented[aria-disabled="true"] {
  opacity: .5;
}

.mc-segmented[aria-disabled="true"] .mc-segmented__option {
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  .mc-segmented__option {
    transition: none;
  }
}

.mc-link-row--unlinked td {
  background: color-mix(in srgb, var(--ten-gold) 15%, white);
}

.mc-match-row--excluded {
  opacity: 0.55;
}

.mc-tag {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
}

.mc-tag--excluded {
  background: color-mix(in srgb, var(--sumi) 12%, white);
  color: color-mix(in srgb, var(--sumi) 76%, white);
}

.mc-tag--imported {
  background: color-mix(in srgb, var(--taku) 14%, white);
  color: var(--taku);
}

.mc-tag--pending {
  background: color-mix(in srgb, var(--ten-gold) 18%, white);
  color: color-mix(in srgb, var(--sumi) 76%, var(--ten-gold));
}

.mc-settings-grid,
.mc-data-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: var(--space-5);
  align-items: start;
}

.mc-settings-panel,
.mc-data-panel {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-6);
}

.mc-settings-form {
  display: grid;
  gap: var(--space-4);
}

.mc-checkbox-field label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.mc-checkbox-field input {
  width: auto;
}

.mc-rule-locks {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--space-2) var(--space-4);
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: var(--space-3);
  background: color-mix(in srgb, var(--stone) 45%, white);
  font-size: 14px;
}

.mc-rule-locks dt {
  font-weight: 700;
}

.mc-rule-locks dd {
  margin: 0;
  font-family: var(--font-number);
}

.mc-inline-warning {
  border: 1px solid color-mix(in srgb, var(--ten-gold) 55%, var(--line));
  border-radius: 6px;
  background: color-mix(in srgb, var(--ten-gold) 14%, white);
  padding: var(--space-3);
  font-size: 14px;
  font-weight: 700;
}

.mc-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgb(32 35 30 / 42%);
  padding: var(--space-5);
}

.mc-modal {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-soft);
  padding: var(--space-6);
}

.mc-modal p {
  margin-bottom: var(--space-5);
}

.mc-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: flex-end;
}

.mc-modal--wide {
  width: min(760px, 100%);
}

.mc-modal-body {
  overflow-y: auto;
  max-height: 70vh;
  margin-bottom: var(--space-5);
}

.mc-bracket-stats__entrants {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.mc-bracket-stats__match {
  margin-bottom: var(--space-5);
}

.mc-bracket-stats__match-heading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: var(--space-2);
}

.mc-bracket-stats__match-date,
.mc-bracket-stats__match-id {
  font-size: 12px;
  font-weight: 400;
  color: color-mix(in srgb, var(--sumi) 60%, white);
}

.mc-bracket-node--clickable {
  cursor: pointer;
  transition: box-shadow 0.1s ease, border-color 0.1s ease;
}

.mc-bracket-node--clickable:hover {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--taku) 40%, transparent);
  border-color: color-mix(in srgb, var(--taku) 60%, var(--line));
}

.mc-bracket-node--clickable:focus-visible {
  outline: 2px solid var(--taku);
  outline-offset: 2px;
}

.mc-toast {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: min(420px, calc(100vw - 2 * var(--space-5)));
  border: 1px solid color-mix(in srgb, var(--taku) 40%, var(--line));
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-soft);
  padding: var(--space-3) var(--space-4);
  font-size: 14px;
  font-weight: 600;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .left-rail {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10;
    border-top: 1px solid var(--line);
    border-right: 0;
    padding: var(--space-2);
  }

  .left-rail__brand {
    display: none;
  }

  .left-rail__nav {
    grid-template-columns: repeat(8, 1fr);
    gap: 0;
  }

  .left-rail__link {
    border-left: 0;
    border-top: 3px solid transparent;
    padding: var(--space-2) var(--space-1);
    text-align: center;
    font-size: 12px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .left-rail__link.is-active {
    border-top-color: var(--ten-gold);
    font-weight: 700;
  }

  .main-content {
    padding: var(--space-5) var(--space-4) 84px;
  }

  .page-header {
    align-items: flex-start;
  }

  h1 {
    font-size: 28px;
  }

  .create-form {
    grid-template-columns: 1fr;
  }

  .mc-schedule-form {
    grid-template-columns: 1fr;
  }

  .mc-schedule-summary {
    justify-self: start;
  }

  .mc-bracket-round-control {
    grid-template-columns: 1fr;
  }

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

  .data-table {
    white-space: nowrap;
  }

  .mc-warning {
    align-items: stretch;
    flex-direction: column;
  }

  .mc-dashboard-meta {
    justify-self: start;
  }

  .mc-participants-grid {
    grid-template-columns: 1fr;
  }

  .mc-settings-grid,
  .mc-data-grid {
    grid-template-columns: 1fr;
  }

  .tournament-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .tournament-card .button--danger {
    justify-self: start;
  }

  .mc-toast {
    right: var(--space-4);
    bottom: 92px;
    left: var(--space-4);
    max-width: none;
  }
}
