:root {
  --bg: #f6f5f1;
  --ink: #181816;
  --muted: #74716a;
  --line: #dedbd2;
  --panel: #ffffff;
  --accent: #0f8b8d;
  --accent-dark: #086467;
  --danger: #d64232;
  --soft: #eaf5f4;
  --shadow: 0 24px 70px rgba(39, 37, 29, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 0%, rgba(15, 139, 141, 0.12), transparent 32rem),
    linear-gradient(140deg, #fbfaf7 0%, var(--bg) 52%, #edf2f0 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.stage,
.timeline {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(222, 219, 210, 0.88);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.stage {
  min-height: calc(100vh - 64px);
  padding: 28px;
}

.topbar,
.participants-head,
.status-row,
.timeline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.top-actions {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-gate,
.admin-only {
  display: none !important;
}

body.show-admin-gate .admin-gate {
  display: grid !important;
}

body.is-admin .admin-only {
  display: inline-flex !important;
}

body.is-admin .admin-gate {
  display: none !important;
}

.admin-gate {
  gap: 6px;
  min-width: 250px;
}

.admin-gate label {
  font-size: 0.76rem;
}

.admin-login-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.admin-message {
  min-height: 1rem;
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4.25rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.wheel-layout {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(320px, 410px);
  gap: 28px;
  margin-top: 30px;
}

.wheel-panel {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 620px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.38)),
    repeating-linear-gradient(90deg, rgba(24, 24, 22, 0.035) 0 1px, transparent 1px 72px);
}

.wheel-wrap {
  position: relative;
  width: min(76vw, 550px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.wheel {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 12px solid #fffdf8;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #d8d5cc 0deg 360deg);
  box-shadow:
    0 30px 70px rgba(30, 30, 24, 0.18),
    inset 0 0 0 2px rgba(24, 24, 22, 0.08);
  transition: transform 6.5s cubic-bezier(0.11, 0.82, 0.13, 1);
}

.wheel::before {
  position: absolute;
  inset: 13px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: inherit;
  content: "";
  pointer-events: none;
}

.wheel-labels {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  pointer-events: none;
}

.selection-banner {
  min-width: min(100%, 430px);
  margin-bottom: 18px;
  padding: 12px 18px;
  border: 1px solid rgba(15, 139, 141, 0.25);
  border-radius: 8px;
  text-align: center;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 14px 38px rgba(30, 30, 24, 0.1);
}

.selection-banner[hidden] {
  display: none;
}

.selection-banner span {
  display: block;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.selection-banner strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(1.45rem, 3vw, 2.45rem);
  font-weight: 900;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wheel-name {
  position: absolute;
  top: var(--label-y);
  left: var(--label-x);
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(var(--label-width), 34%);
  padding: 0 6px;
  color: #fff;
  font-size: var(--label-size, 1rem);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  text-align: center;
  text-shadow:
    0 2px 3px rgba(0, 0, 0, 0.8),
    0 0 10px rgba(0, 0, 0, 0.55);
  transform: translate(-50%, -50%) rotate(var(--label-rotation));
  transform-origin: center;
  white-space: nowrap;
}

.wheel-center {
  position: absolute;
  inset: 50%;
  z-index: 2;
  width: 134px;
  height: 134px;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  border: 8px solid #fffdf8;
  border-radius: 50%;
  color: #fff;
  background: #191917;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}

.wheel-center svg {
  width: 30px;
  height: 30px;
}

.wheel-center strong {
  font-size: 1rem;
}

.pointer {
  position: absolute;
  top: -4px;
  left: 50%;
  z-index: 2;
  width: 46px;
  height: 64px;
  transform: translateX(-50%);
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  background: var(--danger);
  filter: drop-shadow(0 8px 10px rgba(30, 30, 24, 0.2));
}

.wheel-wrap.is-spinning .pointer {
  animation: tick 0.16s linear infinite;
}

@keyframes tick {
  50% {
    transform: translateX(-50%) rotate(4deg);
  }
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.entry-form {
  display: grid;
  gap: 16px;
}

label,
legend {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

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

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

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 139, 141, 0.14);
}

.primary-button,
.ghost-button,
.text-button,
.social-button,
.modal-close {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
}

.primary-button {
  padding: 0 15px;
  color: #fff;
  background: var(--accent);
}

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

.ghost-button {
  padding: 0 13px;
  border-color: var(--line);
  color: var(--ink);
  background: #fff;
}

.text-button {
  min-height: 34px;
  padding: 0;
  color: var(--accent-dark);
  background: transparent;
}

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

.social-button {
  width: 100%;
  min-height: 64px;
  min-width: 0;
  padding: 0 18px;
  border-width: 2px;
  border-color: var(--line);
  border-radius: 13px;
  color: var(--ink);
  background: #fbfaf7;
  font-size: 1.12rem;
  line-height: 1;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.social-button:hover {
  transform: translateY(-1px);
}

.social-button[data-platform="youtube"] {
  border-color: rgba(255, 0, 0, 0.32);
  color: #c90000;
  background: #fff3f3;
}

.social-button[data-platform="instagram"] {
  border-color: rgba(193, 53, 132, 0.34);
  color: #c13584;
  background: linear-gradient(90deg, rgba(245, 133, 41, 0.12), rgba(221, 42, 123, 0.12), rgba(81, 91, 212, 0.12));
}

.social-button[data-platform="facebook"] {
  border-color: rgba(24, 119, 242, 0.34);
  color: #1877f2;
  background: #eff6ff;
}

.social-button[data-platform="tiktok"] {
  border-color: rgba(1, 1, 1, 0.2);
  color: #111;
  background: linear-gradient(90deg, rgba(37, 244, 238, 0.12), #fbfaf7 38%, rgba(254, 44, 85, 0.12));
}

.social-grid.needs-selection .social-button {
  border-color: rgba(214, 66, 50, 0.72);
  background: rgba(214, 66, 50, 0.06);
  box-shadow: inset 0 0 0 1px rgba(214, 66, 50, 0.22), 0 10px 24px rgba(214, 66, 50, 0.12);
}

.social-hint {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin: 12px 0 0;
  padding: 0 14px;
  border: 2px solid rgba(214, 66, 50, 0.62);
  border-radius: 8px;
  color: #9d271f;
  background: #fff1ee;
  font-size: 1rem;
  font-weight: 800;
}

.social-hint[hidden] {
  display: none;
}

.social-button.is-selected {
  color: #fff;
  box-shadow: 0 12px 28px rgba(20, 20, 20, 0.16);
}

.social-button.is-selected[data-platform="youtube"] {
  border-color: #ff0000;
  background: #ff0000;
}

.social-button.is-selected[data-platform="instagram"] {
  border-color: #dd2a7b;
  background: linear-gradient(90deg, #f58529, #dd2a7b 48%, #8134af 72%, #515bd4);
}

.social-button.is-selected[data-platform="facebook"] {
  border-color: #1877f2;
  background: #1877f2;
}

.social-button.is-selected[data-platform="tiktok"] {
  border-color: #111;
  background: linear-gradient(90deg, #25f4ee 0 6px, #111 6px calc(100% - 6px), #fe2c55 calc(100% - 6px));
}

.tiktok-mark {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  font-size: 1.18rem;
  line-height: 1;
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.35;
}

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

.summary-grid > div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
}

.metric {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.metric-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.participant-list,
.history-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.participant-list {
  max-height: 320px;
  overflow: auto;
}

.participant-item,
.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
}

.participant-item.is-kicked {
  animation: kicked 0.65s ease forwards;
}

@keyframes kicked {
  to {
    opacity: 0;
    transform: translateX(28px) scale(0.96);
  }
}

.person-name {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.platform-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  background: var(--soft);
}

.status-row {
  width: min(100%, 550px);
  margin-top: 22px;
  color: var(--muted);
  font-weight: 800;
}

.status-row span:last-child {
  color: var(--accent-dark);
}

.timeline {
  margin-top: 18px;
  padding: 20px;
  align-items: flex-start;
}

.history-list {
  width: min(100%, 620px);
}

.history-item {
  grid-template-columns: auto 1fr auto;
}

.history-index {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
  background: var(--danger);
}

.winner-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 24, 22, 0.45);
}

.winner-modal[hidden] {
  display: none;
}

.winner-card {
  position: relative;
  width: min(440px, 100%);
  padding: 34px;
  border-radius: 8px;
  text-align: center;
  background: #fffdf8;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.28);
}

.winner-card h2 {
  margin: 4px 0 10px;
  font-size: clamp(2rem, 7vw, 3.4rem);
}

.winner-card p:last-of-type {
  margin-bottom: 26px;
  color: var(--muted);
  font-weight: 700;
}

.winner-badge {
  width: 60px;
  height: 60px;
  margin-bottom: 12px;
  color: #c99415;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  min-height: 38px;
  border-color: var(--line);
  background: transparent;
}

@media (max-width: 920px) {
  .stage {
    min-height: auto;
  }

  .wheel-layout,
  .timeline {
    grid-template-columns: 1fr;
  }

  .wheel-panel {
    min-height: auto;
  }

  .timeline {
    display: grid;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .stage,
  .control-panel,
  .timeline {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions,
  .admin-gate {
    width: 100%;
  }

  .input-row,
  .admin-login-row,
  .social-grid {
    grid-template-columns: 1fr;
  }

  .wheel-center {
    width: 106px;
    height: 106px;
  }

  .wheel-name {
    width: min(var(--label-width), 33%);
    font-size: clamp(0.58rem, calc(var(--label-size, 0.8rem) * 0.82), 1.28rem);
  }

  .status-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
}
