/* Inter font is loaded via <link> in index.html for better performance */

/* =========================
   Theme variables
   ========================= */
:root {
  color-scheme: dark;

  /* Base palette */
  --bg-0: #05070f;
  --bg-1: #08101e;
  --bg-2: #0e1526;
  --bg-3: #121c34;

  --text: #eaf0fb;
  --muted: #a9b9d6;

  /* Accents */
  --accent: #64a8ff;    /* blue */
  --accent-2: #22d3ee;  /* cyan */
  --accent-3: #9b6bff;  /* purple */

  /* Radii and shadows */
  --radius: 20px;
  --shadow-1: 0 8px 30px rgba(0,0,0,.25);
  --shadow-2: 0 24px 80px rgba(18,30,52,0.42);

  /* Gradients */
  --grad-ui: conic-gradient(from 180deg at 50% 50%, #2f4a91, #1f2e5e, #142247, #0e1a39, #142247, #1f2e5e, #2f4a91);
  --grad-brand: linear-gradient(135deg, #2b68ff, #22d3ee 50%, #9b6bff);
  --grad-chip: linear-gradient(135deg, rgba(18,28,52,.96), rgba(10,16,30,.92));
  --grad-card: linear-gradient(180deg, rgba(18,27,48,.9), rgba(10,16,30,.86));

  /* Borders */
  --line: rgba(120,160,255,.18);
  --line-strong: rgba(120,160,255,.32);

  /* Motion */
  --ease: cubic-bezier(.2,.7,.1,1);
  --ease-out: cubic-bezier(.16,1,.3,1);
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  :root { --ease: linear; --ease-out: linear; }
  * { animation: none !important; transition: none !important; }
}

/* Ensure anything with the hidden attribute stays hidden */
[hidden] { display: none !important; }

/* =========================
   Base / Background
   ========================= */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", system-ui, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(1400px 840px at 25% -20%, rgba(90,161,255,.25) 0, transparent 48%),
              radial-gradient(1100px 880px at 92% -12%, rgba(34,211,238,.16) 0, transparent 45%),
              linear-gradient(180deg, var(--bg-0), var(--bg-1) 28%, var(--bg-1) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* Subtle moving grid glow */
body::before {
  content: "";
  position: fixed;
  inset: -20vmax;
  background: radial-gradient(50% 50% at 50% 50%, rgba(60,120,255,.08) 0%, transparent 60%) 0 0/40vmax 40vmax no-repeat,
              radial-gradient(50% 50% at 100% 0%, rgba(34,211,238,.08) 0%, transparent 60%) 0 0/40vmax 40vmax no-repeat;
  filter: blur(40px);
  opacity: .8;
  pointer-events: none;
  z-index: 0;
  animation: bg-drift 34s linear infinite;
}
@keyframes bg-drift {
  0% { transform: translate3d(0,0,0) rotate(0deg); }
  50%{ transform: translate3d(1.5%, -1.5%, 0) rotate(180deg); }
  100%{ transform: translate3d(0,0,0) rotate(360deg); }
}

/* =========================
   Header (glass + brand)
   ========================= */
header {
  padding: 16px clamp(16px,3vw,36px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, rgba(12,18,31,.78), rgba(10,16,28,.62));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(120,160,255,.14);
  z-index: 20;
}

header h1 {
  margin: 0;
  font-size: clamp(22px, 2.6vw, 32px);
  font-weight: 900;
  letter-spacing: .01em;
  text-shadow: 0 1px 0 rgba(0,0,0,.3);
}

.season-tag {
  margin-top: 2px;
  font-size: 12px;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: rgba(197,212,235,.76);
}

/* Brand cluster */
header .brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-img {
  width: clamp(30px, 3.3vw, 44px);
  height: clamp(30px, 3.3vw, 44px);
  border-radius: 12px;
  object-fit: cover;
  display: inline-block;
  position: relative;
  z-index: 0;
  box-shadow:
    0 4px 14px rgba(0,0,0,.28),
    inset 0 0 0 1px rgba(255,255,255,.05);
  background: #0b1220;
  border: 1px solid rgba(100,160,255,.45);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
}
.brand-img:hover {
  transform: translateY(-1px) scale(1.03);
  border-color: rgba(120,190,255,.8);
  box-shadow:
    0 10px 30px rgba(32,80,200,.35),
    0 0 0 6px rgba(80,160,255,.08),
    inset 0 0 0 1px rgba(255,255,255,.08);
}

/* =========================
   Page grid / cards
   ========================= */
.container {
  max-width: 1200px;
  margin: 20px auto 48px;
  padding: 0 clamp(12px,4vw,36px);
  display: grid;
  gap: 22px;
  position: relative;
  z-index: 1;
}

@media (min-width: 980px) {
  .container { grid-template-columns: 380px 1fr; }
}
@media (max-width: 979.98px) {
  .container { display: block; }
  .card { margin-bottom: 16px; }
}

/* Card */
.card {
  position: relative;
  background: var(--grad-card);
  border-radius: var(--radius);
  padding: 18px clamp(14px,3vw,26px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  overflow: clip;
  transform: translateY(8px);
  opacity: 0;
  animation: card-in .6s var(--ease-out) forwards;
}
@keyframes card-in {
  to { transform: translateY(0); opacity: 1; }
}

.section-title {
  font-size: 12px;
  letter-spacing: .36em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}

/* =========================
   Quick picks / chips
   ========================= */
.quick-picks {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

button, .chip-btn {
  width: 100%;
  margin-top: 6px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(22,34,64,.96), rgba(12,18,34,.92));
  color: #f4f7ff;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform .15s var(--ease), border-color .15s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
  position: relative;
  overflow: hidden;
}
button:hover, .chip-btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent-2);
  box-shadow: 0 10px 30px rgba(34,211,238,.16);
}
button:active { transform: translateY(0); }
button:disabled { opacity: .6; cursor: wait; }

/* Button shine */
button::after, .chip-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255,255,255,.08), transparent 30% 70%, rgba(255,255,255,.08));
  transform: translateX(-100%);
  transition: transform .7s var(--ease-out);
  pointer-events: none;
}
button:hover::after, .chip-btn:hover::after { transform: translateX(100%); }

