:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #141723;
  --muted: #586074;
  --accent: #0f8a8d;
  --accent-2: #ff7d55;
  --ring: #dce3ec;
  --danger: #ba2f3b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Avenir Next', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 15%, #ffffff, transparent 45%),
    radial-gradient(circle at 85% 80%, #eaf1ff, transparent 50%),
    var(--bg);
}

h1,
h2,
p {
  margin: 0;
}

.page {
  min-height: 100vh;
  width: min(900px, 100% - 1rem);
  margin: 0 auto;
  padding: 1rem 0 2rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  align-items: start;
}


.discord-top-spacer {
  width: 100%;
  height: 0;
}

.is-discord-embed .discord-top-spacer {
  height: 10.5rem;
  height: calc(env(safe-area-inset-top) + 10.5rem);
}

.roulette-panel,
.stats-panel,
.settings-panel {
  background: var(--panel);
  border: 1px solid var(--ring);
  border-radius: 16px;
  box-shadow: 0 15px 35px rgba(11, 30, 60, 0.08);
}

.roulette-panel {
  padding: 0.6rem;
}

.roulette-wrap {
  position: relative;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
}

#wheel {
  width: 100%;
  height: 100%;
  display: block;
}

.pointer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pointer::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7%;
  aspect-ratio: 364 / 1500;
  transform-origin: 50% 100%;
  transform: translate(-50%, -100%) rotate(90deg);
  background-image: url('./images/nakayubi.png');
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center top;
}

.pointer::after {
  content: none;
}

.hub {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: #0b1320;
  transform: translate(-50%, -50%);
}

.controls {
  padding: 2.4rem 1rem 1rem;
  display: grid;
  gap: 1.8rem;
  justify-items: center;
}

.winner-history {
  width: 100%;
  text-align: center;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.status {
  color: var(--muted);
  font-size: 0.95rem;
}

.winner {
  font-size: 1.7rem;
  font-weight: 700;
  padding: 0.4rem 0;
  line-height: 1.25;
}

.btn-primary,
.btn-secondary,
.link-button {
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.3rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: linear-gradient(120deg, var(--accent), #1ca0a3);
  color: #fff;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.link-button.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-secondary,
.link-button {
  background: #edf3f8;
  color: #1e2a3f;
}

.stats-panel {
  padding: 1rem;
  display: grid;
  gap: 0.8rem;
}

.participant-stats,
.participants-list {
  display: grid;
  gap: 0.65rem;
}

.participant-item {
  border: 1px solid var(--ring);
  border-radius: 14px;
  padding: 0.65rem 0.8rem;
  display: grid;
  gap: 0.35rem;
  background: #fbfdff;
}

.participant-item h3 {
  margin: 0;
  font-size: 1rem;
}

.dimmed {
  color: var(--danger);
}

.note {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.settings-page {
  grid-template-columns: 1fr;
  max-width: 900px;
}

.bottom-settings {
  grid-column: 1 / -1;
  justify-self: center;
  align-self: end;
  padding-top: 0.4rem;
}

.settings-panel {
  padding: 1.1rem;
  display: grid;
  gap: 1rem;
}

body.roulette-screen .page {
  min-height: 100dvh;
  height: 100dvh;
  padding-bottom: 0.8rem;
  gap: 0.7rem;
}

body.roulette-screen .roulette-panel {
  padding: 0.45rem;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

body.roulette-screen .roulette-wrap {
  width: min(100%, max(220px, min(calc(100dvh - 25rem), 80vw)));
  max-width: 680px;
}

body.roulette-screen .controls {
  padding: 1.3rem 0.7rem 0.4rem;
  gap: 0.7rem;
}

body.roulette-screen .winner {
  font-size: 1.5rem;
}

body.roulette-screen .stats-panel {
  padding: 0.7rem;
  gap: 0.4rem;
}

body.roulette-screen .bottom-settings {
  padding-top: 0;
}

@media (min-width: 1024px) and (min-height: 640px) {
  .is-discord-embed .discord-top-spacer {
    height: 0;
  }

  body.roulette-screen .roulette-wrap {
    width: min(100%, max(320px, min(calc(100dvh - 20rem), 68vw)));
    max-width: 860px;
  }

  .is-discord-embed body.roulette-screen .page {
    width: min(1400px, 100% - 1rem);
  }

  .is-discord-embed body.roulette-screen .roulette-wrap {
    width: min(100%, max(420px, min(calc(100dvh - 11rem), 90vw)));
    max-width: 1220px;
  }
}

.settings-header,
.participants-header,
.row-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.settings-block {
  border: 1px solid var(--ring);
  border-radius: 14px;
  padding: 0.8rem;
  display: grid;
  gap: 0.6rem;
}

.field-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.slider-row {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: 1fr auto;
  align-items: center;
}

.slider-row input[type='range'] {
  width: 100%;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.participant-edit {
  border: 1px solid var(--ring);
  border-radius: 12px;
  padding: 0.7rem;
  display: grid;
  gap: 0.55rem;
  background: #fcfdff;
}

.participant-grid {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 1fr auto;
}

.text-input {
  border: 1px solid #cfd8e3;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  font-size: 0.95rem;
  width: 100%;
}

.weight-value {
  min-width: 2ch;
  text-align: right;
  font-weight: 700;
}

.delete-btn {
  border: 0;
  border-radius: 10px;
  background: #ffe7ea;
  color: #6a1722;
  padding: 0.42rem 0.75rem;
  cursor: pointer;
  justify-self: end;
}
