/* Shared additions to the existing Il Tavolo visual identity. */
select {
  font: inherit;
  color: var(--navy);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: var(--surface);
  max-width: 100%;
  min-width: 0;
}
[hidden] {
  display: none !important;
}
.tv-create {
  padding: 18px;
  margin: 20px 0 30px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--cream);
}
.tv-create p {
  margin: 0 0 16px;
  line-height: 1.6;
}
.tv-create .primary {
  width: 100%;
}
#phone-join-heading {
  margin: 30px 0 18px;
}
.home-shell.is-joining > .home-hero,
.home-shell.is-joining .game-intro {
  display: none;
}
.home-shell.is-joining > .welcome {
  display: block;
  max-width: 580px;
  margin: 24px auto;
}
.tv-mode .tv-shell.tv-lobby {
  height: calc(100dvh - 90px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 14px;
  padding-top: 12px;
  padding-bottom: 18px;
}
.tv-mode .tv-lobby .tb-lobby-copy {
  margin: 0;
}
.tv-mode .tv-lobby .tb-lobby-copy h1 {
  font-size: clamp(30px, 3.5vw, 58px);
  margin: 8px 0;
}
.tv-mode .tv-lobby .tb-lobby-copy p {
  margin: 4px 0;
}
.tv-mode .tv-lobby .tb-lobby-layout {
  min-height: 0;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 24px;
}
.tv-mode .tv-lobby .tb-panel {
  min-height: 0;
  overflow: auto;
}
.tv-mode .tv-lobby .tv-join {
  margin-top: 12px;
}
.tv-mode .tv-lobby .tv-join p {
  margin: 10px 0;
}
.tv-mode .tv-lobby .tv-host-instruction {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.tv-mode .tv-lobby .tb-roster {
  max-height: calc(100% - 165px);
  overflow: auto;
}
.home-shell .game-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.avatar-picker {
  margin: 22px 0;
  border: 0;
  padding: 0;
  min-width: 0;
}
.avatar-picker legend {
  font-weight: 700;
  margin-bottom: 12px;
}
.avatar-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 8px;
}
.avatar-options label {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  cursor: pointer;
  font-size: 10px;
  line-height: 1.3;
}
.avatar-options input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.avatar-choice {
  width: 60px;
  height: 60px;
  border: 2px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--cream);
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.avatar-choice img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-options input:checked + .avatar-choice {
  outline: 3px solid var(--navy);
  outline-offset: 3px;
}
.avatar-options input:focus-visible + .avatar-choice {
  outline: 3px solid var(--argilla);
  outline-offset: 3px;
}
.initials-choice {
  font-size: 24px;
  font-weight: 800;
}
.party-shell {
  padding-bottom: 30px;
}
.party-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 24px 0;
}
.party-tools button {
  min-height: 44px;
}
.party-settings {
  display: grid;
  gap: 16px;
  margin-bottom: 26px;
}
.party-settings label,
.tb-host-controls > label,
#wager-form > label {
  display: grid;
  gap: 7px;
  font-size: 14px;
  font-weight: 600;
}
.party-settings input:not([type="checkbox"]),
.party-settings select {
  width: 100%;
  margin: 0;
  font-size: 16px;
}
.party-settings fieldset {
  padding: 0;
  border: 0;
  min-width: 0;
}
.category-options {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}
.party-settings .check-label,
.category-options label {
  display: flex;
  align-items: center;
  gap: 10px;
}
.party-settings input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--navy);
}
.settings-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.tb-person select {
  max-width: 145px;
  font-size: 12px;
  padding: 8px;
}
.tb-person .avatar {
  width: 44px;
  height: 44px;
}
.party-shell .tb-ticket-cell {
  padding: 0;
  min-width: 0;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  touch-action: manipulation;
}
.party-shell .tb-ticket-cell[aria-pressed="true"] {
  background: var(--sage);
  color: var(--navy);
}
.party-shell .tb-ticket-cell:focus-visible {
  outline: 3px solid var(--navy);
  outline-offset: 1px;
  z-index: 1;
}
.party-shell .tb-ticket-cell.blank {
  cursor: default;
}
.claim-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 18px;
}
.claim-controls label {
  grid-column: 1/-1;
  font-size: 13px;
  font-weight: 700;
}
.claim-controls .primary {
  padding: 12px 16px;
  min-height: 48px;
}
.tb-host-controls .host-actions {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}
.tb-host-controls > label {
  margin-top: 12px;
}
.tb-host-controls input {
  max-width: 130px;
}
#share-dialog input {
  width: 100%;
  font-size: 13px;
  margin: 14px 0;
}
#share-qr,
#tv-invite-qr,
#join-qr {
  background: white;
  border-radius: 14px;
  max-width: 260px;
  margin: 20px auto;
  padding: 14px;
}
#share-qr svg,
#tv-invite-qr svg,
#join-qr svg {
  width: 100%;
  height: auto;
  display: block;
}
.open-tv-link {
  display: block;
  text-align: center;
  margin-top: 12px;
  text-decoration: none;
}
.quiz-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 24px;
}
.quiz-layout > div,
.quiz-layout > aside {
  display: grid;
  align-content: start;
  gap: 20px;
  min-width: 0;
}
.quiz-question h1,
.quiz-board-panel h1 {
  font-size: clamp(26px, 3vw, 44px);
  line-height: 1.2;
  margin: 20px 0 24px;
  letter-spacing: -0.03em;
}
.quiz-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 22px 0;
}
.quiz-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  background: var(--cream);
  color: var(--navy);
  border: 2px solid transparent;
  border-radius: 14px;
  text-align: left;
  min-height: 80px;
  font-size: 18px;
  opacity: 1;
}
.quiz-option > b {
  font-size: 22px;
  flex-shrink: 0;
}
.quiz-option:disabled {
  opacity: 0.7;
  cursor: default;
}
.quiz-option.is-chosen {
  border-color: var(--navy);
  opacity: 1;
}
.quiz-option.is-correct {
  background: var(--sage);
  border-color: var(--navy);
  opacity: 1;
}
.quiz-reveal {
  padding: 22px;
  background: #eef1e9;
  border-radius: 14px;
  margin-top: 20px;
}
.quiz-reveal h2 {
  font-size: 28px;
}
.quiz-reveal a {
  font-size: 13px;
}
.answer-confirmation {
  padding: 16px;
  background: var(--cream);
  border-radius: 12px;
  font-weight: 600;
}
.quiz-leaderboard ol {
  list-style: none;
  padding: 0;
  margin: 20px 0 0;
  counter-reset: rank;
}
.quiz-leaderboard li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  counter-increment: rank;
}
.quiz-leaderboard li:before {
  content: counter(rank);
  font-weight: 800;
  font-size: 14px;
  color: var(--muted);
}
.quiz-leaderboard li > b {
  flex: 1;
  overflow-wrap: anywhere;
}
.quiz-leaderboard strong {
  font-size: 24px;
  white-space: nowrap;
}
.quiz-leaderboard strong small {
  font-size: 10px;
  margin-left: 5px;
}
.quiz-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 26px;
}
.quiz-board > section {
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
}
.quiz-board h2 {
  font-size: 14px;
  min-height: 44px;
  display: flex;
  align-items: center;
  line-height: 1.25;
}
.quiz-cell {
  background: var(--navy);
  color: var(--gold);
  border: 0;
  border-radius: 12px;
  font-size: 28px;
  font-weight: 800;
  min-height: 70px;
}
.quiz-cell:disabled {
  opacity: 0.45;
}
.buzzer {
  width: 100%;
  min-height: 150px;
  font-size: 36px;
  border-radius: 28px;
  margin-top: 25px;
  background: var(--action-red);
}
#wager-form {
  display: grid;
  gap: 14px;
  max-width: 400px;
  margin-top: 20px;
}
.tv-mode {
  font-size: clamp(17px, 1.3vw, 27px);
}
.tv-mode main#app {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
}
.tv-mode .tv-shell:has(> .tb-game-layout),
.tv-mode .tv-shell:has(> .quiz-layout) {
  height: calc(100dvh - 90px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
  min-height: 600px;
  padding-top: 10px;
  padding-bottom: 16px;
}
.tv-mode .tv-shell > .room-bar {
  margin: 0;
}
.tv-mode .tv-shell > .party-tools {
  margin: 0;
}
.tv-mode .tv-shell > .tb-game-layout {
  height: 100%;
  min-height: 0;
}
.tv-mode .tb-game-layout > .tb-aside {
  height: 100%;
  max-height: 100%;
  overflow: auto;
}
.tv-mode .tb-game-layout > .tb-main {
  height: 100%;
  min-height: 0;
  grid-template-rows: clamp(130px, 17dvh, 184px) minmax(0, 1fr);
}
.tv-mode .tv-board-panel {
  min-height: 0;
}
.tv-mode .tv-number-board {
  height: 100%;
  grid-template-rows: repeat(9, minmax(0, 1fr));
}
.tv-mode .tv-number-board .tb-board-cell {
  min-height: 0;
  height: 100%;
  aspect-ratio: auto;
  font-size: clamp(18px, 3dvh, 40px);
  line-height: 1;
}
.tv-mode .tb-aside {
  min-height: 0;
  overflow: auto;
}
.tv-mode .masthead {
  max-width: none;
  padding: 12px 3vw;
  height: auto;
  min-height: 70px;
}
.tv-mode .masthead > .eyebrow {
  margin-left: auto;
  font-size: 12px;
}
.tv-mode .tv-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 20px 3vw 36px;
}
.tv-mode .tb-game-layout {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 25%);
  gap: 24px;
}
.tv-mode .tb-main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
.tv-mode .tb-call {
  padding: 24px 32px;
  align-items: center;
}
.tv-mode .tb-last-number {
  font-size: clamp(80px, 8vw, 130px);
  line-height: 1;
}
.tv-mode .tb-call > div:first-child {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
}
.tv-mode .tb-call .eyebrow {
  max-width: 140px;
  font-size: 18px;
  margin: 0;
}
.tv-mode .tb-call p:not(.eyebrow) {
  font-size: 20px;
}
.tv-mode .tb-recent {
  width: auto;
}
.tv-mode .tb-recent b {
  font-size: 20px;
  width: 40px;
  height: 40px;
}
.tv-mode .tv-number-board {
  gap: 8px;
  grid-template-columns: repeat(10, minmax(0, 1fr));
}
.tv-mode .tb-board-cell {
  font-size: clamp(22px, 2.4vw, 46px);
  min-height: clamp(42px, 5dvh, 68px);
  font-weight: 800;
  border-radius: 8px;
}
.tv-mode .tb-panel {
  padding: 22px;
}
.tv-mode .room-code strong {
  font-size: clamp(28px, 3vw, 50px);
  letter-spacing: 0.12em;
}
.tv-mode .room-code {
  padding: 14px 22px;
  display: flex;
  gap: 20px;
  align-items: center;
}
.tv-mode .tb-prize {
  font-size: 18px;
  padding: 18px 0;
}
.tv-mode .tb-prize small {
  font-size: 12px;
}
.tv-mode .quiz-layout {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 24%);
}
.tv-mode .quiz-layout,
.tv-mode .quiz-layout > div {
  height: 100%;
  min-height: 0;
}
.tv-mode .quiz-board-panel {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}
.tv-mode .quiz-board-panel h1 {
  font-size: 30px;
  margin: 10px 0;
}
.tv-mode .quiz-board-panel > p:not(.eyebrow) {
  font-size: 14px;
  margin: 8px 0;
}
.tv-mode .quiz-board-panel > .eyebrow {
  margin: 0;
}
.tv-mode .quiz-question h1 {
  font-size: clamp(30px, 3.3vw, 64px);
}
.tv-mode .quiz-option {
  font-size: clamp(22px, 2vw, 38px);
  min-height: 100px;
  opacity: 1;
}
.tv-mode .quiz-board {
  height: 100%;
  min-height: 0;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.tv-mode .quiz-board > section {
  height: 100%;
  min-height: 0;
  grid-template-rows: 65px;
  grid-auto-rows: minmax(0, 1fr);
}
.tv-mode .quiz-board h2 {
  font-size: clamp(12px, 1.1vw, 23px);
  min-height: 0;
  height: 65px;
  margin: 0;
}
.tv-mode .quiz-cell {
  height: 100%;
  line-height: 1.1;
  padding: 4px;
  font-size: clamp(22px, 2.5vw, 46px);
  min-height: 0;
  opacity: 1;
}
.tv-mode .quiz-reveal {
  padding: 14px;
  margin-top: 12px;
}
.tv-mode .quiz-reveal h2 {
  font-size: 26px;
  margin: 8px 0;
}
.tv-mode .quiz-layout > aside {
  max-height: calc(100dvh - 280px);
  overflow: auto;
}
.tv-mode .quiz-meta .pill {
  font-size: 28px;
}
.tv-mode .quiz-leaderboard strong {
  font-size: 34px;
}
.tv-join {
  display: flex;
  align-items: center;
  gap: 25px;
  margin-top: 25px;
}
.tv-join #join-qr {
  width: 220px;
  flex-shrink: 0;
  margin: 0;
}
.tv-pairing {
  max-width: 700px;
  margin: 40px auto;
}
.tv-pairing form {
  display: grid;
  gap: 18px;
}
.tv-pairing label {
  display: grid;
  gap: 8px;
}
.number-announcement {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #16354af5;
  color: var(--cream);
  z-index: 15;
  pointer-events: none;
  animation: number-reveal 2.2s both;
}
.number-announcement span {
  font-size: clamp(24px, 4vw, 65px);
  letter-spacing: 0.1em;
  font-weight: 700;
}
.number-announcement b {
  font-size: clamp(120px, 30vw, 430px);
  line-height: 1.1;
  color: var(--gold);
}
@keyframes number-reveal {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }
  15%,
  70% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    visibility: hidden;
  }
}
@media (max-width: 900px) {
  .quiz-layout {
    grid-template-columns: 1fr;
  }
  .quiz-options {
    grid-template-columns: 1fr;
  }
  .quiz-option {
    min-height: 62px;
    font-size: 17px;
  }
  .quiz-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .quiz-shell .tb-panel {
    padding: 22px;
  }
  .party-shell .room-bar {
    flex-wrap: wrap;
    gap: 12px;
  }
  .tb-person select {
    max-width: 120px;
  }
  .party-settings .settings-pair {
    grid-template-columns: 1fr;
  }
  .tv-mode .tb-game-layout,
  .tv-mode .quiz-layout {
    grid-template-columns: 1fr;
  }
  .tv-mode .quiz-board {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .tv-mode .masthead > .eyebrow {
    display: none;
  }
  .tv-mode .room-code {
    flex-wrap: wrap;
    gap: 10px;
  }
  .tv-mode .tb-call > div:first-child {
    gap: 12px;
  }
  .tv-join {
    flex-wrap: wrap;
  }
}
@media (max-width: 360px) {
  .avatar-choice {
    width: 52px;
    height: 52px;
  }
  .claim-controls {
    grid-template-columns: 1fr;
  }
  .party-shell .tb-ticket-cell {
    min-height: 44px;
    font-size: 17px;
  }
  .party-tools .secondary {
    padding: 12px;
  }
  .tv-mode .tv-number-board {
    gap: 3px;
  }
  .tv-mode .tb-board-cell {
    font-size: 15px;
    min-height: 30px;
  }
}
@media (max-height: 850px) and (min-width: 901px) {
  .tv-mode .room-code {
    padding: 10px 18px;
  }
  .tv-mode .room-code strong {
    font-size: 32px;
    line-height: 1.2;
  }
  .tv-mode .quiz-question {
    padding: 18px;
  }
  .tv-mode .quiz-question h1 {
    font-size: clamp(26px, 2.5vw, 36px);
    line-height: 1.15;
    margin: 14px 0;
  }
  .tv-mode .quiz-question > p {
    font-size: 14px;
    margin: 8px 0;
  }
  .tv-mode .quiz-options {
    margin: 14px 0;
    gap: 10px;
  }
  .tv-mode .quiz-option {
    font-size: clamp(20px, 1.6vw, 26px);
    line-height: 1.2;
    min-height: 64px;
    padding: 12px;
  }
  .tv-mode .quiz-meta .pill {
    font-size: 22px;
  }
  .tv-mode .quiz-reveal {
    padding: 12px;
    margin-top: 10px;
  }
  .tv-mode .quiz-reveal h2 {
    font-size: 24px;
    margin: 4px 0;
  }
  .tv-mode .quiz-reveal .eyebrow {
    margin: 0;
  }
  .tv-mode .quiz-reveal a {
    font-size: 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .number-announcement {
    animation: none;
    display: none;
  }
  .avatar-choice {
    transition: none;
  }
}
.buzzer { touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.team-setup { margin-top: 1rem; }
.team-setup label { display: grid; gap: .4rem; margin: .8rem 0; }
.team-setup input, .team-setup select { width: 100%; min-width: 0; }
.team-turns { margin-top: 1rem; }
.team-turns > div { display: grid; grid-template-columns: repeat(auto-fit,minmax(140px,1fr)); gap: .6rem; }
.team-turns p { margin: 0; overflow-wrap: anywhere; }
.team-turns span { display: block; }
