* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: monospace; background: #0f0f0f; color: #e0e0e0; padding: 24px; }
h1 { color: #c84b11; font-size: 1.4rem; letter-spacing: 2px; text-transform: uppercase; }
h2 { color: #888; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; }

/* HEADER */
.header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.header-right { display: flex; align-items: center; gap: 12px; font-size: 0.8rem; color: #555; }

/* TABS */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid #2a2a2a; }
.tab { padding: 8px 18px; font-family: monospace; font-size: 0.85rem; cursor: pointer;
       background: none; border: none; color: #555; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: #aaa; }
.tab.active { color: #c84b11; border-bottom-color: #c84b11; }
.tab-content { display: none; }
.tab-content.active { display: block; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.panel { background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 6px; padding: 20px; }
.row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
input, select { background: #111; color: #e0e0e0; border: 1px solid #333; border-radius: 4px;
                padding: 6px 10px; font-family: monospace; font-size: 0.9rem; flex: 1; }
button { background: #c84b11; color: #fff; border: none; border-radius: 4px; padding: 7px 14px;
         font-family: monospace; font-size: 0.85rem; cursor: pointer; white-space: nowrap; }
button:hover { background: #e05a1a; }
button.secondary { background: #2a2a2a; color: #aaa; }
button.secondary:hover { background: #333; color: #e0e0e0; }
button.ghost { background: none; color: #555; border: 1px solid #333; }
button.ghost:hover { color: #aaa; border-color: #555; background: none; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th { color: #555; font-weight: normal; text-align: left; padding: 6px 8px; border-bottom: 1px solid #222; }
td { padding: 6px 8px; border-bottom: 1px solid #1e1e1e; }
.badge { display: inline-block; padding: 2px 7px; border-radius: 3px; font-size: 0.75rem; }
.common    { background: #2a2a2a; color: #aaa; }
.rare      { background: #1a2a3a; color: #6ab0e0; }
.epic      { background: #2a1a3a; color: #b06ae0; }
.legendary { background: #3a2a0a; color: #e0a030; }
.status { font-size: 0.8rem; color: #555; margin-top: 10px; min-height: 18px; }
.status.ok  { color: #4caf50; }
.status.err { color: #e05050; }
input.invalid { border-color: #e05050; }
.field-error { font-size: 0.75rem; color: #e05050; display: block; min-height: 16px; margin-bottom: 8px; }

/* LEADERBOARD CARD BREAKDOWN */
.lb-chevron { display: inline-block; margin-left: 5px; font-size: 0.9rem; color: #555;
              transition: transform 0.15s; vertical-align: middle; }
tr:has(+ .lb-card-detail:not(.hidden)) .lb-chevron { transform: rotate(90deg); color: #888; }
.lb-card-detail td { padding: 0 8px 10px; }
.lb-card-breakdown { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 4px; }
.lb-card-chip { display: inline-flex; align-items: center; gap: 5px;
                padding: 3px 8px; border-radius: 4px; font-size: 0.78rem; }
.lb-chip-pts { font-weight: bold; opacity: 0.9; }

/* DECK SUMMARY */
.rarity-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.rarity-box { background: #111; border: 1px solid #2a2a2a; border-radius: 4px;
              padding: 12px 8px; text-align: center; }
.rarity-box .count { font-size: 1.4rem; font-weight: bold; margin-bottom: 4px; }
.rarity-box .label { font-size: 0.7rem; color: #555; text-transform: uppercase; letter-spacing: 1px; }
.rarity-box.common    { border-color: #3a3a3a; }
.rarity-box.common    .count { color: #aaa; }
.rarity-box.rare      { border-color: #1e3a5a; }
.rarity-box.rare      .count { color: #6ab0e0; }
.rarity-box.epic      { border-color: #3a1a5a; }
.rarity-box.epic      .count { color: #b06ae0; }
.rarity-box.legendary { border-color: #5a3a0a; }
.rarity-box.legendary .count { color: #e0a030; }

/* CARD REVEAL MODAL */
.reveal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.9);
                  display: flex; align-items: center; justify-content: center; z-index: 200; }
.reveal-overlay.hidden { display: none; }

/* Full-screen rarity flash — fades out over the modal (card underneath); clicks pass through */
.reveal-draw-burst {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
  visibility: hidden;
}
.reveal-draw-burst.reveal-draw-burst--active {
  visibility: visible;
}
.reveal-draw-burst::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  animation: drawRevealFlash 0.78s cubic-bezier(0.33, 0, 0.25, 1) forwards;
}
@keyframes drawRevealFlash {
  0% { opacity: 0; }
  8% { opacity: 1; }
  100% { opacity: 0; }
}
.reveal-draw-burst.reveal-draw-burst--rarity-common::before {
  background: radial-gradient(
    circle at 50% 40%,
    rgba(255, 255, 255, 0.97) 0%,
    rgba(230, 232, 240, 0.75) 42%,
    rgba(180, 185, 200, 0.35) 100%
  );
}
.reveal-draw-burst.reveal-draw-burst--rarity-rare::before {
  background: radial-gradient(
    circle at 50% 40%,
    rgba(220, 245, 255, 0.98) 0%,
    rgba(120, 190, 255, 0.55) 48%,
    rgba(40, 100, 180, 0.22) 100%
  );
}
.reveal-draw-burst.reveal-draw-burst--rarity-epic::before {
  background: radial-gradient(
    circle at 50% 40%,
    rgba(250, 230, 255, 0.98) 0%,
    rgba(200, 140, 255, 0.52) 48%,
    rgba(100, 50, 160, 0.22) 100%
  );
}
.reveal-draw-burst.reveal-draw-burst--rarity-legendary::before {
  background: radial-gradient(
    circle at 50% 40%,
    rgba(255, 252, 235, 0.99) 0%,
    rgba(255, 210, 120, 0.58) 45%,
    rgba(200, 120, 30, 0.25) 100%
  );
}

.reveal-card { border-radius: 10px; padding: 40px 48px; text-align: center;
               border: 2px solid; min-width: 260px; position: relative; z-index: 1; }
.reveal-card.common    { background: #1a1a1a; border-color: #3a3a3a; }
.reveal-card.rare      { background: #0d1e2e; border-color: #6ab0e0; box-shadow: 0 0 30px #6ab0e040; }
.reveal-card.epic      { background: #1a0d2e; border-color: #b06ae0; box-shadow: 0 0 30px #b06ae040; }
.reveal-card.legendary { background: #2e1a0d; border-color: #e0a030; box-shadow: 0 0 40px #e0a03060; }
.reveal-card .rarity-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 16px; }
.reveal-card.common    .rarity-label { color: #aaa; }
.reveal-card.rare      .rarity-label { color: #6ab0e0; }
.reveal-card.epic      .rarity-label { color: #b06ae0; }
.reveal-card.legendary .rarity-label { color: #e0a030; }
.reveal-card .player-name { font-size: 1.5rem; margin-bottom: 24px; }

/* LOGIN MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.85);
                 display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-overlay.hidden { display: none; }
.modal { background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 8px;
         padding: 32px; width: 320px; }
.modal h2 { color: #c84b11; font-size: 1rem; margin-bottom: 20px; }
.modal select { width: 100%; margin-bottom: 16px; }
.modal .status { margin-top: 8px; }

/* SCHEDULE */
.badge-division { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 1px; padding: 2px 6px; border-radius: 3px; flex-shrink: 0; }
.badge-division.div1 { background: #1a1a2a; color: #6a6aaa; }
.badge-division.div2 { background: #1a2a1a; color: #6aaa6a; }
.series-row { display: grid; grid-template-columns: 46px 1fr 52px 1fr 86px minmax(0, 150px);
              align-items: center; column-gap: 10px; padding: 7px 0; border-bottom: 1px solid #1a1a1a; font-size: 0.85rem; }
.series-row.past { opacity: 0.45; }
.series-team { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.series-team.right { text-align: right; }
.series-score { font-weight: bold; color: #e0e0e0; text-align: center; }
.series-score.no-result { color: #333; }
.series-meta { color: #555; font-size: 0.78rem; text-align: right; white-space: nowrap; }
.stream-link { color: #6ab0e0; text-decoration: none; }
.stream-link:hover { text-decoration: underline; }
.stale-notice { font-size: 0.75rem; color: #666; margin-bottom: 12px; }

/* ENTITY LINKS */
.entity-link { cursor: pointer; }
.entity-link:hover { text-decoration: underline; color: #c84b11; }

/* PLAYER / TEAM DETAIL MODALS */
.modal-wide { width: 680px; max-width: calc(100vw - 48px); max-height: calc(100vh - 80px); overflow-y: auto; }
.player-modal-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 4px; }
.player-modal-stat { background: #111; border: 1px solid #2a2a2a; border-radius: 4px; padding: 10px 8px; text-align: center; }
.player-modal-stat .val { font-size: 1.1rem; font-weight: bold; color: #e0e0e0; margin-bottom: 2px; }
.player-modal-stat .lbl { font-size: 0.7rem; color: #555; text-transform: uppercase; letter-spacing: 1px; }

/* CARD IMAGE GRID */
.card-grid {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 6px 2px 14px;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}
.card-grid::-webkit-scrollbar { height: 5px; }
.card-grid::-webkit-scrollbar-track { background: transparent; }
.card-grid::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

.card-slot {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.card-img {
  width: 180px;
  height: auto;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  display: block;
}
.card-img:hover {
  transform: translateY(-5px) scale(1.03);
  box-shadow: 0 12px 28px rgba(0,0,0,0.6);
}
.card-img-loading {
  width: 180px;
  height: 255px;
  border-radius: 8px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #444;
  font-size: 0.7rem;
}
.card-slot-empty {
  flex: 0 0 auto;
  width: 180px;
  height: 255px;
  border: 2px dashed #2a2a2a;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  font-size: 0.7rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.card-slot-actions {
  display: flex;
  gap: 5px;
  justify-content: center;
}
.card-slot-pts {
  font-size: 0.75rem;
  color: #666;
  text-align: center;
}
/* Rarity glow on card slots */
.card-slot[data-rarity="rare"]      .card-img { box-shadow: 0 0 10px #6ab0e030; }
.card-slot[data-rarity="epic"]      .card-img { box-shadow: 0 0 10px #b06ae030; }
.card-slot[data-rarity="legendary"] .card-img { box-shadow: 0 0 14px #e0a03050; }
.card-slot[data-rarity="rare"]      .card-img:hover { box-shadow: 0 12px 28px rgba(0,0,0,0.6), 0 0 18px #6ab0e050; }
.card-slot[data-rarity="epic"]      .card-img:hover { box-shadow: 0 12px 28px rgba(0,0,0,0.6), 0 0 18px #b06ae050; }
.card-slot[data-rarity="legendary"] .card-img:hover { box-shadow: 0 12px 28px rgba(0,0,0,0.6), 0 0 22px #e0a03070; }

/* Card reveal modal – fixed slot so placeholder ↔ PNG never resizes the dialog */
.reveal-img-wrap {
  position: relative;
  width: 200px;
  height: 283px;
  margin: 0 auto 16px;
  flex-shrink: 0;
}
.reveal-img-wrap .reveal-img-placeholder {
  position: absolute;
  left: 0;
  top: 0;
  width: 200px;
  height: 283px;
  border-radius: 10px;
  background: #111;
  border: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 0.75rem;
  overflow: hidden;
  z-index: 1;
}
.reveal-img-wrap .reveal-card-img {
  position: absolute;
  left: 0;
  top: 0;
  width: 200px;
  height: 283px;
  border-radius: 10px;
  object-fit: contain;
  object-position: center;
  z-index: 2;
  background: #0a0a0a;
  visibility: visible;
}

/* Deck draw: animated “card back” while PNG generates */
.reveal-img-placeholder--drawing {
  color: transparent;
  background: linear-gradient(145deg, #16161c 0%, #252030 45%, #1a1622 100%);
  border-color: #4a3d5c;
  box-shadow:
    inset 0 0 50px rgba(224, 160, 48, 0.12),
    0 0 28px rgba(0, 0, 0, 0.55);
}
.reveal-img-placeholder--drawing::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 8px;
  border: 1px solid rgba(224, 160, 48, 0.2);
  background: repeating-linear-gradient(
    -12deg,
    transparent,
    transparent 6px,
    rgba(255, 255, 255, 0.03) 6px,
    rgba(255, 255, 255, 0.03) 7px
  );
  animation: drawBackPulse 1.1s ease-in-out infinite;
}
.reveal-img-placeholder--drawing::after {
  content: "";
  position: absolute;
  left: -40%;
  top: 0;
  width: 55%;
  height: 100%;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(255, 220, 160, 0.18) 45%,
    transparent 90%
  );
  animation: drawShimmer 1.35s ease-in-out infinite;
}
/* prefers-reduced-motion: still show card-back, no moving stripes/shimmer */
.reveal-img-placeholder--drawing.reveal-img-placeholder--static::before,
.reveal-img-placeholder--drawing.reveal-img-placeholder--static::after {
  animation: none;
}
.reveal-img-placeholder--drawing.reveal-img-placeholder--static::after {
  display: none;
}
@keyframes drawBackPulse {
  0%, 100% { opacity: 0.85; border-color: rgba(224, 160, 48, 0.18); }
  50% { opacity: 1; border-color: rgba(224, 160, 48, 0.38); }
}
@keyframes drawShimmer {
  0% { transform: translateX(-10%); }
  100% { transform: translateX(320%); }
}

.reveal-img-wrap.reveal-img-wrap--draw-soft {
  animation: revealDrawSlotSoft 0.38s ease-out forwards;
}
@keyframes revealDrawSlotSoft {
  0% { opacity: 0.96; }
  100% { opacity: 1; }
}

/* Reroll only: tiny flash, never start invisible (avoids blank slot after swap) */
.reveal-card-img--reroll-flash {
  animation: rerollImgFlash 0.35s ease-out 1;
}
@keyframes rerollImgFlash {
  0% { filter: brightness(1.25); }
  100% { filter: brightness(1); }
}

@media (prefers-reduced-motion: reduce) {
  .reveal-draw-burst::before {
    animation: none !important;
    opacity: 0 !important;
  }
  .reveal-img-placeholder--drawing::before,
  .reveal-img-placeholder--drawing::after {
    animation: none !important;
  }
  .reveal-img-placeholder--drawing::after {
    display: none;
  }
  .reveal-card-img--reroll-flash {
    animation: none !important;
  }
}

