body {
  font-family: system-ui, Arial, sans-serif;
  color: #202b37;
  background: #fbfcfd;
}
.site-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 2px solid #33465b;
}
.wordmark {
  font-weight: 750;
  text-decoration: none;
}
.primary-nav {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}
.result-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.browser-card {
  border: 1px solid #b6c2cc;
  border-top: 3px solid #4d6781;
  padding: 10px;
  min-width: 0;
}
.browser-card img {
  max-height: 122px;
}
.browser-card h3 {
  margin: 8px 0;
}
.browser-card p {
  margin: 4px 0 8px;
  font-size: 0.95rem;
}
.browser-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.browser-actions a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.browser-actions button {
  background: #eef3f7;
  border-color: #637f9b;
}
.session-dialog {
  max-width: min(1080px, calc(100vw - 24px));
  width: 100%;
  border: 2px solid #2f465f;
}
.session-inner {
  display: flex;
  flex-direction: column;
  height: min(820px, calc(100dvh - 28px));
  max-height: calc(100dvh - 28px);
  padding: 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.session-head {
  display: flex;
  gap: 12px;
  align-items: center;
  flex: 0 0 auto;
}
.session-head h2 {
  margin: 0;
  flex: 1;
  font-size: 1.1rem;
}
.session-controls {
  margin: 6px 0;
  font-size: 0.95rem;
}
.session-facts {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  flex: 0 0 auto;
}
.session-stage {
  flex: 1;
  min-height: 0;
}
.session-stage > .stage {
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
}
.session-stage .stage-screen {
  height: 100%;
  aspect-ratio: auto;
  min-height: 0;
}
.session-stage .stage-tools {
  padding: 6px;
}
.session-stage .stage-status {
  padding: 0 8px 6px;
}
.game-heading {
  border-top: 3px solid #607b96;
  padding-top: 12px;
  margin-bottom: 16px;
}
@media (max-width: 999px) {
  .result-cards {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 599px) {
  .site-header {
    display: block;
  }
  .primary-nav {
    gap: 0 18px;
  }
  .browser-card {
    padding: 8px;
  }
  .browser-card img {
    max-height: 96px;
  }
  .browser-actions {
    display: block;
  }
  .browser-actions button {
    width: 100%;
  }
  .browser-actions a {
    display: flex;
  }
  .session-inner {
    padding: 8px;
  }
  .session-head h2 {
    font-size: 1rem;
  }
  .session-controls {
    font-size: 0.9rem;
  }
  .session-facts {
    font-size: 0.9rem;
  }
  .session-stage .stage-tools {
    gap: 4px;
  }
  .session-stage .stage-tools button {
    padding: 5px 8px;
  }
}
@media (max-height: 450px) {
  .session-facts {
    min-height: 28px;
    font-size: 0.85rem;
  }
  .session-controls {
    margin: 2px 0;
    font-size: 0.85rem;
  }
  .session-head h2 {
    font-size: 1rem;
  }
  .session-stage .stage-status {
    font-size: 0.8rem;
    line-height: 1.2;
  }
}

.result-row {
  padding: 6px 0 14px;
  margin-bottom: 12px;
  border-bottom: 1px solid #bac3c3;
}
.game-block .image-cell {
  display: block;
  position: relative;
  min-width: 0;
  min-height: 72px;
  aspect-ratio: 16/9;
  overflow: hidden;
  align-self: stretch;
}
.game-block .image-cell > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none !important;
  max-height: none !important;
  aspect-ratio: auto;
  object-fit: cover;
  object-position: center;
  padding: 0 !important;
  margin: 0 !important;
  align-self: stretch;
}
.notice-item > .image-cell,
.notice-reading > .image-cell,
.index-frame > .image-cell,
.register-record > .image-cell,
.answer-example > .image-cell,
.switch-entry > .image-cell,
.picture-entry > .image-cell,
.saved-picture-head > .image-cell,
.question-game > .image-cell,
.saved-quote > .image-cell,
.quote-summary > .image-cell {
  aspect-ratio: auto;
  max-height: none;
  min-height: 90px;
}
.fact-frame > .image-cell {
  height: 170px;
}
.picture-choice > .game-block {
  display: block;
}
.picture-card-main > .image-cell,
.browser-card-main > .image-cell,
.picture-choice-main > .image-cell,
.answer-card > .image-cell,
.stage-choice > .image-cell,
.catalogue-notice > .image-cell,
.word-game > .image-cell,
.clip-game-card > .image-cell {
  height: 116px;
  aspect-ratio: auto;
}
.game-block {
  padding: 10px;
}
.picture-actions {
  padding: 0 10px 8px;
}
.compact-notices .notice-item > .image-cell {
  min-height: 88px;
}
.quote-summary > .image-cell {
  min-height: 130px;
}
@media (max-width: 999px) {
  .index-frame > .image-cell {
    height: 104px;
    aspect-ratio: 16/9;
  }
  .register-record > .image-cell {
    height: 90px;
    aspect-ratio: 16/9;
  }
}
@media (max-width: 649px) {
  .register-record > .image-cell {
    height: auto;
    aspect-ratio: auto;
  }
  .picture-entry > .image-cell,
  .quote-summary > .image-cell {
    height: 140px;
    aspect-ratio: 16/9;
  }
  .picture-card-main > .image-cell,
  .browser-card-main > .image-cell,
  .picture-choice-main > .image-cell,
  .answer-card > .image-cell,
  .stage-choice > .image-cell,
  .catalogue-notice > .image-cell,
  .word-game > .image-cell,
  .clip-game-card > .image-cell {
    height: 92px;
  }
  .compact-notices .notice-item {
    display: block;
  }
  .compact-notices .notice-item > .image-cell {
    height: 106px;
    aspect-ratio: 16/9;
  }
  .switch-entry.game-block {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
  }
  .fact-frame > .image-cell {
    height: auto;
    min-height: 110px;
  }
  .quote-summary.game-block {
    display: block;
  }
}

.result-cards {
  align-items: start;
}
.register-leaves {
  align-items: start;
}
.register-leaves > .register-leaf:only-child,
.switch-listing > .game-block:only-child,
[data-notice-extra] > .game-block:only-child {
  grid-column: 1/-1;
}
.site-header {
  position: relative;
}
@media (max-height: 450px) {
  .site-header {
    padding-block: 6px;
  }
  .primary-nav {
    margin-top: 0;
  }
  .site-header a {
    min-height: 44px;
  }
  h1 {
    margin-block: 6px 10px;
  }
}

.game-block .image-cell {
  width: 100%;
  max-width: 100%;
}

/* Content first: identity and tools stay shallow; only navigation scrolls. */
.site-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 12px;
  padding-block: 6px;
  position: relative;
}
.site-header .wordmark {
  flex: 1 1 auto;
  min-width: 0;
  max-width: calc(100% - 112px);
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}
.site-header .catalogue-trigger {
  flex: 0 0 44px;
  width: 44px;
  min-height: 44px;
  padding: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}
