/* Let setup and play views use the viewport while keeping comfortable edge gutters. */
.page-body.center {
  width: 100%;
  max-width: none;
  margin-inline: 0;
  padding-inline: clamp(16px, 2.4vw, 44px);
}

.page-body.center > .toolbar,
.page-body.center > .category-group,
.page-body.center > .selection-bar,
.page-body.center > .team-form {
  width: 100%;
  max-width: none;
}

.page-body.center > .team-form {
  margin-inline: auto;
}

.page-body.center .team-grid {
  width: 100%;
}

.page-body.center .category-section .section-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: clamp(12px, 1.2vw, 22px);
}

.page-body.center .category-section .category-with-info {
  width: 100%;
  min-width: 0;
  max-width: none;
}

body.playing .game-wrap.game-board {
  --board-gutter: clamp(12px, 2vw, 36px);
  width: 100%;
  max-width: none;
  padding-inline: var(--board-gutter);
}

body.playing .game-wrap.game-board > .board,
body.playing .game-wrap.game-board > .board-layout-picker,
body.playing .game-wrap.game-board > .board-status {
  width: 100%;
  max-width: none !important;
}

body.playing .game-wrap.game-board .board {
  margin-inline: 0;
}

body.playing .game-wrap.game-board > .scoreboard {
  width: calc(100% + 2 * var(--board-gutter));
  max-width: none;
  margin-inline: calc(-1 * var(--board-gutter));
}

@media (max-width: 600px) {
  .page-body.center {
    padding-inline: 16px;
  }

  body.playing .game-wrap.game-board {
    --board-gutter: 12px;
  }
}

/* Setup is a single reading path: categories first, team configuration below. */

@media (min-width: 1100px) and (min-height: 650px) {
  body.playing .game-wrap.game-board {
    height: calc(100dvh - 66px);
    min-height: 0;
    overflow: hidden;
    padding-top: clamp(8px, 1.4vh, 16px);
  }

  body.playing .game-wrap.game-board > .board {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(2, minmax(0, 1fr)) !important;
    align-content: stretch !important;
    gap: clamp(8px, 1vh, 14px) clamp(12px, 1.2vw, 24px);
    margin: 0;
  }

  body.playing .game-wrap.game-board .board-category {
    height: auto !important;
    min-height: 0 !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1fr) !important;
  }

  body.playing .game-wrap.game-board .board-art {
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: auto !important;
  }

  body.playing .game-wrap.game-board .board-card h2 {
    flex: 0 0 30px;
    min-height: 30px !important;
    padding: 4px !important;
    font-size: 12px !important;
  }

  body.playing .game-wrap.game-board > .board-status {
    flex: 0 0 auto;
    margin: 3px auto 5px;
    line-height: 1.2;
  }

  body.playing[data-score-concept="extra-ticket"] .game-wrap.game-board > .scoreboard {
    flex: 0 0 auto;
    padding: 8px clamp(12px, 3vw, 48px) !important;
    gap: clamp(12px, 2vw, 32px) !important;
  }

  body.playing[data-score-concept="extra-ticket"] .game-wrap.game-board .score-team {
    gap: 8px !important;
    padding: 8px !important;
  }

  body.playing[data-score-concept="extra-ticket"] .game-wrap.game-board .stub-powerup,
  body.playing[data-score-concept="extra-ticket"] .game-wrap.game-board .stub-powerup > button[data-life] {
    min-height: clamp(84px, 12vh, 108px) !important;
  }

  body.playing[data-score-concept="extra-ticket"] .game-wrap.game-board .stub-powerup .powerup-icon {
    width: clamp(66px, 6vw, 92px) !important;
    height: clamp(66px, 6vw, 92px) !important;
  }
}

