/* Compact mode brings clues and actions closer together while keeping the
   same paper, portraits, readable letters and 44px controls. */
body.compact main {
  padding: 12px clamp(10px, 1.5vw, 24px) 24px;
}

body.compact .topbar {
  gap: 6px 14px;
  padding: 8px clamp(12px, 1.5vw, 24px);
}

body.compact .tools {
  flex-wrap: wrap;
}

body.compact #compact-view[aria-pressed='true'] {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--table-heading, var(--forest));
}

body.compact button {
  min-height: 44px;
  min-width: 44px;
}

body.compact :is(.tools > button, .table-tabs button, .theory-controls button,
    .pupil-name, .pupil-state, .paper-note, .guess-points, .sheet-caption,
    .clue-meta, .notes-area p, .classmate p, .turn-action-copy p,
    .pupil-clue-table th, .pupil-clue-table td small,
    .sheet-clue-table td small, .own-class p, .roll-heading p,
    .roll-heading button, .entry-avatar button, .revealed-letters span,
    .notebook-table th, .alphabet-table th:first-child) {
  font-size: .8rem;
}

body.compact small {
  font-size: .8rem;
}

body.compact .entry-scene {
  min-height: 0;
  gap: 24px;
  max-width: 1100px;
  margin-bottom: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 360px);
}

body.compact .welcome {
  padding: 6px 0;
}

body.compact .welcome h1 {
  font-size: clamp(3.6rem, 7vw, 5.3rem);
  margin-bottom: 18px;
}

body.compact .welcome h2 {
  font-size: clamp(1.35rem, 2vw, 1.7rem);
  margin-bottom: 8px;
}

body.compact :is(.welcome-line, .intro, .entry-footnote) {
  margin-bottom: 8px;
  font-size: .9rem;
}

body.compact .entry-footnote {
  margin-top: 10px;
}

body.compact .entry-portraits {
  max-width: 420px;
  padding: 8px 8px 5px;
}

body.compact .entry-portraits figure {
  max-width: 140px;
  border-width: 4px;
  border-bottom-width: 12px;
}

body.compact .entry-paper {
  padding: 22px 22px 18px;
}

body.compact .entry-paper h2 {
  margin: 4px 0 12px;
  font-size: 1.5rem;
}

body.compact form label {
  margin: 8px 0 5px;
}

body.compact .entry-actions {
  margin: 10px 0 12px;
  gap: 6px;
}

body.compact .entry-avatar {
  gap: 8px;
  margin: 10px 0;
}

body.compact .entry-avatar > img {
  width: 48px;
  height: 48px;
}

body.compact .paper-note {
  margin-top: 12px;
}

body.compact .cast-strip {
  max-width: 1100px;
  margin: 16px auto;
}

body.compact .cast-strip > p {
  margin-bottom: 10px;
  font-size: .85rem;
}

body.compact .cast-preview {
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}

body.compact .cast-preview .pupil-card {
  max-width: 140px;
}

body.compact .gallery-controls {
  margin: 10px 0;
}

body.compact .lobby-scene {
  margin: 16px auto;
}

body.compact .lobby-intro h1 {
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  margin-bottom: 10px;
}

body.compact .lobby-intro > p {
  margin-bottom: 10px;
}

body.compact .invite-url {
  margin: 8px 0 12px;
}

body.compact .seat-ring {
  gap: 12px;
  margin: 18px 0;
}

body.compact .lobby-seat > img {
  width: min(100%, 140px);
  border-width: 4px;
}

body.compact .lobby-seat h2 {
  margin: 9px 0 4px;
  font-size: 1.1rem;
}

body.compact .lobby-seat p {
  margin-bottom: 8px;
  font-size: .8rem;
}

body.compact .empty-seat {
  min-height: 140px;
}

body.compact :is(.lobby-avatar-change, .lobby-seat .text-button) {
  max-width: 100%;
  padding-inline: 8px;
  overflow-wrap: anywhere;
}

body.compact :is(.table-top, .classmates, .turn-banner, .roll-heading) {
  margin-bottom: 10px;
  gap: 8px;
}

