:root {
  --ink: #17211d;
  --muted: #66716b;
  --line: #ded8cc;
  --paper: #fffdf8;
  --wash: #f5efe3;
  --green: #1f6f55;
  --green-2: #dff2e8;
  --gold: #e7c873;
  --red: #b83b35;
  --blue: #2d5f8f;
  --shadow: 0 18px 50px rgba(44, 35, 22, 0.08);
  font-family: "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--wash);
}

button,
input,
select {
  font: inherit;
}

button,
.as-button,
.primary-link {
  border: 0;
  border-radius: 7px;
  min-height: 44px;
  padding: 11px 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(135deg, #f7f1e6, #e8f0ec 52%, #f3e4d7);
}

.auth-card {
  width: min(460px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.code-card {
  min-height: 310px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-line {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--gold);
  color: var(--ink);
  font-weight: 900;
}

.brand-line h1,
.brand-line p {
  margin: 0;
}

.brand-line h1 {
  font-size: 26px;
}

.brand-line p,
.muted-text,
.muted {
  color: var(--muted);
}

.form-stack,
.code-form,
.stack {
  display: grid;
  gap: 11px;
}

.form-stack label {
  display: grid;
  gap: 7px;
  font-weight: 750;
  color: #303a35;
}

.form-stack input,
.code-form input,
.mobile-input,
.answer-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 13px;
  outline: none;
  background: #fbf8f1;
  color: var(--ink);
}

.code-form input {
  text-align: center;
  text-transform: uppercase;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0;
}

.form-stack input:focus,
.code-form input:focus,
.mobile-input:focus,
.answer-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 111, 85, 0.14);
}

.primary-btn,
.primary-link,
.mobile-primary {
  color: var(--ink);
  background: var(--gold);
}

.green-btn {
  color: #fff;
  background: var(--green);
}

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

.notice {
  padding: 12px 13px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-weight: 750;
}

.notice.error {
  color: #8b2f29;
  background: #f9dfdb;
}

.notice.success {
  color: #15543f;
  background: var(--green-2);
}

code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #eee7da;
}

.app-shell {
  display: grid;
  grid-template-columns: 310px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #17211d;
  color: #f8f4eb;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar .brand-line {
  margin-bottom: 0;
}

.sidebar .brand-line p {
  color: #b9c0ba;
}

.side-panel {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.045);
}

.panel-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin-bottom: 12px;
}

.field-label {
  display: block;
  font-size: 13px;
  color: #cbd1cc;
  margin-bottom: 8px;
}

.field-label.top-gap {
  margin-top: 12px;
}

.dark-input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  padding: 11px 12px;
  color: #fffdf8;
  background: #25312c;
  outline: none;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.ghost-dark-btn {
  color: #fffdf8;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.danger-line {
  border-color: rgba(255, 120, 110, 0.45);
  color: #ffd9d5;
}

.full {
  width: 100%;
  margin-top: 8px;
}

.logout-link {
  margin-top: auto;
  color: #f5d781;
  text-decoration: none;
  font-weight: 800;
}

.main {
  padding: 26px;
  overflow: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 22px;
}

