
:root {
  color-scheme: dark;
  --bg: #111014;
  --bg-deep: #08080b;
  --panel: #1b1720;
  --panel-soft: #251f2c;
  --ink: #f2ead8;
  --muted: #b9ad9b;
  --gold: #d9ae62;
  --ember: #b85f41;
  --moss: #6c8f72;
  --rune: #7d91b8;
  --danger: #c96d6d;
  --line: rgba(242, 234, 216, 0.16);
  --shadow: rgba(0, 0, 0, 0.38);
  font-family: Georgia, 'Times New Roman', serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(217, 174, 98, 0.16), transparent 32rem),
    linear-gradient(135deg, var(--bg-deep), var(--bg) 42%, #17141b);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  color: var(--ink);
  background: var(--panel-soft);
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: rgba(217, 174, 98, 0.8);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  color: var(--ink);
  background: rgba(8, 8, 11, 0.64);
  resize: vertical;
}

textarea:disabled {
  opacity: 0.7;
}

.admin-shell {
  display: grid;
  grid-template-columns: minmax(20rem, 27rem) 1fr;
  gap: 1.25rem;
  width: min(96rem, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 1.25rem;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.1rem;
  background: rgba(27, 23, 32, 0.92);
  box-shadow: 0 1.2rem 3rem var(--shadow);
}

.brand-row,
.section-heading-row,
.input-actions,
.copy-row,
.control-buttons,
.buzzer-control-row,
.toggle-row {
  display: flex;
  gap: 0.7rem;
  align-items: center;
}

.brand-row,
.section-heading-row,
.buzzer-control-row {
  justify-content: space-between;
}

h1 {
  margin: 0;
  font-size: 1.65rem;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.eyebrow,
.input-label,
.status-label {
  display: block;
  margin: 0 0 0.35rem;
  color: var(--muted);
  font: 700 0.74rem/1.2 system-ui, sans-serif;
  letter-spacing: 0.08rem;
  text-transform: uppercase;
}

.icon-button {
  width: 2.75rem;
  padding: 0;
  font: 700 1.6rem/1 system-ui, sans-serif;
}

.primary-button {
  background: linear-gradient(180deg, #d9ae62, #9c6339);
  color: #160f0b;
  border-color: rgba(255, 235, 178, 0.42);
  font-weight: 700;
}

.secondary-button {
  background: rgba(125, 145, 184, 0.14);
}

.compact-button {
  width: 2.75rem;
  min-width: 2.75rem;
  padding: 0;
}

.invite-box {
  display: grid;
  gap: 0.35rem;
}

.copy-row input {
  min-width: 0;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

.status-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(8, 8, 11, 0.4);
}

.status-grid strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 1.2rem;
  white-space: nowrap;
}

.player-list {
  display: grid;
  gap: 0.45rem;
  min-height: 3rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
}

.player-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  background: rgba(8, 8, 11, 0.36);
}

.player-list .ready-player {
  color: #d8f0c9;
  border-color: rgba(108, 143, 114, 0.72);
}

.buzzer-admin-panel {
  display: grid;
  gap: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem;
  background: rgba(8, 8, 11, 0.26);
}

.buzzer-settings-list {
  display: grid;
  gap: 0.5rem;
}

.buzzer-setting-row {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) 5rem auto;
  gap: 0.5rem;
  align-items: center;
}

.buzzer-setting-row input[type="color"] {
  width: 3rem;
  min-height: 2.75rem;
  padding: 0.2rem;
  cursor: pointer;
}

.toggle-row {
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 0.8rem;
  color: var(--muted);
  background: rgba(125, 145, 184, 0.14);
  font: 700 0.9rem/1.2 system-ui, sans-serif;
  cursor: pointer;
}

.toggle-row input {
  width: auto;
  accent-color: var(--gold);
}

.soft-message,
.connection-status {
  min-height: 1.4rem;
  margin: 0;
  color: var(--muted);
  font: 0.95rem/1.4 system-ui, sans-serif;
}

