#remainderSortGame { display: grid; grid-template-rows: auto minmax(0,1fr); min-height: 0; }
#remainderSortGame button, #remainderSortGame select, #remainderSortGame input, #remainderSortGame summary { font: inherit; font-weight: 700; }
#remainderSortGame button, #remainderSortGame select, #remainderSortGame summary { min-height: 48px; border: 2px solid #cbdbe6; border-radius: 8px; padding: 8px 12px; color: #102131; background: #fff; cursor: pointer; }
#remainderSortGame button:disabled { cursor: default; opacity: .65; }
#remainderSortGame button:focus-visible, #remainderSortGame select:focus-visible, #remainderSortGame summary:focus-visible, #remainderSortGame input:focus-visible { outline: 4px solid #149bd7; outline-offset: 2px; }
#remainderSortGame button[aria-pressed="true"], #remainderSortGame button[aria-current="true"] { background: #e4f4fd; border-color: #0877b0; }
.rs-toolbar { position: relative; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; padding: 8px; background: #fff; border-bottom: 1px solid #cbdbe6; z-index: 2; }
.rs-toolbar .tool-menu { position: relative; }
.rs-toolbar .tool-menu > summary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; list-style: none; }
.rs-toolbar .tool-menu > summary::-webkit-details-marker { display: none; }
.rs-settings-chevron { width: 16px; height: 16px; flex: 0 0 auto; }
.rs-toolbar .tool-menu[open] .rs-settings-chevron { transform: rotate(180deg); }
.rs-toolbar .menu-panel { position: absolute; top: calc(100% + 6px); right: 0; width: 260px; background: #fff; border: 2px solid #cbdbe6; border-radius: 8px; padding: 14px; box-shadow: 0 8px 20px #10213130; }
.rs-toolbar fieldset { border: 0; padding: 0; margin: 0 0 10px; }
.rs-toolbar label { display: inline-flex; align-items: center; gap: 6px; min-height: 48px; margin-right: 8px; }
#remainderSortGame .rs-primary { background: #6d5fd0; border-color: #4d409f; color: #fff; }
.rs-board { display: grid; grid-template-rows: auto minmax(0,1fr) auto; gap: 12px; margin: 12px; padding: 16px; background: #fff; border: 1px solid #cbdbe6; border-radius: 8px; min-height: 0; }
.rs-status { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; font-size: clamp(16px,1.4vw,22px); }
.rs-status span { color: #536572; }
.rs-layout { display: grid; grid-template-columns: minmax(0,1.25fr) minmax(0,1fr); gap: 24px; min-height: 0; }
.rs-work { display: grid; grid-template-rows: 48px minmax(0,1fr) 48px 76px; gap: 12px; min-height: 0; }
#rsCards { display: flex; gap: 6px; }
#rsCards button { flex: 1; padding-inline: 2px; }
.rs-model { min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.rs-model figure { margin: 0; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.rs-model figure svg { flex: 1; min-height: 0; width: 100%; height: 100%; max-width: 100%; max-height: 100%; }
.rs-model .model-number-sentence { flex: 0 0 auto; }
.rs-model figcaption { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.rs-support { display: flex; justify-content: center; gap: 6px; }
.rs-support button { flex: 1; padding-inline: 6px !important; }
.rs-answer { display: flex; align-items: center; justify-content: center; gap: 12px; }
.rs-answer label { display: flex; align-items: center; gap: 12px; font-size: 22px; }
.rs-answer input { width: 90px; height: 64px; border: 2px solid #0877b0; border-radius: 8px; text-align: center; font-size: 30px !important; background: #fff; color: #102131; }
.rs-sort { display: grid; grid-template-rows: minmax(0,1fr) 64px; gap: 12px; min-height: 0; }
#rsCheck, #rsDiscussion { grid-row: 2; align-self: start; }
#rsGroups { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-height: 0; }
.rs-group { display: grid; grid-template-rows: 74px minmax(0,1fr); gap: 8px; padding: 8px; background: #f4f9fc; border: 2px solid #cbdbe6; border-radius: 8px; min-height: 0; }
#remainderSortGame .rs-group-choice { font-size: clamp(20px,1.7vw,28px); background: #e6f4fd; border-color: #149bd7; }
.rs-group-cards { display: grid; grid-auto-rows: minmax(60px,1fr); gap: 6px; min-height: 0; }
.rs-group-cards:has(> button:nth-child(5)) { grid-template-columns: repeat(2,minmax(0,1fr)); }
#remainderSortGame .rs-sorted-card { padding: 0 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; }
.rs-sorted-card figure { margin: 0; width: 100%; height: 34px; flex: 0 0 auto; }
.rs-sorted-card .equation-list { padding-block: 0; }
.rs-sorted-card svg { display: block; width: 100%; height: 100%; }
.rs-sorted-card figcaption { display: none; }
.rs-sorted-card .rs-card-result { font-size: 16px; height: 20px; flex: 0 0 auto; }
#remainderSortGame .rs-sorted-card.is-correct { border-color: #1d8f5a; }
#remainderSortGame .rs-sorted-card.needs-check { border-color: #d84f4f; }
#rsDiscussion { font-size: 20px; margin: 0; }
.rs-feedback { margin: 0; padding: 10px 14px; background: #eef5f9; border-radius: 8px; min-height: 58px; font-size: clamp(18px,1.5vw,24px); display: flex; align-items: center; }
.rs-feedback[data-tone="success"] { color: #12623d; background: #edf8f1; }
.rs-feedback[data-tone="error"] { color: #a52323; background: #fff0ef; }
@media (max-width: 900px), (max-height: 650px) {
  .app { height: auto; min-height: 100dvh; overflow: visible; }
  #remainderSortGame { display: block; }
  .rs-board { min-height: 630px; }
  .rs-layout { grid-template-columns: minmax(0,1fr); }
  .rs-work { grid-template-rows: 48px 260px 48px 76px; }
  .rs-sort { min-height: 430px; grid-template-rows: minmax(0,1fr) 96px; }
  .rs-group-cards { grid-auto-rows: 82px; }
  .rs-model { min-height: 0; }
}
@media (max-width: 520px) {
  .rs-toolbar { justify-content: start; }
  #remainderSortGame select { max-width: 100%; }
  .rs-toolbar .menu-panel { right: auto; left: 0; }
  .rs-board { margin: 8px; padding: 10px; }
  .rs-layout { gap: 16px; }
  .rs-answer { gap: 8px; }
  .rs-answer label { font-size: 18px; gap: 8px; }
  .rs-answer input { width: 66px; }
  .rs-group { padding: 4px; }
  #rsGroups { gap: 6px; }
  #rsGroups { grid-template-columns: minmax(0,1fr); }
  .rs-sort { min-height: 0; }
  .rs-group { min-height: 310px; grid-template-rows: 74px auto; align-content: start; }
  .rs-group-cards { grid-auto-rows: 64px; }
  .rs-sorted-card .rs-card-result { font-size: 14px; }
}
@media print {
  .app { height: 175mm !important; min-height: 0 !important; overflow: hidden !important; }
  #remainderSortGame { display: grid; grid-template-rows: minmax(0,1fr); }
  .rs-toolbar, .rs-support, #rsCards, #rsClear, #rsCheck { display: none !important; }
  .rs-board { margin: 0; padding: 4mm; min-height: 0; }
  .rs-layout { grid-template-columns: minmax(0,1.25fr) minmax(0,1fr); }
  .rs-work { grid-template-rows: minmax(0,1fr) 18mm; }
  .rs-sort { min-height: 0; }
  .rs-group { grid-template-rows: 20mm minmax(0,1fr); }
  .rs-group-cards { grid-auto-rows: minmax(0,1fr); }
  .rs-answer input { border-color: #102131; }
  .rs-feedback { min-height: 14mm; font-size: 16px; }
}
@media (forced-colors: active) {
  #remainderSortGame button[aria-current="true"], #remainderSortGame button[aria-pressed="true"] { border: 3px solid Highlight; }
}