.chip-btn.active {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px rgba(34,211,238,.20) inset, 0 12px 26px rgba(34,211,238,.12);
  background: linear-gradient(180deg, rgba(32,46,88,.96), rgba(14,24,48,.92));
}

/* Ghost variant for “Show more” */
.chip-btn.ghost {
  background: linear-gradient(180deg, rgba(18,22,36,.86), rgba(10,14,26,.82));
  border-style: dashed;
}

/* League chips container AND “Show on wheel” container */
#chips .chips,
#showOnWheel,
.showopts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 6px 0 14px;
}

/* League chips AND “Show on wheel” chips (same visuals) */
#chips .chip,
#showOnWheel .chip,
.showopts .chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 10px 46px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--grad-chip);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: transform .16s var(--ease), border-color .16s var(--ease), box-shadow .2s var(--ease);
  max-width: 100%;
  will-change: transform;
}
#chips .chip:hover,
#showOnWheel .chip:hover,
.showopts .chip:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px) scale(1.02);
}

/* Checkbox visuals inside chips (league + show-on-wheel) */
#chips .chip input[type="checkbox"],
#showOnWheel .chip input[type="checkbox"],
.showopts .chip input[type="checkbox"] {
  appearance: none;
  position: absolute;
  left: 16px;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid rgba(120,150,220,.45);
  background: rgba(4,9,19,.8);
  display: grid;
  place-items: center;
  transition: .18s var(--ease);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
#chips .chip input[type="checkbox"]::after,
#showOnWheel .chip input[type="checkbox"]::after,
.showopts .chip input[type="checkbox"]::after {
  content: "";
  width: 9px; height: 9px; border-radius: 4px;
  background: var(--accent);
  transform: scale(.2);
  opacity: 0;
  transition: .18s var(--ease);
}
#chips .chip input[type="checkbox"]:checked,
#showOnWheel .chip input[type="checkbox"]:checked,
.showopts .chip input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: rgba(90,161,255,.18);
  box-shadow: 0 0 0 2px rgba(90,161,255,.18) inset;
}
#chips .chip input[type="checkbox"]:checked::after,
#showOnWheel .chip input[type="checkbox"]:checked::after,
.showopts .chip input[type="checkbox"]:checked::after {
  transform: scale(1);
  opacity: 1;
}

