/* The phone console uses the visible viewport, including keyboard resizes. */
body.spy-mode {
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}
.app-shell.spymaster {
  position: fixed;
  top: var(--spy-top, 0px);
  left: 0;
  width: 100%;
  height: var(--spy-height, 100dvh);
  min-height: 0;
  max-width: none;
  margin: 0;
  padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  display: block;
  overflow: hidden;
}
.spy-console {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(4px, 1vmin, 10px);
}
.spy-console:has(.spy-compose) { grid-template-rows: auto minmax(0, 1fr) auto; }
.spy-status {
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 20px);
  padding: clamp(6px, 1.5vmin, 12px) clamp(9px, 2vw, 20px);
  min-width: 0;
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: 7px;
  background: var(--white);
}
.spy-status.blue { border-left-color: var(--blue); }
.spy-status.red { border-left-color: var(--red); }
.spy-status-main { min-width: 0; }
.spy-identity {
  display: block;
  font-size: clamp(9px, 1.5vmin, 13px);
  font-weight: 650;
  margin-bottom: 3px;
}
.spymaster.blue .spy-identity { color: var(--blue); }
.spymaster.red .spy-identity { color: var(--red); }
.spy-status h1 {
  font-size: clamp(11px, 2.1vmin, 20px);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.15px;
}
.spy-active-clue {
  min-width: 0;
  max-width: 45%;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .5em;
  font-size: clamp(11px, 2.4vmin, 24px);
  font-weight: 750;
}
.spy-active-clue span { overflow-wrap: anywhere; }
.spy-active-clue b { border-radius: 4px; padding: .2em .45em; background: var(--paper); }
.spymaster .spy-console .word-grid {
  container-type: size;
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  gap: clamp(3px, 1vmin, 9px);
  grid-template-rows: repeat(5, minmax(0, 1fr));
}
.spymaster .spy-console .word-grid.grid-4 { grid-template-rows: repeat(4, minmax(0, 1fr)); }
.spymaster .spy-console .word-card {
  min-height: 0;
  min-width: 0;
  padding: 0 .25em;
  box-shadow: inset 0 -2px 0 #00000015;
  border-radius: clamp(3px, 1vmin, 9px);
}
.spymaster .spy-console .card-word {
  font-size: clamp(7px, min(2.8cqw, 8cqh), 32px);
  line-height: 1.05;
  letter-spacing: 0;
  overflow-wrap: normal;
}
.spymaster .spy-console .short-word .card-word { font-size: clamp(7px, min(3.8cqw, 8cqh), 36px); }
.spymaster .spy-console .grid-4 .card-word { font-size: clamp(8px, min(3.5cqw, 12cqh), 38px); }
.spymaster .spy-console .grid-4 .short-word .card-word { font-size: clamp(8px, min(4.8cqw, 12cqh), 40px); }
.spymaster .spy-console .word-card.selected {
  box-shadow: inset 0 0 0 2px #ffffffe0;
  outline: 2px solid var(--ink);
  outline-offset: -1px;
  transform: none;
}
.spymaster .spy-console .word-card.revealed { opacity: .48; }
.spymaster .spy-console .card-mark { right: 3px; bottom: 2px; }
.spymaster .spy-console .card-mark svg { width: clamp(7px, 3cqh, 15px); height: clamp(7px, 3cqh, 15px); }
.spy-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(5px, 1.5vw, 12px);
  margin: 0;
  padding: 0;
  min-width: 0;
}
.spy-compose input, .spy-compose .selection-summary {
  width: 100%;
  min-width: 0;
  height: clamp(40px, 6dvh, 55px);
  border: 1px solid #b9c4b7;
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  padding: 6px 10px;
  font-size: 16px;
  text-transform: uppercase;
}
.spy-compose input::placeholder { text-transform: none; font-size: 13px; color: var(--muted); }
.spy-compose .primary-button { padding: 8px 12px; font-size: clamp(11px, 2.2vmin, 16px); border-radius: 6px; gap: 6px; }
.spy-compose .primary-button svg { width: 15px; height: 15px; }
.spy-compose .selection-summary { display: flex; align-items: center; font-size: 13px; text-transform: none; }
.change-words { flex-shrink: 0; margin-left: auto; padding: 5px 7px; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); color: var(--ink); font-size: clamp(9px, 1.8vmin, 13px); }
body.spy-mode #toast { bottom: auto; top: calc(var(--spy-top, 0px) + 3.5rem); }

