.match-active .topbar {
  width: min(980px, 96vw);
  margin: 0 auto 10px;
  align-items: center;
}

.match-active .topbar h1 {
  font-size: 1.55rem;
  letter-spacing: -.035em;
}

.match-active .topbar .eyebrow,
.match-active .tagline {
  display: none;
}

.match-active .alpha-note {
  padding: 6px 10px;
  font-size: .72rem;
}

.game {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.scorebar {
  width: min(980px, 100%);
  margin: 0 auto 10px;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 1.2fr) minmax(0, 1fr);
}

.player-card,
.turn-card {
  min-height: 66px;
  padding: 10px 16px;
}

.turn-card strong {
  font-size: 1rem;
}

.game-grid {
  display: block;
}

.board-panel {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 10px;
}

.board-heading {
  margin-bottom: 7px;
}

.board-heading h2 {
  font-size: 1rem;
}

.board {
  width: min(860px, 94vw, calc(100dvh - 275px));
  min-width: min(94vw, 420px);
  margin: 0 auto;
}

.controls-panel {
  position: sticky;
  z-index: 20;
  bottom: 8px;
  top: auto;
  width: min(900px, calc(100% - 12px));
  margin: 10px auto 0;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: minmax(120px, 160px) minmax(360px, 1fr) minmax(220px, 300px);
  grid-template-areas:
    "owner rack actions"
    "summary summary actions"
    "message message actions";
  gap: 8px 12px;
  align-items: center;
  backdrop-filter: blur(14px);
  background: rgba(27, 29, 27, .95);
  box-shadow: 0 -10px 32px rgba(0, 0, 0, .28);
}

.rack-owner-block {
  grid-area: owner;
}

.rack-owner-block h2 {
  margin-top: 2px;
  font-size: 1.05rem;
}

.controls-panel .rack {
  grid-area: rack;
  width: 100%;
  max-width: 520px;
}

.controls-actions {
  grid-area: actions;
  display: grid;
  gap: 7px;
}

.controls-panel .selection-summary {
  grid-area: summary;
  min-height: 0;
  padding: 7px 10px;
}

.controls-panel .message {
  grid-area: message;
}

.controls-panel .mode-row,
.controls-panel .action-row {
  gap: 7px;
}

.controls-panel .action-row {
  grid-template-columns: repeat(3, 1fr);
}

.controls-panel .primary.wide {
  min-height: 44px;
  font-size: .98rem;
}

.match-details-button {
  background: #242824;
  color: #d6dbd6;
  border: 1px solid #3b413b;
}

.match-details-shell {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: 1fr minmax(360px, 500px);
}

.match-details-scrim {
  grid-column: 1;
  background: rgba(4, 5, 4, .45);
  backdrop-filter: blur(3px);
}

.match-details-drawer {
  grid-column: 2;
  height: 100%;
  background: #1b1e1b;
  border-left: 1px solid #3b413b;
  box-shadow: -22px 0 60px rgba(0, 0, 0, .42);
  padding: 18px;
  overflow: auto;
}

.match-details-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  background: #242824;
  color: #eef1ee;
  border: 1px solid #3b413b;
  font-size: 1.2rem;
}

.match-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-bottom: 12px;
}

.match-tab {
  background: #242824;
  color: #b7beb7;
  border: 1px solid #3b413b;
}

.match-tab.active {
  background: #e5eadf;
  color: #171a17;
  border-color: #e5eadf;
}

.history {
  display: grid;
  gap: 8px;
  max-height: none;
  overflow: visible;
}

.empty-history {
  padding: 18px 2px;
}

.turn-accordion {
  border: 1px solid #343934;
  border-radius: 11px;
  background: #151715;
  overflow: hidden;
}

.turn-accordion summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  color: #b8c0b8;
  font-size: .84rem;
}

.turn-accordion summary::-webkit-details-marker {
  display: none;
}

.turn-accordion summary::before {
  content: "▸";
  color: #7f897f;
  flex: 0 0 auto;
}

.turn-accordion[open] summary::before {
  content: "▾";
}

.turn-summary-main {
  flex: 1;
}

.turn-summary-main strong {
  color: #f1f3f1;
}

.turn-summary-score {
  font-weight: 900;
  color: #eef1ee;
}

.turn-detail-body {
  border-top: 1px solid #303530;
  padding: 12px 13px 14px;
}

.turn-score-breakdown {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.turn-score-breakdown > div,
.turn-detail-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
}

.turn-score-breakdown span,
.turn-detail-grid span {
  color: #8f978f;
}

.turn-score-breakdown strong,
.turn-detail-grid strong {
  text-align: right;
}