body.compact .table-top h1 {
  font-size: 1.35rem;
}

body.compact .game-layout {
  gap: 16px;
}

body.compact .classmate {
  min-width: 135px;
  gap: 7px;
  padding: 3px 0 8px;
}

body.compact .classmate > img {
  width: 32px;
  height: 32px;
}

body.compact .classmate h3 {
  font-size: .9rem;
}

body.compact .turn-banner {
  padding-bottom: 8px;
}

body.compact .turn-banner h2 {
  font-size: 1.12rem;
}

body.compact .turn-banner p {
  font-size: .8rem;
}

body.compact .turn-action-bar {
  padding: 8px 10px;
  gap: 8px;
  margin-bottom: 8px;
}

body.compact .turn-action-bar > img {
  width: 40px;
  height: 40px;
}

body.compact .turn-action-copy h3 {
  font-size: 1.12rem;
}

body.compact .theory-dock {
  padding: 6px;
  margin: 0 0 10px;
}

body.compact .theory-dock .theory-line {
  gap: 10px;
  padding-bottom: 6px;
}

body.compact .theory-head h3 {
  font-size: 1rem;
  margin-bottom: 3px;
}

body.compact .theory-head p {
  font-size: .8rem;
}

body.compact .theory-slots {
  gap: 6px;
}

body.compact .theory-slot {
  width: 58px;
  min-height: 72px;
}

body.compact .theory-slot .pupil-card {
  padding: 3px;
}

body.compact .theory-slot .pupil-name {
  padding: 3px 0 1px;
  font-size: .8rem;
}

body.compact .theory-dock .theory-controls {
  gap: 6px;
  margin-top: 6px;
}

body.compact .preview-action {
  gap: 6px;
  padding: 5px 7px;
  flex-wrap: wrap;
  background: var(--mark-certain-bg);
  color: var(--ink);
}

body.compact .theory-dock .guess-history {
  margin-top: 6px;
}

body.compact .guess-history p {
  margin: 4px 0;
  font-size: .8rem;
}

