:root {
  --bg: #eef3f8;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: #ffffff;
  --border: rgba(22, 53, 87, 0.12);
  --text: #122033;
  --muted: #607086;
  --primary: #1d5fd1;
  --primary-strong: #1148a7;
  --success: #1f9d68;
  --success-soft: #dff6eb;
  --danger: #d95a3f;
  --danger-soft: #fde7e1;
  --warning: #d7a83a;
  --accent: #0f2b56;
  --shadow: 0 20px 60px rgba(17, 34, 68, 0.14);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(29, 95, 209, 0.18), transparent 32%),
    radial-gradient(circle at bottom right, rgba(31, 157, 104, 0.14), transparent 28%),
    linear-gradient(135deg, #edf3f9 0%, #f7fbff 100%);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 360px) minmax(0, 1fr);
  gap: 20px;
  min-height: 100vh;
  padding: 20px;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-left {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
}

.board {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 20px;
  min-height: calc(100vh - 40px);
}

.panel-center,
.panel-right {
  padding: 22px;
}

.panel-center {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 18px;
}

.panel-right {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 20px;
}

.pool-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
}

.brand-block h1 {
  margin: 8px 0 6px;
  font-size: clamp(34px, 3vw, 46px);
  line-height: 1.08;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.subtle {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

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

.section-head h2,
.pool-header h2 {
  margin: 0;
  font-size: 24px;
}

.auth-card,
.control-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  border-radius: 22px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  background: #e7edf6;
  color: var(--accent);
}

.status-pill.active {
  background: #dcf6ea;
  color: #0f7a4e;
}

.qr-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 264px;
  border-radius: 18px;
  background: linear-gradient(180deg, #f9fbff 0%, #edf4fc 100%);
  border: 1px dashed rgba(17, 72, 167, 0.18);
}

.qr-code {
  width: 240px;
  height: 240px;
}

.qr-code img,
.qr-code canvas {
  max-width: 100%;
  max-height: 100%;
}

.auth-actions,
.button-stack {
  display: grid;
  gap: 12px;
}

.field-label,
.meta-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.select {
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  border-radius: 16px;
  border: 1px solid rgba(17, 72, 167, 0.18);
  background: #f8fbff;
  color: var(--text);
  font-size: 18px;
}

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

.meta-item {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 18px;
  background: #f6f9fd;
  border: 1px solid rgba(17, 72, 167, 0.08);
}

.meta-item strong {
  font-size: 20px;
}

.button,
.icon-button {
  border: none;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease, background-color 0.18s ease;
  font-family: inherit;
}

.button {
  min-height: 58px;
  padding: 14px 20px;
  border-radius: 18px;
  font-size: 20px;
  font-weight: 700;
}

.button:hover:not(:disabled),
.icon-button:hover {
  transform: translateY(-1px);
}

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

.button.primary {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-strong) 100%);
  color: #fff;
}

.button.secondary {
  background: #eff5fc;
  color: var(--accent);
  border: 1px solid rgba(17, 72, 167, 0.15);
}

