.play-modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 13px;
}
.play-mode {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 12px;
  min-height: 47px;
  padding: 8px 16px;
  border: 2px solid var(--ink);
  border-radius: 9px;
  box-shadow: 0 2px var(--ink);
  background: var(--cream);
  color: var(--ink);
  text-align: left;
  text-decoration: none;
}
.play-mode strong { font: 700 1.42rem/1 var(--display); text-transform: uppercase; }
.play-mode span { font-size: .87rem; line-height: 1.2; }
.play-mode:hover { background: #fff1bf; }
.play-mode:focus-visible { outline: 3px solid #0069b4; outline-offset: 3px; }
.play-mode:active { transform: translateY(2px); box-shadow: none; }
.match-entry { background: var(--sun); }
.match-entry:hover { background: #fff1aa; }
body[data-in-room] .play-modes,
body[data-phase="lineup"] .solo-resume,
body:not([data-phase="lineup"]) .solo-setup { display: none; }
.match-dialog { width: min(540px, calc(100% - 30px)); }
.match-dialog h2 { margin: 0 25px 10px 0; }
.match-dialog p { color: var(--muted); }
#mp-setup { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 22px; }
.match-form { display: grid; align-content: start; gap: 6px; min-width: 0; }
.match-form + .match-form { border-left: 1px solid #d4cfb3; padding-left: 20px; }
.match-form h3 { font: 700 1.45rem/1.1 var(--display); }
.match-form label { font-size: .875rem; color: var(--muted); }
.match-form input, .match-form select {
  border: 2px solid #768983; border-radius: 6px; height: 41px; font: inherit;
  color: var(--ink); background: #fffef9; padding: 5px 9px; width: 100%; min-width: 0;
}
.match-form input { text-transform: uppercase; letter-spacing: .1em; font-weight: bold; }
.match-form input::placeholder { text-transform: none; letter-spacing: normal; font-weight: normal; }
.match-mode-options { display: grid; gap: 5px; min-width: 0; margin: 0; padding: 0; border: 0; }
.match-mode-options legend { padding: 0 0 4px; font-size: .875rem; color: var(--muted); }
.match-mode-options label {
  display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 9px;
  color: var(--ink); background: #fffef9; border: 2px solid #768983; border-radius: 6px;
  font-weight: bold; cursor: pointer;
}
.match-mode-options label:has(:checked) { background: #d7eee0; border-color: #166556; }
.match-mode-options input { width: 17px; height: 17px; margin: 0; padding: 0; accent-color: var(--teal); }
.match-form button { margin-top: 3px; min-height: 40px; }
.match-form :is(input, select):focus-visible { outline: 3px solid #0069b4; outline-offset: 2px; }
.match-label { display: block; font: 700 .87rem/1.15 var(--display); text-transform: uppercase; letter-spacing: .08em; color: #1d665b; }
.room-ticket {
  display: grid; justify-items: center; gap: 5px; margin: 16px 0 10px; padding: 14px 10px;
  border: 2px dashed #388275; border-radius: 8px; background: #e6f4de;
}
#mp-ticket-code { font: 700 clamp(2.4rem, 8vw, 3.25rem)/1.1 var(--display); letter-spacing: .15em; }
.match-link { padding: 4px 2px; color: #15594f; background: none; border: none; text-decoration: underline; text-underline-offset: 3px; font-size: .9rem; font-weight: 700; }
.match-wait-note { margin-bottom: 14px; }
#mp-room-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.match-message:not(:empty) { margin-top: 10px; color: #743719; font-weight: bold; font-size: .9rem; }
.match-board {
  margin-bottom: 12px; padding: 10px 14px; color: var(--ink); border-radius: 12px;
  border: 2px solid var(--ink); box-shadow: 0 2px var(--ink); background: #fff9e7;
}
.match-board:focus-visible { outline: 3px solid #0069b4; outline-offset: 3px; }
.match-heading, .match-scores { display: flex; gap: 12px; align-items: center; }
.match-heading { justify-content: space-between; margin-bottom: 7px; }
.match-heading>div { display: flex; flex-wrap: wrap; gap: 5px 12px; align-items: baseline; }
.match-heading h2 { font-size: clamp(1.4rem,2.5vw,1.85rem); }
.match-scores { align-items: stretch; gap: 8px; }
.match-score {
  display: grid; grid-template-columns: auto 1fr max-content; gap: 3px 8px;
  flex: 1; min-width: 0; padding: 6px 9px; background: #eef0e4;
  border-left: 4px solid #889a91; border-radius: 4px;
}
.match-score.mine { background: #def1e4; border-color: #198473; }
.match-score>strong { font: 700 1.14rem/1.2 var(--display); }
.match-score .tally { grid-column: 3; grid-row: 1; font: 700 1.15rem/1.2 var(--display); font-variant-numeric: tabular-nums; }
.match-score .progress { grid-column: 1 / -1; color: var(--muted); font-size: .84rem; }
@media (max-width: 590px) {
  .play-modes { gap: 7px; margin-bottom: 9px; }
  .play-mode { flex-direction: column; align-items: flex-start; justify-content: center; padding: 7px 10px; }
  .play-mode strong { font-size: 1.22rem; }
  .play-mode span { font-size: .77rem; }
  .match-dialog .dialog-shell { padding: 18px; }
  .match-board { padding: 8px; }
  .match-score { padding: 4px 6px; gap: 2px; grid-template-columns: 1fr auto; }
  .match-score .tally { grid-column: 2; }
  .match-score>strong, .match-score .tally { font-size: 1rem; }
  .match-heading { align-items: start; }
  .match-heading>div { display: grid; gap: 2px; }
}
@media (max-width: 420px) {
  #mp-setup { grid-template-columns: 1fr; gap: 16px; margin-top: 16px; }
  .match-form { grid-template-columns: minmax(0,1fr) auto; }
  .match-form + .match-form { padding: 12px 0 0; border-left: none; border-top: 1px solid #d4cfb3; }
  .match-form :is(h3,label) { grid-column: 1 / -1; }
  .match-form button { margin: 0; align-self: stretch; }
}

#mp-mode-help { font-size: .91rem; line-height: 1.3; margin: 0 0 5px; }
.duel-panel { display: grid; gap: 7px; }
.duel-context { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: baseline; font: 700 1.05rem/1.2 var(--display); }
#duel-role { color: #1a6152; text-transform: uppercase; letter-spacing: .06em; }
#duel-inning { color: var(--muted); }
#duel-heading { font-size: clamp(1.6rem, 3vw, 2.2rem); line-height: 1.06; }
#duel-instruction { color: var(--muted); }
#duel-actions { display: flex; flex-wrap: wrap; align-items: stretch; gap: 9px; }
#duel-actions:empty, #duel-feedback:empty, #duel-instruction:empty { display: none; }
#duel-feedback { color: #8a4021; font-weight: 700; }
body[data-duel-keys="none"] .shortcuts,
body[data-duel-keys="swing"] .shortcuts span:first-child,
body[data-duel-keys="answer"] .shortcuts span:last-child { display: none; }
.duel-answers { display: flex; flex-wrap: wrap; gap: 8px; flex-basis: 100%; }
.duel-pitch-controls {
  display: grid;
  grid-template-columns: minmax(9rem, 13rem) max-content;
  align-items: start;
  gap: 8px 20px;
  max-width: 100%;
}
.duel-pitch-controls fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.duel-pitch-controls legend { padding: 0; margin-bottom: 5px; font: 700 1.2rem/1.1 var(--display); }
.pitch-calls { display: grid; gap: 4px; }
.duel-throw { grid-column: 1 / -1; }
.strike-grid {
  display: grid;
  grid-template-columns: max-content repeat(3, 44px);
  grid-template-rows: max-content repeat(3, 44px);
  gap: 2px;
}
.zone-axis { align-self: center; justify-self: center; font: 600 .9rem/1.2 var(--display); color: var(--muted); }
.zone-row { justify-self: end; padding-right: 3px; }
.zone-cell {
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid #697f76;
  border-radius: 3px;
  background: #e3efe5;
  cursor: pointer;
}
.zone-cell input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: inherit; }
.zone-cell:hover { background: #c5e4d6; }
.zone-cell:has(:checked) { border: 2px solid var(--teal); background: #ffe28b; }
.zone-cell:has(:focus-visible) { outline: 3px solid #0069b4; outline-offset: 1px; z-index: 1; }
.zone-cell:has(:checked)::after {
  content: '';
  width: 19px;
  height: 19px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: radial-gradient(circle at -44% 50%, transparent 52%, #b74638 54% 59%, transparent 61%),
    radial-gradient(circle at 144% 50%, transparent 52%, #b74638 54% 59%, transparent 61%), #fffdf6;
  transform: rotate(25deg);
  pointer-events: none;
}
.duel-fire #duel-heading { color: #a33112; }
.duel-fire .duel-throw { background: #ffc55f; }
.duel-final {
  border-top: 4px solid #e0a51b;
  background: linear-gradient(115deg, #ffefb7, #fffaf0 62%);
}
.duel-final #duel-heading { color: #15574a; font-size: clamp(2rem, 4vw, 3.25rem); }
.duel-final #duel-instruction { font-weight: 700; color: var(--ink); }
.duel-last-play { color: var(--muted); }
.pitch-choice {
  display: grid; text-align: left; padding: 6px 13px; gap: 2px; background: #fffdf6;
  color: var(--ink); border: 2px solid #768983; border-radius: 8px;
}
.pitch-choice strong { font: 700 1.24rem/1.1 var(--display); }
.pitch-choice span { color: var(--muted); font-size: .88rem; }
.pitch-choice[aria-pressed="true"] { border-color: #166556; background: #d7eee0; box-shadow: inset 0 -2px #198473; }
#duel-actions button:focus-visible { outline: 3px solid #0069b4; outline-offset: 2px; }
@media (max-width: 590px) {
  #duel-actions { gap: 6px; }
  .duel-pitch-controls { grid-template-columns: minmax(0, 1fr) max-content; gap: 7px; width: 100%; }
  .pitch-choice { padding: 6px; }
  .pitch-choice strong { font-size: 1.12rem; }
  .duel-throw { width: 100%; }
  .duel-answers { width: 100%; }
  .duel-answers .answer { flex: 1 1 28%; min-width: 0; }
}
@media (max-width: 420px) {
  .match-mode-options, #mp-mode-help { grid-column: 1/-1; }
  .match-mode-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .match-mode-options label { grid-column: auto; gap: 5px; padding-inline: 5px; }
  #mp-mode-help { margin-bottom: 2px; }
}