body.compact .table-tabs {
  gap: 4px;
  padding-bottom: 5px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

body.compact .roll-grid {
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}

body.compact .roll-grid .pupil-card {
  padding: 3px;
}

body.compact .roll-grid .pupil-name {
  padding: 4px 0 2px;
  font-size: .8rem;
}

body.compact .roll-grid .letter {
  font-size: 1.1rem;
  left: 3px;
  top: 3px;
}

body.compact .action-paper {
  padding: 10px 12px;
  margin-bottom: 10px;
}

body.compact .action-paper h3 {
  font-size: 1.12rem;
}

body.compact .action-paper p {
  font-size: .8rem;
  margin-bottom: 6px;
}

body.compact .clue-book {
  padding: 12px 10px;
}

body.compact .clue-entry {
  padding: 8px 0;
}

body.compact :is(.sheet-clue-scroll, .pupil-clue-scroll) {
  max-height: 160px;
  min-height: 80px;
}

body.compact .pupil-clue-table tr.pupil-empty ~ tr.pupil-empty,
body.compact .pupil-clue-table tbody:has(> tr:not(.pupil-empty)) > tr.pupil-empty {
  display: none;
}

body.compact :is(.scoresheet, .pupil-sheet) {
  margin-block: 10px 14px;
}

body.compact .scoresheet {
  padding-block: 10px;
}

body.compact :is(.scoresheet-heading, .pupil-sheet-heading) {
  margin-bottom: 10px;
  padding-bottom: 8px;
}

body.compact :is(.scoresheet-heading, .pupil-sheet-heading) h2 {
  font-size: 1.2rem;
  margin-bottom: 4px;
}

body.compact :is(.scoresheet-heading, .pupil-sheet-heading) p {
  font-size: .85rem;
}

body.compact .sheet-clues {
  gap: 10px;
  margin-top: 10px;
}

body.compact :is(.pupil-sheet-layout, .pupil-sheet-summary,
    .pupil-sheet-opponents, .sheet-guesses) {
  gap: 12px;
}

body.compact :is(.pupil-opponent > h3, .pupil-sheet-summary h3,
    .pupil-guess-record h3) {
  min-height: 44px;
  padding: 7px 10px;
  font-size: 1rem;
}

body.compact :is(.pupil-guess-row, .guess-row) {
  padding-block: 7px;
  gap: 5px;
}

body.compact .pupil-opponent > .pupil-alphabet-scroll {
  padding-top: 6px;
}

body.compact .pupil-sheet-controls {
  margin-top: 10px;
  padding-top: 8px;
  font-size: .8rem;
}

body.compact :is(.own-class, .playground-row) {
  margin-top: 10px;
  gap: 7px;
}

body.compact .own-hand {
  gap: 6px;
}

body.compact .own-hand .pupil-card {
  width: 58px;
}

body.compact .playground-row {
  flex-wrap: wrap;
}

body.compact .compact-fold {
  min-width: 0;
  margin-block: 8px;
  border: 1px solid var(--table-edge, var(--edge));
  border-radius: 4px;
}

body.compact .compact-fold > summary {
  min-height: 44px;
  padding: 11px 10px;
  color: var(--table-heading, var(--forest));
  font-weight: 700;
  line-height: 1.35;
  cursor: pointer;
  list-style-position: inside;
  overflow-wrap: anywhere;
}

body.compact .compact-fold[open] > summary {
  border-bottom: 1px solid var(--edge);
}

body.compact :is(.action-paper, .scoresheet, .pupil-guess-record,
    .pupil-opponent, .clue-book, dialog) .compact-fold > summary {
  color: var(--forest);
}

body.compact .compact-fold > :not(summary) {
  margin: 8px 10px;
}

body.compact .compact-fold .notes-area {
  padding-top: 0;
  border-top: 0;
}

body.compact .notes-area textarea {
  height: 80px;
}

body.compact .final-classes {
  gap: 8px;
}

body.compact .final-class {
  padding: 0 0 8px;
}

body.compact .final-class summary {
  min-height: 44px;
  padding: 11px 10px;
  color: var(--ink);
  background: var(--linen);
  border: 1px solid var(--edge);
  border-radius: 4px;
  cursor: pointer;
  font-weight: 700;
  line-height: 1.35;
  list-style-position: inside;
  overflow-wrap: anywhere;
}

body.compact .final-class .letter-choices {
  gap: 4px;
  margin-top: 8px;
}

body.compact .score-scene {
  margin-top: 0;
}

body.compact .score-heading {
  margin-bottom: 14px;
}

body.compact .score-heading h1 {
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  margin: 8px 0;
}

body.compact .missing-three {
  gap: 12px;
  margin: 12px auto 18px;
}

body.compact .missing-three .pupil-card {
  width: min(140px, calc((100% - 24px) / 3));
}

body.compact .rankings {
  gap: 12px;
  margin-block: 12px;
}

body.compact .result-player {
  padding: 12px;
}

body.compact .result-player.winner {
  padding: 10px;
}

body.compact .score-actions {
  margin-block: 14px;
}

body.compact dialog {
  padding: 18px;
}

body.compact .avatar-options {
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 8px;
}

@media (max-width: 850px) {
  body.compact .entry-scene {
    grid-template-columns: minmax(0, 1fr);
    max-width: 560px;
    gap: 18px;
  }
}

@media (max-width: 570px) {
  body.compact .classmate {
    min-width: 0;
  }

  body.compact .roll-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
  }

  body.compact .theory-dock .theory-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  body.compact .theory-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 10px;
  }

  body.compact .turn-action-copy {
    min-width: 0;
  }

  body.compact .turn-action-copy p {
    font-size: .8rem;
  }

  body.compact .turn-action-bar > img {
    width: 36px;
    height: 36px;
  }

  body.compact .entry-paper {
    padding-inline: 18px;
  }
}

@media (forced-colors: active) {
  body.compact .compact-fold {
    border-color: ButtonText;
  }

  body.compact :is(.compact-fold > summary, .final-class summary) {
    color: CanvasText;
    background: Canvas;
  }
}
