:root {
  color-scheme: dark;
  --bg: #1b1f2a;
  --ink: #f5f3f1;
  --muted: #aeb6c8;
  --panel: #242a38;
  --panel-soft: #1f2532;
  --line: #3a4256;
  --accent: #2f5faa;
  --blue: #3f76d1;
  --accent-strong: #244f93;
  --coral: #c76264;
  --green: #46c978;
  --yellow: #e4bd62;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body::before {
  position: fixed;
  inset: -24px;
  z-index: -2;
  background:
    linear-gradient(rgba(27, 31, 42, 0.44), rgba(27, 31, 42, 0.6)),
    url("./assets/downtown_theme.png") center / cover no-repeat;
  content: "";
  filter: blur(4px);
  transform: scale(1.025);
}

body::after {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(27, 31, 42, 0.3);
  content: "";
}

.player-preload #settings-overlay,
.player-preload #settings-button,
.player-preload #join-card,
.player-preload #midi-card,
.player-preload .top-bar,
.player-preload .list-panel {
  display: none !important;
}

.player-preload .workspace {
  grid-template-columns: 1fr;
}

button,
select,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.top-bar,
.workspace,
.live-strip {
  max-width: 1440px;
  margin-right: auto;
  margin-left: auto;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--yellow);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.5rem, 2.5vw, 2.8rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 4px;
  font-size: 1rem;
  line-height: 1.2;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.live-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.live-card {
  position: relative;
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.live-strip span,
.last-message span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.live-strip strong,
.last-message strong {
  overflow-wrap: anywhere;
}

.link-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.copy-button,
.card-main {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
}

.copy-button {
  min-height: 38px;
  padding: 0 12px;
  background: rgba(245, 243, 241, 0.1);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 800;
}

.copy-button:hover {
  background: rgba(245, 243, 241, 0.16);
}

.control-card {
  padding: 0;
}

.card-main {
  display: block;
  width: 100%;
  min-height: 72px;
  padding: 14px;
  cursor: pointer;
  text-align: left;
}

.card-main:hover {
  background: rgba(245, 243, 241, 0.06);
}

.card-menu {
  position: absolute;
  z-index: 10;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.compact-field {
  font-size: 0.82rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 18px;
}

.panel,
.stage {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  border-radius: 8px;
  padding: 18px;
}

.stage {
  position: relative;
  min-height: 620px;
  overflow: hidden;
  border-radius: 8px;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 5vw, 72px);
}

.screen.active {
  display: flex;
}

#empty-state {
  background:
    linear-gradient(135deg, rgba(47, 95, 170, 0.28), transparent 48%),
    linear-gradient(315deg, rgba(19, 116, 95, 0.18), transparent 48%),
    var(--panel);
}

body:not(.player-mode) #empty-state {
  position: relative;
  inset: auto;
  width: min(560px, calc(100% - clamp(56px, 10vw, 144px)));
  min-height: 0;
  border: 1px solid rgba(245, 243, 241, 0.12);
  border-radius: 8px;
  padding: 32px 34px;
  transform: none;
}

body:not(.player-mode).screen-empty .stage {
  min-height: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

body:not(.player-mode).screen-empty #empty-state {
  margin: clamp(28px, 5vw, 56px) 0 0 clamp(28px, 5vw, 72px);
  box-shadow: var(--shadow);
}

body:not(.player-mode) #empty-state h2 {
  font-size: clamp(1.9rem, 3vw, 3rem);
}

#empty-state p {
  max-width: 680px;
  text-wrap: balance;
}

#lobby-copy {
  max-width: 40ch;
  font-size: 1.22rem;
  line-height: 1.5;
}

.button,
.icon-button {
  cursor: pointer;
  font-weight: 800;
}

.button {
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 18px;
  background: var(--blue);
  color: var(--ink);
}

.button:hover {
  background: var(--accent-strong);
}

.button:disabled,
.icon-button:disabled {
  border-color: var(--line);
  background: #31384a;
  color: #8f98ad;
  cursor: not-allowed;
}

.button.secondary {
  background: var(--panel);
  color: var(--ink);
}