.stage-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  display: grid;
  align-content: center;
  justify-items: center;
  min-width: 0;
  gap: 1rem;
}

.admin-stage {
  min-height: calc(100vh - 2.5rem);
}

.player-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  display: grid;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  padding: 0.5rem;
}

body[data-view="player"] {
  overflow: hidden;
}

.connection-status {
  justify-self: center;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 8, 11, 0.5);
}

.player-stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-content: stretch;
  gap: clamp(0.25rem, 0.8vh, 0.75rem);
  height: calc(100vh - 1rem);
  min-height: 0;
  overflow: hidden;
}

.buzzers-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: 2rem;
  width: min(100%, 72rem);
  min-height: 0;
  padding: 0.5rem;
}

.compact-buzzers {
  gap: 0.55rem;
}

.player-buzzers {
  display: grid;
  grid-template-columns: repeat(5, max-content);
  justify-content: center;
  align-items: end;
  gap: clamp(0.12rem, 0.45vh, 0.42rem) clamp(0.18rem, 0.85vw, 0.62rem);
  width: min(98vw, 112rem);
  max-height: 32vh;
  overflow: hidden;
  padding: 1rem;
}

.buzzer {
  --buzzer-unit: 1rem;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: calc(10 * var(--buzzer-unit));
  min-height: calc(10 * var(--buzzer-unit));
  margin: 0.2rem;
  color: var(--ink);
  user-select: none;
  cursor: pointer;
  transform-origin: center bottom;
}

.compact-buzzers .buzzer {
  --buzzer-unit: 0.68rem;
  margin: 0;
}

.player-buzzers .buzzer {
  --buzzer-unit: clamp(0.34rem, 1.12vh, 0.64rem);
  margin: 0;
}

.buzzer.disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.buzzer-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 100ms ease, filter 100ms ease;
  filter: drop-shadow(0 0.65rem 0.35rem rgba(0, 0, 0, 0.26));
}

.b-dome {
  position: relative;
  z-index: 5;
  width: calc(7.5 * var(--buzzer-unit));
  height: calc(4.4 * var(--buzzer-unit));
  overflow: hidden;
  border: max(2px, calc(0.18 * var(--buzzer-unit))) solid rgba(242, 234, 216, 0.9);
  border-bottom: none;
  border-radius: calc(4 * var(--buzzer-unit)) calc(4 * var(--buzzer-unit)) 0 0;
  background:
    radial-gradient(circle at 72% 24%, rgba(255, 255, 255, 0.5), transparent 11%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.24), transparent 36%),
    var(--buzzer-color, var(--gold));
  box-shadow: 0 0 calc(1.1 * var(--buzzer-unit)) var(--buzzer-glow, rgba(217, 174, 98, 0.42));
  transition: transform 100ms ease, filter 100ms ease, box-shadow 100ms ease;
}

.b-dome::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 42%;
  border-radius: calc(4 * var(--buzzer-unit)) 0 0 0;
  background: rgba(0, 0, 0, 0.15);
  pointer-events: none;
}

.b-highlight {
  position: absolute;
  top: calc(0.95 * var(--buzzer-unit));
  right: calc(1.25 * var(--buzzer-unit));
  width: calc(1.2 * var(--buzzer-unit));
  height: calc(1.2 * var(--buzzer-unit));
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.34);
}

.b-highlight::after {
  content: '';
  position: absolute;
  right: calc(-0.3 * var(--buzzer-unit));
  bottom: calc(-0.55 * var(--buzzer-unit));
  width: calc(0.65 * var(--buzzer-unit));
  height: calc(0.65 * var(--buzzer-unit));
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
}

