:root {
  color-scheme: light;
  --bg: #f5f7f3;
  --panel: #ffffff;
  --ink: #1d2522;
  --muted: #66706b;
  --line: #dce3dd;
  --brand: #0f7a5f;
  --brand-strong: #095c49;
  --accent: #d97706;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(21, 33, 28, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

button,
.ghost-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: #fff;
  background: var(--brand);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

button:hover,
.ghost-button:hover {
  background: var(--brand-strong);
}

button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 122, 95, 0.14);
}

label {
  display: grid;
  gap: 7px;
}

label span {
  color: #39443f;
  font-size: 14px;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.join-page {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 122, 95, 0.14), transparent 38%),
    linear-gradient(315deg, rgba(217, 119, 6, 0.13), transparent 34%),
    var(--bg);
}

.join-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.join-panel {
  width: min(100%, 460px);
  padding: 32px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.join-panel h1 {
  margin: 0 0 24px;
  font-size: 24px;
  line-height: 1.2;
  text-align: left;
}

.fixed-title span {
  display: block;
  white-space: nowrap;
}

.fixed-title .justify-line {
  text-align: justify;
  text-align-last: justify;
}

@media (max-width: 420px) {
  .join-panel h1 {
    font-size: 19px;
  }
}

.join-panel .eyebrow {
  font-size: 14px;
}

#entryForm {
  display: grid;
  gap: 16px;
}

#entryForm button {
  margin-top: 6px;
  min-height: 52px;
  font-size: 17px;
}

.message {
  min-height: 24px;
  margin: 18px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.message.success {
  color: var(--brand-strong);
  font-weight: 700;
}

.message.error {
  color: var(--danger);
  font-weight: 700;
}

.admin-page {
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 auto 20px;
  max-width: 1280px;
}

.topbar h1 {
  margin: 0;
  font-size: 32px;
}

.top-actions,
.sub-actions,
.draw-controls,
.copy-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button {
  width: 44px;
  padding: 0;
  font-size: 21px;
}

.ghost-button,
.secondary-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.ghost-button:hover,
.secondary-button:hover {
  color: #fff;
  border-color: var(--brand-strong);
}

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

.danger-button:hover {
  background: #8f1d14;
}

.admin-grid {
  display: grid;
  grid-template-columns: 360px minmax(360px, 1fr);
  gap: 18px;
  max-width: 1280px;
  margin: 0 auto;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--panel);
  box-shadow: 0 10px 32px rgba(21, 33, 28, 0.07);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0 0 5px;
  font-size: 20px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.qr-code {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1;
  margin: 0 auto 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.qr-code svg {
  display: block;
  width: 100%;
  height: 100%;
}

.copy-row {
  align-items: stretch;
}

.copy-row button {
  min-width: 76px;
}

.compact-field {
  margin-top: 16px;
}

.secondary-button {
  width: 100%;
  margin-top: 10px;
}

.draw-panel {
  min-height: 360px;
}

.draw-controls {
  align-items: flex-end;
}

.draw-controls label {
  width: 130px;
}

.draw-controls button {
  min-width: 140px;
  min-height: 46px;
}

.winner-box {
  min-height: 150px;
  margin: 20px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  padding: 18px;
  text-align: center;
  background: #fbfcfb;
}

.winner-box.winner-celebrate {
  animation: winner-pop 780ms cubic-bezier(0.2, 1.15, 0.35, 1);
  border-color: rgba(217, 119, 6, 0.5);
  box-shadow: 0 18px 50px rgba(217, 119, 6, 0.18);
}

.winner-box span {
  color: var(--muted);
  font-weight: 700;
}

.winner-name {
  margin: 0;
  color: var(--brand-strong);
  font-size: clamp(32px, 7vw, 62px);
  line-height: 1;
  font-weight: 900;
}

.winner-org {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 18px;
  font-weight: 700;
}

.celebration {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  transition: opacity 120ms ease;
}

.celebration.show {
  opacity: 1;
}

.confetti {
  position: absolute;
  top: -18px;
  left: var(--left);
  width: 9px;
  height: 16px;
  border-radius: 2px;
  background: var(--color);
  transform: translate3d(0, 0, 0) rotate(0deg);
  animation: confetti-fall var(--duration) ease-in forwards;
  animation-delay: var(--delay);
  opacity: 0.95;
}

.confetti-circle {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

@keyframes confetti-fall {
  0% {
    transform: translate3d(0, -20px, 0) rotate(0deg);
  }
  100% {
    transform: translate3d(var(--drift), 110vh, 0) rotate(var(--rotation));
  }
}

@keyframes winner-pop {
  0% {
    transform: scale(0.96);
  }
  45% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

.sub-actions {
  flex-wrap: wrap;
}

.list-panel {
  grid-column: 1 / -1;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: #fff;
}

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

th {
  color: #405049;
  background: #f6f8f6;
  font-size: 13px;
}

td {
  color: #25302b;
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

.status {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  color: #365149;
  background: #e8f1ed;
  font-size: 12px;
  font-weight: 800;
}

.status.won {
  color: #7a3d00;
  background: #fff0d6;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #20322c;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 180ms ease;
}

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

@media (max-width: 840px) {
  .admin-page {
    padding: 16px;
  }

  .topbar,
  .admin-grid,
  .top-actions,
  .draw-controls,
  .copy-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .admin-grid {
    max-width: 560px;
  }

  .draw-controls label,
  .draw-controls button {
    width: 100%;
  }

  .join-panel {
    padding: 26px 20px;
  }
}