/* Chip text */
#chips .chip .chip-text,
#showOnWheel .chip .chip-text,
.showopts .chip .chip-text {
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 28ch;
}

@media (max-width: 560px) {
  #chips .chip,
  #showOnWheel .chip,
  .showopts .chip {
    padding: 10px 18px 10px 46px;
  }
  #chips .chip .chip-text,
  #showOnWheel .chip .chip-text,
  .showopts .chip .chip-text {
    max-width: 24ch;
  }
}

/* =========================
   Result / History
   ========================= */
.result {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(13,22,40,.9), rgba(7,12,24,.85));
  backdrop-filter: blur(6px);
}
.result img, .item img {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  object-fit: contain;
  background: #0b1220;
  border: 1px solid rgba(90,161,255,.22);
  box-shadow: 0 2px 8px rgba(16,24,48,.28);
}

.current-name {
  font-weight: 800;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-title {
  margin: 18px 0 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .34em;
  text-transform: uppercase;
}
.history {
  max-height: 260px;
  overflow: auto;
  display: grid;
  gap: 10px;
}
.item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(17,28,48,.85);
  border: 1px solid rgba(90,161,255,.12);
  transition: transform .16s var(--ease);
}
.item:hover { transform: translateY(-1px); }

/* =========================
   Selection banner
   ========================= */
.perf-tip {
  font-size: 12px;
  color: #bcd4ff;
  background: rgba(40, 60, 100, 0.28);
  border: 1px solid rgba(120, 160, 255, 0.25);
  border-radius: 10px;
  padding: 6px 10px;
  margin: 6px 0 10px;
  text-align: center;
  width: 100%;
}

/* Extra spacing around chips and pointer area */
#chips { margin-bottom: 28px; }
#chipsMore { margin-top: 10px; }

/* =========================
   Wheel / Pointer / Spin FAB
   ========================= */
.wheel-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: clamp(36px, 5vw, 64px) clamp(10px, 2.5vw, 18px) clamp(10px, 2.5vw, 18px);
}

canvas#wheel {
  width: 100%;
  max-width: 820px;
  height: auto;
  filter: drop-shadow(0 30px 60px rgba(0,0,0,.55));
  border-radius: 50%;
  background: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  animation: wheel-pop .6s var(--ease-out);
}
@keyframes wheel-pop {
  0% { transform: scale(.98); opacity: .8; }
  100% { transform: scale(1); opacity: 1; }
}

#fx { position: absolute; inset: 0; pointer-events: none; }

/* Pointer (float) */
.pointer {
  position: absolute;
  top: clamp(4px, 1vw, 12px);
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-top: 26px solid var(--accent-2);
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.35));
  z-index: 3;
  animation: pointer-float 3.5s ease-in-out infinite;
}
@keyframes pointer-float {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-3px); }
}
@media (max-width: 600px) {
  .pointer {
    border-left-width: 12px;
    border-right-width: 12px;
    border-top-width: 20px;
  }
}