.catalogue-trigger svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}
.site-header .primary-nav {
  display: flex;
  flex: 1 1 100%;
  min-width: 0;
  max-width: 100%;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 0 18px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  margin: 0;
  border-top: 0;
  scrollbar-width: thin;
}
.site-header .primary-nav a {
  flex: 0 0 auto;
  min-width: 44px;
  white-space: nowrap;
  padding-inline: 2px;
}
.site-header .primary-nav a:focus-visible {
  outline-offset: -3px;
}
[data-results] {
  min-width: 0;
}
[data-catalogue-list] {
  display: grid;
  gap: 12px;
  align-items: start;
  padding-top: 8px;
}
[data-catalogue-item] {
  min-width: 0;
  margin: 0;
}
[data-catalogue-item][data-batch-start] {
  scroll-margin-block-start: 8px;
}
[data-catalogue-more] {
  margin-block: 12px 8px;
}
[data-search-form] {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-block: 12px;
}
[data-search-form] input {
  width: 100%;
  min-width: 0;
  font-size: 16px;
}
[data-filter-dialog] .modal-body {
  padding-bottom: 8px;
}
.game-block h2,
.game-block h3 {
  line-height: 1.3;
}
@media (min-width: 1000px) {
  .site-header {
    flex-wrap: nowrap;
  }
  .site-header .wordmark {
    flex: 0 1 auto;
    max-width: none;
  }
  .site-header .primary-nav {
    flex: 1 1 auto;
    margin-left: auto;
    justify-content: flex-end;
  }
  .catalogue-trigger {
    order: 3;
  }
}
@media (max-height: 600px) and (max-width: 999px) {
  .site-header .primary-nav {
    font-size: 0.9rem;
  }
  .game-block {
    padding: 8px;
  }
  [data-catalogue-list] {
    gap: 10px;
  }
}

