:root {
  --ink: #172554;
  --ink-soft: #475569;
  --paper: #fff7ed;
  --card: #ffffff;
  --blue: #2563eb;
  --blue-dark: #1e40af;
  --orange: #f97316;
  --orange-text: #c2410c;
  --yellow: #facc15;
  --green: #10b981;
  --red: #dc2626;
  --line: #172554;
  --soft-line: #fed7aa;
  --shadow: 6px 6px 0 var(--line);
  --radius: 20px;
  --max-width: 1180px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 10%, rgba(250, 204, 21, 0.2), transparent 24rem),
    radial-gradient(circle at 88% 30%, rgba(37, 99, 235, 0.12), transparent 30rem),
    var(--paper);
  font-family: "Trebuchet MS", "Avenir Next", Avenir, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:not(:disabled),
a {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 4px solid var(--yellow);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 10px 14px;
  color: #fff;
  background: var(--ink);
  border-radius: 10px;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header,
.tool-nav,
main,
footer {
  width: min(calc(100% - 32px), var(--max-width));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 96px;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: clamp(8px, 1.5vw, 14px);
  color: var(--blue);
  font-size: clamp(2rem, 6vw, 3.25rem);
  font-weight: 900;
  letter-spacing: -0.08em;
  line-height: 1;
  text-decoration: none;
}

.brand__logo {
  width: clamp(28px, 4vw, 36px);
  height: auto;
  flex: 0 0 auto;
}

.brand__word {
  display: inline-block;
}

.brand .brand__bang {
  color: var(--orange);
}

.tagline {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 700;
}

.tool-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 7px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 18px;
  box-shadow: 4px 4px 0 var(--line);
}

.tool-nav__link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  gap: 10px;
  padding: 10px 16px;
  color: var(--ink);
  border-radius: 11px;
  font-weight: 900;
  text-decoration: none;
  transition: color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.tool-nav__link:hover {
  background: #eff6ff;
}

.tool-nav__link[aria-current="page"] {
  color: #fff;
  background: var(--blue);
}

.tool-nav__link:active {
  transform: translateY(1px);
}

.tool-nav svg,
.primary-button svg,
.icon-button svg,
.edit-button svg,
.remove-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

main {
  min-height: calc(100vh - 260px);
}

.tool-view {
  padding-block: clamp(46px, 8vw, 86px) 70px;
}

.view-intro {
  max-width: 650px;
  margin-bottom: 38px;
}

.eyebrow,
.step {
  margin: 0 0 6px;
  color: var(--orange-text);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.view-intro h1 {
  margin: 0;
  font-size: clamp(2.8rem, 9vw, 5.8rem);
  font-weight: 900;
  letter-spacing: -0.075em;
  line-height: 0.95;
}

.view-intro > p:last-child {
  max-width: 560px;
  margin: 18px 0 0;
  color: var(--ink-soft);
  font-size: clamp(1rem, 2vw, 1.2rem);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  align-items: start;
  gap: 28px;
}

.wheel-layout {
  grid-template-columns: minmax(0, 0.74fr) minmax(360px, 1.26fr);
}

.panel {
  min-width: 0;
  padding: clamp(20px, 4vw, 30px);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}

.panel h2 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 1.8rem);
  letter-spacing: -0.04em;
}

.count-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  color: var(--blue-dark);
  background: #dbeafe;
  border: 1px solid #93c5fd;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 900;
}

label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.88rem;
  font-weight: 900;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  gap: 8px;
}

input {
  width: 100%;
  min-height: 52px;
  padding: 11px 14px;
  color: var(--ink);
  background: #fffbeb;
  border: 2px solid var(--line);
  border-radius: 12px;
}

select {
  width: 100%;
  min-height: 48px;
  padding: 9px 38px 9px 12px;
  color: var(--ink);
  background: #fffbeb;
  border: 2px solid var(--line);
  border-radius: 12px;
  font-weight: 800;
}

.list-manager {
  padding: 14px;
  margin-bottom: 22px;
  background: #fff7ed;
  border: 2px solid var(--soft-line);
  border-radius: 14px;
}

.list-actions,
.list-editor__actions,
.wheel-toolbar,
.mode-switch,
.elimination-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-actions {
  flex-wrap: wrap;
  margin-top: 8px;
}

.list-actions button,
.wheel-toolbar button,
.elimination-bar button {
  min-height: 44px;
  padding: 8px 12px;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 900;
}