/* Spin FAB with animated ring */
.spin-fab {
  position: absolute;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: clamp(88px, 14vw, 132px);
  height: clamp(88px, 14vw, 132px);
  border-radius: 999px;
  border: 2px solid rgba(120, 200, 255, 0.55);
  background: radial-gradient(120% 120% at 30% 20%, #2b3d72 0%, #132447 55%, #0b1530 100%);
  color: #f4f7ff;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
  box-shadow: 0 10px 30px rgba(0,0,0,.45), inset 0 0 30px rgba(90,161,255,.15);
  pointer-events: auto;
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), border-color .12s var(--ease), background .12s var(--ease);
}
.spin-fab::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 999px;
  background: conic-gradient(from 0deg, #22d3ee, #2b68ff, #9b6bff, #22d3ee);
  -webkit-mask: radial-gradient(closest-side, transparent calc(100% - 8px), black 0);
          mask: radial-gradient(closest-side, transparent calc(100% - 8px), black 0);
  animation: ring-spin 4s linear infinite;
  opacity: .9;
}
@keyframes ring-spin {
  to { transform: rotate(360deg); }
}
.spin-fab:hover { transform: translate(-50%, -50%) scale(1.03); border-color: #22d3ee; box-shadow: 0 14px 34px rgba(34,211,238,.25); }
.spin-fab:active { transform: translate(-50%, -50%) scale(0.985); }
.spin-fab:disabled { opacity: .7; cursor: wait; }

/* =========================
   Modal (glass, reveal buttons)
   ========================= */
#backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4,10,24,0.82);
  backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

#modal {
  border-radius: 18px;
  max-width: 420px;
  width: min(95vw, 420px);
  background: linear-gradient(180deg, rgba(16,24,42,.96), rgba(13,20,38,.92));
  box-shadow: var(--shadow-2);
  border: 1px solid #4f82ff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(8px) scale(.98);
  opacity: 0;
  transition: transform .22s var(--ease-out), opacity .22s var(--ease-out);
}
#modal.show {
  transform: translateY(0) scale(1);
  opacity: 1;
}

#mHead {
  padding: 22px 26px 0;
  font-weight: 900;
  font-size: 24px;
  color: #f4f7ff;
  text-align: center;
}
#mSub {
  font-size: 14px;
  color: #a3b8e7;
  margin: 6px 0 2px;
  text-align: center;
}

.m-body {
  padding: 10px 22px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#mLogo {
  width: 110px; height: 110px;
  max-width: 60vw;
  object-fit: contain;
  border-radius: 16px;
  margin: 10px auto 6px;
  background: #0b1220;
  border: 1px solid #5aa1ff;
  box-shadow: 0 2px 10px rgba(16,24,48,.45);
  display: block;
}

.m-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 6px 0;
}

#modal .swatch, #mColor {
  width: 20px;
  height: 20px;
  border-radius: 8px;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(90,161,255,0.18);
}

.m-sep { width: 100%; height: 1px; background: #234080; margin: 8px 0; }

#mStadium {
  display: inline-block;
  min-width: 180px;
  max-width: 260px;
  text-align: center;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(17,28,48,.85);
  border: 1px solid rgba(90,161,255,.16);
  color: #d7e8ff;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.m-actions {
  padding: 14px 22px 20px;
  background: #0f1830;
  border-top: 1px solid #234080;
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* Keep modal buttons narrow */
#backdrop .chip-btn, #backdrop button { width: auto; min-width: 160px; }

/* Reveal button styling used by JS */
.reveal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(90,161,255,.6);
  background: #152036;
  color: #fff;
  font-weight: 800;
  letter-spacing: .03em;
  cursor: pointer;
  user-select: none;
  z-index: 3;
  position: relative;
  white-space: nowrap;
  transition: transform .12s var(--ease), border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.reveal-btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent-2);
  box-shadow: 0 6px 18px rgba(34,211,238,.18);
}
#modal #mHead + .reveal-btn { display: inline-block; margin-left: 0; margin-top: 6px; }

.reveal-wrap { position: relative; display: inline-block; z-index: 0; }
.reveal-overlay {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: transparent;
  pointer-events: none;
  z-index: 2;
}

/* =========================
   Pointer room / misc tweaks
   ========================= */
.wheel-wrap { padding-top: clamp(36px, 5vw, 64px); }
.pointer { top: clamp(6px, 1vw, 12px); z-index: 3; }

.small { font-size: 12px; color: var(--muted); }
.hidden { display: none !important; }

/* While UI is locked for spin: show wait cursor */
body.ui-locked, body.ui-locked button, body.ui-locked input, body.ui-locked label, body.ui-locked .chip {
  cursor: wait !important;
}
