﻿:root {
  --screen: #1e1e1e;
  --banner: #111111;
  --cream: #ded164;
  --blue: #2625d9;
  --red: #ff1d18;
  --red-dark: #b50000;
  --green: #00cf00;
  --green-dark: #008f00;
  --white: #fffdf3;
  --ink: #101a13;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--screen);
  color: var(--white);
  font-family: Tahoma, Arial, sans-serif;
}

p {
  margin: 0;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

/* â”€â”€ App shell â”€â”€ */

.display-app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* â”€â”€ Header â”€â”€ */

.display-header {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: linear-gradient(180deg, var(--banner), #003003);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.disp-team {
  display: flex;
  align-items: center;
  gap: 14px;
}

.disp-team.red-team {
  flex-direction: row;
}

.disp-team.green-team {
  flex-direction: row-reverse;
}

.disp-wins {
  flex: 0 0 auto;
  width: clamp(44px, 7vw, 80px);
  height: clamp(44px, 7vw, 80px);
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--white);
  font-size: clamp(1.6rem, 3.8vw, 3.2rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}

.red-team .disp-wins {
  background: var(--red);
  box-shadow: 0 4px 0 #880000;
}

.green-team .disp-wins {
  background: #009c6d;
  box-shadow: 0 4px 0 #005c40;
}

.disp-name {
  color: var(--white);
  font-size: clamp(0.9rem, 2.5vw, 2rem);
  font-weight: 900;
  line-height: 1.2;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* â”€â”€ Center: phase + timer + round â”€â”€ */

.disp-center {
  display: grid;
  grid-template-columns: auto minmax(150px, 190px);
  grid-template-areas: "timer room";
  align-items: center;
  justify-content: center;
  gap: 3px 8px;
}

.disp-phase-label {
  grid-area: phase;
  text-align: center;
  color: rgba(255, 253, 243, 0.75);
  font-size: clamp(0.72rem, 1.2vw, 1rem);
  font-weight: 800;
  white-space: nowrap;
}

.disp-phase-label[hidden] {
  display: none;
}

.disp-timer {
  grid-area: timer;
  direction: ltr;
  text-align: center;
  padding: clamp(5px, 1vh, 8px) clamp(10px, 2vw, 18px);
  border-radius: 10px;
  background: #092316;
  color: var(--white);
  font-size: clamp(1.8rem, 4.5vw, 3.5rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 3px 0 var(--blue);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25);
  white-space: nowrap;
}

.disp-timer.is-low {
  background: var(--red-dark);
  text-shadow: none;
}

.disp-round {
  display: none;
  grid-area: round;
  text-align: center;
  color: rgba(255, 253, 243, 0.65);
  font-size: clamp(0.65rem, 1vw, 0.88rem);
  font-weight: 800;
  white-space: nowrap;
}

.display-room-form {
  grid-area: room;
  width: min(100%, 220px);
  display: grid;
  gap: 4px;
  justify-items: center;
}

.display-room-form[hidden],
.contestant-buzz-button[hidden] {
  display: none;
}

.display-room-form label {
  color: rgba(255, 253, 243, 0.78);
  font-size: clamp(0.62rem, 0.9vw, 0.82rem);
  font-weight: 900;
  line-height: 1;
}

.display-room-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.display-room-row input {
  width: 100%;
  min-width: 0;
  height: 34px;
  border: 1px solid rgba(255, 253, 243, 0.32);
  border-radius: 8px;
  background: rgba(255, 253, 243, 0.95);
  color: #06160d;
  direction: ltr;
  text-align: center;
  font: 900 1.05rem/1 Tahoma, Arial, sans-serif;
  letter-spacing: 0;
  outline: none;
}

.display-room-row input:focus {
  border-color: #ffd84a;
  box-shadow: 0 0 0 3px rgba(255, 216, 74, 0.24);
}

.display-room-row button {
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  background: #ffd84a;
  color: #06160d;
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.display-room-status {
  min-height: 0;
  color: rgba(255, 253, 243, 0.72);
  font-size: clamp(0.58rem, 0.78vw, 0.72rem);
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

/* â”€â”€ Main area â”€â”€ */

.display-main {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* â”€â”€ Board zone â”€â”€ */

.display-board-zone {
  flex: 1 1 0;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 2vw, 20px);
  overflow: hidden;
  background: linear-gradient(180deg, #1e1e1e, #141414);
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  background: rgba(8, 17, 10, 0.9);
  z-index: 2;
}

.empty-state[hidden] {
  display: none;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: clamp(1.2rem, 3vw, 2rem);
  color: var(--white);
}

.empty-state p {
  margin: 0 0 14px;
  color: rgba(255, 253, 243, 0.8);
  font-size: clamp(0.95rem, 2vw, 1.2rem);
}

.empty-state button {
  padding: 10px 16px;
  border-radius: 999px;
  background: #ffd84a;
  color: #06160d;
  font-weight: 900;
}

/* â”€â”€ Board frame â”€â”€ */

.board-frame {
  display: grid;
  grid-template-areas:
    "top   top   top"
    "left  board right"
    "bottom bottom bottom";
  grid-template-columns: clamp(22px, 5vw, 68px) 1fr clamp(22px, 5vw, 68px);
  width: 100%;
  max-width: 1060px;
}

/* â”€â”€ Frame bars â”€â”€ */

.frame-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 900;
  color: var(--white);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.frame-top {
  grid-area: top;
  min-height: clamp(24px, 4vh, 54px);
  background: linear-gradient(180deg, #009a00, #00b800);
  border-radius: 14px 14px 0 0;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2);
}

.frame-bottom {
  grid-area: bottom;
  min-height: clamp(24px, 4vh, 54px);
  background: linear-gradient(180deg, #00b800, #009a00);
  border-radius: 0 0 14px 14px;
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.2);
}

.frame-left {
  grid-area: left;
  background: linear-gradient(180deg, #cc0000, var(--red), #cc0000);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.frame-right {
  grid-area: right;
  background: linear-gradient(180deg, #cc0000, var(--red), #cc0000);
  writing-mode: vertical-rl;
}

.frame-name {
  font-size: clamp(0.55rem, 1.4vw, 1.3rem);
}

.frame-arrow {
  font-size: clamp(0.5rem, 1.1vw, 1.1rem);
  opacity: 0.85;
}

/* â”€â”€ Letter board â”€â”€ */

.letter-board {
  grid-area: board;
  display: grid;
  direction: ltr;
  gap: 0;
}

.letter-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin-top: -1px;
}

.letter-row:first-child {
  margin-top: 0;
}

.letter-cell {
  position: relative;
  min-width: 0;
  direction: rtl;
  margin-inline: -8px;
  margin-block: -1px;
  aspect-ratio: 2.05;
  display: grid;
  place-items: center;
  background: var(--cream);
  color: var(--blue);
  clip-path: polygon(14% 0, 86% 0, 100% 50%, 86% 100%, 14% 100%, 0 50%);
  font-size: clamp(0.9rem, 3.5vw, 3.05rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
  filter: drop-shadow(0 2px 0 rgba(31, 42, 18, 0.52));
  user-select: none;
}

.letter-cell::after {
  content: "";
  position: absolute;
  inset: 3px 5px;
  clip-path: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(0, 0, 0, 0.08));
  pointer-events: none;
}

.letter-cell.is-selected {
  background: #fff17b;
  filter: drop-shadow(0 0 0 var(--white)) drop-shadow(0 0 14px var(--white));
}

.letter-cell.is-red {
  background: var(--red);
  color: var(--white);
}

.letter-cell.is-green {
  background: var(--green);
  color: var(--ink);
}

.letter-cell.is-path {
  filter: drop-shadow(0 0 12px var(--white)) drop-shadow(0 3px 0 rgba(31, 42, 18, 0.52));
}

/* â”€â”€ Round / match overlay â”€â”€ */

.round-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(580px, calc(100% - 48px));
  z-index: 5;
  display: grid;
  justify-items: center;
  gap: 12px;
  border: 4px solid #f0d860;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(3, 45, 9, 0.98), rgba(0, 18, 6, 0.96));
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5), inset 0 -6px 0 rgba(0, 0, 0, 0.22);
  padding: 36px 28px;
  text-align: center;
}

.round-message[hidden] {
  display: none;
}

.round-message span {
  color: rgba(255, 253, 243, 0.82);
  font-size: clamp(0.9rem, 1.5vw, 1.15rem);
  font-weight: 900;
}

.round-message strong {
  color: var(--white);
  font-size: clamp(1.8rem, 5vw, 4rem);
  line-height: 1.1;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.28);
}

.round-message.is-red {
  background: linear-gradient(180deg, rgba(180, 0, 0, 0.98), rgba(75, 0, 0, 0.96));
}

.round-message.is-green {
  background: linear-gradient(180deg, rgba(0, 118, 0, 0.98), rgba(0, 40, 0, 0.96));
}

/* â”€â”€ Question bar â”€â”€ */

.display-question {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: clamp(10px, 2vh, 16px) clamp(14px, 3vw, 32px) clamp(20px, 4vh, 40px);
  min-height: clamp(80px, 14vh, 112px);
  background: var(--banner);
  border-top: 3px solid rgba(255, 253, 243, 0.1);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.25);
}

.display-exit-button {
  flex-shrink: 0;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(255, 253, 243, 0.22);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.52);
  color: var(--white);
  padding: 0 16px;
  font: 900 1rem/1 Tahoma, Arial, sans-serif;
}

.display-exit-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.disp-letter-badge {
  flex: 0 0 auto;
  width: clamp(46px, 6vw, 78px);
  height: clamp(46px, 6vw, 78px);
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #082516;
  color: #f0d860;
  font-size: clamp(1.6rem, 3vw, 2.8rem);
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.3);
}

.disp-question-body {
  flex: 1 1 0;
  min-width: 0;
  display: grid;
  gap: 6px;
}

.disp-subject {
  color: rgba(255, 253, 243, 0.65);
  font-size: clamp(0.72rem, 1vw, 0.92rem);
  font-weight: 900;
  text-transform: uppercase;
}

.disp-question-text {
  color: var(--white);
  font-size: clamp(0.95rem, 2vw, 1.65rem);
  font-weight: 800;
  line-height: 1.4;
}

.contestant-buzz {
  flex: 1 1 0;
  min-width: 0;
  display: grid;
  gap: 8px;
}

.contestant-buzz-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.contestant-buzz-buttons.is-single {
  grid-template-columns: minmax(0, 1fr);
}

.contestant-red .contestant-buzz-buttons,
.contestant-green .contestant-buzz-buttons {
  grid-template-columns: minmax(0, 1fr);
}

.contestant-red #display-green-buzz,
.contestant-green #display-red-buzz {
  display: none;
}