.list-actions .danger {
  color: var(--red);
}

.list-editor {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--soft-line);
}

.list-editor input {
  min-height: 44px;
  background: #fff;
}

.list-editor__actions {
  flex-wrap: wrap;
}

.list-manager .field-message {
  margin-bottom: 0;
}

input::placeholder {
  color: #64748b;
}

.icon-button,
.number-control button,
.edit-button,
.remove-button {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  border: 2px solid var(--line);
}

.add-button {
  color: #fff;
  background: var(--orange);
  border-radius: 12px;
  box-shadow: 3px 3px 0 var(--line);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.add-button:active {
  box-shadow: 1px 1px 0 var(--line);
  transform: translate(2px, 2px);
}

.field-message {
  min-height: 1.5em;
  margin: 8px 0 0;
  color: var(--red);
  font-size: 0.85rem;
  font-weight: 800;
}

.item-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 20px 0 0;
  list-style: none;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 50px;
  gap: 12px;
  padding: 5px 6px 5px 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.item-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 2px;
}

.inline-edit-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  gap: 8px;
}

.inline-edit-form input {
  min-height: 44px;
  background: #fff;
}

.inline-edit-actions {
  display: flex;
  gap: 5px;
}

.inline-save-button,
.inline-cancel-button {
  min-height: 44px;
  padding: 7px 10px;
  border: 2px solid var(--line);
  border-radius: 9px;
  font-size: 0.78rem;
  font-weight: 900;
}

.inline-save-button {
  color: #fff;
  background: var(--blue);
}

.inline-cancel-button {
  color: var(--ink);
  background: #fff;
}

.edit-button,
.remove-button {
  flex: 0 0 auto;
  color: var(--ink-soft);
  background: transparent;
  border-color: transparent;
  border-radius: 9px;
}

.remove-button:hover {
  color: var(--red);
  background: #fee2e2;
}

.edit-button:hover {
  color: var(--blue-dark);
  background: #dbeafe;
}

.edit-button svg,
.remove-button svg {
  width: 18px;
  height: 18px;
}

.empty-note {
  padding: 18px;
  margin: 20px 0 0;
  color: var(--ink-soft);
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  text-align: center;
}

.text-button {
  min-height: 44px;
  padding: 8px 0;
  margin-top: 10px;
  background: transparent;
  border: 0;
  font-size: 0.86rem;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-button.danger {
  color: var(--red);
}

.number-control {
  position: relative;
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;
  max-width: 260px;
  margin-bottom: 22px;
  background: #fffbeb;
  border: 2px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.number-control:focus-within {
  outline: 4px solid var(--yellow);
  outline-offset: 3px;
}

.number-control button {
  color: var(--ink);
  background: #fde68a;
  border: 0;
  border-radius: 0;
  font-size: 1.5rem;
  font-weight: 900;
}

.number-control output {
  font-size: 1.3rem;
  font-weight: 900;
  text-align: center;
}

.number-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  gap: 10px;
  padding: 12px 18px;
  color: #fff;
  background: var(--blue);
  border: 2px solid var(--line);
  border-radius: 14px;
  box-shadow: 4px 4px 0 var(--line);
  font-weight: 900;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 160ms ease;
}

.primary-button:hover:not(:disabled) {
  background: var(--blue-dark);
}

.primary-button:active:not(:disabled) {
  box-shadow: 1px 1px 0 var(--line);
  transform: translate(3px, 3px);
}

.primary-button:disabled {
  color: #64748b;
  background: #cbd5e1;
  box-shadow: none;
  cursor: not-allowed;
}

.team-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.team-card {
  padding: 16px;
  background: #fff7ed;
  border: 2px solid var(--line);
  border-radius: 14px;
}

.team-card:nth-child(4n + 2) {
  background: #eff6ff;
}

.team-card:nth-child(4n + 3) {
  background: #ecfdf5;
}

.team-card:nth-child(4n + 4) {
  background: #fef9c3;
}

.team-card h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.team-card ol {
  padding-left: 1.3rem;
  margin: 0;
}

.team-card li + li {
  margin-top: 5px;
}

.team-card li {
  overflow-wrap: anywhere;
}

.wheel-panel {
  overflow: hidden;
}

.wheel-toolbar {
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.mode-switch {
  padding: 3px;
  background: #e2e8f0;
  border-radius: 12px;
}

.wheel-toolbar .mode-switch button {
  border-color: transparent;
  box-shadow: none;
}

.wheel-toolbar .mode-switch button[aria-pressed="true"] {
  color: #fff;
  background: var(--blue);
  border-color: var(--line);
}

.wheel-toolbar .sound-toggle[aria-pressed="false"] {
  color: var(--ink-soft);
  background: #f1f5f9;
}

.elimination-bar {
  justify-content: space-between;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: #fef9c3;
  border: 2px solid #fde047;
  border-radius: 12px;
}

.elimination-bar p {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 900;
}

.wheel-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 480px);
  aspect-ratio: 1;
  margin: 6px auto 26px;
}