.b-neck {
  z-index: 4;
  width: calc(6.25 * var(--buzzer-unit));
  height: calc(1 * var(--buzzer-unit));
  margin-top: -2px;
  border: max(2px, calc(0.18 * var(--buzzer-unit))) solid rgba(242, 234, 216, 0.88);
  border-top: none;
  border-bottom: none;
  background: linear-gradient(90deg, #202334, #47516a 55%, #1a1a24);
}

.b-base {
  position: relative;
  z-index: 3;
  width: calc(8.75 * var(--buzzer-unit));
  height: calc(2.2 * var(--buzzer-unit));
  margin-top: -2px;
  border: max(2px, calc(0.18 * var(--buzzer-unit))) solid rgba(242, 234, 216, 0.88);
  border-radius: calc(0.95 * var(--buzzer-unit)) calc(0.95 * var(--buzzer-unit)) 0 0;
  background: linear-gradient(180deg, #c5bda9, #6f7680 72%, #444852);
  box-shadow: 0 0 calc(0.75 * var(--buzzer-unit)) rgba(125, 145, 184, 0.24);
}

.b-base::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 42%;
  border-radius: calc(0.95 * var(--buzzer-unit)) 0 0 0;
  background: rgba(0, 0, 0, 0.12);
}

.b-base::after {
  content: '';
  position: absolute;
  right: calc(-0.65 * var(--buzzer-unit));
  bottom: calc(-0.8 * var(--buzzer-unit));
  left: calc(-0.65 * var(--buzzer-unit));
  height: calc(1 * var(--buzzer-unit));
  border: max(2px, calc(0.18 * var(--buzzer-unit))) solid rgba(242, 234, 216, 0.88);
  border-radius: 999px;
  background: #4a4d56;
}

.b-label {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: calc(0.22 * var(--buzzer-unit));
  max-width: calc(9 * var(--buzzer-unit));
  min-height: calc(3.15 * var(--buzzer-unit));
  margin-top: calc(1.35 * var(--buzzer-unit));
  overflow-wrap: anywhere;
  color: var(--ink);
  font: 700 max(0.62rem, calc(1.1 * var(--buzzer-unit)))/1.15 system-ui, sans-serif;
  text-align: center;
}

.b-label-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(0.35 * var(--buzzer-unit));
  min-width: 0;
  max-width: 100%;
}

.b-label-main > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.b-score {
  display: inline-grid;
  place-items: center;
  min-width: calc(1.6 * var(--buzzer-unit));
  border: 1px solid rgba(217, 174, 98, 0.64);
  border-radius: 999px;
  padding: 0.05em 0.45em;
  color: #160f0b;
  background: var(--gold);
  box-shadow: 0 0 0.65rem rgba(217, 174, 98, 0.28);
  font-size: 0.78em;
}

.b-timing {
  display: block;
  min-height: 1.15em;
  color: var(--gold);
  text-shadow: 0 0 0.55rem rgba(217, 174, 98, 0.42);
  font: 800 max(0.58rem, calc(0.84 * var(--buzzer-unit)))/1.15 system-ui, sans-serif;
  letter-spacing: 0;
}

.buzzer.locked .b-dome {
  transform: translateY(calc(0.9 * var(--buzzer-unit)));
  filter: brightness(1.3) saturate(1.5);
  box-shadow: 0 0 calc(1.5 * var(--buzzer-unit)) var(--buzzer-glow, rgba(217, 174, 98, 0.64));
}

.buzzer.locked .buzzer-content {
  transform: translateY(calc(0.2 * var(--buzzer-unit))) scaleY(0.98);
  filter: drop-shadow(0 0.3rem 0.18rem rgba(0, 0, 0, 0.24));
}