/* The live clue owns the space below the game bar; it never pushes the page into scroll. */
@media (min-width: 761px) {
  body.playing #app:has(.question-wrap) {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
  }

  body.playing #app:has(.question-wrap) > .game-nav {
    flex: 0 0 auto;
    min-height: clamp(54px, 7vh, 68px);
  }

  body.playing #app:has(.question-wrap) > .game-wrap:has(.question-wrap) {
    flex: 1 1 0;
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: hidden;
    padding: clamp(8px, 1.1vh, 14px) clamp(12px, 2vw, 36px) !important;
  }

  body.playing .question-wrap {
    grid-template-rows: 54px minmax(0, 1fr) 12px 68px !important;
    gap: clamp(6px, .9vh, 12px) clamp(10px, 1.2vw, 20px) !important;
  }

  body.playing .question-wrap .question-meta {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    min-height: 48px;
    gap: clamp(8px, 1.2vw, 18px);
    margin: 0 !important;
  }

  body.playing .question-wrap .question-meta > a { grid-column: 1; justify-self: start; }
  body.playing .question-wrap .question-meta > .timer { grid-column: 2; justify-self: center; }
  body.playing .question-wrap .question-meta > strong {
    grid-column: 3;
    justify-self: end;
    padding: 9px 15px;
    background: #101b2e;
    color: #fffaf4;
    border-radius: 3px;
    font-size: clamp(14px, 1.2vw, 18px);
    line-height: 1.2;
    text-align: center;
  }

  body.playing .question-wrap .question-meta > .timer {
    min-width: clamp(128px, 10vw, 164px);
    min-height: clamp(46px, 5.4vh, 58px);
    padding: 8px 17px;
    gap: 10px;
    background: #fffaf4;
    color: #243775;
    border: 1px solid #b9c4d9;
    border-radius: 5px;
    font-size: clamp(20px, 1.8vw, 27px);
    font-variant-numeric: tabular-nums;
    box-shadow: 0 4px 12px #0e1e3b30;
  }

  body.playing[data-question-layout="opposite"] .question-wrap {
    grid-template-columns: minmax(176px, 15vw) minmax(0, 1fr) minmax(176px, 15vw);
  }

  body.playing[data-question-layout="opposite"][data-score-concept] .question-wrap > .scoreboard > .score-team {
    padding: clamp(8px, 1vh, 14px) clamp(6px, .7vw, 12px) !important;
    gap: clamp(8px, 1.2vh, 14px) !important;
  }

  body.playing[data-question-layout="opposite"][data-score-concept] .question-wrap .score-title h2 {
    font-size: clamp(15px, 1.15vw, 19px) !important;
    line-height: 1.2;
  }

  body.playing[data-question-layout="opposite"][data-score-concept] .question-wrap .score-counter strong {
    width: auto !important;
    height: auto !important;
    font-size: clamp(23px, 2vw, 32px) !important;
    line-height: 1.1;
  }

  body.playing[data-question-layout="opposite"][data-score-concept] .question-wrap .score-counter button {
    width: 34px !important;
    height: 34px !important;
    font-size: 18px;
  }

  body.playing[data-question-layout="opposite"][data-score-concept] .question-wrap .scoreboard .score-team .score-helps {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-content: start;
    justify-items: center;
    width: 100% !important;
    max-width: 148px !important;
    gap: clamp(5px, .8vh, 9px) !important;
  }

  body.playing[data-question-layout="opposite"][data-score-concept] .question-wrap .scoreboard .score-team .score-helps button {
    width: 100% !important;
    min-height: clamp(84px, 10vh, 104px) !important;
    padding: 3px !important;
    gap: 3px !important;
    flex-direction: column !important;
    justify-content: center !important;
    font-size: 12px !important;
    line-height: 1.15;
    white-space: normal;
    text-align: center;
  }

  body.playing[data-question-layout="opposite"][data-score-concept] .question-wrap .scoreboard .score-team .score-helps .powerup-icon {
    width: clamp(58px, 6.5vh, 76px) !important;
    height: clamp(58px, 6.5vh, 76px) !important;
    flex: 0 0 auto;
  }
}

/* A clue opens as a focused viewing surface over the dimmed, softened game. */
.image-lightbox {
  position: fixed;
  inset: 0;
  width: min(90vw, 1540px);
  height: min(90dvh, 1000px);
  max-width: none;
  max-height: none;
  margin: auto;
  padding: clamp(16px, 2vw, 28px);
  overflow: hidden;
  border: 1px solid #dce6ffb8;
  border-radius: 8px;
  background: #0c1424;
  color: #fffaf4;
  box-shadow: 0 24px 80px #0509148c;
}

.image-lightbox::backdrop {
  background: #0710208c;
  -webkit-backdrop-filter: blur(10px) brightness(.42) saturate(.72);
  backdrop-filter: blur(10px) brightness(.42) saturate(.72);
}

.image-lightbox-image,
.image-lightbox-image > img {
  width: 100%;
  height: 100%;
}

.image-lightbox-image > img {
  object-fit: contain;
  object-position: center;
  border-radius: 3px;
}

.image-lightbox-close {
  position: absolute;
  z-index: 1;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 8px;
  border: 1px solid #243775;
  border-radius: 4px;
  background: #fffaf4;
  color: #101b2e;
}