@media (max-width: 999px) {
  .site-header {
    flex-wrap: nowrap;
    gap: 8px;
  }
  .site-header .primary-nav {
    display: none;
  }
  .site-header .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    width: 44px;
    min-height: 44px;
    padding: 8px;
    background: transparent;
  }
  .site-header .wordmark {
    max-width: calc(100% - 104px);
  }
}
@media (min-width: 1000px) {
  .site-header .menu-toggle {
    display: none;
  }
}
.browser-card {
  padding: 0;
  border-width: 1px;
}
.browser-card h3 {
  margin: 6px 0 0;
}
.browser-actions {
  display: flex;
  padding: 0 8px 8px;
}
.browser-actions button {
  font-size: 1rem;
  min-width: 44px;
  padding: 6px 8px;
  width: auto;
}

/* The site owns one condition form; panel placement follows its reading workflow. */
[data-filter-dialog] .condition-field {
  display: grid;
  gap: 6px;
  margin-block: 12px;
}
[data-filter-dialog] select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px;
  font: inherit;
  color: inherit;
  background: transparent;
}
[data-filter-dialog] .radio-label {
  cursor: pointer;
}
[data-filter-dialog] .modal-layout {
  max-height: calc(100dvh - 26px);
}
[data-filter-dialog] .modal-head {
  border-bottom: 1px solid currentColor;
}
[data-filter-dialog] [data-category-options]:not(select) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
}
@media (max-width: 419px) {
  [data-filter-dialog] [data-category-options]:not(select) {
    grid-template-columns: 1fr;
  }
}
[data-filter-dialog] {
  width: min(400px, calc(100% - 16px));
  margin: 8px 8px 8px auto;
  height: fit-content;
}
[data-filter-dialog] .modal-layout {
  height: auto;
}
[data-filter-dialog] .modal-body {
  flex: 0 1 auto;
}
[data-filter-dialog] .modal-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 16px;
}
[data-filter-dialog] [data-search-form],
[data-filter-dialog] .modal-body > p {
  grid-column: 1/-1;
}
@media (max-width: 419px) {
  [data-filter-dialog] .modal-body {
    display: block;
  }
}

/* Short landscape keeps the existing native image and title side by side. */
@media (orientation: landscape) and (max-height: 520px) and (max-width: 999px) {
  .site-header {
    padding-block: 2px;
  }
  [data-catalogue-list] {
    padding-top: 4px;
  }
  .browser-card-main.game-block {
    display: grid;
    grid-template-columns: 34% minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 6px;
  }
  .browser-card-main.game-block > .image-cell {
    height: 64px;
    min-height: 64px;
  }
  .browser-card-main.game-block h3 {
    margin: 0;
  }
}

/* Rules 8–12: source-owned columns, compact continuous cards, full local preview. */
[data-discovery-grid] {
  display: grid;
  gap: 16px;
  align-items: start;
}
[data-discovery-grid] > * {
  min-width: 0;
  margin-block: 0;
}
[data-discovery-grid] .game-block {
  min-width: 0;
}
[data-discovery-grid] .game-block h2,
[data-discovery-grid] .game-block h3 {
  margin-block: 8px 0;
  font-size: 1rem;
  line-height: 1.3;
  min-height: 2.6em;
  max-height: 2.6em;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
button,
[data-filter-dialog],
[data-discovery-grid] > * {
  border-radius: 10px;
}
.site-header .primary-nav {
  scrollbar-width: thin;
  gap: 0 16px;
}
.site-header .primary-nav::-webkit-scrollbar {
  height: 3px;
}
.site-header {
  border-bottom-width: 1px;
}
[data-filter-dialog] .modal-head {
  border-bottom: 1px solid rgb(100 110 115 / 0.25);
}
[data-filter-dialog] .radio-label {
  border-radius: 10px;
}
[data-filter-dialog] .radio-label:has(input:checked) {
  background: rgb(100 110 115 / 0.08);
}
.stage-screen {
  position: relative;
}
.stage-screen > img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  object-fit: cover;
  object-position: center;
  padding: 0;
  margin: 0;
}
@media (max-width: 649px) {
  [data-discovery-grid] {
    gap: 12px;
  }
}
@media (orientation: landscape) and (max-height: 520px) and (max-width: 999px) {
  [data-discovery-grid] {
    gap: 12px;
  }
}
[data-catalogue-list] .browser-card {
  border: 1px solid #b8c4ce;
  overflow: hidden;
}
.browser-actions {
  padding: 0 10px 10px;
}
