@import url("https://fonts.googleapis.com/css2?family=Lato:wght@400;700;900&family=Poppins:wght@600;700;800;900&display=swap");

:root {
  font-synthesis: none;
  --ink: #08122f;
  --muted: #667085;
  --line: #e5e7f0;
  --surface: #ffffff;
  --soft: #f5f7ff;
  --purple: #8b2cff;
  --blue: #2f66ff;
  --teal: #04d3ad;
  --red: #ff335f;
  --yellow: #ffc83d;
  --green: #08c781;
  --shadow: 0 18px 60px rgba(17, 24, 39, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
strong,
button {
  font-family: Poppins, Lato, ui-sans-serif, system-ui, sans-serif;
}

.home-shell {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 36px;
  min-height: 100vh;
  padding: 32px;
}

.landing-hero {
  display: grid;
  justify-items: center;
  gap: 22px;
  width: min(860px, 100%);
  text-align: center;
}

.home-logo {
  width: min(620px, 84vw);
}

.landing-hero h1 {
  max-width: 780px;
  font-size: clamp(42px, 7vw, 76px);
  line-height: 1;
}

.landing-hero p {
  max-width: 640px;
  color: var(--muted);
  font-size: 22px;
}

.landing-join {
  display: flex;
  gap: 10px;
  width: min(520px, 100%);
}

.landing-join input {
  height: 54px;
  font-size: 20px;
  text-align: center;
}

.admin-link {
  color: var(--blue);
  font-weight: 900;
}

.action-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.action-card {
  display: grid;
  gap: 8px;
  padding: 22px;
}

.action-card strong {
  font-size: 24px;
}

.action-card span,
.muted {
  color: var(--muted);
}

.admin-shell {
  min-height: 100vh;
  background: linear-gradient(180deg, #ffffff 0%, #f7f8ff 100%);
}

.admin-topbar,
.display-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(4, 211, 173, 0.14);
  backdrop-filter: blur(12px);
}

.admin-topbar img,
.display-header img {
  width: 190px;
}

.admin-topbar nav {
  display: flex;
  gap: 10px;
}

.hidden {
  display: none !important;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 25% 20%, rgba(4, 211, 173, 0.35), transparent 28%),
    linear-gradient(135deg, #8b2cff 0%, #2f66ff 100%);
}

.login-card {
  display: grid;
  gap: 12px;
  width: min(430px, 100%);
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-card img {
  width: 220px;
}

.admin-link-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.admin-game-code {
  display: grid;
  gap: 10px;
  margin: 16px 0;
  padding: 16px;
  text-align: center;
  background: linear-gradient(135deg, rgba(139, 44, 255, 0.09), rgba(47, 102, 255, 0.09));
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-game-code span {
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

.admin-game-code strong {
  font-size: 52px;
  line-height: 1;
}

.admin-game-code h3 {
  margin: 0;
  color: var(--purple);
  font-size: 22px;
  line-height: 1.1;
}

.admin-game-code p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.admin-settings {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.admin-settings h2 {
  font-size: 18px;
}

.admin-settings label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.settings-message {
  min-height: 18px;
  font-size: 13px;
  font-weight: 900;
}

.settings-message.error {
  color: var(--red);
}

.settings-message.ok {
  color: var(--green);
}

.hype-mini {
  padding: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  border-radius: 8px;
  font-weight: 900;
}

.admin-topbar nav a,
.secondary-link {
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-weight: 800;
  text-align: center;
}

.admin-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 330px;
  gap: 18px;
  padding: 18px;
}

.panel {
  padding: 18px;
}

.panel-title,
.editor-head,
.question-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

h1,
h2,
p {
  margin: 0;
}

.game-list,
.question-list,
.control-stack,
.live-summary {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.delete-game-button {
  margin-top: 16px;
}

.game-row {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 14px;
  text-align: left;
  color: var(--ink);
  background: var(--soft);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.game-row.active {
  border-color: var(--purple);
  background: #fff;
}

.game-row span {
  color: var(--muted);
  font-size: 13px;
}

.field,
.question-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.field {
  flex: 1;
}

input,
textarea,
select {
  width: 100%;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  padding: 12px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
}

.primary-button,
.secondary-button,
.danger-button,
.mini-button {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 900;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--purple), var(--blue));
}

.secondary-button {
  color: var(--ink);
  background: var(--soft);
  border: 1px solid var(--line);
}

.danger-button {
  color: #fff;
  background: var(--red);
}

.mini-button {
  min-height: 34px;
  color: var(--red);
  background: #fff1f4;
}

.full-width {
  width: 100%;
}

.question-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.question-settings,
.answers-editor,
.media-editor {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.answers-editor {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.answer-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.answer-section-head label {
  min-width: 170px;
}

.media-editor {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  align-items: end;
}

.media-preview {
  display: grid;
  place-items: center;
  min-height: 94px;
  padding: 10px;
  color: var(--muted);
  background: var(--soft);
  border: 1px dashed var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.media-preview img {
  max-width: 100%;
  max-height: 160px;
  object-fit: contain;
}

.answer-editor {
  position: relative;
}

.answer-editor span {
  position: absolute;
  left: 10px;
  bottom: 12px;
  color: #fff;
  font-weight: 900;
}

.answer-editor input {
  padding-left: 34px;
  padding-right: 34px;
  color: #fff;
  border: 0;
  font-weight: 900;
}

.answer-editor input[readonly] {
  opacity: 0.9;
}

.answer-remove {
  position: absolute;
  right: 6px;
  bottom: 8px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  min-height: 0;
  padding: 0;
  color: #fff;
  background: rgba(0, 0, 0, 0.22);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 900;
}

.matching-editor {
  display: grid;
  gap: 10px;
}

.pair-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.answer-0 input,
.red {
  background: var(--red);
}

.answer-1 input,
.blue {
  background: var(--blue);
}

.answer-2 input,
.yellow {
  color: var(--ink);
  background: var(--yellow);
}

.answer-3 input,
.green {
  background: var(--green);
}

.code-pill {
  padding: 8px 12px;
  border-radius: 999px;
  color: #fff;
  background: var(--ink);
  font-weight: 900;
}

.summary-stat {
  display: flex;
  justify-content: space-between;
  padding: 12px;
  border-radius: 6px;
  background: var(--soft);
}

.summary-stat span {
  color: var(--muted);
}

.leader-mini {
  display: grid;
  gap: 8px;
}

.leader-mini p {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  color: #fff;
  background: var(--purple);
  border-radius: 8px;
}

.display-shell {
  min-height: 100vh;
  background: #fff;
}

.join-code-form {
  display: flex;
  gap: 10px;
}

.join-code-form input {
  width: 150px;
}

.display-stage {
  min-height: 100vh;
  padding: 32px;
}

.empty-display,
.lobby-display,
.question-display,
.results-display,
.podium-display {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 24px;
  min-height: calc(100vh - 64px);
  text-align: center;
}

.empty-display img {
  width: min(620px, 80vw);
}

.centered-code-entry {
  min-height: calc(100vh - 64px);
}

.centered-code-entry h1 {
  font-size: clamp(38px, 7vw, 82px);
  line-height: 1;
}

.join-code-form.centered {
  width: min(520px, 100%);
}

.join-code-form.centered input {
  height: 58px;
  text-align: center;
  font-size: 22px;
}

.lobby-display {
  grid-template-columns: 1fr 420px;
  text-align: left;
}

.eyebrow {
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

.lobby-display h1 {
  color: var(--purple);
  font-size: clamp(76px, 13vw, 190px);
  line-height: 0.9;
}

.lobby-game-title {
  margin: 4px 0 22px;
  font-size: clamp(30px, 5vw, 66px);
  line-height: 1;
}

.join-url {
  color: var(--muted);
  font-size: 22px;
  overflow-wrap: anywhere;
}

.qr-code {
  width: min(380px, 35vw);
  border: 10px solid #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.players-cloud {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.players-cloud span {
  padding: 10px 14px;
  color: #fff;
  background: var(--purple);
  border-radius: 999px;
  font-weight: 900;
}

.question-display {
  align-content: stretch;
}

.question-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  font-size: 24px;
  font-weight: 900;
}

.question-topline strong {
  display: grid;
  place-items: center;
  width: 90px;
  height: 90px;
  color: #fff;
  background: var(--ink);
  border-radius: 999px;
  font-size: 40px;
}

.question-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  width: 100%;
}

.question-main {
  display: grid;
  gap: 18px;
}

.question-display h1 {
  display: grid;
  place-items: center;
  min-height: 120px;
  font-size: clamp(40px, 6vw, 88px);
}

.question-media {
  display: grid;
  place-items: center;
  width: min(820px, 100%);
  justify-self: center;
  max-height: 38vh;
  overflow: hidden;
  border-radius: 8px;
  background: var(--soft);
  border: 1px solid var(--line);
}

.question-media img {
  width: 100%;
  max-height: 38vh;
  object-fit: contain;
}

.question-media.video {
  aspect-ratio: 16 / 9;
  max-height: none;
}

.question-media iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.leaderbox {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 18px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.leaderbox p {
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

.leaderbox h2 {
  font-size: 24px;
  line-height: 1.1;
}

.leaderbox div {
  display: grid;
  gap: 8px;
}

.leaderbox article {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: var(--soft);
  border-radius: 8px;
  font-weight: 900;
}

.leaderbox article.leading {
  color: #fff;
  background: linear-gradient(135deg, var(--purple), var(--blue));
}

.hype-banner {
  padding: 16px 22px;
  color: #fff;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  border-radius: 8px;
  font-size: 28px;
  font-weight: 900;
}

.answers-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  width: 100%;
}

.matching-display {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  width: 100%;
  text-align: left;
}

.matching-display > div {
  display: grid;
  gap: 10px;
  padding: 18px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.matching-display h3 {
  margin: 0 0 6px;
}

.matching-display p {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #fff;
  border-radius: 8px;
  font-weight: 900;
}

.matching-display b {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  color: #fff;
  background: var(--purple);
  border-radius: 999px;
}

.answer-card {
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 150px;
  padding: 26px;
  color: #fff;
  border-radius: 8px;
  font-size: clamp(24px, 3vw, 46px);
  font-weight: 900;
  text-align: left;
}

.answer-card b {
  font-size: 52px;
}

.bars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  align-items: end;
  gap: 20px;
  width: min(920px, 100%);
  height: 420px;
}

.result-bar {
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-items: end;
  gap: 12px;
  height: 100%;
  font-size: 30px;
  font-weight: 900;
}

.bar-fill {
  width: 100%;
  min-height: 8px;
  border-radius: 8px 8px 0 0;
}

.correct-answer {
  font-size: 28px;
  font-weight: 900;
}

.podium-list {
  display: grid;
  gap: 12px;
  width: min(760px, 100%);
}

.podium-row {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 22px;
  border-radius: 8px;
  background: var(--soft);
  font-size: 28px;
  font-weight: 900;
}

.rank-1 {
  background: #fff4c4;
}

.rank-2 {
  background: #eef1f7;
}

.rank-3 {
  background: #ffe0cc;
}

.player-body {
  background: linear-gradient(180deg, #ffffff 0%, #f5f7ff 100%);
}

.player-shell {
  display: grid;
  align-content: start;
  gap: 24px;
  min-height: 100vh;
  padding: 24px;
}

.player-logo {
  width: min(270px, 72vw);
  justify-self: center;
}

.player-stage {
  display: grid;
  justify-items: center;
}

.player-card {
  display: grid;
  gap: 14px;
  width: min(430px, 100%);
  padding: 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.player-card h1 {
  font-size: 34px;
}

.wait-card {
  text-align: center;
}

.wait-card p {
  color: var(--blue);
  font-size: 26px;
  font-weight: 900;
}

.form-error {
  color: var(--red);
  font-weight: 800;
}

.player-question {
  display: grid;
  gap: 20px;
  width: 100%;
}

.player-question h1,
.player-question p {
  text-align: center;
}

.player-hype {
  padding: 14px;
  color: #fff;
  text-align: center;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  border-radius: 8px;
  font-weight: 900;
}

.player-answer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.player-answer {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  min-height: 160px;
  padding: 18px;
  color: #fff;
  border: 0;
  border-radius: 8px;
  text-align: left;
  font-weight: 900;
}

.player-answer b {
  font-size: 42px;
  line-height: 1;
}

.player-answer span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: clamp(18px, 5vw, 28px);
  line-height: 1.1;
}

.player-answer:disabled {
  opacity: 0.55;
}

.player-matching {
  display: grid;
  gap: 12px;
}

.player-matching label {
  display: grid;
  gap: 8px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 900;
}

.player-matching span {
  color: var(--ink);
}

.player-matching button:disabled {
  opacity: 0.55;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 12px 16px;
  color: #fff;
  border-radius: 999px;
  font-weight: 900;
  box-shadow: var(--shadow);
}

.toast.ok {
  background: var(--green);
}

.toast.bad {
  background: var(--red);
}

@media (max-width: 980px) {
  .home-actions,
  .admin-grid,
  .lobby-display,
  .answers-grid,
  .question-layout {
    grid-template-columns: 1fr;
  }

  .landing-join,
  .join-code-form {
    display: grid;
  }

  .admin-grid {
    padding: 12px;
  }

  .question-settings,
  .answers-editor,
  .media-editor,
  .matching-display,
  .pair-row {
    grid-template-columns: 1fr;
  }

  .answer-section-head {
    display: grid;
  }

  .admin-topbar,
  .display-header {
    flex-wrap: wrap;
  }

  .display-stage {
    padding: 18px;
  }

  .qr-code {
    width: min(320px, 80vw);
  }
}