.contestant-buzz-button {
  min-width: 0;
  min-height: clamp(52px, 8vh, 72px);
  display: grid;
  place-items: center;
  gap: 4px;
  border-radius: 10px;
  color: var(--white);
  padding: 10px 12px;
  line-height: 1.1;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.24), 0 4px 0 rgba(0, 0, 0, 0.18);
}

.contestant-buzz-button span {
  font-size: clamp(0.7rem, 1vw, 0.82rem);
  font-weight: 900;
  opacity: 0.88;
}

.contestant-buzz-button strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: clamp(1rem, 1.5vw, 1.35rem);
  font-weight: 900;
}

.contestant-buzz-button.red-team {
  background: linear-gradient(180deg, #ff3a32, var(--red-dark));
}

.contestant-buzz-button.green-team {
  background: linear-gradient(180deg, #00d28f, #006f50);
}

.contestant-buzz-button.is-active {
  outline: 4px solid #f0d860;
  outline-offset: 3px;
  filter: brightness(1.12);
}

.contestant-buzz-button.is-public-active {
  min-height: clamp(72px, 14vh, 116px);
  outline-width: 5px;
}

.contestant-buzz-button.is-public-active span {
  font-size: clamp(0.9rem, 1.5vw, 1.1rem);
}

.contestant-buzz-button.is-public-active strong {
  font-size: clamp(1.3rem, 2.2vw, 1.7rem);
}

.contestant-buzz-button:not(:disabled):hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.contestant-buzz-button:not(:disabled):active {
  transform: translateY(1px);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.24), 0 2px 0 rgba(0, 0, 0, 0.18);
}

.contestant-buzz-button:disabled {
  cursor: default;
  opacity: 0.5;
}

.contestant-buzz-status {
  min-height: 1.3em;
  color: rgba(255, 253, 243, 0.72);
  font-size: clamp(0.75rem, 1vw, 0.92rem);
  font-weight: 900;
  line-height: 1.3;
  text-align: center;
}

/* â”€â”€ 900px: tablet â”€â”€ */

@media (max-width: 900px) {
  .display-header {
    padding: 10px 18px;
    gap: 10px;
  }

  .display-question {
    padding: 12px 16px;
  }

  .contestant-buzz-button {
    min-height: 58px;
  }
}

/* â”€â”€ 640px: phone landscape / small tablet â”€â”€ */

@media (max-width: 640px) {
  .display-header {
    padding: 8px 12px;
    gap: 8px;
  }

  .disp-team {
    gap: 8px;
  }

  .disp-wins {
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    border-radius: 8px;
  }

  .red-team .disp-wins { box-shadow: 0 3px 0 #880000; }
  .green-team .disp-wins { box-shadow: 0 3px 0 #005c40; }

  .disp-name {
    font-size: 0.85rem;
  }

  .disp-timer {
    font-size: 1.7rem;
    padding: 4px 10px;
  }

  .disp-phase-label,
  .disp-round {
    font-size: 0.65rem;
  }

  .display-board-zone {
    padding: 6px;
  }

  .board-frame {
    grid-template-columns: 18px 1fr 18px;
  }

  .frame-top,
  .frame-bottom {
    min-height: 20px;
  }

  .frame-name {
    font-size: 0.55rem;
  }

  .frame-arrow {
    display: none;
  }

  .letter-cell {
    font-size: clamp(0.85rem, 5vw, 1.6rem);
  }

  .display-question {
    padding: 8px 12px;
    gap: 10px;
    min-height: unset;
  }

  .disp-letter-badge {
    width: 42px;
    height: 42px;
    font-size: 1.5rem;
    border-radius: 8px;
  }

  .disp-subject {
    font-size: 0.7rem;
  }

  .disp-question-text {
    font-size: 0.9rem;
    line-height: 1.35;
  }

  .contestant-buzz-button {
    min-height: 46px;
  }

  .contestant-buzz-button strong {
    font-size: 0.95rem;
  }

  .contestant-buzz-status {
    font-size: 0.7rem;
  }

  .round-message {
    padding: 20px 16px;
    gap: 8px;
  }
}

/* â”€â”€ 400px: small phone â”€â”€ */

@media (max-width: 400px) {
  .display-header {
    padding: 6px 8px;
  }

  .disp-wins {
    width: 34px;
    height: 34px;
    font-size: 1.25rem;
  }

  .disp-name {
    font-size: 0.75rem;
  }

  .disp-timer {
    font-size: 1.4rem;
    padding: 3px 8px;
  }

  .board-frame {
    grid-template-columns: 14px 1fr 14px;
  }

  .frame-top,
  .frame-bottom {
    min-height: 16px;
  }

  .frame-name {
    font-size: 0;
  }

  .letter-cell {
    font-size: clamp(0.7rem, 5.5vw, 1.2rem);
  }

  .disp-question-text {
    font-size: 0.82rem;
  }
}

/* Professional responsive display shell */

html {
  min-height: 100%;
  background: #06120d;
}

body {
  height: 100svh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0) 160px),
    linear-gradient(180deg, #06140d 0%, #0b2417 48%, #06100b 100%);
}

.display-app {
  height: 100svh;
  min-width: 0;
}

.display-header {
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  padding: 7px 16px;
  border-bottom: 1px solid rgba(255, 253, 243, 0.1);
  background: linear-gradient(180deg, #063817, #02150b);
}

.disp-team {
  min-width: 0;
}

.disp-wins {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  font-size: 1.9rem;
}

.disp-name {
  min-width: 0;
  max-width: 30ch;
  font-size: 1.18rem;
}

.disp-phase-label {
  font-size: 0.74rem;
}

.disp-timer {
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 2.25rem;
}

.disp-round {
  font-size: 0.7rem;
}

.display-room-form {
  width: min(100%, 180px);
  gap: 3px;
}

.display-room-form label {
  font-size: 0.68rem;
}

.display-room-row input,
.display-room-row button {
  height: 26px;
  min-height: 26px;
  padding-block: 4px;
  font-size: 0.74rem;
}

.display-main {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.display-board-zone {
  min-height: 0;
  padding: 12px;
  border-top: 1px solid rgba(255, 253, 243, 0.05);
  background:
    linear-gradient(180deg, rgba(16, 59, 32, 0.64), rgba(4, 17, 11, 0.96)),
    #101a13;
}

.board-frame {
  width: min(100%, 1060px, calc((100svh - 204px) * 1.78));
  min-width: 0;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
}

.frame-top,
.frame-bottom {
  min-height: 40px;
  border-radius: 8px 8px 0 0;
}

.frame-bottom {
  border-radius: 0 0 8px 8px;
}

.frame-name {
  font-size: 1.08rem;
}

.frame-arrow {
  font-size: 0.9rem;
}

.letter-cell {
  font-size: 2.75rem;
  user-select: none;
}

.round-message {
  border-radius: 8px;
}

.display-question {
  min-width: 0;
  min-height: 96px;
  gap: 16px;
  padding: 12px 24px;
  border-top: 1px solid rgba(255, 253, 243, 0.14);
}

.disp-letter-badge {
  width: 62px;
  height: 62px;
  border-radius: 8px;
  font-size: 2.25rem;
}

.disp-subject {
  font-size: 0.82rem;
}

.disp-question-text {
  font-size: 1.35rem;
}

.contestant-buzz {
  flex: 1 1 0;
  min-width: 0;
}

.contestant-buzz-button {
  border-radius: 8px;
}

@media (max-width: 900px) {
  .display-header {
    padding: 6px 12px;
    gap: 8px;
  }

  .disp-wins {
    width: 42px;
    height: 42px;
    font-size: 1.55rem;
  }

  .disp-name {
    max-width: 16ch;
    font-size: 0.95rem;
  }

  .disp-timer {
    font-size: 1.8rem;
  }

  .disp-center {
    grid-template-columns: auto minmax(120px, 150px);
    gap: 2px 6px;
  }

  .display-room-form {
    width: min(100%, 150px);
  }

  .board-frame {
    width: min(100%, 940px, calc((100svh - 246px) * 1.86));
    grid-template-columns: 34px minmax(0, 1fr) 34px;
  }

  .frame-top,
  .frame-bottom {
    min-height: 30px;
  }

  .frame-name {
    font-size: 0.78rem;
  }

  .letter-cell {
    font-size: 1.9rem;
  }

  .display-question {
    min-height: 0;
  }
}

@media (max-width: 640px) {
  .display-header {
    grid-template-columns: minmax(0, 0.88fr) auto minmax(0, 0.88fr);
    padding: 5px 8px;
    gap: 5px;
  }

  .disp-team {
    gap: 7px;
  }

  .disp-wins {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 1.1rem;
  }

  .disp-name {
    max-width: 9ch;
    font-size: 0.7rem;
  }

  .disp-phase-label,
  .disp-round {
    font-size: 0.58rem;
  }

  .disp-timer {
    font-size: 1.28rem;
    padding: 3px 7px;
  }

  .disp-center {
    grid-template-columns: auto minmax(92px, 118px);
    gap: 1px 4px;
  }

  .display-room-form {
    width: min(100%, 118px);
    gap: 1px;
  }

  .display-room-form label,
  .display-room-status {
    font-size: 0.48rem;
  }

  .display-room-row {
    gap: 3px;
  }

  .display-room-row input,
  .display-room-row button {
    height: 22px;
    min-height: 22px;
    border-radius: 6px;
    padding: 2px 5px;
    font-size: 0.58rem;
  }

  .display-board-zone {
    padding: 6px;
  }

  .board-frame {
    width: min(100%, calc((100svh - 232px) * 1.86));
    grid-template-columns: 18px minmax(0, 1fr) 18px;
  }

  .frame-top,
  .frame-bottom {
    min-height: 20px;
  }

  .frame-name {
    font-size: 0.55rem;
  }

  .frame-arrow {
    display: none;
  }

  .letter-cell {
    margin-inline: -5px;
    font-size: 1.25rem;
  }

  .display-question {
    gap: 8px 10px;
    padding: 8px 10px;
  }

  .contestant-buzz-button {
    min-height: 46px;
    padding: 8px;
  }

  .contestant-buzz-button span {
    font-size: 0.68rem;
  }

  .contestant-buzz-button strong {
    font-size: 0.9rem;
  }

  .contestant-buzz-status {
    font-size: 0.68rem;
  }
}

@media (max-width: 420px) {
  .disp-team {
    gap: 5px;
  }

  .disp-name {
    max-width: 7ch;
    font-size: 0.72rem;
  }

  .board-frame {
    width: 100%;
    grid-template-columns: 14px minmax(0, 1fr) 14px;
  }

  .frame-top,
  .frame-bottom {
    min-height: 16px;
  }

  .frame-name {
    font-size: 0;
  }

  .letter-cell {
    margin-inline: -4px;
    font-size: 1rem;
  }

  .disp-question-text {
    font-size: 0.8rem;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .display-header {
    padding: 6px 12px;
  }

  .disp-wins {
    width: 38px;
    height: 38px;
    font-size: 1.35rem;
  }

  .disp-name {
    font-size: 0.82rem;
  }

  .disp-phase-label,
  .disp-round {
    font-size: 0.64rem;
  }

  .disp-timer {
    font-size: 1.5rem;
  }

  .display-question {
    min-height: 62px;
    padding: 6px 12px;
    gap: 8px 10px;
  }

  .disp-letter-badge {
    width: 38px;
    height: 38px;
    font-size: 1.3rem;
  }

  .disp-subject,
  .contestant-buzz-status {
    display: none;
  }

  .disp-question-text {
    font-size: 0.84rem;
  }

  .contestant-buzz-button {
    min-height: 38px;
    padding: 6px 8px;
  }

  .board-frame {
    width: min(100%, calc((100svh - 126px) * 1.9));
    grid-template-columns: 20px minmax(0, 1fr) 20px;
  }

  .frame-top,
  .frame-bottom {
    min-height: 18px;
  }

  .frame-name {
    font-size: 0.58rem;
  }

  .letter-cell {
    margin-inline: -5px;
    font-size: 1.18rem;
  }
}

/* Extra tap comfort for contestant answer screens, especially on phones. */
.contestant-red .display-question,
.contestant-green .display-question {
  padding-bottom: max(28px, calc(18px + env(safe-area-inset-bottom)));
}

.contestant-red .contestant-buzz,
.contestant-green .contestant-buzz {
  padding-bottom: 6px;
}

@media (max-width: 640px) {
  .contestant-red .display-question,
  .contestant-green .display-question {
    padding-bottom: max(34px, calc(22px + env(safe-area-inset-bottom)));
  }

  .contestant-red .contestant-buzz,
  .contestant-green .contestant-buzz {
    padding-bottom: 10px;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .contestant-red .display-question,
  .contestant-green .display-question {
    padding-bottom: max(16px, calc(10px + env(safe-area-inset-bottom)));
  }

  .contestant-red .contestant-buzz,
  .contestant-green .contestant-buzz {
    padding-bottom: 2px;
  }
}

/* Interlocking cellular board */

.board-frame {
  width: min(100%, 920px, calc((100svh - 204px) * 1.58));
  max-width: 920px;
  display: block;
  padding: 2px;
  border: 2px solid #020202;
  border-radius: 0;
  background: #020202;
  overflow: hidden;
}

.letter-board {
  --hex-gap: 0px;
  --hex-overlap-x: clamp(8px, 1.15vw, 16px);
  --hex-outline: 2px;
  --letter-fill: #f3f0dc;
  grid-area: auto;
  display: grid;
  direction: ltr;
  gap: var(--hex-gap);
  background: #020202;
}

.letter-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--hex-gap);
  margin-top: 0;
}

.letter-row:first-child {
  margin-top: 0;
}

.letter-row:nth-child(even)::before {
  content: none;
}

.letter-row > * {
  grid-column: auto;
}

.letter-cell,
.frame-cell {
  position: relative;
  min-width: 0;
  aspect-ratio: 2.05;
  display: grid;
  place-items: center;
  margin-inline: calc(var(--hex-overlap-x) * -1);
  border: 0;
  border-radius: 0;
  background: #020202;
  clip-path: polygon(18% 0, 82% 0, 100% 50%, 82% 100%, 18% 100%, 0 50%);
  color: #111111;
  font-size: clamp(1rem, 3vw, 2.65rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: none;
  filter: none;
  user-select: none;
}

.letter-cell::before,
.frame-cell::before {
  content: "";
  position: absolute;
  inset: var(--hex-outline);
  clip-path: inherit;
  background: var(--cell-fill, var(--letter-fill));
  z-index: -1;
}

.letter-cell::after {
  content: "";
  position: absolute;
  inset: var(--hex-outline);
  clip-path: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(0, 0, 0, 0.04));
  pointer-events: none;
}

.frame-cell-red {
  --cell-fill: #f00000;
}

.frame-cell-green {
  --cell-fill: #008c10;
}

.letter-cell.is-selected {
  --cell-fill: #fff3a0;
  filter: drop-shadow(0 0 10px rgba(255, 253, 243, 0.95));
}

.letter-cell.is-red {
  --cell-fill: var(--red);
  color: var(--white);
}

.letter-cell.is-green {
  --cell-fill: #00b315;
  color: var(--ink);
}

.letter-cell.is-path {
  filter: drop-shadow(0 0 11px var(--white));
}

@media (max-width: 640px) {
  .board-frame {
    width: min(100%, calc((100svh - 232px) * 1.58));
    padding: 2px;
  }

  .letter-board {
    --hex-gap: 0px;
    --hex-overlap-x: clamp(3px, 2vw, 7px);
    --hex-outline: 2px;
  }

  .letter-cell,
  .frame-cell {
    font-size: clamp(0.9rem, 5.8vw, 1.25rem);
  }
}

@media (max-width: 420px) {
  .board-frame {
    width: 100%;
  }

  .letter-cell,
  .frame-cell {
    font-size: clamp(0.82rem, 5.4vw, 1.05rem);
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .board-frame {
    width: min(100%, calc((100svh - 126px) * 1.58));
  }

  .letter-cell,
  .frame-cell {
    font-size: clamp(0.76rem, 4.6vh, 1.05rem);
  }
}

/* Column-staggered honeycomb board */

.board-frame {
  width: min(100%, 940px, calc((100svh - 204px) * 1.54));
  max-width: 940px;
}

.letter-board {
  --hex-col-overlap: clamp(14px, 2.4vw, 34px);
  --hex-column-offset: clamp(18px, 2.8vw, 40px);
  --hex-outline: 1.5px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  padding: 2px;
  overflow: hidden;
}

.hex-column {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.hex-column + .hex-column {
  margin-inline-start: calc(var(--hex-col-overlap) * -1);
}

.hex-column.is-offset {
  margin-block-start: var(--hex-column-offset);
}

.hex-column-red {
  margin-block-start: var(--hex-column-offset);
}

.letter-cell,
.frame-cell {
  width: 100%;
  aspect-ratio: 2.05;
  margin: -1px 0 0;
  clip-path: polygon(24% 0, 76% 0, 100% 50%, 76% 100%, 24% 100%, 0 50%);
  font-size: clamp(0.95rem, 2.5vw, 2.25rem);
}

.letter-cell:first-child,
.frame-cell:first-child {
  margin-top: 0;
}

@media (max-width: 640px) {
  .board-frame {
    width: min(100%, calc((100svh - 232px) * 1.54));
  }

  .letter-board {
    --hex-col-overlap: clamp(6px, 3.8vw, 14px);
    --hex-column-offset: clamp(10px, 5.5vw, 22px);
    --hex-outline: 1px;
  }

  .letter-cell,
  .frame-cell {
    font-size: clamp(0.78rem, 4.8vw, 1.12rem);
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .board-frame {
    width: min(100%, calc((100svh - 126px) * 1.54));
  }
}

@media (max-width: 640px) {
  .display-room-form {
    width: min(100%, 118px);
    gap: 1px;
  }

  .display-room-row {
    gap: 3px;
  }

  .display-room-row input,
  .display-room-row button {
    height: 22px;
    min-height: 22px;
    border-radius: 6px;
  }

  .display-room-row input {
    font-size: 0.58rem;
  }

  .display-room-row button {
    padding: 0 5px;
    font-size: 0.58rem;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .display-room-form label,
  .display-room-status {
    display: none;
  }

  .display-room-form {
    width: 118px;
  }
}
