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

:root {
  --bg:          #111111;
  --surface:     #1c1c1e;
  --surface2:    #2c2c2e;
  --accent:      #00cfff;
  --accent-dark: #0099cc;
  --text:        #f0f0f0;
  --text-muted:  #8e8e93;
  --radius:      14px;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1;
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 20px;
  text-align: center;
}

footer {
  padding: 24px 20px;
  text-align: center;
  font-size: 0.8rem;
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
}

footer a:hover {
  color: var(--accent);
}

/* ── Breadcrumb ──────────────────────────────────────────────── */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-align: left;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 28px;
}

/* ── Input row ───────────────────────────────────────────────── */
.input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.item-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.item-input::placeholder {
  color: var(--text-muted);
}

.item-input:focus {
  border-color: var(--accent);
}

.add-btn {
  width: 48px;
  flex-shrink: 0;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.add-btn:hover {
  background: var(--accent-dark);
}

.add-btn:active {
  transform: scale(0.95);
}

/* ── Item list ───────────────────────────────────────────────── */
.item-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
  min-height: 0;
}

.item-list:empty {
  margin-bottom: 0;
}

.item-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 20px;
  padding: 6px 10px 6px 14px;
  font-size: 0.9rem;
}

.item-tag .color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.item-tag .remove-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s ease;
}

.item-tag .remove-btn:hover {
  color: #ff4d4d;
}

/* ── Wheel ───────────────────────────────────────────────────── */
/* ── Settings ─────────────────────────────────────────────────── */
.settings-wrapper {
  position: absolute;
  top: 44px;
  left: 4px;
  z-index: 4;
}

.settings-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--surface2);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.settings-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

/* ── Info button & popup ──────────────────────────────────────── */
.info-wrapper {
  position: absolute;
  top: 44px;
  right: 4px;
  z-index: 4;
}

.info-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--surface2);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.info-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.info-popup {
  display: none;
  position: absolute;
  top: 40px;
  right: 0;
  width: 240px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  text-align: left;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.info-popup.visible {
  display: block;
}

.info-popup p {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text);
  margin: 0;
}

.settings-popup {
  display: none;
  position: absolute;
  top: 40px;
  left: 0;
  width: 200px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.settings-popup.visible {
  display: block;
}

.settings-popup label {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 8px;
}

.speed-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.speed-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  outline: none;
}

.speed-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

.speed-row input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.speed-row #speed-value {
  font-size: 0.85rem;
  color: var(--text);
  min-width: 32px;
}

.setting-divider {
  height: 1px;
  background: var(--surface2);
  margin: 12px 0;
}

/* ── Score toggle ────────────────────────────────────────────── */
.toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  margin-bottom: 0;
}

.toggle-label span:first-child {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.toggle-label input {
  display: none;
}

.toggle-switch {
  width: 36px;
  height: 20px;
  background: var(--surface2);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.2s ease, background 0.2s ease;
}

.toggle-label input:checked + .toggle-switch {
  background: var(--accent-dark);
}

.toggle-label input:checked + .toggle-switch::after {
  transform: translateX(16px);
  background: var(--accent);
}

/* ── Score badge ─────────────────────────────────────────────── */
.score-badge {
  background: var(--accent);
  color: var(--bg);
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: 10px;
  padding: 0 6px;
  margin-left: 6px;
}

.reset-btn {
  display: none;
  width: 100%;
  margin-top: 10px;
  padding: 8px;
  background: var(--surface2);
  border: none;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.reset-btn.visible {
  display: block;
}

.reset-btn:hover {
  background: #3a3a3c;
}

.wheel-wrapper {
  position: relative;
  display: inline-block;
  margin-top: 16px;
  margin-bottom: 24px;
}

/* pointer is drawn on canvas now */

.current-label {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 10px;
  padding: 6px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 8px;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas {
  display: block;
  position: relative;
  z-index: 1;
}

/* ── Spin button ─────────────────────────────────────────────── */
.spin-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
  margin-bottom: 20px;
}

.spin-btn:hover:not(:disabled) {
  background: var(--accent-dark);
}

.spin-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.spin-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Backdrop ────────────────────────────────────────────────── */
.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2;
}

.backdrop.visible {
  display: block;
}

/* ── Result popup ────────────────────────────────────────────── */
.result-overlay {
  display: none;
  position: absolute;
  left: -4px;
  right: -4px;
  top: 50%;
  transform: translateY(-50%);
  height: 180px;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  z-index: 3;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.result-overlay.visible {
  display: flex;
}

.result-overlay span {
  flex: 1;
  display: flex;
  align-items: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  padding: 0 24px;
  text-align: center;
  word-break: break-word;
}

.result-overlay .close-btn {
  background: var(--surface2);
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 28px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease;
  margin-bottom: 16px;
}

.result-overlay .close-btn:hover {
  background: #3a3a3c;
}
