:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    Inter, ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  background: #ffffff;
  color: #1d1d1f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: #ffffff;
}

.app {
  width: min(1000px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.page-content {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

@supports (height: 100svh) {
  .page-content {
    min-height: 100svh;
  }
}

.hidden { display: none !important; }

/* --- Top bar: title left, collapsible toolbar right ---
   Full-bleed border: extend the bottom line to the full viewport width by using
   negative margins to escape the .app max-width container. */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  padding-left: calc(50vw - 50%);
  padding-right: calc(50vw - 50%);
  border-bottom: 1px solid #e5e5ea;
}

.eyebrow {
  margin: 0;
  color: #1d1d1f;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  padding-top: 6px;
}

.toolbar {
  display: flex;
  gap: 6px;
}

.tool { position: relative; }

.tool-btn {
  border: 1px solid #e5e5ea;
  background: #ffffff;
  color: #6e6e73;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 550;
  font-size: 0.84rem;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.tool-btn:hover { background: #f5f5f7; color: #1d1d1f; }
.tool-btn.active { background: #1d1d1f; color: #ffffff; border-color: #1d1d1f; }

.tool-count {
  color: #a1a1a6;
  font-weight: 500;
}
.tool-btn.active .tool-count { color: rgba(255,255,255,.65); }

.panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: 320px;
  max-width: calc(100vw - 32px);
  background: #ffffff;
  border: 1px solid #e5e5ea;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.05);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel[hidden] { display: none; }

.panel-narrow { width: 200px; }

label { font-weight: 600; font-size: 0.86rem; color: #1d1d1f; }

textarea {
  min-height: 130px;
  resize: vertical;
  border: 1px solid #e5e5ea;
  border-radius: 12px;
  padding: 12px;
  color: #1d1d1f;
  background: #fafafa;
  outline: none;
  font-size: 0.92rem;
  line-height: 1.5;
  font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}

textarea:focus { border-color: #1d1d1f; box-shadow: 0 0 0 3px rgba(29,29,31,0.06); }

.button-row { display: flex; flex-wrap: wrap; gap: 6px; }
.button-row button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  color: #ffffff;
  background: #1d1d1f;
  font-weight: 550;
  font-size: 0.8rem;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.button-row button:hover:not(:disabled) { background: #000; }
.secondary { background: #ffffff !important; color: #1d1d1f !important; border-color: #d2d2d7 !important; }
.secondary:hover:not(:disabled) { background: #f5f5f7 !important; }
.ghost { background: transparent !important; color: #6e6e73 !important; border-color: #d2d2d7 !important; border: 1px solid #d2d2d7; border-radius: 999px; padding: 7px 13px; cursor: pointer; font-weight: 550; font-size: 0.8rem; transition: background .15s ease, color .15s ease; }
.ghost:hover:not(:disabled) { background: #f5f5f7 !important; color: #1d1d1f !important; }
.ghost.small { padding: 5px 10px; font-size: 0.76rem; }

.hint { margin: 0; color: #a1a1a6; font-size: 0.78rem; }

button { font: inherit; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.panel-label {
  margin: 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #86868b;
  font-weight: 600;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.eliminated-wrap { display: flex; flex-direction: column; gap: 8px; }
.eliminated-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.eliminated-list span {
  background: #f5f5f7;
  border: 1px solid #e5e5ea;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  text-decoration: line-through;
  color: #86868b;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 220px;
  overflow-y: auto;
}
.history-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: #f5f5f7;
  border: 1px solid #ececee;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 0.8rem;
  color: #3a3a3c;
}
.history-list .h-time {
  color: #a1a1a6;
  white-space: nowrap;
  font-size: 0.75rem;
}
.history-empty {
  color: #a1a1a6;
  font-size: 0.82rem;
}

.mode-option {
  border: 0;
  background: transparent;
  color: #6e6e73;
  padding: 8px 12px;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 550;
  font-size: 0.86rem;
  text-align: left;
  transition: background .15s ease, color .15s ease;
}
.mode-option.active { background: #f5f5f7; color: #1d1d1f; }
.mode-option:hover:not(.active) { background: #fafafa; }

/* --- Wheel workspace: the wheel is the star, everything else recedes --- */
.workspace {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 10px 0;
}

.round-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: #1d1d1f;
  color: #f5f5f7;
  padding: 6px 13px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.78rem;
}

.wheel-frame {
  position: relative;
  width: min(100%, calc(100vh - 260px), 640px);
  aspect-ratio: 1 / 1;
}

@supports (height: 100svh) {
  .wheel-frame {
    width: min(100%, calc(100svh - 260px), 640px);
  }
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 12px 28px rgba(0,0,0,.1));
  transition: transform 8.6s cubic-bezier(.1,.9,.05,1);
}

.pointer {
  position: absolute;
  top: 50%;
  right: -6px;
  z-index: 3;
  transform: translate(0, -50%);
  width: 0;
  height: 0;
  border-top: 30px solid transparent;
  border-bottom: 30px solid transparent;
  border-right: 58px solid #ff3b30;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.35));
}

.spin-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.spin-button {
  min-width: 140px;
  padding: 14px 36px;
  border-radius: 999px;
  border: 0;
  background: #1d1d1f;
  color: #f5f5f7;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease;
}

.spin-button:hover:not(:disabled) { background: #000; }
.spin-button:active:not(:disabled) { transform: scale(0.96); }

.spin-hint {
  margin: 0;
  color: #a1a1a6;
  font-size: 0.8rem;
}

.spin-hint kbd {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  background: #fafafa;
  font-family: inherit;
  font-size: 0.76rem;
  color: #6e6e73;
}

.result {
  border-radius: 14px;
  padding: 10px 20px;
  background: #f5f5f7;
  font-size: 0.98rem;
  font-weight: 600;
  color: #1d1d1f;
  text-align: center;
}

.result span { color: #0071e3; }

.site-footer {
  padding: 12px 0;
  border-top: 1px solid #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.footer-left {
  color: #a3a3a3;
  font-size: 0.75rem;
  font-weight: 400;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.footer-links a {
  color: #a3a3a3;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  transition: color .15s ease;
}

.footer-links a:hover { color: #525252; }

.footer-icon {
  width: 12px;
  height: 12px;
  display: block;
}

@media (max-width: 600px) {
  .app { padding: 16px 0 28px; }
  .toolbar { gap: 4px; }
  .tool-btn { padding: 6px 11px; font-size: 0.78rem; }
  .panel {
    position: fixed;
    top: 68px;
    left: 16px;
    right: 16px;
    width: auto;
    max-width: none;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
  }
}

@media (max-width: 480px) {
  .pointer {
    right: -4px;
    border-top-width: 22px;
    border-bottom-width: 22px;
    border-right-width: 42px;
  }
}