.wheel {
  position: relative;
  width: 88%;
  aspect-ratio: 1;
  background: #e2e8f0;
  border: 5px solid var(--line);
  border-radius: 50%;
  box-shadow: 8px 10px 0 var(--line);
  transition: transform 4.2s cubic-bezier(0.12, 0.62, 0.05, 1);
  will-change: transform;
}

.wheel::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 50%;
  pointer-events: none;
}

.wheel-pointer {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 4;
  width: 0;
  height: 0;
  border-right: 20px solid transparent;
  border-left: 20px solid transparent;
  border-top: 42px solid var(--line);
  filter: drop-shadow(0 4px 0 #fff);
  transform: translateX(-50%);
}

.wheel-center {
  position: absolute;
  z-index: 3;
  width: 17%;
  aspect-ratio: 1;
  background: var(--card);
  border: 4px solid var(--line);
  border-radius: 50%;
  box-shadow: 2px 3px 0 var(--line);
}

.wheel-label {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 42%;
  padding: 4px 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  border-radius: 999px;
  font-size: clamp(0.67rem, 2.1vw, 0.95rem);
  font-weight: 900;
  line-height: 1.1;
  text-align: right;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform-origin: left center;
  pointer-events: none;
}

.spin-button {
  max-width: 360px;
  margin-inline: auto;
}

.wheel-panel .field-message {
  text-align: center;
}

.winner {
  padding: 18px;
  margin-top: 20px;
  background: #fef9c3;
  border: 2px solid var(--line);
  border-radius: 16px;
  box-shadow: 4px 4px 0 var(--line);
  text-align: center;
  animation: winner-pop 300ms ease-out both;
}

.winner span {
  display: block;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.winner strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(1.55rem, 5vw, 2.35rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow: hidden;
  pointer-events: none;
}

.confetti-layer i {
  position: absolute;
  top: -18px;
  left: var(--x);
  width: 10px;
  height: 18px;
  border-radius: 2px;
  animation: confetti-fall 1.45s var(--delay) ease-in both;
}

@keyframes confetti-fall {
  to {
    transform: translate3d(var(--drift), 110vh, 0) rotate(760deg);
  }
}

@keyframes winner-pop {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

footer {
  padding-block: 25px 40px;
  color: var(--ink-soft);
  border-top: 1px solid var(--soft-line);
  font-size: 0.85rem;
  text-align: center;
}

footer p {
  margin: 0;
}

@media (max-width: 780px) {
  .workspace-grid,
  .wheel-layout {
    grid-template-columns: 1fr;
  }

  .action-panel {
    order: -1;
  }

  .wheel-layout .wheel-panel {
    order: -1;
  }
}

@media (max-width: 520px) {
  .site-header,
  .tool-nav,
  main,
  footer {
    width: min(calc(100% - 22px), var(--max-width));
  }

  .site-header {
    min-height: 78px;
  }

  .tagline {
    display: none;
  }

  .tool-nav__link {
    min-width: 0;
    padding-inline: 7px;
    font-size: 0.88rem;
  }

  .tool-nav__link svg {
    width: 19px;
    height: 19px;
  }

  .tool-view {
    padding-block: 40px 55px;
  }

  .view-intro {
    margin-bottom: 26px;
  }

  .panel {
    padding: 19px;
    border-radius: 16px;
    box-shadow: 4px 4px 0 var(--line);
  }

  .team-results {
    grid-template-columns: 1fr;
  }

  .inline-edit-form {
    grid-template-columns: 1fr;
  }

  .list-actions button {
    flex: 1 1 calc(50% - 8px);
  }

  .wheel-toolbar,
  .elimination-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .mode-switch button {
    flex: 1;
  }

  .wheel {
    box-shadow: 5px 7px 0 var(--line);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }

  .confetti-layer {
    display: none;
  }
}