.rank-badge {
  position: absolute;
  top: calc(-0.65 * var(--buzzer-unit));
  right: calc(0.15 * var(--buzzer-unit));
  z-index: 10;
  display: grid;
  place-items: center;
  width: calc(2.5 * var(--buzzer-unit));
  height: calc(2.5 * var(--buzzer-unit));
  border: 2px solid var(--ink);
  border-radius: 50%;
  color: #151318;
  background: #ffffff;
  box-shadow: 0.15rem 0.15rem 0 rgba(0, 0, 0, 0.24);
  font: 800 max(0.72rem, calc(1.15 * var(--buzzer-unit)))/1 system-ui, sans-serif;
  animation: pop-in 300ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.buzzer-results {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.buzzer-result-item {
  display: grid;
  min-width: 7rem;
  border: 2px solid var(--ink);
  border-radius: 10px 22px 10px 20px / 20px 10px 20px 12px;
  padding: 0.55rem 0.7rem;
  font: 700 0.95rem/1.15 system-ui, sans-serif;
  text-align: center;
}

.buzzer-result-item small {
  margin-top: 0.2rem;
  opacity: 0.78;
  font-size: 0.72rem;
}

.player-results {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  justify-content: center;
  width: min(98vw, 112rem);
  overflow: hidden;
}

.player-results .buzzer-result-item {
  min-width: 0;
  padding: clamp(0.25rem, 0.8vh, 0.5rem) 0.35rem;
  font-size: clamp(0.58rem, 1.25vh, 0.9rem);
}

.game-card {
  display: flex;
  width: 100%;
  max-width: 72rem;
  height: 72vh;
  max-height: 42rem;
  display: grid;
  width: min(100%, 72rem);
  height: min(72vh, 42rem);
  min-height: 18rem;
  border: 1px solid rgba(217, 174, 98, 0.34);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(217, 174, 98, 0.14), transparent 28%),
    linear-gradient(180deg, rgba(37, 31, 44, 0.96), rgba(13, 12, 16, 0.96));
  box-shadow: 0 1.4rem 4rem var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.player-stage .game-card {
  width: 98vw;
  max-width: none;
  height: 96vh;
  max-height: none;
  min-height: 34rem;
  width: min(98vw, 112rem);
  height: 100%;
  min-height: 0;
}

.player-stage .game-card.type-image {
  align-self: center;
  justify-self: center;
  max-width: min(98vw, 112rem);
  max-height: 100%;
}

.card-content {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  display: grid;
  align-items: center;
  justify-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 1rem;
  padding: clamp(1rem, 4vw, 3.5rem);
  text-align: center;
}

.empty-state {
  color: var(--muted);
  font: 1.25rem/1.4 system-ui, sans-serif;
}

.text-content {
  align-content: center;
  justify-items: center;
  overflow: hidden;
  text-align: center;
  font-size: 2rem;
  font-size: var(--card-text-size, clamp(1.5rem, 7vh, 7rem));
  line-height: 1.3;
}

.text-content > * {
  width: 100%;
  max-width: 32em;
  margin-left: auto;
  margin-right: auto;
  width: min(100%, 32em);
  max-width: 100%;
  margin-inline: auto;
}

.text-content h2,
.text-content h3,
.text-content h4 {
  margin: 0 0 0.6em;
  color: var(--gold);
  letter-spacing: 0;
}

.text-content p,
.text-content ul {
  margin: 0 0 0.75em;
}

.text-content a {
  color: #9fb7e8;
}

.text-content code {
  border-radius: 6px;
  padding: 0.08em 0.25em;
  background: rgba(8, 8, 11, 0.7);
  color: #f8d28a;
}

.text-content ul {
  display: grid;
  justify-items: center;
  padding-left: 0;
  list-style-position: inside;
}

.media-content {
  padding: 0;
}

.type-image .media-content {
  align-self: center;
  justify-self: center;
  width: calc(100% - 2px);
  height: calc(100% - 2px);
}

.media-content img,
.media-content video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.media-content audio {
  display: none;
}

.video-content {
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0.7rem;
  padding: 0.7rem;
}

.video-content video {
  min-height: 0;
  border-radius: 6px;
}

.video-content .volume-control {
  width: min(92%, 42rem);
}

.audio-content {
  gap: 1.2rem;
  align-content: center;
  background:
    repeating-linear-gradient(90deg, rgba(217, 174, 98, 0.06) 0 1px, transparent 1px 3rem),
    rgba(8, 8, 11, 0.38);
}

.audio-sigil {
  display: grid;
  place-items: center;
  width: min(42vw, 18rem);
  aspect-ratio: 1;
  border: 1px solid rgba(217, 174, 98, 0.36);
  border-radius: 50%;
  color: var(--gold);
  font-size: clamp(1.3rem, 5vw, 3.8rem);
  background: radial-gradient(circle, rgba(217, 174, 98, 0.2), rgba(8, 8, 11, 0.4) 62%);
}

.audio-progress {
  width: min(78%, 42rem);
  height: 0.75rem;
  overflow: hidden;
  border: 1px solid rgba(217, 174, 98, 0.35);
  border-radius: 999px;
  background: rgba(8, 8, 11, 0.62);
}

.audio-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--moss), var(--gold));
  transition: width 160ms linear;
}