.button.secondary:hover {
  background: #30384d;
}

.button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.button.ghost:hover {
  background: #30384d;
}

.button.wide {
  width: 100%;
  margin-top: 18px;
}

.reconnect-button {
  width: fit-content;
  min-width: 160px;
  margin-top: 18px;
}

.icon-button {
  display: inline-grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1;
}

.icon-button:hover {
  background: #30384d;
}

.round-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.timer-strip {
  display: block;
  margin-top: 4.5rem;
}

.timer-track {
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(245, 243, 241, 0.18);
  border-radius: 999px;
  background: rgba(12, 15, 22, 0.66);
}

.timer-track span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: rgba(245, 243, 241, 0.78);
  transition: width 180ms linear;
}

.round-timer-hidden .timer-strip,
.round-timer-hidden #timer-card {
  display: none;
}

.vote-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.vote-button {
  min-height: 178px;
  border: 3px solid transparent;
  border-radius: 8px;
  padding: 28px;
  color: var(--ink);
  cursor: pointer;
  font-size: clamp(1.35rem, 2vw, 2.2rem);
  font-weight: 900;
  line-height: 1.08;
  text-align: left;
}

.vote-button:first-child {
  background:
    linear-gradient(rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.08)),
    var(--blue);
}

.vote-button:last-child {
  background:
    linear-gradient(rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.08)),
    var(--coral);
}

.vote-button:hover,
.vote-button.selected {
  border-color: var(--yellow);
}

.vote-button:disabled {
  cursor: default;
  opacity: 0.72;
}

.vote-button.selected {
  opacity: 1;
}

.vote-status {
  min-height: 28px;
  margin: 18px 0 12px;
  color: rgba(245, 243, 241, 0.72);
  font-size: 1.2rem;
  font-style: italic;
  font-weight: 500;
  line-height: 1.35;
  text-align: center;
}

.thanks-screen {
  text-align: center;
}

.thanks-screen p {
  margin-right: auto;
  margin-left: auto;
  max-width: 680px;
}

.meter-group {
  display: grid;
  gap: 18px;
  width: min(720px, 100%);
  margin: 30px auto 6px;
  text-align: left;
}

.meter-group.compact {
  margin-top: 24px;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  font-weight: 850;
}

.meter {
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #171b25;
  border: 1px solid var(--line);
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 180ms ease;
}

#bar-a,
#live-bar-a {
  background: var(--blue);
}

#bar-b,
#live-bar-b {
  background: var(--coral);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header h2 {
  margin: 0 0 4px;
  font-size: 1rem;
  line-height: 1.2;
}

.panel-header span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.question-list {
  display: grid;
  gap: 10px;
  align-items: start;
}

.question-item {
  width: 100%;
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.question-item:hover,
.question-item.active {
  border-color: var(--accent);
  background: #28324a;
}

.question-item.system-cue {
  border-color: rgba(228, 189, 98, 0.5);
  background: rgba(48, 45, 38, 0.72);
}

.question-item strong {
  display: block;
  margin-bottom: 4px;
  line-height: 1.2;
}

.question-item span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.player-mode .workspace {
  grid-template-columns: 1fr;
}

.player-mode .top-bar {
  display: none;
}

.player-mode .app-shell {
  padding: 12px;
}

.player-mode .list-panel {
  display: none;
}

.player-mode #question-trigger,
.player-mode #question-title {
  display: none;
}

.player-mode .meter-group {
  display: none;
}

.player-mode .live-strip {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.player-mode .live-card {
  display: flex;
  min-height: 82px;
  flex-direction: column;
  justify-content: flex-start;
  padding: 14px 14px;
}

.player-mode .live-strip span {
  font-size: 0.86rem;
  line-height: 1.1;
}

.player-mode .live-strip strong {
  font-size: 1.18rem;
  line-height: 1.15;
}

.player-mode.connection-status-pulse #connection-status-card {
  animation: connectionStatusPulse 0.8s ease-in-out infinite;
}