.button.success {
  background: linear-gradient(180deg, #28b072 0%, #1f9d68 100%);
  color: #fff;
}

.button.danger {
  background: linear-gradient(180deg, #ea7256 0%, #d95a3f 100%);
  color: #fff;
}

.button.large {
  min-width: 220px;
  min-height: 74px;
  font-size: clamp(26px, 2.4vw, 34px);
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #eef4fc;
  color: var(--accent);
  font-size: 28px;
  line-height: 1;
}

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

.count-badge {
  min-width: 54px;
  padding: 7px 14px;
  border-radius: 999px;
  background: #edf3fb;
  color: var(--accent);
  text-align: center;
  font-size: 18px;
  font-weight: 700;
}

.count-badge.success {
  background: var(--success-soft);
  color: var(--success);
}

.count-badge.failure {
  background: var(--danger-soft);
  color: var(--danger);
}

.draw-stage {
  display: grid;
  gap: 10px;
  align-items: center;
  justify-items: center;
  min-height: 220px;
  padding: 26px;
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(29, 95, 209, 0.1) 0%, rgba(29, 95, 209, 0.03) 100%),
    #ffffff;
  border: 1px solid rgba(17, 72, 167, 0.1);
  overflow: hidden;
}

.draw-stage.drawing .draw-name {
  animation: pulseName 0.22s ease-in-out infinite alternate;
}

.draw-label {
  color: var(--muted);
  font-size: 22px;
  font-weight: 700;
}

.draw-name {
  font-size: clamp(54px, 5vw, 84px);
  font-weight: 800;
  letter-spacing: 0.03em;
  text-align: center;
}

@keyframes pulseName {
  from {
    transform: scale(0.98);
    opacity: 0.72;
  }
  to {
    transform: scale(1.04);
    opacity: 1;
  }
}

.name-grid {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 12px;
  overflow: auto;
  padding-right: 4px;
}

.name-grid.compact {
  gap: 10px;
}

.name-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 10px 16px;
  border-radius: 16px;
  background: #f7fbff;
  border: 1px solid rgba(17, 72, 167, 0.1);
  font-size: 22px;
  font-weight: 700;
}

.success-card .name-pill {
  background: #f1fbf6;
  border-color: rgba(31, 157, 104, 0.16);
}

.failure-card .name-pill {
  background: #fff6f3;
  border-color: rgba(217, 90, 63, 0.16);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 180px;
  padding: 20px;
  border-radius: 18px;
  background: #f7faff;
  border: 1px dashed rgba(17, 72, 167, 0.12);
  color: var(--muted);
  text-align: center;
}

.modal-backdrop,
.history-drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(9, 23, 44, 0.45);
  backdrop-filter: blur(10px);
}

.modal-card {
  width: min(760px, calc(100vw - 48px));
  padding: 34px;
  border-radius: 28px;
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(12, 28, 54, 0.32);
  text-align: center;
}

.modal-kicker {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 26px;
  font-weight: 700;
}

.modal-name {
  margin: 0;
  font-size: clamp(74px, 8vw, 116px);
  line-height: 1.08;
}

.modal-result {
  margin: 18px 0 0;
  font-size: 34px;
  font-weight: 800;
}

.modal-result.success {
  color: var(--success);
}

.modal-result.failure {
  color: var(--danger);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-top: 28px;
}

.history-panel {
  width: min(1180px, calc(100vw - 48px));
  height: min(82vh, 860px);
  padding: 24px;
  border-radius: 28px;
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(12, 28, 54, 0.32);
}

.history-content {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 20px;
  height: calc(100% - 56px);
  margin-top: 16px;
}

.history-list,
.history-detail {
  overflow: auto;
  min-height: 0;
}

.history-record {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(17, 72, 167, 0.1);
  background: #f8fbff;
  cursor: pointer;
}

.history-record + .history-record {
  margin-top: 12px;
}

.history-record.active {
  border-color: rgba(29, 95, 209, 0.26);
  background: rgba(29, 95, 209, 0.08);
}

.history-record h3,
.history-detail h3,
.history-detail h4 {
  margin: 0;
}

.history-record p,
.history-detail p {
  margin: 0;
  color: var(--muted);
}

.history-detail-card {
  display: grid;
  gap: 18px;
  padding: 20px;
  border-radius: 22px;
  border: 1px solid rgba(17, 72, 167, 0.1);
  background: #f9fbff;
}

.history-block {
  display: grid;
  gap: 12px;
}

.history-name-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.history-name-list .name-pill {
  min-height: 46px;
  font-size: 18px;
}

.history-toggle {
  justify-self: start;
}

.hidden {
  display: none !important;
}

@media (max-width: 1360px) {
  .app-shell {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .board {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  }

  .panel-right {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: none;
  }
}

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

  .board,
  .panel-right,
  .history-content {
    grid-template-columns: 1fr;
  }

  .history-panel {
    height: min(90vh, 920px);
  }
}
