:root {
  color-scheme: dark;
  --bg: #11101d;
  --panel: #1c1a2d;
  --muted: #aaa7c0;
  --accent: #8b5cf6;
  --line: #353149
}

* {
  box-sizing: border-box
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #292044 0, #11101d 48%);
  color: #fff;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  padding: 20px
}

main {
  width: min(1050px, 100%);
  margin: auto
}

header {
  text-align: center;
  margin: 8px 0 24px
}

h1 {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  margin: 0 0 6px
}

header p {
  color: var(--muted);
  margin: 0
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, .9fr);
  gap: 22px;
  align-items: center
}

.panel {
  background: rgba(28, 26, 45, .94);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 18px 55px #0005
}

.wheel-wrap {
  position: relative;
  width: min(min(78vw, 540px), 100%);
  aspect-ratio: 1;
  margin: 0 auto 18px
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 12px 18px #0006)
}

.pointer {
  position: absolute;
  z-index: 2;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 17px solid transparent;
  border-right: 17px solid transparent;
  border-top: 38px solid #fff;
  filter: drop-shadow(0 3px 3px #0008)
}

.spin {
  display: block;
  width: min(100%, 320px);
  margin: 0 auto;
  border: 0;
  border-radius: 14px;
  padding: 16px 24px;
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  color: white;
  font-size: 1.15rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 22px #7c3aed55
}

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

label {
  display: block;
  font-weight: 700;
  margin-bottom: 9px
}

textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border: 1px solid #48435f;
  border-radius: 13px;
  background: #12111e;
  color: white;
  padding: 14px;
  font: inherit;
  line-height: 1.55;
  outline: none
}

textarea:focus {
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px #8b5cf633
}

.hint {
  font-size: .88rem;
  color: var(--muted);
  margin: 8px 0 14px
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap
}

.secondary {
  border: 1px solid #514b6a;
  background: #29263d;
  color: #fff;
  border-radius: 11px;
  padding: 11px 14px;
  font-weight: 650;
  cursor: pointer
}

.count {
  color: var(--muted);
  font-size: .9rem;
  margin: 14px 0 0
}

.winner-history-button {
  display: block;
  margin: 12px auto 0
}

.history {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line)
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px
}

.history-head strong {
  font-size: .98rem
}

.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 150px;
  overflow: auto
}

.history-name {
  border: 1px solid #514b6a;
  background: #29263d;
  color: #eee;
  border-radius: 999px;
  padding: 7px 11px;
  cursor: pointer;
  font: inherit;
  font-size: .88rem
}

.history-name:active {
  background: #59428d
}

.history-empty {
  color: var(--muted);
  font-size: .88rem;
  margin: 0
}

.history-dialog {
  width: min(92%, 480px);
  max-height: 82vh;
  overflow: hidden;
  padding: 24px;
  text-align: left
}

.history-dialog h2 {
  margin: 0;
  font-size: 1.25rem
}

.winner-history-list {
  max-height: min(48vh, 360px);
  overflow-y: auto;
  list-style: none;
  margin: 18px 0;
  padding: 0
}

.winner-record {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-wrap: anywhere;
  padding: 12px 0;
  border-bottom: 1px solid var(--line)
}

.winner-record:last-child {
  border-bottom: 0
}

.winner-record time {
  color: var(--muted);
  font-size: .88rem
}

.winner-history-empty {
  color: var(--muted);
  margin: 0;
  padding: 24px 0;
  text-align: center
}

.dialog-actions {
  display: flex;
  gap: 10px
}

.dialog-actions .secondary,
.dialog-actions .close {
  flex: 1;
  width: auto
}

dialog {
  width: min(90%, 420px);
  border: 1px solid #554a78;
  border-radius: 22px;
  background: #211d35;
  color: white;
  padding: 28px;
  text-align: center;
  box-shadow: 0 25px 80px #000a
}

dialog::backdrop {
  background: #05040bcc;
  backdrop-filter: blur(5px)
}

.winner-label {
  color: #c4b5fd;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .8rem;
  font-weight: 800
}

.winner-name {
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 900;
  overflow-wrap: anywhere;
  margin: 12px 0 22px
}

.close {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 13px;
  background: #8b5cf6;
  color: white;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer
}

@media(max-width:760px) {
  body {
    padding: 14px
  }

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

  .panel {
    padding: 16px
  }

  .wheel-wrap {
    width: min(82vw, 440px)
  }

  textarea {
    min-height: 170px
  }
}