/* Timers are shared server deadlines, rather than per-device countdowns. */
.phase-clock {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: .45em .7em;
  border-radius: 7px;
  background: #ffffff20;
  font-variant-numeric: tabular-nums;
}
.clock-caption { font-size: 9px; opacity: .8; white-space: nowrap; }
.phase-clock strong { font-size: clamp(17px, 2vw, 32px); letter-spacing: .03em; line-height: 1.25; }
.clue-banner > .phase-clock { margin-left: auto; }
.clue-banner:has(.phase-clock) .stage-label { display: none; }
.phase-clock.is-low { background: #ffe6d5; color: #933023; }
.spy-status .phase-clock { margin-left: auto; padding: 4px 7px; background: var(--paper); }
.spy-status .phase-clock.is-low { background: #ffe6d5; }
.spy-status .clock-caption { display: none; }
.spy-status .phase-clock strong { font-size: clamp(16px, 3vmin, 25px); }
.table-intro:has(.lobby-options) { flex-wrap: wrap; gap: 10px 18px; padding-block: 10px; }
.lobby-options { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 22px; margin-inline: auto; max-width: 100%; }
.lobby-options .setup-options { margin: 0; }
.timer-setup { display: flex; align-items: end; gap: 10px; }
.timer-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 15px; border: 0; padding: 0; margin: 0; }
.timer-fields legend { font-size: 10px; font-weight: 700; color: var(--ink); margin-bottom: 5px; }
.timer-fields legend span { font-weight: 400; color: var(--muted); margin-left: .7em; font-size: 9px; }
.timer-fields label { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--ink); }
.timer-fields label > span { display: flex; align-items: center; gap: 3px; color: var(--muted); }
.timer-fields input { width: 5.5em; padding: 7px 5px; border: 1px solid #b9c4b7; border-radius: 5px; color: var(--ink); background: var(--white); font-size: 12px; }
.timer-save { padding: 9px 10px; border: 1px solid #b9c4b7; border-radius: 5px; background: transparent; font-size: 10px; font-weight: 650; white-space: nowrap; }
.timer-save:disabled { opacity: .5; }
dialog .timer-fields { margin-top: 22px; }
dialog .timer-fields label { flex: 1; font-size: 12px; }

/* Confirmations clearly belong to the team making the choice. */
.team-dialog { border-top: 6px solid var(--team-accent); }
.team-dialog.blue { --team-accent: var(--blue); background: #eaf1f8; border-color: #bed0e5; border-top-color: var(--blue); }
.team-dialog.red { --team-accent: var(--red); background: #f9eae6; border-color: #e9c6be; border-top-color: var(--red); }
.team-dialog .eyebrow, .team-dialog h2 { color: var(--team-accent); }
.team-dialog .secondary-button { border: 1px solid #758ca03b; background: #ffffff80; }
.team-dialog.blue::backdrop { background: #173e6e88; }
.team-dialog.red::backdrop { background: #722c2788; }
.team-dialog .phase-clock { width: fit-content; margin-top: 15px; background: #ffffff80; color: var(--team-accent); }

@media (max-width: 1100px) {
  .table-intro:has(.lobby-options) .table-tagline { display: none; }
}
@media (max-width: 750px) {
  .lobby-options { width: 100%; order: 3; justify-content: space-between; gap: 12px; }
  .lobby-options .setup-options { width: 100%; }
  .timer-setup { width: 100%; justify-content: space-between; }
  .timer-fields { gap: 10px; }
  .timer-fields label { font-size: 10px; gap: 4px; }
  .timer-fields input { width: 5em; }
  .lobby-options + .board-label { order: 2; }
}
@media (orientation: landscape) {
  .spy-status { padding-block: 5px; }
  .spy-identity { display: inline; margin-right: .75em; margin-bottom: 0; }
  .spy-status h1 { display: inline; }
  .spy-compose input, .spy-compose .selection-summary { height: 40px; }
}
@media (max-height: 300px) {
  .app-shell.spymaster { padding-top: 3px; padding-bottom: 3px; }
  .spy-console { gap: 3px; }
  .spy-status { padding: 3px 7px; border-radius: 4px; }
  .spy-identity { display: none; }
  .spy-status h1 { font-size: 11px; }
  .spy-status .phase-clock { padding: 0 4px; }
  .spy-status .phase-clock strong { font-size: 13px; }
  .spy-compose input, .spy-compose .selection-summary { height: 34px; padding-block: 3px; }
  .spy-compose .primary-button { padding-block: 4px; font-size: 11px; }
}
