.buzzer-page {
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background: var(--t2t-stage-bg);
  color: var(--t2t-stage-text-soft);
}

.buzzer-stage {
  width: min(1240px, calc(100% - 32px));
  height: calc(100vh - 78px);
  box-sizing: border-box;
  margin: 0 auto;
  padding: 10px 0 16px;
}

.buzzer-card {
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #ddd3c5;
  border-radius: 28px;
  background: #fffaf0;
  box-shadow: 0 18px 40px rgba(36, 22, 64, 0.12);
  padding: clamp(18px, 2.5vw, 30px);
}

.buzzer-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 22px;
  flex: 0 0 auto;
}

.buzzer-kicker {
  margin: 0 0 6px;
  color: #7a50c9;
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .11em;
}

.buzzer-top h2,
.controls-heading h2 {
  margin: 0;
  color: var(--t2t-ink);
  font-size: clamp(1.7rem, 3.4vw, 2.65rem);
}

.buzzer-subtitle {
  max-width: 760px;
  margin: 9px 0 0;
  line-height: 1.45;
  color: #6d6280;
}

.round-status {
  min-width: 170px;
  padding: 14px 18px;
  border: 2px solid #d7cde4;
  border-radius: 18px;
  background: #ffffff;
  text-align: center;
  box-shadow: 0 5px 0 #d7cde4;
}

.round-status span {
  display: block;
  color: #7a50c9;
  font-size: .7rem;
  font-weight: 900;
  letter-spacing: .12em;
}

.round-status strong {
  display: block;
  margin-top: 4px;
  color: var(--t2t-ink);
  font-size: 1rem;
}

.buzzer-main {
  min-height: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(250px, .72fr) minmax(0, 1.65fr);
  gap: 20px;
  margin-top: 18px;
}

.host-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 2px solid #ded4c7;
  border-radius: 24px;
  background: #f4eee3;
  padding: 22px;
}