.image-lightbox-close svg { width: 28px; height: 28px; stroke-width: 2.3; }
[data-expand-image] { cursor: zoom-in; }
[data-expand-image]:focus-visible { outline: 3px solid #e8bd60; outline-offset: 4px; }

@media (max-width: 760px) {
  .image-lightbox {
    width: calc(100vw - 20px);
    height: calc(100dvh - 24px);
    padding: 56px 12px 12px;
    border-radius: 6px;
  }
  .image-lightbox-close { top: 7px; right: 7px; width: 44px; height: 44px; }
}

/* The setup follows the task: choose categories, then configure the teams. */
.page-body.center:has(> .category-group) {
  display: block;
  height: auto;
  min-height: 0;
  max-height: none;
  overflow: visible;
  padding-block: 28px 56px;
}

.page-body.center > .toolbar {
  justify-content: flex-start;
  margin: 22px 0 16px;
}

.page-body.center > .category-group {
  height: auto;
  min-height: 0;
  max-height: none;
  overflow: visible !important;
  margin: 0;
  padding: 18px 0 0;
  border: 0;
}

.page-body.center > .category-group > .group-title {
  position: static;
  display: block;
  transform: none;
  width: fit-content;
  margin: 0 0 10px;
  padding: 0;
  background: transparent;
  color: #dbe8ff;
  text-align: left;
}

.page-body.center > .category-group .category-view-controls {
  margin: 8px 0 12px;
}

.page-body.center > .category-group .category-section > summary {
  min-height: 54px;
  padding-block: 6px;
}

.page-body.center > .category-group .section-previews {
  height: 42px;
  flex-basis: 80px;
}

.page-body.center > .category-group .section-previews > span {
  height: 40px;
  width: 29px;
  flex-basis: 29px;
}

.page-body.center > .category-group .section-category-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 230px));
  align-items: start;
  justify-content: center;
  gap: 16px;
  padding-block: 8px 14px;
}

.page-body.center > .category-group .category-with-info {
  width: 100%;
  max-width: 230px;
  margin-inline: 0;
}

/* Use the available desktop width on the home page. */
.club-home .club-opening {
  width: 100%;
  max-width: none;
  padding-inline: clamp(18px, 2.4vw, 44px);
}

.club-home .club-choices {
  padding-inline: clamp(18px, 2.4vw, 44px);
}

@media (min-width: 1101px) {
  body .club-home .club-choices .choice-ticket {
    flex-basis: calc((100% - 110px) / 6);
  }
}

body[data-cover-design] .page-body.center > .category-group:not([data-category-view=index]) .category-grid .category .category-art {
  display: block;
  width: 100%;
  height: auto !important;
  min-height: 0 !important;
  aspect-ratio: 2 / 3 !important;
}

body[data-cover-design] .page-body.center > .category-group:not([data-category-view=index]) .category-grid .category .category-art img {
  width: 100% !important;
  height: 100% !important;
  padding: 40px 0 0 !important;
  object-fit: cover !important;
  object-position: center !important;
}

.page-body.center > .selection-bar {
  min-height: 60px;
  margin: 10px 0 40px;
}

.page-body.center > .team-form {
  height: auto;
  max-width: none;
  max-height: none;
  overflow: visible;
  margin: 0;
  padding: 24px 0 0;
  border-top: 1px solid #475d80;
}

@media (min-width: 761px) {
  body:has(#setup-form) .nav {
    height: 94px;
    min-height: 94px;
    padding-block: 6px;
  }

  body:has(#setup-form) .nav .ko-logo {
    width: 105px;
    height: 78px;
  }

  body:has(#setup-form) .page-head {
    padding-top: 18px;
  }

  body:has(#setup-form) .page-head h1 {
    font-size: 36px;
    margin-bottom: 8px;
  }

  body:has(#setup-form) .page-head > p {
    max-width: 900px;
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.35;
  }

  body:has(#setup-form) .page-head .modes {
    min-height: 66px;
    margin-top: 8px;
  }

  body:has(#setup-form) .page-head .mode,
  body:has(#setup-form) .page-head .mode.active {
    min-height: 60px;
  }

  .page-body.center:has(> .category-group) > h2 {
    font-size: 32px;
    margin-bottom: 8px;
  }

  .page-body.center:has(> .category-group) > .intro {
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.4;
  }
}

@media (max-width: 760px) {
  .page-body.center:has(> .category-group) { padding-block: 24px 44px; }
  .page-body.center > .category-group .section-category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  body[data-cover-design] .page-body.center > .category-group:not([data-category-view=index]) .category-grid .category .category-art img {
    padding-top: 32px !important;
  }

  body:has(#setup-form) .page-head .modes {
    justify-content: flex-start;
    width: 100%;
    max-width: none;
    min-height: 72px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 3px 16px 8px;
    scrollbar-width: thin;
  }

  body:has(#setup-form) .page-head .mode,
  body:has(#setup-form) .page-head .mode.active {
    flex: 0 0 92px;
    width: 92px !important;
    min-height: 60px;
    font-size: 12px !important;
  }
}
