/* Shared header palette — edit these values to customize this game only. */
:root {
  --game-header-bg: #101c48;
  --game-header-border: #ffe18a;
  --game-header-shadow: #080f3066;
  --game-header-title: #b3e4ff;
  --game-header-button-bg: #172e78;
  --game-header-button-border: #5876aa;
  --game-header-button-color: #ffe18a;
  --game-header-button-hover-bg: #263e70;
  --game-header-button-hover-border: #ffe18a;
  --game-header-button-hover-color: #fff0bd;
  --game-header-button-active-bg: #304b9e;
  --game-header-button-active-border: #ffe18a;
  --game-header-button-active-color: #fff0bd;
  --game-header-focus: #ffe18a;
  --game-header-logo-bg: #fff;
  --game-header-logo-border: #5876aa;
  --game-header-brand-hover-shadow: #ffe18a33;
}

/* Foundation and shared controls */

.jeopardy {
  --ink: #20334c;
  --muted: #50667d;
  --blue: #3359cb;
  --line: #d7e2ef;
  --stage: #080f30;
  --tile: #172eaa;
  --tile-light: #304bdb;
  --tile-dark: #0c1b70;
  --category: #b3e4ff;
  --gold: #ffe18a;
  --stage-ink: #eef1fa;
  --header-space: var(--games-header-height, 60px);
  margin: 0;
  min-height: 100dvh;
  background: var(--stage);
  color: var(--stage-ink);
  font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.jeopardy * {
  box-sizing: border-box;
}

.jeopardy [hidden] {
  display: none !important;
}

:where(.jp-main button, .jp-main input, .jp-main select, .jp-dialog button) {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

.jeopardy button {
  cursor: pointer;
  touch-action: manipulation;
}

.jeopardy button:disabled {
  cursor: default;
}

.jeopardy :focus-visible {
  outline: 3px solid #318bd4;
  outline-offset: 3px;
}

.jp-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.jp-primary, .jp-secondary {
  border: 0;
  border-radius: 12px;
  padding: 12px 20px;
  min-height: 46px;
  font-weight: 800;
}

.jp-primary {
  background: linear-gradient(115deg, #3157d3, #2541ae);
  color: #fff;
  box-shadow: 0 3px 0 #253c94;
}

.jp-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.jp-secondary {
  border: 1px solid #b9cbe4;
  background: #edf4ff;
  color: #30486b;
}

.jp-secondary:hover:not(:disabled) {
  background: #dceafe;
}

.jp-primary:disabled {
  opacity: .65;
}

.jp-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.jp-dialog {
  width: min(540px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  border: 1px solid #5876aa;
  border-radius: 20px;
  background: linear-gradient(145deg, #141d39, #080f30);
  color: var(--category);
  color-scheme: dark;
  padding: clamp(18px, 4vw, 34px);
  box-shadow: 0 18px 65px #1c2c6540;
}

.jp-dialog::backdrop {
  background: #060d28a8;
  backdrop-filter: blur(9px);
}

.jp-dialog h2 {
  color: var(--gold);
  margin: 0 0 12px;
  font-size: clamp(20px, 3.8vw, 30px);
  line-height: 1.3;
}

/* Setup: the same studio palette, player controls and question tiles. */
#setupScreen {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 1600px;
  margin-inline: auto;
  height: calc(100dvh - var(--header-space));
  min-height: 0;
  overflow: clip;
  padding: clamp(5px, 1.2vh, 14px) clamp(6px, 2vw, 32px) clamp(9px, 1.5vh, 18px);
}

.jp-setup {
  width: min(1200px, 100%);
  position: relative;
  height: 100%;
  container-type: size;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(4px, 1.5vh, 14px);
  min-height: 0;
  min-width: 0;
  padding: clamp(6px, 2vh, 22px) clamp(6px, 2vw, 26px);
  border: 2px solid #333e60;
  border-radius: 22px;
  background: linear-gradient(90deg, #111727, #030714 5%, #090e21 50%, #030714 95%, #111727);
  box-shadow: inset 0 2px 0 #ffffff24, inset 0 0 0 4px #0008, 0 5px 0 #03050d, 0 10px 24px #0008;
}

.jp-setup select {
  display: block;
  width: 100%;
  min-width: 0;
  height: clamp(28px, 9cqh, 60px);
  padding: 2px clamp(4px, 1cqw, 12px) 2px clamp(7px, 1.4cqw, 16px);
  border: 1px solid;
  border-radius: 13px;
  font-size: clamp(10px, min(2.2cqw, 4.2cqh), 24px);
  font-weight: 800;
  color-scheme: dark;
  cursor: pointer;
}
.jp-setup select option { background: #17264d; color: var(--gold); }
.jp-units {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  border: 0;
  padding: 0;
  margin: 0;
}
.jp-unit-grid {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  min-height: 0;
  min-width: 0;
  gap: clamp(3px, min(1cqw, 1.6cqh), 12px);
}
/* Tile surface is shared with the game; only typography and selection differ. */
.jp-unit.jp-tile {
  min-height: 0;
  padding: clamp(2px, .8cqh, 8px) clamp(2px, .7cqw, 8px);
  text-align: center;
  font-size: clamp(10px, min(2.7cqw, 5cqh), 30px);
  line-height: 1.2;
  letter-spacing: normal;
  overflow-wrap: anywhere;
}
.jp-unit.jp-tile small {
  display: block;
  margin-top: .15em;
  color: var(--category);
  font-size:  .67em;
  font-weight: 600;
}
.jp-unit.jp-tile[aria-pressed="true"] {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 2px var(--gold), 0 0 14px #ffe18a55;
  background: linear-gradient(115deg, #1c438f, #243b81);
}
.jp-unit.jp-tile:disabled { opacity: .45; }
.jp-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(3px, 1cqw, 14px);
  min-width: 0;
}
/* Status shares the action row, so the setup always has three grid tracks. */
.jp-setup-actions { min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(4px, 1cqw, 12px); }
.jp-status { grid-column: 1 / -1; margin: 0; font-size: clamp(10px, 1.4cqw, 16px); text-align: center; }
.jp-status:empty { display: none; }
#startButton, #teamSettingsButton { width: 100%; min-height: 0; height: clamp(28px, 9cqh, 60px); padding: 2px 8px; font-size: clamp(12px, min(2.4cqw, 4.5cqh), 26px); }
/* Keep all twelve cells in the responsive setup grid. */
.jp-unit-grid .jp-unit-empty { pointer-events: none; }
.jp-unit-grid .jp-mobile-home { display: none; }
.jp-unit-grid[aria-busy="true"] > .jp-unit {
  filter: brightness(.40);
  pointer-events: none;
  transform: none;
  transition: filter .10s;
}
.jp-unit-grid[aria-busy="true"] > .jp-unit.jp-random-flash {
  opacity: 1;
  filter: brightness(1.65);
  border-color: var(--gold);
  box-shadow: inset 0 0 0 2px var(--gold), 0 0 14px #ffe18a88;
}
.jp-unit.jp-menu-link, .jp-unit.jp-menu-link:hover, .jp-unit.jp-menu-link:visited { text-decoration: none; color: var(--gold); }
.jp-menu-label {
  display: grid; grid-template-columns: minmax(0, 23%) minmax(0, 1fr);
  width: 100%; min-width: 0; min-height: 0; align-items: center;
}
.jp-menu-brand { display: grid; place-items: center; align-self: stretch; min-width: 0; min-height: 0; border-right: 1px solid #b3e4ff33; padding: 2px clamp(3px, .65cqw, 9px); }
.jp-menu-brand img { display: block; width: 100%; max-width: 80px; max-height: 10cqh; object-fit: contain; opacity: .85; }
.jp-menu-copy { min-width: 0; padding-inline: clamp(2px, .5cqw, 8px); text-align: center; overflow-wrap: anywhere; }
html:has(body.jeopardy), body.jeopardy { height: 100%; overflow: hidden; }

.jp-designer {
  position: fixed;
  right: max(6px, env(safe-area-inset-right));
  bottom: max(6px, env(safe-area-inset-bottom));
  z-index: 20;
  padding: 1px 5px;
  border: 1px solid #cad6e8;
  border-radius: 5px;
  background: #ffffffd9;
  color: #52657e;
  font-size: 9px;
  font-weight: 650;
  line-height: 1.3;
  text-decoration: none;
}

.jp-designer:hover {
  background: #fff;
  color: var(--blue);
}

.games-is-fullscreen #setupScreen {
  padding-top: 52px;
}

/* Jeopardy branding inside the shared header; no changes to other games. */

.jeopardy .games-header .games-header-home {
  padding: 0 6px;
}

.jp-header-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  padding: 3px 2px;
  font-family: system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  white-space: nowrap;
}

.jp-header-word {
  color: var(--game-header-title);
  font-size: clamp(18px,2.4vw,29px);
  font-weight: 800;
  letter-spacing: -.055em;
  line-height: 1.1;
  transform: translateY(5px);
}

.jp-header-word>span {
  color: var(--gold);
}

.jp-header-tiles {
  display: grid;
  grid-template-columns: repeat(2,1fr);
  gap: 3px;
  transform: rotate(-5deg);
  flex: none;
}

.jp-header-tiles>span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 21px;
  border-radius: 4px;
  background: #2547bf;
  color: var(--gold);
  font-size: 13px;
  font-weight: 850;
  line-height: 1;
}

.jp-header-tiles>span:nth-child(2) {
  background: #3561ce;
}

.jp-header-tiles>span:nth-child(4) {
  background: #21419f;
}

@media(max-width:639px) {
  .jeopardy .games-header .games-header-home {
    padding: 0 2px;
  }
  .jp-header-logo {
    gap: 5px;
    padding: 2px;
  }
  .jp-header-word {
    font-size: clamp(15px,4.6vw,22px);
    transform: translateY(2px);
  }
  .jp-header-tiles {
    gap: 2px;
  }
  .jp-header-tiles>span {
    width: 23px;
    height: 15px;
    font-size: 9px;
    border-radius: 3px;
  }
}

@media(max-width:360px) {
  .jp-header-tiles>span {
    width: 19px;
    height: 13px;
    font-size: 8px;
  }
  .jp-header-logo {
    gap: 3px;
  }
}

.jeopardy .games-header #restartHeader {
  order: 15;
}

/* Game viewport and uniformly fitted logical canvas. */

.jp-playing {
  background: var(--stage);
  color: var(--stage-ink);
  height: 100dvh;
  overflow: hidden;
}

html:has(.jp-playing) {
  overflow: hidden;
}

#gameScreen {
  position: relative;
  width: 100%;
  max-width: 1600px;
  margin-inline: auto;
  height: calc(100dvh - var(--header-space));
  overflow: clip;
}

#gameScreen, #setupScreen {
  background: radial-gradient(ellipse at 50% 12%, #182f70, transparent 65%), linear-gradient(180deg, #0b153b, #040817 85%);
}

.jp-game-canvas {
  position: absolute;
  inset: 0 auto auto 0;
  transform-origin: top left;
  container-type: size;
  --stage-gap: clamp(8px, 1.15vw, 18px);
  display: flex;
  flex-direction: column;
  gap: var(--stage-gap);
  padding: 8px clamp(10px, 1.35vw, 24px) 20px;
}

.games-is-fullscreen .jeopardy {
  --header-space: 0px;
}

.games-is-fullscreen .jp-scoreboard {
  margin-right: max(60px, calc(env(safe-area-inset-right) + 48px));
  min-height: 48px;
}

.jp-scoreboard {
  display: grid;
  grid-template-columns: repeat(var(--players, 2), minmax(0, 1fr));
  gap: var(--stage-gap);
  flex: none;
}

.jp-player {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  min-width: 0;
  padding: clamp(8px, 1cqh, 14px) clamp(12px, 1.6cqw, 25px);
  border: 1px solid #435476;
  border-radius: 13px;
  background: #17264d;
  color: #d3e2fa;
  box-shadow: inset 4px 0 #536887;
}

.jp-player.active, .jp-setup select {
  border-color: var(--gold);
  background: linear-gradient(115deg, #1c438f, #243b81);
  box-shadow: inset 5px 0 var(--gold), 0 0 20px #ffe18a28;
  color: var(--gold);
}

.jp-scoreboard:has(.jp-player.active) .jp-player:not(.active) {
  opacity: .72;
}

.jp-player-identity {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  min-width: 0;
}

.jp-player span {
  font-weight: 800;
  font-size: clamp(17px, 1.75cqw, 29px);
  line-height: 1.2;
}

.jp-player strong {
  font-size: clamp(30px, 3.5cqw, 56px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
}

/* Studio frame: curved golden fascia, segmented side lamps and blue lower trim.
   Curvature stays on the decorative frame; the playable grid remains flat. */

.jp-board {
  --category-height: clamp(46px, calc(2.6cqw + 20px), 68px);
  --frame-top: clamp(32px, 3cqw, 48px);
  --frame-side: clamp(25px, 2.65cqw, 46px);
  --frame-bottom: clamp(12px, 1.4cqw, 23px);
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(var(--columns, 6), minmax(0, 1fr));
  gap: clamp(5px, .65cqw, 12px);
  min-height: calc(var(--frame-top) + var(--frame-bottom) + var(--category-height) + var(--rows, 5) * 60px);
  padding: var(--frame-top) var(--frame-side) var(--frame-bottom);
  border: 2px solid #333e60;
  border-radius: clamp(16px, 2.1cqw, 34px);
  background: radial-gradient(ellipse 105% calc(var(--frame-top) + 5px) at 50% -10px,
      transparent 59%, #a76b23 61%, #ffdc8b 63%, #fff0be 68%, #9a591a 71%,
      transparent 73%, transparent 84%, #aa6a22 86%, #ffcf70 88%, #ffedb2 93%,
      #8c511c 96%, transparent 98%) top / 100% var(--frame-top) no-repeat,
    linear-gradient(180deg, #050a1e, #1839aa 40%, #4e7bff 52%, #142879 65%, #050917) bottom / 100% var(--frame-bottom) no-repeat,
    linear-gradient(90deg, #111727, #030714 5%, #090e21 50%, #030714 95%, #111727);
  box-shadow: inset 0 2px 0 #ffffff24, inset 0 0 0 4px #0008, 0 5px 0 #03050d, 0 10px 24px #0008;
}

/* Independent lamp cells allow the two rails to illuminate in sync. */

.jp-lamps {
  position: absolute;
  top: calc(var(--frame-top) + 1px);
  bottom: calc(var(--frame-bottom) + 1px);
  width: calc(var(--frame-side) - clamp(9px, .85cqw, 16px));
  display: grid;
  grid-template-rows: repeat(8, minmax(0, 1fr));
  gap: 5px;
  padding: 3px 0;
  border: 2px solid #263e79;
  border-radius: 5px;
  background: #050b20;
  box-shadow: 0 0 9px #487aff65, inset 0 0 8px #071d92;
  pointer-events: none;
}

.jp-lamps.left {
  left: clamp(4px, .42cqw, 8px);
}

.jp-lamps.right {
  right: clamp(4px, .42cqw, 8px);
}

.jp-lamp-cell {
  min-height: 0;
  background: repeating-linear-gradient(90deg, #c1e5ff38 0 1px, transparent 1px 4px),
    linear-gradient(90deg, #152c8c, #3c6be2 22%, #b9e3ff 49%, #4478f1 78%, #152c8c);
  box-shadow: inset 0 0 8px #071d92;
}

.jp-column {
  display: grid;
  grid-template-rows: var(--category-height) repeat(var(--rows, 5), minmax(45px, 1fr));
  gap: clamp(5px, .65cqw, 12px);
  min-width: 0;
}

.jp-column h2 {
  display: grid;
  place-items: center;
  text-align: center;
  margin: 0;
  padding: 3px 5px;
  border-radius: 6px;

  font-size: clamp(14px, 1.45cqw, 24px);
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.jp-column h2, #startButton, #teamSettingsButton {
  border: 1px solid #5876aa;
  background: linear-gradient(180deg, #203967, #101d40);
  color: var(--category);
  text-shadow: 0 2px 3px #030b3a;
  box-shadow: inset 0 1px #b7d3ff35, inset 0 -3px #769bdc80;
}

.jp-tile {
  display: grid;
  place-items: center;
  padding: 0;
  min-width: 0;
  border: 1px solid #4f70c8;
  border-radius: clamp(5px, .55cqw, 10px);
  background: radial-gradient(ellipse at 50% 28%, var(--tile-light), var(--tile) 66%, var(--tile-dark));
  color: var(--gold);
  font-size: clamp(26px, min(3.5cqw, 7cqh), 64px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 3px 2px #020719;
  box-shadow: inset 0 1px #c9ddff45, inset 0 -3px #070f4a, 0 2px 4px #0009;
  transition: filter .16s, transform .16s, background .25s;
}

.jp-tile:hover:not(:disabled) {
  filter: brightness(1.16);
  transform: translateY(-1px);
}

.jp-tile:active:not(:disabled) {
  transform: translateY(1px);
}

.jp-tile.used {
  background: #0c1538;
  color: #8495be;
  border-color: #273b77;
  box-shadow: inset 0 2px 6px #0007;
  text-shadow: none;
  font-size: clamp(20px, 2.4cqw, 40px);
}

/* Question, pause and result panels. */

.jp-clue-stage, .jp-pause-stage, .jp-results {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(9px, 1.4cqh, 18px);
  min-width: 0;
  padding: clamp(14px, 2cqw, 34px);
  border: 1px solid var(--dialog-border, #3c58ad);
  border-radius: 18px;
  background: linear-gradient(145deg, #203c91, #15265c);
  color: var(--stage-ink);
}

/* The question overlays the unchanged board; the shared header remains usable. */

.jp-clue-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  padding: clamp(14px, 2.5cqw, 40px);
  background: #060d28a8;
  backdrop-filter: blur(9px);
  animation: jp-fade-in .2s ease-out both;
}

.jp-clue-stage {
  --dialog-border: #6485e0;
  width: min(100%, var(--clue-width, 900px));
  box-shadow: 0 24px 80px #0009, inset 0 1px #ffffff26;
  transform: scale(var(--clue-scale, 1));
  transform-origin: center;
}

.jp-clue-stage > *, .jp-pause-stage > *, .jp-results > * {
  flex: none;
}

.jp-pause-stage, .jp-results {
  flex: 1 0 auto;
  animation: jp-fade-in .25s ease-out both;
  text-align: center;
  align-items: center;
}

.jp-clue-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.jp-kicker {
  color: var(--category);
  font-size: clamp(13px, 1.2cqw, 21px);
  font-weight: 800;
  letter-spacing: .04em;
}

.jp-points {
  padding: 5px 13px;
  border-radius: 999px;
  background: var(--gold);
  color: #1a2c69;
  font-size: clamp(14px, 1.2cqw, 22px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}


.jp-clue-stage h2 {
  margin: 0;
  text-align: left;
  font-size: clamp(24px, min(3cqw, 5.8cqh), 54px);
  line-height: 1.22;
  font-weight: 800;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.jp-clue-question {
  color: var(--gold);
}

/* Automatic listening status and currently spoken answer option. */
.jp-clue-audio {
  min-height: 1.4em;
  color: var(--category);
  text-align: center;
  font-size: clamp(13px, 1.65cqw, 22px);
  font-weight: 750;
  line-height: 1.4;
}

.jp-answer-stage {
  position: relative;
  min-width: 0;
}

.jp-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(10px, 1.2cqw, 20px);
}

.jp-choice {
  display: flex;
  align-items: center;
  text-align: left;
  min-height: clamp(56px, 8cqh, 108px);
  padding: clamp(10px, 1.35cqw, 22px);
  border: 2px solid #8da6cd;
  border-radius: 12px;
  background: #eef1fa;
  color: #18294e;
  box-shadow: 0 3px #14243e;
  font-size: clamp(18px, min(2.1cqw, 4.2cqh), 36px);
  font-weight: 650;
  line-height: 1.28;
  white-space: pre-line;
  overflow-wrap: anywhere;
  transition: background .2s, border-color .2s, color .2s, transform .15s;
}

.jp-choice:active:not(:disabled) {
  transform: scale(.985);
}

.jp-choice:hover:not(:disabled) {
  background: #dcecff;
  border-color: #97c8ff;
}

.jp-choice:disabled:not(.correct):not(.incorrect):not(.jp-audio-playing) {
  background: #c4d0e3;
  color: #3a506f;
}

.jp-choice.jp-audio-playing {
  background: var(--gold);
  border-color: var(--gold);
  color: #18294e;
  box-shadow: 0 0 18px #ffe18a80;
}

.jp-choice.correct {
  animation: jp-correct-pulse .55s ease-out both;
  background: #c8f5dc;
  color: #105738;
  border-color: #4bcd87;
}

.jp-choice.incorrect {
  animation: jp-incorrect-shake .35s ease-out both;
  background: #ffe1df;
  color: #932f36;
  border-color: #ed7775;
}

/* Overlay feedback on the choices without changing the dialog's dimensions. */
.jp-feedback {
  position: relative;
  z-index: 2;
  width: 96%;
  box-sizing: border-box;
  margin: 0;
  padding: clamp(20px, 3cqw, 48px) clamp(20px, 3.4cqw, 54px);
  border: 2px solid #ffe18a;
  border-radius: 12px;
  background: linear-gradient(145deg, #fff6d9, #ffe9a7);
  color: #172650;
  box-shadow: 0 8px 24px #050d30b3, 0 2px 5px #0006;
  text-align: center;
  font-size: clamp(24px, min(2.7cqw, 5cqh), 44px);
  font-weight: 750;
  line-height: 1.3;
  overflow-wrap: anywhere;
  transform: rotate(-2deg);
  pointer-events: none;
}

.jp-feedback[data-result="correct"] {
  border-color: #a3c9ad;
  background: linear-gradient(145deg, #edf5e9, #cde3cd);
  color: #244634;
}

.jp-feedback[data-result="incorrect"] {
  border-color: #d8a6a6;
  background: linear-gradient(145deg, #faeeeb, #eacbcb);
  color: #633b40;
}

.jp-feedback:empty {
  display: none;
}

.jp-answer-stage:has(.jp-feedback:not(:empty)) {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
}
.jp-answer-stage:has(.jp-feedback:not(:empty)) > * { grid-area: 1 / 1; }
.jp-feedback:not(:empty) {
  justify-self: center;
  animation: jp-feedback-pop .24s cubic-bezier(.16,.8,.3,1.15) both;
}

.jp-feedback-answer, .jp-feedback-wrong, .jp-explanation {
  display: block;
}

.jp-feedback-wrong {
  margin-bottom: 4px;
  font-size: .9em;
  font-weight: 600;
}

.jp-explanation {
  margin-top: 7px;
  font-size: .95em;
  font-weight: 500;
}

/* Keep the action row's dimensions stable when the answer is revealed. */
#passButton:disabled {
  visibility: hidden;
}

.jp-clue-stage .jp-actions button, .jp-pause-stage button, .jp-results button {
  font-size: clamp(17px, 1.45cqw, 25px);
  min-height: 52px;
}

.jp-pause-stage h2, .jp-results h2 {
  margin: 8px 0;
  font-size: clamp(28px, 4cqw, 60px);
}

.jp-results p {
  margin: 0;
  font-size: clamp(17px, 2cqw, 30px);
  color: var(--stage-ink);
}

.jp-pause-symbol {
  font-size: 70px;
  color: var(--category);
  font-weight: 900;
}

@media (max-width: 639px), (max-width: 1024px) and (orientation: portrait), (orientation: landscape) and (max-height: 600px) and (max-width: 1000px) {
  html:has(body.jeopardy) {
    overflow: hidden;
  }
  body.jeopardy {
    height: 100dvh;
    overflow: hidden;
  }
  .jp-setup { border-radius: 13px; }
  .jp-setup select { border-radius: 8px; }
  #startButton, #teamSettingsButton { border-radius: 6px; }
  .jp-playing .jp-header-tiles {
    display: none;
  }
  .jp-playing .jp-header-word {
    font-size: clamp(13px, 3.6vw, 21px);
  }
}

@media (max-width: 1024px) and (orientation: portrait) {
  .jp-unit-grid .jp-mobile-home { display: grid; }
  .jp-unit-grid .jp-desktop-empty { display: none; }
  /* Fit twelve setup tiles into six equal rows without growing the viewport. */
  #setupScreen { padding: 5px 6px 8px; }
  .games-is-fullscreen #setupScreen { padding-top: 52px; }
  .jp-setup { padding: 6px; gap: clamp(3px, .9cqh, 9px); }
  .jp-options { gap: 4px; }
  .jp-setup select {
    height: clamp(25px, 6.5cqh, 44px);
    padding: 2px 3px 2px 7px;
    font-size: clamp(10px, min(3.3cqw, 3.2cqh), 19px);
  }
  .jp-unit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(6, minmax(0, 1fr));
    gap: clamp(3px, .8cqh, 8px);
  }
  .jp-unit.jp-tile {
    padding: 2px 4px;
    font-size: clamp(10px, min(4.5cqw, 3.8cqh), 25px);
    line-height: 1.12;
  }
  .jp-unit.jp-tile small { margin-top: .1em; font-size: .72em; }
  .jp-menu-brand img { max-height: 7cqh; }
  #startButton, #teamSettingsButton {
    height: clamp(27px, 6.5cqh, 45px);
    font-size: clamp(12px, min(4cqw, 3.2cqh), 22px);
  }
  /* Transpose the same playable groups, preserving DOM order, frame and lights. */
  .jp-game-canvas {
    --stage-gap: 7px;
    padding: 6px 5px 10px;
  }
  .jp-player {
    padding: 7px 8px 7px 10px;
    column-gap: 5px;
    border-radius: 9px;
  }
  .jp-player-identity {
    gap: 2px 5px;
  }
  .jp-player span {
    font-size: clamp(12px, 3.5cqw, 20px);
  }
  .jp-player strong {
    font-size: clamp(21px, 6cqw, 32px);
  }
  .jp-board {
    --frame-top: clamp(18px, 5cqw, 27px);
    --frame-side: clamp(13px, 3.5cqw, 20px);
    --frame-bottom: clamp(10px, 2.6cqw, 15px);
    --category-width: clamp(32px, 10.5cqw, 58px);
    --portrait-gap: 4px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(var(--columns, 6), minmax(42px, 1fr));
    gap: var(--portrait-gap);
    min-height: calc(var(--frame-top) + var(--frame-bottom) + var(--columns, 6) * 42px + (var(--columns, 6) - 1) * var(--portrait-gap) + 4px);
    border-radius: 12px;
  }
  .jp-column {
    grid-template-columns: var(--category-width) repeat(var(--rows, 5), minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr);
    gap: var(--portrait-gap);
    min-height: 0;
  }
  .jp-column h2 {
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
    padding: 3px 2px;
    font-size: clamp(9px, min(3.05cqw, 1.9cqh), 15px);
    border-radius: 4px;
    line-height: 1.12;
  }
  .jp-column h2 span {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    max-height: 100%;
    max-width: 100%;
  }
  .jp-tile {
    font-size: clamp(17px, 5.7cqw, 32px);
  }
  .jp-tile.used {
    font-size: clamp(16px, 5cqw, 28px);
  }
  .jp-lamps {
    width: calc(var(--frame-side) - 6px);
    gap: 3px;
    border-width: 1px;
    padding: 2px 0;
    border-radius: 3px;
  }
  .jp-lamps.left {
    left: 3px;
  }
  .jp-lamps.right {
    right: 3px;
  }
  /* The existing tile-to-dialog animation uses actual tile coordinates in both layouts. */
  .jp-clue-overlay {
    padding: 10px;
  }
  .jp-clue-stage {
    padding: 14px;
    gap: 9px;
    border-radius: 14px;
  }
  .jp-clue-head {
    gap: 6px;
  }
  .jp-clue-stage h2 {
    font-size: clamp(17px, 5.4cqw, 27px);
    line-height: 1.25;
  }
  .jp-choices {
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
  }
  .jp-choice {
    min-height: 42px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: clamp(14px, 4.2cqw, 21px);
  }
  .jp-feedback {
    font-size: clamp(17px, 5.1cqw, 27px);
  }
  .jp-clue-stage .jp-actions button {
    min-height: 42px;
    font-size: 15px;
    padding: 8px 14px;
  }
}



@keyframes jp-feedback-pop {
  from {
    opacity: 0;
    transform: rotate(-6deg) scale(.82);
  }
  to {
    opacity: 1;
    transform: rotate(-2deg) scale(1);
  }
}

@keyframes jp-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes jp-correct-pulse {
  0%,100% {
    box-shadow: 0 3px #14243e;
  }
  45% {
    box-shadow: 0 0 0 5px #4bcd8760, 0 3px #14243e;
  }
}

@keyframes jp-incorrect-shake {
  0%,100% {
    translate: 0 0;
  }
  25%,75% {
    translate: -4px 0;
  }
  50% {
    translate: 4px 0;
  }
}

/* Hidden board rewards and their reveal-to-question transition. */
.jp-reward-icon { display: inline-flex; color: #ffe189; width: 1.4em; height: 1.4em; flex: none; }
.jp-reward-icon svg { width: 100%; height: 100%; filter: drop-shadow(0 2px 3px #0008); }
.jp-tile.used .jp-reward-icon { opacity: .42; }
.jp-reward-reveal {
  position: absolute; z-index: 2; grid-area: 1 / 1; inset: auto; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; text-align: center;
  width: min(86%, 460px); box-sizing: border-box; padding: clamp(18px, 3cqw, 40px);
  border: 2px solid #ffe189; border-radius: 24px;
  background: radial-gradient(ellipse at top, #315cc4, #101b49 78%);
  color: #fff2c6; box-shadow: 0 0 36px #f6c85555, 0 20px 65px #0009;
  transform-origin: center; pointer-events: none;
}
.jp-reward-reveal .jp-reward-icon { width: clamp(88px, 14cqw, 152px); height: clamp(88px, 14cqw, 152px); }
.jp-reward-reveal strong { font-size: clamp(23px, 3cqw, 35px); color: #ffe189; }
.jp-reward-reveal > span:last-child { font-size: clamp(15px, 1.8cqw, 21px); }
.jp-reward-badge { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid #ffe189; border-radius: 12px; background: #122455; }
.jp-reward-badge .jp-reward-icon { width: 34px; height: 34px; }
.jp-clue-stage:has(.jp-reward-badge:not([hidden])) .jp-clue-head { padding-inline: 48px; }

/* Three to five teams: retain the original two-team presentation. */
.jp-scoreboard:is([data-teams="3"],[data-teams="4"],[data-teams="5"]) .jp-player {padding-inline: clamp(8px,1cqw,16px);column-gap:6px;}
.jp-scoreboard:is([data-teams="3"],[data-teams="4"],[data-teams="5"]) .jp-player strong {font-size:clamp(22px,2.6cqw,42px);}
.jp-scoreboard[data-teams="5"] .jp-player {padding-inline: clamp(6px,.85cqw,12px);column-gap:5px;}
.jp-scoreboard[data-teams="5"] .jp-player span {font-size:clamp(14px,1.35cqw,24px);}
.jp-scoreboard[data-teams="5"] .jp-player strong {font-size:clamp(20px,2.3cqw,38px);}
@media (max-width:1024px) and (orientation:portrait) {
  .jp-scoreboard[data-teams="5"] {grid-template-columns:repeat(6,minmax(0,1fr));}
  .jp-scoreboard[data-teams="5"] .jp-player {grid-column:span 2;grid-template-columns:minmax(0,1fr);gap:3px;padding:5px 8px;text-align:center;}
  .jp-scoreboard[data-teams="5"] .jp-player:nth-child(n+4) {grid-column:span 3;}
  .jp-scoreboard[data-teams="5"] .jp-player-identity {justify-content:center;}
  .jp-scoreboard[data-teams="5"] .jp-player span {font-size:clamp(12px,3.3cqw,19px);}
  .jp-scoreboard:is([data-teams="3"],[data-teams="4"]) {grid-template-columns:repeat(2,minmax(0,1fr));}
  .jp-scoreboard:is([data-teams="3"],[data-teams="4"],[data-teams="5"]) .jp-player strong {font-size:clamp(21px,5cqw,32px);}
}

/* Team customization uses the same studio palette as the game board. */
.jp-team-dialog { width: min(680px, calc(100% - 20px)); padding: clamp(10px, 2.5vw, 24px); background: linear-gradient(145deg, #141d39, #080f30); border: 1px solid #5876aa; color: var(--category); color-scheme: dark; box-shadow: 0 0 24px #416cd655, inset 0 1px #ffe18a66; }
.jp-team-dialog h2 { color: var(--gold); }
.jp-team-settings-list { display: grid; gap: 7px; margin-bottom: 12px; }
.jp-team-setting { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 5px 10px; align-items: center; padding: 8px; background: #17264d; border: 1px solid #435476; border-radius: 9px; }
.jp-team-label { font-weight: 800; color: var(--category); white-space: nowrap; }
.jp-team-setting input[type=text] { width: 100%; min-width: 0; border: 1px solid #5876aa; background: #0e1937; color: var(--gold); border-radius: 6px; padding: 6px 8px; font: inherit; }
.jp-team-colors { grid-column: 2 / -1; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px; padding: 0; margin: 0; border: 0; min-width: 0; }
.jp-team-swatch { position: relative; cursor: pointer; display: inline-grid; place-items: center; }
.jp-team-swatch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.jp-team-swatch span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--swatch); color: #152444; font-size: 13px; font-weight: 900; border: 2px solid #17264d; }
.jp-team-color-label { color: var(--category); font-size: 12px; font-weight: 700; }
.jp-team-swatch-default span { width: auto; padding-inline: 7px; border-radius: 6px; background: #0e1937; color: var(--gold); }
@media (max-width: 540px) { .jp-team-colors { grid-column: 1 / -1; gap: 5px; } .jp-team-color-label { flex-basis: 100%; text-align: right; } .jp-team-swatch:not(.jp-team-swatch-default) span { width: 23px; height: 23px; } }
.jp-team-swatch input:checked + span { outline: 2px solid #fff; outline-offset: 1px; }
.jp-team-swatch input:focus-visible + span { outline: 3px solid #318bd4; outline-offset: 2px; }
.jp-team-dialog .jp-actions { gap: 6px; }
.jp-team-dialog .jp-actions button { flex: 1 1 auto; min-height: 36px; padding: 7px 10px; border-radius: 7px; font-size: 14px; }
.jp-player-identity span { overflow-wrap: anywhere; min-width: 0; }

.jp-dialog .jp-secondary { background: #17264d; border-color: #5876aa; color: var(--category); }
.jp-dialog .jp-primary { color: var(--gold); }
.jp-dialog .jp-secondary:hover:not(:disabled) { background: #263e70; border-color: #83a3d8; color: #e0f3ff; }
.jp-pause-dialog { text-align: center; }
.jp-team-remove { background: #26375e; color: #ffb7b7; border: 1px solid #5876aa; border-radius: 6px; font-size: 22px; width: 32px; height: 32px; cursor: pointer; }
.jp-team-remove:hover:not(:disabled) { background: #49304b; border-color: #d8949e; color: #ffe0e0; }
.jp-team-remove:disabled, .jp-team-add:disabled { opacity: .4; cursor: default; }
.jp-team-add { width: 100%; margin-bottom: 12px; }
.jp-clue-stage { position: relative; }
.jp-clue-player { position: absolute; top: 7px; left: 12px; max-width: calc(100% - 76px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--gold); font-size: clamp(12px,1.6cqw,23px); font-weight: 800; }
.jp-clue-head { margin-top: 18px; }