.host-buzzer-visual {
  position: relative;
  width: min(210px, 70%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin-bottom: 20px;
}

.host-buzzer-base {
  position: absolute;
  inset: 19% 8% 8%;
  border: 5px solid #241640;
  border-radius: 38px 38px 54px 54px;
  background: #2d9eea;
  box-shadow: inset 0 -16px 0 rgba(36, 22, 64, .13), 0 12px 0 #c9bdad;
}

.host-buzzer-top {
  position: absolute;
  z-index: 2;
  width: 58%;
  aspect-ratio: 1;
  top: 9%;
  border: 5px solid #241640;
  border-radius: 50%;
  background: #30303a;
  box-shadow: inset 0 -12px 0 rgba(0, 0, 0, .18);
}

.host-buzzer-ring {
  position: absolute;
  z-index: 3;
  width: 24%;
  aspect-ratio: 1;
  top: 45%;
  border: 5px solid #241640;
  border-radius: 50%;
  background: #ffcc3d;
}

.host-buzzer-cap {
  position: absolute;
  z-index: 4;
  top: 49%;
  width: 13%;
  height: 7%;
  border-radius: 8px;
  background: #fff;
  border: 2px solid #241640;
}

.host-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.host-btn { min-width: 125px; }
.host-btn--primary { background: #2fe6c9; color: #241640; }

.input-hint {
  margin: 12px 0 0;
  text-align: center;
  color: #766b82;
  font-size: .9rem;
}

.buzzer-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.buzzer-grid--count-5,
.buzzer-grid--count-6 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.player-buzzer {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: 6px;
  padding: 12px;
  border: 3px solid #ddd2c2;
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 7px 0 #ddd2c2;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}

.player-buzzer__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.player-buzzer__name {
  color: var(--t2t-ink);
  font-size: 1.1rem;
  font-weight: 900;
}

.player-buzzer__key {
  padding: 5px 9px;
  border-radius: 9px;
  background: #241640;
  color: #fff;
  font-size: .78rem;
  font-weight: 800;
}

.player-buzzer__button {
  align-self: center;
  width: min(120px, 48%, 15vh);
  min-width: 72px;
  aspect-ratio: 1;
  border: 7px solid #241640;
  border-radius: 50%;
  background: #ff5d73;
  box-shadow: 0 11px 0 #c72e48, inset 0 10px 0 rgba(255,255,255,.17);
  color: #fff;
  font-size: clamp(.9rem, 1.5vw, 1.2rem);
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.player-buzzer__button:hover { filter: brightness(1.04); }
.player-buzzer__button:active,
.player-buzzer.is-pressed .player-buzzer__button {
  transform: translateY(8px);
  box-shadow: 0 3px 0 #c72e48, inset 0 10px 0 rgba(255,255,255,.12);
}

.player-buzzer.is-winner {
  border-color: #2fe6c9;
  box-shadow: 0 7px 0 #1eb49e, 0 0 0 5px rgba(47,230,201,.15);
}

.player-buzzer.is-winner .player-buzzer__button {
  background: #2fe6c9;
  box-shadow: 0 11px 0 #159783, inset 0 10px 0 rgba(255,255,255,.2);
}

.player-buzzer.is-disabled {
  opacity: .38;
  filter: grayscale(1);
}

.player-buzzer.is-disabled.is-winner {
  opacity: 1;
  filter: none;
}

.player-buzzer__result {
  min-height: 1.2em;
  margin: 6px 0 0;
  text-align: center;
  color: #7a50c9;
  font-weight: 900;
}

.controls-popup {
  position: fixed;
  z-index: 20;
  top: 50%;
  left: 50%;
  width: min(820px, calc(100vw - 40px));
  max-height: calc(100vh - 120px);
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  overflow: hidden;
  border: 2px solid #d8cde5;
  border-radius: 28px;
  background: #fffaf0;
  box-shadow: 0 24px 70px rgba(36, 22, 64, .24);
  padding: 28px;
}

.controls-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 22px;
}

.control-row {
  display: flex;
  align-items: end;
  gap: 18px;
  margin-bottom: 18px;
}

.control-field {
  display: grid;
  gap: 8px;
  min-width: 220px;
  color: var(--t2t-ink);
  font-weight: 800;
}

.control-field select,
.key-setting select {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 13px;
  border: 2px solid #d4c9bb;
  border-radius: 12px;
  background: #fff;
  color: #241640;
  font: inherit;
  font-weight: 700;
}

.key-settings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.key-setting {
  padding: 12px;
  border-radius: 15px;
  background: #f4eee3;
  border: 1px solid #ded4c7;
}

.key-setting label {
  display: grid;
  gap: 7px;
  color: var(--t2t-ink);
  font-weight: 800;
}

.key-setting span { font-size: .9rem; }

.controls-help {
  border-top: 1px solid #ded4c7;
  padding-top: 16px;
  color: #665b72;
}

.controls-help h3 { margin: 0 0 8px; color: var(--t2t-ink); }
.controls-help p { margin: 5px 0; }

.text-button {
  border: 2px solid #cfc3b4;
  border-radius: 12px;
  padding: 10px 14px;
  background: #fff;
  color: #241640;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.text-button:hover { background: #f4eee3; }

@media (max-width: 820px) {
  .buzzer-top { flex-direction: column; }
  .round-status { min-width: 0; width: 100%; box-sizing: border-box; }
  .buzzer-main { grid-template-columns: 1fr; }
  .host-panel { min-height: 210px; }
  .host-buzzer-visual { width: 130px; margin-bottom: 12px; }
  .key-settings { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .buzzer-stage { width: calc(100% - 18px); padding-top: 4px; }
  .buzzer-card { padding: 14px; border-radius: 20px; }
  .buzzer-main { gap: 12px; }
  .buzzer-grid { gap: 9px; }
  .player-buzzer { padding: 10px; border-radius: 16px; }
  .player-buzzer__button { width: 80px; border-width: 5px; }
  .key-settings { grid-template-columns: 1fr 1fr; }
  .controls-popup { padding: 20px; width: calc(100vw - 20px); }
  .control-row { flex-direction: column; align-items: stretch; }
  .control-field { min-width: 0; }
}


@media (max-width: 900px) {
  .buzzer-main {
    grid-template-columns: minmax(190px, .65fr) minmax(0, 1.5fr);
    gap: 14px;
  }

  .host-panel {
    padding: 14px;
  }

  .host-buzzer-visual {
    width: min(170px, 80%);
    margin-bottom: 12px;
  }

  .player-buzzer {
    padding: 9px;
  }

  .player-buzzer__name {
    font-size: .95rem;
  }

  .player-buzzer__key {
    padding: 4px 7px;
    font-size: .68rem;
  }
}

@media (max-width: 700px) {
  .buzzer-main {
    grid-template-columns: 1fr;
    overflow: auto;
    padding-bottom: 4px;
  }

  .host-panel {
    min-height: 250px;
  }

  .buzzer-grid,
  .buzzer-grid--count-5,
  .buzzer-grid--count-6 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
    grid-auto-rows: minmax(150px, 1fr);
  }
}

/* Winner / loser states */
.player-buzzer.is-loser {
  opacity: .34;
  filter: grayscale(1);
  pointer-events: none;
}

.player-buzzer.is-winner {
  position: relative;
  overflow: hidden;
  opacity: 1;
  filter: none;
  border-color: #2fe6c9;
  background: #ffffff;
  box-shadow: 0 7px 0 #1eb49e, 0 0 0 5px rgba(47,230,201,.18);
}

.player-buzzer.is-winner .player-buzzer__name,
.player-buzzer.is-winner .player-buzzer__result {
  position: relative;
  z-index: 3;
}

.player-buzzer.is-winner .player-buzzer__key {
  position: relative;
  z-index: 3;
}

.winner-confetti {
  position: absolute;
  z-index: 2;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}

.confetti-piece {
  position: absolute;
  top: -18px;
  left: var(--confetti-x);
  width: 8px;
  height: 14px;
  border-radius: 2px;
  background: #ff5d73;
  animation: winnerConfetti var(--confetti-duration) linear var(--confetti-delay) infinite;
  transform: rotate(var(--confetti-rotate));
}

.confetti-piece:nth-child(3n) { background: #2fe6c9; }
.confetti-piece:nth-child(3n + 1) { background: #7a50c9; }
.confetti-piece:nth-child(4n) { width: 6px; height: 11px; }
.confetti-piece:nth-child(5n) { border-radius: 50%; width: 9px; height: 9px; }

@keyframes winnerConfetti {
  0% {
    top: -18px;
    transform: translate3d(0, 0, 0) rotate(var(--confetti-rotate));
  }
  100% {
    top: 115%;
    transform: translate3d(22px, 0, 0) rotate(calc(var(--confetti-rotate) + 420deg));
  }
}

@media (prefers-reduced-motion: reduce) {
  .confetti-piece { animation-duration: 4s; }
}
