:root {
  --ink: #0e1a2d;
  --paper: #f4f1e7;
  --gold: #c29b40;
  --navy: #102a43;
  --emerald: #1e7c67;
  --rust: #b5532f;
  --crimson: #8e1f2f;
  --cream: #fffaf0;
  --success: #2a9d57;
  --reject: #9d2a2a;
  --waitlist: #a16207;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Spectral", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(194, 155, 64, 0.2), transparent 35%),
    radial-gradient(circle at 80% 90%, rgba(30, 124, 103, 0.25), transparent 30%),
    linear-gradient(125deg, #f8f2df, #ece8dc 35%, #e5ece9 100%);
  display: grid;
  place-items: center;
  padding: 24px;
}

.app-shell {
  width: min(920px, 100%);
  border: 1px solid rgba(16, 42, 67, 0.16);
  border-radius: 24px;
  background: rgba(255, 250, 240, 0.82);
  backdrop-filter: blur(8px);
  box-shadow: 0 24px 60px rgba(16, 42, 67, 0.18);
  padding: clamp(20px, 4vw, 34px);
}

.eyebrow {
  margin: 0;
  font-family: "Cinzel", serif;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--navy);
}

h1 {
  margin: 8px 0 8px;
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 0.02em;
  font-size: clamp(2.2rem, 6vw, 4rem);
  line-height: 0.95;
}

.subhead {
  margin: 0 0 22px;
  font-size: clamp(1rem, 2.2vw, 1.2rem);
}

.picker-note {
  margin: -10px 0 10px;
  font-size: 0.95rem;
  font-weight: 600;
}

#selectedCount {
  font-family: "Cinzel", serif;
}

.ivy-logo-strip {
  margin: 10px 0 6px;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
}

.ivy-logo-item {
  appearance: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(16, 42, 67, 0.18);
  border-radius: 10px;
  min-height: 68px;
  display: grid;
  place-items: center;
  padding: 6px 6px 8px;
  align-content: center;
  gap: 4px;
  transition: transform 120ms ease, opacity 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.ivy-logo-item:hover {
  transform: translateY(-1px);
}

.ivy-logo-item-active {
  border-color: rgba(16, 42, 67, 0.45);
  box-shadow: 0 6px 14px rgba(16, 42, 67, 0.12);
}

.ivy-logo-item-inactive {
  opacity: 0.42;
  filter: saturate(0.45);
}

.ivy-logo-item:focus-visible {
  outline: 2px solid #0f4f7f;
  outline-offset: 2px;
}

.ivy-logo-item img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.ivy-logo-name {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1;
  font-weight: 600;
  text-align: center;
  font-family: "Cinzel", serif;
}

.selection-hint {
  margin: 8px 0 0;
  min-height: 1.3rem;
  color: #8e1f2f;
  font-size: 0.9rem;
}

.spinner-layout {
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: 28px;
  align-items: center;
}

.wheel-wrap {
  width: min(520px, 70vw);
  aspect-ratio: 1 / 1;
  margin-inline: auto;
  position: relative;
  display: grid;
  place-items: center;
}

.pointer {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-top: 38px solid var(--crimson);
  border-bottom: 0;
  z-index: 4;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
}

.wheel {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 12px solid #fefefe;
  box-shadow:
    inset 0 0 0 2px rgba(16, 42, 67, 0.2),
    0 12px 25px rgba(16, 42, 67, 0.3);
  position: relative;
  transition: transform 4.8s cubic-bezier(0.15, 0.7, 0.05, 1);
  transform: rotate(0deg);
  overflow: hidden;
}

.segment-label {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 118px;
  transform-origin: 0 0;
}

.segment-chip {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  font-weight: 700;
  font-size: clamp(0.78rem, 1.2vw, 0.95rem);
}

.segment-chip img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.3));
}

.segment-chip span {
  font-family: "Cinzel", serif;
  line-height: 1;
  letter-spacing: 0.015em;
  text-align: center;
  max-width: 100px;
}

.logo-hidden {
  display: none;
}

.logo-fallback {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.9);
  background: rgba(16, 42, 67, 0.36);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.ivy-logo-item .logo-fallback {
  width: 40px;
  height: 40px;
  font-size: 0.8rem;
}

.controls {
  display: grid;
  gap: 12px;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  font-family: "Spectral", serif;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease;
}

.btn:hover:enabled {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

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

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #0f4f7f, #1d795f);
}

.btn-secondary {
  color: #fff;
  background: linear-gradient(135deg, #7a1c2d, #b5532f);
}

.btn-ghost {
  color: var(--ink);
  border: 1px solid rgba(16, 42, 67, 0.26);
  background: rgba(255, 255, 255, 0.55);
}

.result-card {
  margin-top: 22px;
  padding: 18px;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.85), rgba(242, 237, 223, 0.85));
  border: 1px solid rgba(16, 42, 67, 0.16);
}

.selected-school {
  display: flex;
  align-items: center;
  gap: 12px;
}

.school-logo {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.65);
  padding: 4px;
}

.school-logo-hidden {
  display: none;
}

.result-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 0.8rem;
  opacity: 0.8;
}

h2,
h3 {
  margin: 6px 0 14px;
  min-height: 1.5em;
}

.decision-accepted {
  color: var(--success);
}

.decision-rejected {
  color: var(--reject);
}

.decision-waitlisted {
  color: var(--waitlist);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 19, 33, 0.42);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.modal-hidden {
  display: none;
}

.modal-card {
  width: min(460px, 100%);
  border-radius: 14px;
  border: 1px solid rgba(16, 42, 67, 0.2);
  background: #fdfaf2;
  box-shadow: 0 18px 40px rgba(14, 26, 45, 0.22);
  padding: 20px;
}

.modal-card h3 {
  margin: 0 0 8px;
}

.modal-card p {
  margin: 0;
}

.modal-actions {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 900px) {
  .ivy-logo-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .spinner-layout {
    grid-template-columns: 1fr;
  }

  .controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body {
    padding: 12px;
  }

  .app-shell {
    border-radius: 18px;
    padding: 16px;
  }

  h1 {
    font-size: clamp(2rem, 12vw, 3.2rem);
  }

  .subhead {
    margin-bottom: 14px;
    font-size: 0.95rem;
  }

  .picker-note {
    margin: 0 0 8px;
    font-size: 0.9rem;
  }

  .ivy-logo-strip {
    gap: 10px;
  }

  .ivy-logo-item {
    min-height: 64px;
    padding: 6px;
  }

  .ivy-logo-item img {
    width: 36px;
    height: 36px;
  }

  .ivy-logo-name {
    font-size: 0.72rem;
  }

  .wheel-wrap {
    width: min(100%, 360px);
  }

  .pointer {
    top: 10px;
    border-left-width: 16px;
    border-right-width: 16px;
    border-top-width: 30px;
  }

  .wheel {
    border-width: 10px;
  }

  .segment-label {
    width: 82px;
  }

  .segment-chip {
    gap: 4px;
    padding: 4px 2px;
  }

  .segment-chip img {
    width: 32px;
    height: 32px;
  }

  .segment-chip span {
    max-width: 72px;
    font-size: 0.62rem;
  }

  .btn {
    padding: 13px 14px;
  }
}