.topbar h2 {
  margin: 9px 0 0;
  font-size: 30px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.status-pill.idle {
  background: #e7e0d3;
}

.status-pill.registration {
  background: #e6edf8;
  color: #214d7d;
}

.status-pill.running {
  background: var(--green-2);
  color: #15543f;
}

.status-pill.stopped {
  background: #f9dfdb;
  color: #8b2f29;
}

.top-stats {
  display: grid;
  grid-template-columns: repeat(3, 130px);
  gap: 10px;
}

.top-stats div,
.qr-panel,
.participants-panel,
.results-section {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.top-stats div {
  padding: 14px;
}

.top-stats span {
  display: block;
  font-size: 28px;
  font-weight: 900;
}

.top-stats small,
.eyebrow,
.link-stack label,
.participant-row small,
.history-item small {
  color: var(--muted);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(520px, 1.35fr) minmax(340px, 0.85fr);
  gap: 18px;
}

.qr-panel,
.participants-panel {
  padding: 20px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
}

.eyebrow {
  display: inline-block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.panel-head h3 {
  margin: 0;
  font-size: 22px;
}

.small-btn {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.qr-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  align-items: center;
  margin-top: 18px;
}

.qr-box {
  width: 260px;
  height: 260px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.qr-box img {
  width: 236px;
  height: 236px;
}

.qr-box.empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  background: #f8f3ea;
}

.link-stack {
  display: grid;
  gap: 8px;
}

.link-value {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #f8f3ea;
  font-size: 14px;
  word-break: break-all;
}

.participants-list {
  margin-top: 14px;
  display: grid;
  gap: 8px;
  max-height: 308px;
  overflow: auto;
}

.participant-row,
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  background: #fbf7ef;
  border-radius: 8px;
  padding: 11px 12px;
}

.participant-row strong,
.history-item strong {
  display: block;
}

.mini-status {
  padding: 5px 9px;
  border-radius: 999px;
  background: #ece5d8;
  font-size: 12px;
  font-weight: 800;
}

.mini-status.done {
  background: var(--green-2);
  color: #15543f;
}

.mini-status.wait {
  background: #fff1d7;
  color: #7d5414;
}

.results-section {
  margin-top: 18px;
  padding: 0;
  overflow: hidden;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #f8f3ea;
}

.tab {
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
}

.tab.active {
  background: var(--paper);
  border-color: var(--line);
}

.tab-panel {
  display: none;
  padding: 18px;
}

.tab-panel.active {
  display: block;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #fbf8f1;
}

.place {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.test-chip {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eee7da;
  color: #7a7164;
  font-size: 12px;
  font-weight: 800;
}

.test-chip.filled {
  color: #15543f;
  background: var(--green-2);
}

.empty-state,
.empty-cell {
  color: var(--muted);
  text-align: center;
  padding: 22px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 13px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 0.16s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.participant-page {
  background: linear-gradient(135deg, #f7f1e6, #e8f0ec 52%, #f3e4d7);
}

.mobile-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.mobile-shell.wide {
  width: min(900px, 100%);
}

.mobile-card,
.question-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.mobile-card {
  padding: 22px;
  margin-bottom: 14px;
}

.hero {
  min-height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero h1 {
  margin: 12px 0 8px;
  font-size: clamp(34px, 9vw, 62px);
  line-height: 1;
}

.hero p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
}

.pill {
  align-self: start;
  padding: 6px 10px;
  border-radius: 999px;
  background: #e7e0d3;
  font-size: 13px;
  font-weight: 900;
}

.pill.done {
  color: #15543f;
  background: var(--green-2);
}

.pill.stopped {
  color: #8b2f29;
  background: #f9dfdb;
}

.mobile-primary,
.mobile-secondary {
  border-radius: 8px;
  min-height: 48px;
  padding: 13px 16px;
}

.mobile-primary {
  color: #fff;
  background: var(--green);
}

.mobile-secondary {
  color: var(--ink);
  background: var(--gold);
}

.link-button {
  display: inline-flex;
}

.error {
  min-height: 22px;
  color: var(--red);
  font-weight: 800;
}

.loader {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #e7e0d3;
  position: relative;
}

.loader::before {
  content: "";
  position: absolute;
  width: 42%;
  height: 100%;
  left: -42%;
  background: var(--green);
  animation: load 1.2s infinite ease-in-out;
}

@keyframes load {
  to {
    left: 100%;
  }
}

.test-top {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 0 14px;
  background: #f5efe3;
}

.test-top > div:first-child {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 9px;
}

#timerText {
  color: var(--green);
}

.progress {
  height: 8px;
  background: #e1d8ca;
  border-radius: 999px;
  overflow: hidden;
}

.progress div {
  height: 100%;
  width: 0;
  background: var(--green);
  transition: width 0.15s ease;
}

.question-list {
  display: grid;
  gap: 12px;
}

.question-card {
  padding: 18px;
}

.question-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.question-card h2 {
  margin: 0 0 16px;
  font-size: 19px;
  line-height: 1.35;
}

.question-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.save-answer-btn {
  min-height: 38px;
  padding: 9px 12px;
  color: var(--ink);
  background: #eee7da;
  border: 1px solid var(--line);
}

.save-state {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.save-state.saved {
  color: #15543f;
}

.choice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice-row label {
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbf8f1;
  font-weight: 800;
}

.submit-btn {
  margin: 4px 0 20px;
}

.score-list {
  display: grid;
  gap: 9px;
}

.score-row {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 11px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf8f1;
}

.score-place {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.score-name strong,
.score-name small {
  display: block;
}

.score-name small {
  margin-top: 3px;
  color: var(--muted);
}

.center {
  text-align: center;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .topbar,
  .hero-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .top-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .qr-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .main,
  .sidebar {
    padding: 16px;
  }

  .top-stats {
    grid-template-columns: 1fr;
  }

  .button-grid,
  .choice-row {
    grid-template-columns: 1fr;
  }

  .qr-box {
    width: 100%;
  }
}