.player-mode.connection-status-pulse #connection-status-card span,
.player-mode.connection-status-pulse #connection-status-card strong {
  animation: connectionStatusTextPulse 0.8s ease-in-out infinite;
}

.player-mode.connection-status-pulse #voter-count::before {
  animation: connectionDotPulse 0.8s ease-in-out infinite;
}

.player-mode .stage {
  min-height: min(560px, calc(100vh - 136px));
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.player-mode #question-screen {
  justify-content: flex-start;
  padding-top: 18px;
}

.player-mode h2 {
  font-size: clamp(1.85rem, 8vw, 3rem);
  line-height: 1.05;
}

.player-mode p {
  font-size: 1.125rem;
}

.player-mode .vote-status {
  font-size: 1.2rem;
}

.player-mode #empty-state {
  inset: auto;
  top: 50%;
  left: 50%;
  width: min(360px, calc(100% - 34px));
  min-height: 0;
  border: 1px solid rgba(245, 243, 241, 0.16);
  border-radius: 8px;
  padding: 24px 26px 26px;
  background:
    linear-gradient(135deg, rgba(47, 95, 170, 0.2), transparent 56%),
    rgba(36, 42, 56, 0.84);
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
}

.player-mode #empty-state p {
  max-width: 27ch;
  margin-bottom: 0;
  line-height: 1.38;
}

.player-mode #voter-count {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.player-mode #voter-count::before {
  display: inline-block;
  width: 0.72em;
  height: 0.72em;
  border-radius: 50%;
  background: var(--yellow);
  content: "";
}

.player-mode.connection-connected #voter-count::before {
  background: var(--green);
}

.player-mode.connection-disconnected #voter-count::before {
  background: var(--coral);
}

@keyframes connectionStatusPulse {
  0%,
  100% {
    border-color: var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
    transform: scale(1);
  }
  50% {
    border-color: var(--yellow);
    background: rgba(228, 189, 98, 0.24);
    box-shadow:
      0 0 0 8px rgba(228, 189, 98, 0.35),
      0 0 36px rgba(245, 243, 241, 0.38);
    transform: scale(1.025);
  }
}

@keyframes connectionStatusTextPulse {
  0%,
  100% {
    color: inherit;
  }
  50% {
    color: var(--ink);
  }
}

@keyframes connectionDotPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.45);
  }
}

.player-mode .vote-button {
  font-size: clamp(1.6rem, 8vw, 2.7rem);
  min-height: 160px;
}

.player-mode.prompt-pulse .vote-button {
  animation: answerPulse 1.2s ease-out;
}

.one-option .vote-grid {
  grid-template-columns: 1fr;
}

@keyframes answerPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: var(--shadow);
  }
  18% {
    transform: scale(1.035);
    box-shadow:
      0 0 0 6px rgba(245, 243, 241, 0.38),
      0 0 34px rgba(245, 243, 241, 0.42);
  }
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 12, 18, 0.72);
}

.overlay.active {
  display: flex;
}

.settings-panel {
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(20px, 4vw, 34px);
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(24, 32, 28, 0.26);
}

.settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.connection-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.connection-card p {
  margin-bottom: 0;
}

.connection-light {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--coral);
}

.connection-light.connected {
  background: var(--green);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--ink);
}

.last-message {
  display: grid;
  gap: 4px;
  margin-top: 18px;
  padding: 14px;
  border-radius: 8px;
  background: var(--panel-soft);
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .stage {
    min-height: 600px;
  }

  body:not(.player-mode).screen-empty .stage {
    min-height: 0;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .top-bar {
    align-items: flex-start;
  }

  .live-strip,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .screen {
    padding: 24px;
  }

  .round-header {
    align-items: center;
  }

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

  .vote-button {
    min-height: 126px;
  }

  .player-mode .live-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .player-mode .live-card {
    min-height: 92px;
    padding: 18px 14px;
  }

  .player-mode .live-strip span {
    font-size: 0.9rem;
    line-height: 1.1;
    margin-bottom: 6px;
  }

  .player-mode .live-strip strong {
    font-size: 1.26rem;
    line-height: 1.12;
  }
}