.audio-content .time-label {
  color: var(--muted);
  font: 0.95rem/1.2 system-ui, sans-serif;
}

.volume-control {
  display: grid;
  grid-template-columns: auto minmax(9rem, 20rem) 3.5rem;
  gap: 0.75rem;
  align-items: center;
  width: min(78%, 42rem);
  color: var(--muted);
  font: 0.9rem/1.2 system-ui, sans-serif;
}

.volume-control input {
  width: 100%;
  height: 2rem;
  border: 0;
  padding: 0;
  background: transparent;
  accent-color: var(--gold);
}

.volume-control strong {
  color: var(--ink);
  font-weight: 700;
  text-align: right;
}

.splash-layer {
  z-index: 2;
  grid-area: 1 / 1;
  align-self: stretch;
  justify-self: stretch;
  background-color: #08080b;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  animation: reveal-in 520ms ease both;
}

.hidden-card .text-content,
.hidden-card.type-image .media-content,
.hidden-card.type-video .media-content,
.hidden-card.type-audio .media-content {
  filter: blur(22px) brightness(0.35);
  transform: scale(0.985);
  opacity: 0.42;
}

.hidden-card::after {
  content: '';
  z-index: 1;
  place-self: stretch;
  grid-area: 1 / 1;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(8, 8, 11, 0.78), rgba(27, 23, 32, 0.56));
}

.game-card > * {
  grid-area: 1 / 1;
}

.revealed-card .text-content,
.revealed-card.type-image .media-content {
  animation: reveal-in 680ms ease both;
}

.revealed-card.type-image .media-content {
  animation-name: image-reveal-in;
}

.control-buttons {
  flex-wrap: wrap;
  justify-content: center;
}

.control-buttons button {
  min-width: 7rem;
}

@keyframes reveal-in {
  0% {
    opacity: 0;
    filter: blur(24px) brightness(1.7);
    transform: scale(1.035);
  }
  55% {
    filter: blur(2px) brightness(1.25);
  }
  100% {
    opacity: 1;
    filter: blur(0) brightness(1);
    transform: scale(1);
  }
}

@keyframes image-reveal-in {
  0% {
    opacity: 0;
    filter: blur(18px) brightness(1.35);
  }
  55% {
    filter: blur(2px) brightness(1.12);
  }
  100% {
    opacity: 1;
    filter: blur(0) brightness(1);
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 820px) {
  .admin-shell {
    grid-template-columns: 1fr;
    padding: 0.75rem;
  }

  .admin-stage {
    min-height: 28rem;
  }

  .brand-row,
  .section-heading-row,
  .input-actions,
  .copy-row,
  .buzzer-control-row {
    align-items: stretch;
  }

  .input-actions,
  .copy-row,
  .buzzer-control-row {
    flex-direction: column;
  }

  .buzzers-grid {
    gap: 0.8rem;
  }

  .player-buzzers .buzzer {
    margin: -1.15rem -0.8rem;
    transform: scale(0.76);
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .game-card,
  .player-stage .game-card {
    width: 100%;
    height: 92vh;
    max-height: 44rem;
    height: min(92vh, 44rem);
  }

  .volume-control {
    grid-template-columns: 1fr auto;
    width: min(90%, 42rem);
  }

  .volume-control span {
    grid-column: 1 / -1;
  }
}
