:root {
  --paper: #f7f3ec;
  --ink: #20201f;
  --muted: #77736d;
  --line: #ded8ce;
  --purple: #8e64d6;
  --purple-dark: #5c3b9d;
  --yellow: #f4c943;
  --coral: #f28b73;
  --teal: #66baa9;
  --cream: #fffdf8;
  --shadow: 0 24px 70px rgba(68, 52, 39, .13);
  --radius: 24px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "DM Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(142, 100, 214, .25); outline-offset: 3px; }

.paper-noise {
  position: fixed; inset: 0; pointer-events: none; z-index: 10; opacity: .2;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.12'/%3E%3C/svg%3E");
}

.site-header {
  height: 88px; padding: 0 clamp(24px, 6vw, 96px); border-bottom: 1px solid rgba(54, 49, 43, .13);
  display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 5;
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font: 800 18px/1 "Manrope", sans-serif; letter-spacing: .08em; }
.brand-dot { color: var(--purple); }
.brand-mark { width: 32px; height: 32px; border-radius: 50%; background: var(--purple); position: relative; display: grid; place-items: center; transform: rotate(-9deg); }
.brand-mark span { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #fff; }
.brand-mark span:nth-child(1) { transform: translate(-7px, -4px); }
.brand-mark span:nth-child(2) { transform: translate(7px, -4px); }
.brand-mark span:nth-child(3) { width: 13px; height: 6px; background: transparent; border-bottom: 2px solid #fff; transform: translateY(5px); }

.button { border: 0; border-radius: 999px; min-height: 44px; padding: 0 20px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; font-weight: 700; cursor: pointer; transition: transform .2s, background .2s, box-shadow .2s; }
.button:hover { transform: translateY(-2px); }
.button:active { transform: translateY(0); }
.button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.button-ghost { background: transparent; border: 1px solid var(--ink); }
.button-ghost:hover { background: var(--ink); color: #fff; }
.button-dark { background: var(--ink); color: #fff; }
.button-primary { background: var(--purple); color: #fff; box-shadow: 0 8px 20px rgba(112, 71, 182, .24); }
.button-danger { color: #bd4f43; background: #fff0ed; }
.button-small { min-height: 36px; padding: 0 15px; }
.button-wide { width: 100%; }

main { width: min(1220px, calc(100% - 48px)); margin: 0 auto; padding: 54px 0 88px; }
.hero-copy { text-align: center; position: relative; z-index: 1; }
.eyebrow, .kicker { font: 700 11px/1 "Manrope", sans-serif; letter-spacing: .18em; text-transform: uppercase; color: #5b5751; }
.eyebrow { display: flex; gap: 8px; align-items: center; justify-content: center; }
.eyebrow span { width: 18px; height: 1px; background: var(--purple); }
.hero-copy h1 { margin: 15px 0 12px; font: 800 clamp(48px, 5.6vw, 76px)/.94 "Manrope", sans-serif; letter-spacing: -.065em; }
.hero-copy h1 em { color: var(--purple); font-family: Georgia, serif; font-weight: 400; letter-spacing: -.045em; position: relative; }
.hero-copy h1 em::after { content: ""; position: absolute; left: 3%; right: 0; bottom: -8px; height: 9px; border-top: 3px solid var(--yellow); border-radius: 50%; transform: rotate(-2deg); }
.hero-copy p { color: var(--muted); margin: 22px 0 0; font-size: 15px; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(360px, .92fr); gap: clamp(44px, 7vw, 100px); align-items: center; margin-top: 42px; }
.wheel-side { min-width: 0; }
.wheel-stage { width: min(560px, 100%); aspect-ratio: 1; margin: 0 auto; position: relative; display: grid; place-items: center; }
.wheel-rim { width: 91%; aspect-ratio: 1; border-radius: 50%; padding: 11px; background: #fffaf1; border: 2px solid var(--ink); box-shadow: 0 24px 55px rgba(75, 59, 45, .17), inset 0 0 0 4px #fff; position: relative; }
#wheelCanvas { width: 100%; height: 100%; border-radius: 50%; display: block; transition: transform 5.4s cubic-bezier(.13,.74,.12,1); }
.wheel-pointer { width: 48px; position: absolute; z-index: 4; top: -1px; left: 50%; transform: translateX(-50%); filter: drop-shadow(0 5px 2px rgba(46,36,29,.14)); }
.wheel-pointer svg { display: block; width: 100%; fill: var(--ink); stroke: #fffaf1; stroke-width: 2; }
.wheel-center { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); z-index: 3; width: 102px; height: 102px; border-radius: 50%; border: 7px solid rgba(255,255,255,.8); color: #fff; background: var(--ink); box-shadow: 0 9px 22px rgba(36, 27, 21, .3); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; transition: transform .2s, background .2s; }
.wheel-center:hover { transform: translate(-50%, -50%) scale(1.06); background: #353331; }
.wheel-center:active { transform: translate(-50%, -50%) scale(.98); }
.wheel-center:disabled { cursor: wait; }
.wheel-center strong { font: 800 12px/1 "Manrope", sans-serif; letter-spacing: .08em; }
.play-icon { width: 0; height: 0; border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-left: 13px solid var(--yellow); margin: 0 0 7px 3px; }
.spark { position: absolute; font-size: 34px; color: var(--yellow); }
.spark-one { left: 3px; top: 12%; transform: rotate(13deg); }
.spark-two { right: 0; bottom: 17%; color: var(--purple); font-size: 23px; }
.doodle { position: absolute; left: 0; bottom: 5%; font: 58px/1 Georgia,serif; color: var(--coral); transform: rotate(-35deg); }
.spin-hint { display: flex; justify-content: center; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.spin-hint span { color: var(--purple); font: 24px/1 Georgia,serif; }

.info-side { display: flex; flex-direction: column; gap: 14px; }
.stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stat-card { background: rgba(255,255,255,.57); border: 1px solid rgba(63,56,48,.12); border-radius: 18px; padding: 17px; display: flex; align-items: center; gap: 13px; }
.stat-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 13px; font-size: 22px; }
.stat-icon-purple { color: #fff; background: var(--purple); }
.stat-icon-yellow { background: var(--yellow); }
.stat-card div { display: flex; flex-direction: column; }
.stat-card strong { font: 800 24px/1 "Manrope",sans-serif; }
.stat-card small { color: var(--muted); font-size: 11px; margin-top: 5px; }

.participants-card { background: var(--cream); border: 1px solid rgba(63,56,48,.15); border-radius: var(--radius); padding: 24px; box-shadow: 0 13px 35px rgba(70, 53, 39, .06); }
.card-heading { display: flex; justify-content: space-between; align-items: center; }
.card-heading h2, .panel-header h2 { font: 800 22px/1.15 "Manrope", sans-serif; margin: 5px 0 0; letter-spacing: -.03em; }
.kicker { color: var(--purple-dark); font-size: 9px; }
.icon-button, .close-button { border: 1px solid var(--line); background: transparent; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.icon-button { width: 38px; height: 38px; }
.icon-button:hover, .close-button:hover { background: #eee8df; }
.icon-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.legend { display: flex; gap: 16px; margin: 18px 0 15px; padding-bottom: 14px; border-bottom: 1px dashed var(--line); color: var(--muted); font-size: 10px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.legend-dot.regular { background: var(--teal); }
.legend-dot.late { background: var(--coral); }
.participant-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; max-height: 208px; overflow-y: auto; padding-right: 3px; }
.participant-chip { min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px; display: flex; align-items: center; gap: 9px; background: #fff; font-size: 12px; font-weight: 600; }
.participant-chip.is-late { background: #fff4ef; border-color: #f0c8be; }
.participant-chip .avatar { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center; color: #fff; font: 700 10px "Manrope",sans-serif; background: var(--teal); }
.participant-chip.is-late .avatar { background: var(--coral); }
.participant-chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.participant-chip .late-icon { margin-left: auto; color: #c46756; }
.empty-state { text-align: center; padding: 28px 0 18px; color: var(--muted); }
.empty-state span { color: var(--yellow); font-size: 30px; }
.empty-state p { margin: 5px 0; }
.empty-state button { border: 0; color: var(--purple-dark); background: transparent; text-decoration: underline; cursor: pointer; }

.history-card { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: rgba(255,255,255,.5); }
.history-toggle { width: 100%; min-height: 48px; padding: 0 16px; border: 0; background: transparent; display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-size: 12px; }
.history-toggle > span { display: flex; align-items: center; gap: 8px; }
.history-icon { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: #dff1ed; color: #388578; font-weight: 700; }
.history-toggle svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform .2s; }
.history-card.open .history-toggle svg { transform: rotate(180deg); }
.history-list { display: none; list-style: none; margin: 0; padding: 0 16px 12px; }
.history-card.open .history-list { display: block; }
.history-list li { display: flex; gap: 10px; padding: 9px 0; border-top: 1px dashed var(--line); font-size: 12px; }
.history-list li span:first-child { width: 20px; color: var(--purple); font-weight: 700; }
.history-list time { color: var(--muted); margin-left: auto; }
.fairness-note { display: flex; align-items: flex-start; gap: 12px; padding: 2px 4px; color: var(--muted); }
.fairness-note svg { width: 25px; flex: 0 0 auto; fill: none; stroke: var(--purple); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.fairness-note div { display: flex; flex-direction: column; }
.fairness-note strong { color: #55504b; font-size: 11px; }
.fairness-note span { font-size: 10px; margin-top: 2px; line-height: 1.45; }

footer { min-height: 84px; border-top: 1px solid var(--line); padding: 0 clamp(24px, 6vw, 96px); display: flex; align-items: center; gap: 24px; font-size: 11px; color: var(--muted); }
footer > span:first-child { font: 800 11px "Manrope",sans-serif; letter-spacing: .08em; color: var(--ink); }
.footer-spark { margin-left: auto; color: var(--purple); font-size: 18px; }

.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(26,23,20,.48); backdrop-filter: blur(7px); display: flex; align-items: stretch; justify-content: flex-end; animation: fadeIn .2s ease; }
.overlay[hidden] { display: none; }
.settings-panel { width: min(520px, 100%); min-width: 0; background: var(--paper); box-shadow: -24px 0 70px rgba(22,17,14,.2); display: flex; flex-direction: column; animation: slideIn .28s ease; }
.panel-header { padding: 27px 28px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.close-button { width: 38px; height: 38px; font: 400 26px/1 sans-serif; }
.panel-body { padding: 25px 28px; flex: 1; overflow-y: auto; }
.add-form label, .bulk-box label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.input-row { display: flex; gap: 9px; }
.input-row input { min-width: 0; }
.input-row .button { flex: 0 0 auto; }
input, textarea { width: 100%; border: 1px solid #cbc4ba; border-radius: 12px; background: #fffdf9; color: var(--ink); padding: 12px 14px; transition: border .2s, box-shadow .2s; }
input:focus, textarea:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(142,100,214,.1); outline: 0; }
.field-error { min-height: 17px; color: #ba4d42; font-size: 11px; margin: 5px 0 0; }
.settings-list-heading { margin: 18px 0 11px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.settings-list-heading > div { display: flex; flex-direction: column; }
.settings-list-heading strong { font-size: 13px; }
.settings-list-heading span { color: var(--muted); font-size: 10px; }
.text-button { color: var(--purple-dark); border: 0; background: transparent; font-size: 11px; font-weight: 700; text-align: right; cursor: pointer; }
.bulk-box { border: 1px dashed #b9ada2; border-radius: 14px; padding: 14px; margin-bottom: 12px; background: rgba(255,255,255,.5); }
.bulk-box textarea { resize: vertical; min-height: 100px; }
.bulk-box div { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.settings-names { display: flex; flex-direction: column; gap: 7px; }
.setting-row { display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 10px; border: 1px solid var(--line); background: #fffdf9; padding: 10px 10px 10px 13px; border-radius: 12px; }
.setting-person { min-width: 0; display: flex; flex-direction: column; }
.setting-person strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.setting-person span { color: var(--muted); font-size: 9px; }
.late-switch { display: inline-flex; align-items: center; gap: 7px; font-size: 10px; color: var(--muted); cursor: pointer; }
.late-switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { width: 32px; height: 18px; border-radius: 20px; background: #d4cec5; padding: 2px; transition: background .2s; }
.switch-track::after { content: ""; display: block; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.late-switch input:checked + .switch-track { background: var(--coral); }
.late-switch input:checked + .switch-track::after { transform: translateX(14px); }
.remove-button { width: 30px; height: 30px; border: 0; border-radius: 9px; color: #aa6e65; background: #fff0ed; cursor: pointer; font-size: 17px; }
.panel-footer { padding: 17px 28px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }

.winner-overlay { justify-content: center; align-items: center; padding: 20px; }
.winner-modal { width: min(430px, 100%); background: var(--cream); border-radius: 28px; padding: 39px 38px 34px; text-align: center; position: relative; box-shadow: var(--shadow); overflow: hidden; animation: popIn .35s cubic-bezier(.17,.89,.35,1.3); }
.winner-close { position: absolute; right: 16px; top: 16px; z-index: 2; }
.winner-crown { display: grid; place-items: center; width: 67px; height: 67px; margin: 0 auto 19px; border-radius: 50%; color: var(--purple-dark); background: var(--yellow); font-size: 35px; transform: rotate(-6deg); }
.winner-modal h2 { font: 800 30px/1 "Manrope",sans-serif; margin: 9px 0 20px; }
.winner-names { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.winner-name { background: #f3edf9; border: 1px solid #d7c5ed; border-radius: 16px; padding: 14px 10px; color: var(--purple-dark); overflow-wrap: anywhere; }
.winner-name span { display: block; margin-bottom: 4px; color: #8d7aa7; font: 700 9px/1 "Manrope",sans-serif; letter-spacing: .12em; text-transform: uppercase; }
.winner-name strong { font: 800 clamp(18px,5vw,26px)/1.1 "Manrope",sans-serif; }
.winner-modal p { color: var(--muted); font-size: 13px; margin: 17px 0 23px; }
.confetti i { position: absolute; width: 8px; height: 18px; border-radius: 3px; background: var(--coral); transform: rotate(24deg); }
.confetti i:nth-child(1) { left: 10%; top: 12%; background: var(--yellow); transform: rotate(-30deg); }
.confetti i:nth-child(2) { left: 20%; top: 28%; background: var(--teal); transform: rotate(55deg); }
.confetti i:nth-child(3) { right: 13%; top: 16%; background: var(--purple); transform: rotate(32deg); }
.confetti i:nth-child(4) { right: 24%; top: 32%; background: var(--yellow); transform: rotate(-58deg); }
.confetti i:nth-child(5) { left: 7%; top: 54%; background: var(--purple); transform: rotate(65deg); }
.confetti i:nth-child(6) { right: 8%; top: 57%; background: var(--teal); transform: rotate(-22deg); }
.confetti i:nth-child(7) { left: 29%; top: 8%; height: 9px; background: var(--coral); transform: rotate(80deg); }
.confetti i:nth-child(8) { right: 32%; top: 8%; height: 9px; background: var(--yellow); transform: rotate(-80deg); }
.toast { position: fixed; z-index: 40; left: 50%; bottom: 26px; transform: translate(-50%, 20px); padding: 11px 17px; border-radius: 999px; color: #fff; background: var(--ink); box-shadow: 0 10px 28px rgba(0,0,0,.2); font-size: 12px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideIn { from { transform: translateX(100%); } }
@keyframes popIn { from { opacity: 0; transform: scale(.85); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

@media (max-width: 920px) {
  .game-layout { grid-template-columns: 1fr; gap: 35px; }
  .info-side { width: min(570px,100%); margin: 0 auto; }
  .wheel-stage { width: min(530px, 100%); }
}
@media (max-width: 560px) {
  .site-header { height: 70px; padding: 0 18px; }
  .brand { font-size: 14px; gap: 9px; }
  .brand-mark { width: 28px; height: 28px; }
  .button-ghost { font-size: 0; padding: 0; width: 43px; height: 43px; }
  .button-ghost svg { width: 20px; }
  main { width: min(100% - 28px, 500px); padding: 37px 0 57px; }
  .hero-copy h1 { font-size: clamp(43px,15vw,62px); }
  .hero-copy p { font-size: 13px; padding: 0 20px; }
  .game-layout { margin-top: 32px; }
  .wheel-rim { width: 94%; padding: 7px; }
  .wheel-center { width: 82px; height: 82px; border-width: 5px; }
  .wheel-pointer { width: 39px; }
  .spark-one { left: -5px; }
  .doodle { display: none; }
  .stats-row { gap: 8px; }
  .stat-card { padding: 12px 10px; gap: 8px; }
  .stat-icon { width: 34px; height: 34px; font-size: 18px; border-radius: 10px; }
  .stat-card strong { font-size: 19px; }
  .stat-card small { font-size: 9px; }
  .participants-card { padding: 19px 16px; border-radius: 20px; }
  .participant-grid { grid-template-columns: 1fr 1fr; }
  .participant-chip { padding: 8px; gap: 7px; }
  .participant-chip .avatar { width: 23px; height: 23px; border-radius: 7px; }
  footer { padding: 19px 20px; min-height: 70px; }
  footer p { display: none; }
  .panel-header, .panel-body { padding-left: 20px; padding-right: 20px; }
  .panel-footer { padding: 13px 20px; }
  .panel-footer .button { padding: 0 15px; font-size: 12px; }
  .settings-list-heading .text-button { max-width: 150px; }
  .late-switch > span:first-child { display: none; }
  .winner-modal { padding: 35px 22px 27px; }
  .winner-names { grid-template-columns: 1fr; }
}
