:root {
  color-scheme: light;
  --bg: #f4f7f2;
  --surface: #ffffff;
  --surface-soft: #edf7ef;
  --text: #142018;
  --muted: #637268;
  --line: #dce6de;
  --primary: #168348;
  --primary-dark: #0d6536;
  --danger: #b42318;
  --gold: #a56a12;
  --shadow: 0 18px 44px rgba(27, 44, 32, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.screen-page {
  background:
    linear-gradient(115deg, rgba(22, 131, 72, 0.13), transparent 42%),
    radial-gradient(circle at 90% 12%, rgba(165, 106, 18, 0.15), transparent 28%),
    var(--bg);
}

.screen-shell {
  width: min(1440px, calc(100% - 48px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 34px 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 24px;
}

.screen-hero,
.qr-card,
.wall-card,
.signin-card,
.modal-panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.screen-hero {
  padding: 28px 32px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 28px;
}

.secondary-button {
  grid-column: auto;
  width: 150px;
  min-height: 44px;
  color: var(--primary-dark);
  background: var(--surface-soft);
}

.secondary-button:hover {
  background: #dceee0;
}

.screen-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  min-height: 0;
}

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

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 4vw, 60px);
  line-height: 1.05;
}

h2 {
  font-size: 22px;
}

.subtle {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

label {
  display: grid;
  gap: 8px;
  color: #334138;
  font-size: 14px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 13px;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  background: #fbfcfb;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 131, 72, 0.16);
}

.event-control {
  width: min(420px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: end;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(20, 32, 24, 0.48);
}

.modal-backdrop.hidden {
  display: none;
}

.modal-panel {
  width: min(520px, 100%);
  padding: 24px;
}

.modal-head {
  margin-bottom: 18px;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.hidden {
  display: none !important;
}

.event-control label:first-child,
.event-control button,
.status-text {
  grid-column: 1 / -1;
}

.status-text {
  margin: 0;
  color: var(--primary-dark);
  font-weight: 900;
}

.status-text[data-status="not_started"],
.status-text[data-status="ended"],
.status-text[data-status="error"] {
  color: var(--danger);
}

.qr-card {
  padding: 24px;
  display: grid;
  align-content: start;
  gap: 20px;
}

.qr-title,
.wall-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

#totalCount,
#lastUpdate {
  color: var(--primary-dark);
  font-weight: 900;
}

#qrImage {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.qr-link {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.qr-refresh-time {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.wall-card {
  min-height: 0;
  padding: 24px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 20px;
}

.stage-wrap {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  perspective: 1000px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 50%, rgba(22, 131, 72, 0.12), transparent 32%),
    linear-gradient(180deg, #ffffff, #f7faf7);
}

.stage-wrap::before {
  content: "";
  position: absolute;
  inset: 12%;
  border: 1px solid rgba(22, 131, 72, 0.18);
  border-radius: 50%;
  transform: rotateX(68deg);
}

.avatar-wall {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  animation: stageSpin 28s linear infinite;
}

.avatar-item {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 106px;
  min-height: 126px;
  min-width: 0;
  padding: 14px 10px;
  display: grid;
  justify-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f7faf7);
  box-shadow: 0 12px 30px rgba(28, 44, 33, 0.14);
  transform:
    translate3d(var(--x), var(--y), var(--z))
    rotateY(var(--rot));
  animation: avatarFly 0.86s cubic-bezier(.16,.88,.28,1.18) both;
  animation-delay: var(--delay);
  backface-visibility: visible;
}

.avatar-item.is-settled {
  animation: none;
}

.avatar-item img,
.avatar-fallback,
.profile img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--primary);
}

.avatar-fallback {
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 30px;
  font-weight: 900;
}

.avatar-item strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  color: #102018;
}

.avatar-item span,
.empty {
  color: var(--muted);
  font-size: 13px;
}

.avatar-item span {
  color: #536157;
}

.empty {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 260px;
  font-size: 18px;
}

@keyframes stageSpin {
  from {
    transform: rotateX(-8deg) rotateY(0deg);
  }
  to {
    transform: rotateX(-8deg) rotateY(360deg);
  }
}

@keyframes avatarFly {
  from {
    opacity: 0;
    transform:
      translate3d(calc(var(--x) * 0.18), calc(var(--y) - 260px), 520px)
      rotateY(calc(var(--rot) - 80deg))
      scale(0.45);
  }
  to {
    opacity: 1;
    transform:
      translate3d(var(--x), var(--y), var(--z))
      rotateY(var(--rot))
      scale(1);
  }
}

.signin-page {
  background:
    linear-gradient(145deg, rgba(22, 131, 72, 0.12), transparent 45%),
    var(--bg);
}

.admin-page {
  background: var(--bg);
}

.admin-shell {
  width: min(1280px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 34px 0;
}

.admin-login {
  width: min(460px, 100%);
  margin: 10vh auto 0;
}

.admin-panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.admin-head {
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.admin-actions,
.export-bar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.export-bar {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.export-bar label {
  min-width: 240px;
}

.table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

.admin-table th {
  color: #47564c;
  background: #f7faf7;
  font-weight: 900;
}

.table-button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  border: 0;
  color: #fff;
  background: var(--primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.table-button:hover {
  background: var(--primary-dark);
}

.table-button.delete-button {
  background: var(--danger);
}

.table-button.delete-button:hover {
  background: #9a1e15;
}

.admin-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mobile-shell {
  width: min(100% - 24px, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0;
  display: grid;
  align-items: center;
}

.signin-card {
  padding: 24px;
}

.profile {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.profile img {
  width: 68px;
  height: 68px;
}

.profile h1 {
  font-size: 26px;
  line-height: 1.2;
}

.notice {
  margin: 0 0 18px;
  padding: 10px 12px;
  color: var(--gold);
  background: #fff7e6;
  border: 1px solid #f4d9a6;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
}

.notice.ok {
  color: var(--primary-dark);
  background: var(--surface-soft);
  border-color: #cfe5d5;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.wide {
  grid-column: 1 / -1;
}

textarea {
  resize: vertical;
}

button {
  grid-column: 1 / -1;
  border: 0;
  border-radius: 6px;
  min-height: 48px;
  padding: 0 18px;
  color: #fff;
  background: var(--primary);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.event-control button {
  min-height: 42px;
}

button:hover {
  background: var(--primary-dark);
}

button:disabled {
  cursor: default;
  background: #7fa98e;
}

.result {
  min-height: 24px;
  margin-top: 18px;
  color: var(--muted);
  font-weight: 800;
}

.result.ok {
  color: var(--primary-dark);
}

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

.result.pending {
  color: var(--gold);
}

@media (max-width: 900px) {
  .screen-shell {
    width: min(100% - 24px, 1440px);
  }

  .screen-hero {
    display: grid;
    align-items: start;
  }

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

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

  .signin-card {
    padding: 20px;
  }
}
