*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #f5f6f8;
  --surface: #fff;
  --text: #1a1a2e;
  --muted: #5c6370;
  --accent: #e85d04;
  --border: #dde1e6;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

.header {
  padding: 1.25rem 1.5rem 0.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.layout {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem 2rem;
  align-items: flex-start;
}

.wheel-section {
  flex: 1 1 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wheel-wrap {
  position: relative;
  width: min(100%, 480px);
  aspect-ratio: 1;
}

#wheel-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: var(--shadow);
  cursor: pointer;
  background: var(--surface);
}

#wheel-canvas:disabled,
#wheel-canvas.spinning {
  cursor: wait;
}

.pointer {
  position: absolute;
  top: 50%;
  right: -4px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 14px solid transparent;
  border-bottom: 14px solid transparent;
  border-right: 22px solid var(--accent);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
  pointer-events: none;
}

.spin-hint {
  margin: 1rem 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.spin-hint.warn {
  color: #b45309;
}

.result {
  margin: 0.75rem 0 0;
  font-size: 1.25rem;
  font-weight: 600;
  text-align: center;
}

.result strong {
  color: var(--accent);
}

.sidebar {
  flex: 0 1 340px;
  min-width: 280px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.list-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.names-input {
  width: 100%;
  min-height: 200px;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
}

.names-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.btn {
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
}

.btn:hover {
  background: var(--bg);
}

.btn-secondary {
  flex: 1 1 auto;
}

.weights-panel {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.weights-panel summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  user-select: none;
}

.weights-panel-body {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.weights-table {
  width: 100%;
  border-collapse: collapse;
}

.weights-table th,
.weights-table td {
  text-align: left;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.weights-table th {
  color: var(--muted);
  font-weight: 600;
}

.history-list {
  margin: 1rem 0 0;
  padding-left: 1.25rem;
  color: var(--muted);
}

.history-list li {
  margin-bottom: 0.25rem;
}

@media (max-width: 720px) {
  .layout {
    flex-direction: column;
    align-items: stretch;
  }

  .wheel-section {
    order: -1;
  }
}