.turn-total {
  border-top: 1px solid #343934;
  padding-top: 7px;
}

.good-text {
  color: #cce8bd;
}

.bad-text {
  color: #f0bdb8;
}

.stats-table {
  display: grid;
  border: 1px solid #343934;
  border-radius: 12px;
  overflow: hidden;
}

.stats-row {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 8px;
  padding: 11px 12px;
  border-top: 1px solid #303530;
  align-items: center;
}

.stats-row:first-child {
  border-top: 0;
}

.stats-row span {
  color: #9aa29a;
  font-size: .8rem;
}

.stats-row strong {
  text-align: right;
  font-size: .82rem;
}

.stats-head {
  background: #232623;
}

.definition-result-card {
  position: fixed;
  z-index: 70;
  top: 18px;
  right: 18px;
  width: min(440px, calc(100vw - 24px));
  border: 2px solid;
  border-radius: 16px;
  padding: 16px;
  background: rgba(25, 28, 25, .98);
  box-shadow: 0 22px 60px rgba(0, 0, 0, .42);
  pointer-events: auto;
}

.definition-result-card.correct {
  border-color: #7aa66b;
}

.definition-result-card.miss {
  border-color: #b66561;
}

.definition-result-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.definition-result-head h3 {
  margin: 0;
  font-size: 1.08rem;
}

.definition-result-definition {
  margin: 12px 0;
  color: #eef1ee;
  line-height: 1.45;
}

.definition-result-meta {
  color: #9fa79f;
  font-size: .78rem;
  margin-bottom: 12px;
}

.definition-result-actions {
  display: flex;
  justify-content: flex-end;
}

.definition-result-card.correct h3 {
  color: #cce8bd;
}

.definition-result-card.miss h3 {
  color: #f0bdb8;
}

@media (max-width: 900px) {
  .board {
    width: min(94vw, calc(100dvh - 300px), 760px);
  }

  .controls-panel {
    grid-template-columns: 1fr;
    grid-template-areas:
      "owner"
      "rack"
      "summary"
      "actions"
      "message";
  }

  .rack-owner-block {
    display: flex;
    align-items: baseline;
    gap: 8px;
  }

  .controls-panel .rack {
    max-width: none;
  }

  .controls-actions {
    grid-template-columns: 1fr 1.2fr;
    grid-template-areas:
      "mode submit"
      "secondary secondary";
  }

  .controls-actions .mode-row {
    grid-area: mode;
  }

  .controls-actions #submitMove,
  .controls-actions #exchangeTiles {
    grid-area: submit;
  }

  .controls-actions .action-row {
    grid-area: secondary;
  }
}

@media (max-width: 620px) {
  .match-active .topbar {
    display: none;
  }

  .scorebar {
    position: sticky;
    top: 0;
    z-index: 24;
    border-radius: 0 0 10px 10px;
    grid-template-columns: 1fr 1.25fr 1fr;
    margin-bottom: 5px;
  }

  .player-card,
  .turn-card {
    min-height: 54px;
    padding: 7px 8px;
  }

  .player-name {
    font-size: .72rem;
  }

  .player-score {
    font-size: 1.25rem;
  }

  .turn-card .eyebrow {
    font-size: .58rem;
  }

  .turn-card strong {
    font-size: .78rem;
  }

  .turn-card .muted {
    font-size: .65rem;
  }

  .board-panel {
    width: 100%;
    padding: 3px;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .board-heading {
    display: none;
  }

  .board {
    width: min(98vw, calc(100dvh - 290px));
    min-width: 0;
  }

  .controls-panel {
    bottom: 0;
    width: 100%;
    margin-top: 5px;
    border-radius: 12px 12px 0 0;
    padding: 9px;
  }

  .rack-owner-block .eyebrow {
    display: none;
  }

  .rack-owner-block h2 {
    font-size: .9rem;
  }

  .controls-panel .rack {
    gap: 4px;
  }

  .controls-panel .selection-summary {
    display: none;
  }

  .controls-actions {
    grid-template-columns: 1fr;
    grid-template-areas:
      "submit"
      "secondary"
      "mode";
  }

  .controls-panel .message:not(:empty) {
    padding: 7px 9px;
    font-size: .76rem;
  }

  .match-details-shell {
    display: block;
  }

  .match-details-scrim {
    position: absolute;
    inset: 0;
  }

  .match-details-drawer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: min(78dvh, 720px);
    border-left: 0;
    border-top: 1px solid #3b413b;
    border-radius: 18px 18px 0 0;
    padding: 14px;
  }

  .definition-result-card {
    top: 8px;
    left: 8px;
    right: 8px;
    width: auto;
    padding: 13px;
  }
}
