/* ============================================================
   ARAW Challenge — Ashfall Arena stylesheet
   Palette: charred void / oxblood / trophy gold / aged bronze / bone parchment / sage
   Type: Oswald (display) · Roboto Slab (body) · Space Mono (stats)
   ============================================================ */

:root{
  --void: #0c0a08;
  --panel: #17110d;
  --panel-raised: #221a14;
  --panel-raised-2: #2b2118;
  --ash: #3c322a;
  --ash-soft: #2a2219;

  --blood: #7c2020;
  --blood-bright: #b53a30;
  --blood-glow: rgba(181,58,48,.45);

  --gold: #c69a2e;
  --gold-bright: #e9c257;
  --gold-glow: rgba(233,194,87,.35);

  --bronze: #8a5a26;
  --bronze-bright: #c9863f;
  --bronze-glow: rgba(201,134,63,.4);
  
  --sage: #4a6a3f;
  --sage-bright: #7ba065;
  --sage-glow: rgba(123,160,101,.4);

  --bone: #ece0c6;
  --bone-dim: #a8967c;
  --bone-faint: #6e6152;

  --font-display: 'Oswald', sans-serif;
  --font-body: 'Roboto Slab', serif;
  --font-mono: 'Space Mono', monospace;

  --radius: 4px;
}

*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }

body{
  background:
    radial-gradient(ellipse 120% 80% at 50% -10%, #241a12 0%, var(--void) 55%),
    var(--void);
  color: var(--bone);
  font-family: var(--font-body);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.grain-overlay{
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
  opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a{ color: inherit; }
::selection{ background: var(--gold); color: var(--void); }

/* ---------- Header ---------- */
.site-header{ border-bottom: 1px solid var(--ash); background: linear-gradient(180deg, rgba(0,0,0,.35), transparent); }
.header-inner{ max-width: 1180px; margin: 0 auto; padding: 18px 24px; display:flex; align-items:center; justify-content:space-between; }
.brand{ display:flex; align-items:baseline; gap:10px; }
.brand-mark{ font-family: var(--font-display); font-weight:700; font-size: 30px; letter-spacing: 3px; color: var(--bone); text-shadow: 0 0 18px var(--gold-glow); }
.brand-sub{ font-family: var(--font-mono); font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--bone-dim); }
.progress-badge{ font-family: var(--font-mono); font-weight:700; font-size: 22px; color: var(--gold-bright); border: 1px solid var(--ash); border-radius: var(--radius); padding: 6px 14px; background: var(--panel); letter-spacing: 1px; }
.progress-slash{ color: var(--bone-faint); font-size: 16px; }

/* ---------- Layout shell ---------- */
.app-shell{ max-width: 1180px; margin: 0 auto; padding: 28px 24px 40px; }
.section-label{ font-family: var(--font-display); text-transform: uppercase; letter-spacing: 2px; font-size: 14px; color: var(--bone-dim); margin: 0; font-weight: 500; }

/* ---------- Ticker ---------- */
.ticker-section{ margin-bottom: 22px; }
.ticker-head{ display:flex; align-items:baseline; justify-content:space-between; margin-bottom:10px; flex-wrap:wrap; gap:6px; }
.ticker-hint{ font-family: var(--font-mono); font-size: 11px; color: var(--bone-faint); margin:0; }

.ticker{ display:grid; grid-template-columns: repeat(11, 1fr); gap: 6px; background: var(--panel); border: 1px solid var(--ash); border-radius: var(--radius); padding: 10px; position: relative; }

.tile{
  position: relative;
  background: var(--panel-raised);
  border: 1px solid var(--ash-soft);
  border-radius: var(--radius);
  padding: 8px 4px 6px;
  min-height: 92px;
  display:flex; flex-direction:column; align-items:center; justify-content:flex-start;
  text-align:center;
  transition: opacity .3s ease, box-shadow .3s ease, transform .25s ease, filter .3s ease;
}
.tile.tile-core{ border-bottom: 2px solid var(--gold); }
.tile-num{ position:absolute; top:3px; left:5px; font-family: var(--font-mono); font-size: 9px; color: var(--bone-faint); }

/* skill icons: SQUARE, not circular */
.tile-icon{
  width: 38px; height: 38px; margin: 10px 0 4px;
  border-radius: 5px; background: var(--void); border: 1px solid var(--ash);
  display:flex; align-items:center; justify-content:center; overflow:hidden;
}
.tile-icon img{ width: 100%; height:100%; object-fit: contain; }
.tile-fallback{ font-family: var(--font-mono); font-size: 10px; color: var(--bone-dim); }
.tile-name{ font-family: var(--font-body); font-size: 10px; line-height:1.2; color: var(--bone); }
.tile-empty .tile-icon{ opacity:.15; }
.tile-empty .tile-name{ color: var(--bone-faint); }
.tile-empty::after{ content:"—"; color: var(--bone-faint); font-family: var(--font-mono); font-size:11px; }

/* floodlight sweep states, applied on team hover */
.tile.tile-lit{ box-shadow: 0 0 0 1px var(--gold-bright), 0 0 16px var(--gold-glow); transform: translateY(-2px); }
.tile.tile-dim{ filter: grayscale(.7) brightness(.5); opacity: .5; }
.ticker.sweeping .tile{ transition: opacity .35s ease, box-shadow .35s ease, transform .25s ease, filter .35s ease; }

/* roll-in animation — slowed down + a bit more theatrical; per-tile duration/delay set inline via JS */
@keyframes tileRollIn{
  0%{ transform: translateY(-22px) rotateX(55deg) scale(.85); opacity:0; }
  55%{ opacity: 1; }
  70%{ transform: translateY(3px) rotateX(0) scale(1.04); box-shadow: 0 0 18px var(--gold-glow); }
  100%{ transform: translateY(0) rotateX(0) scale(1); opacity:1; box-shadow: none; }
}
.tile.tile-rolling{ animation-name: tileRollIn; animation-timing-function: cubic-bezier(.2,.7,.3,1.1); animation-fill-mode: both; }

/* ---------- Controls ---------- */
.controls-row{ display:flex; flex-wrap:wrap; gap: 10px; align-items:center; margin-bottom: 22px; }
.controls-spacer{ flex: 1 1 auto; }

.btn{
  font-family: var(--font-display); font-weight:600; letter-spacing: .5px;
  text-transform: uppercase; font-size: 13px;
  padding: 10px 18px; border-radius: var(--radius);
  border: 1px solid var(--ash); cursor:pointer;
  background: var(--panel-raised); color: var(--bone);
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
}
.btn:hover{ transform: translateY(-1px); }
.btn:active{ transform: translateY(0); }
.btn:disabled{ opacity:.35; cursor:not-allowed; transform:none; }

.btn-gold{ background: linear-gradient(180deg, var(--gold-bright), var(--gold)); color: #241a08; border-color: var(--gold); }
.btn-gold:hover{ box-shadow: 0 0 18px var(--gold-glow); }
.btn-blood{ background: linear-gradient(180deg, var(--blood-bright), var(--blood)); color: var(--bone); border-color: var(--blood-bright); }
.btn-blood:hover{ box-shadow: 0 0 18px var(--blood-glow); }
.btn-ghost{ background: transparent; }
.btn-ghost:hover{ border-color: var(--gold); color: var(--gold-bright); }

/* ---------- Team grid ---------- */
.team-grid{ display:grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 900px){ .team-grid{ grid-template-columns: repeat(3,1fr); } .ticker{ grid-template-columns: repeat(6,1fr); } }
@media (max-width: 560px){ .team-grid{ grid-template-columns: repeat(2,1fr); } .ticker{ grid-template-columns: repeat(4,1fr); } }

.team-card{
  position:relative;
  background: var(--panel);
  border: 1px solid var(--ash);
  border-radius: var(--radius);
  padding: 10px 12px;
  display:flex; align-items:center; gap: 10px;
  cursor: default;
  transition: border-color .2s ease, box-shadow .2s ease, opacity .2s ease, transform .15s ease;
}
.team-card .tier-badge{ position:absolute; top:6px; right:8px; font-family: var(--font-mono); font-size: 10px; color: var(--bone-faint); }
.team-card .icon{
  position: relative;
  width: 44px; height:44px; flex: 0 0 auto; border-radius: 50%;
  background: var(--void); border: 1px solid var(--ash);
  display:flex; align-items:center; justify-content:center; overflow:visible;
}
.team-card .icon img{ width:100%; height:100%; object-fit:contain; border-radius: 50%; }
.team-card .icon-fallback{ font-family: var(--font-mono); font-weight:700; font-size: 12px; color: var(--bone-dim); }
.team-card .name{ font-family: var(--font-body); font-weight:700; font-size: 14px; line-height:1.2; }
.team-card .status-line{ font-family: var(--font-mono); font-size: 10px; color: var(--bone-faint); margin-top:2px; }

/* pre-roll: nothing has happened yet */
.team-card.state-locked{ opacity: .4; }

/* mid-reveal: this team's window hasn't fully appeared in the ticker yet */
.team-card.state-pending{ opacity: .55; }
.team-card.state-pending .status-line{ color: var(--bone-dim); animation: pendingPulse 1.1s ease-in-out infinite; }
@keyframes pendingPulse{ 0%,100%{ opacity:.5; } 50%{ opacity:1; } }

/* run over, this team never got picked */
.team-card.state-frozen{ opacity: .3; }

.team-card.state-invalid{ opacity:.45; }
.team-card.state-invalid .status-line{ color: var(--blood-bright); }

.team-card.state-valid{
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 0 14px var(--gold-glow);
  cursor: pointer;
}
.team-card.state-valid:hover{ transform: translateY(-2px); box-shadow: 0 0 0 1px var(--gold-bright), 0 0 22px var(--gold-glow); }
.team-card.state-valid .status-line{ color: var(--gold-bright); }

/* completed teams: deliberately a DIFFERENT hue (sage) from "valid" (gold), so the two never read as the same state */
.team-card.state-completed{
  border-color: var(--sage);
  box-shadow: 0 0 0 1px var(--sage), 0 0 10px var(--sage-glow);
  background: linear-gradient(180deg, var(--panel-raised-2), var(--panel));
}
.team-card.state-completed .icon{ box-shadow: 0 0 0 2px var(--sage); }
.team-card.state-completed .status-line{ color: var(--sage-bright); }

/* the team that ended a lost run */
.team-card.state-lost-team{
  border-color: var(--blood-bright);
  box-shadow: 0 0 0 1px var(--blood-bright), 0 0 14px var(--blood-glow);
  background: linear-gradient(180deg, #241512, var(--panel));
}
.team-card.state-lost-team .icon{ box-shadow: 0 0 0 2px var(--blood-bright); }
.team-card.state-lost-team .status-line{ color: var(--blood-bright); }

/* big ink-stamp effect over the team icon — checkmark (won) or skull (loss) */
.stamp{
  position:absolute; inset: -8px;
  display:flex; align-items:center; justify-content:center;
  border-radius: 50%;
  border: 3px solid var(--sage-bright);
  transform: rotate(-13deg);
  background: rgba(12,10,8,.3);
  pointer-events:none;
}
.stamp::before{ content:""; position:absolute; inset:3px; border-radius:50%; border: 1px solid var(--sage-bright); opacity:.6; }
.stamp .stamp-glyph{ font-size: 40px; font-weight:700; color: var(--sage-bright); text-shadow: 0 1px 2px rgba(0,0,0,.8); }

.stamp.stamp-blood{ border-color: var(--blood-bright); }
.stamp.stamp-blood::before{ border-color: var(--blood-bright); }
.stamp.stamp-blood .stamp-glyph{ color: var(--blood-bright); }

/* ---------- Rules section ---------- */
.rules-section{
  margin-top: 26px;
  background: var(--panel);
  border: 1px solid var(--ash);
  border-radius: var(--radius);
  padding: 22px 24px 26px;
}
.rules-title{
  font-family: var(--font-display); font-weight:700; font-size: 26px;
  letter-spacing: 1px; color: var(--gold-bright); margin: 0 0 14px;
  text-shadow: 0 0 14px var(--gold-glow);
}
.rules-list{ margin: 0 0 16px; padding-left: 20px; font-family: var(--font-body); font-size: 15px; line-height:1.7; color: var(--bone); }
.rules-list li{ margin-bottom: 4px; }
.rules-note{ font-family: var(--font-body); font-size: 14px; line-height:1.6; color: var(--bone-dim); margin: 0 0 12px; }
.rules-share{ font-family: var(--font-body); font-size: 14px; line-height:1.6; color: var(--bone); margin: 0; }
.rules-share a{ color: var(--gold-bright); text-decoration: underline; }
.rules-share a:hover{ color: var(--gold); }

/* ---------- Rules columns (ARAW rules + Arena rules side by side) ---------- */
.rules-columns{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
  margin-top: 26px;
}
@media (max-width: 820px){
  .rules-columns{ grid-template-columns: 1fr; }
}

/* the .rules-section margin-top is now handled by the wrapper, not the section itself */
.rules-columns .rules-section,
.rules-columns .arena-rules-section{
  margin-top: 0;
  height: 100%;
}

.arena-rules-section{
  background: var(--panel);
  border: 1px solid var(--ash);
  border-radius: var(--radius);
  padding: 22px 24px 26px;
}
.arena-rules-title{
  font-family: var(--font-display); font-weight:700; font-size: 26px;
  letter-spacing: 1px; color: var(--gold-bright); margin: 0 0 14px;
  text-shadow: 0 0 14px var(--gold-glow);
}
.arena-rules-note{
  font-family: var(--font-body); font-size: 14px; line-height:1.6;
  color: var(--bone-dim); margin: 0 0 14px;
}

.arena-table-wrap{ overflow-x: auto; }
.arena-table{
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.arena-table caption{ display:none; }
.arena-table th,
.arena-table td{
  padding: 8px 10px;
  text-align: center;
  border-bottom: 1px solid var(--ash-soft);
  white-space: nowrap;
}
.arena-table th{
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-size: 11px;
  color: var(--bone-dim);
  border-bottom: 1px solid var(--gold);
  padding-bottom: 10px;
}
.arena-table td:first-child,
.arena-table th:first-child{
  text-align: left;
  color: var(--gold-bright);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13px;
}
.arena-table tbody tr:hover{
  background: var(--panel-raised);
}
.arena-table tbody tr:last-child td{
  border-bottom: none;
}
.arena-table .cash-col{
  color: var(--sage-bright);
}

/* ---------- Footer ---------- */
.site-footer{ border-top:1px solid var(--ash); margin-top: 20px; }
.footer-inner{ max-width: 1180px; margin:0 auto; padding: 18px 24px; display:flex; flex-wrap:wrap; gap: 8px 0; align-items:center; justify-content:space-between; font-family: var(--font-mono); font-size: 12px; color: var(--bone-dim); }
.footer-block{ display:flex; align-items:center; gap: 8px; flex-wrap:wrap; }
.footer-link{ color: var(--bone-dim); text-decoration:none; }
.footer-link:hover{ color: var(--gold-bright); }
.footer-link-gold{ color: var(--gold-bright); }
.footer-dot{ color: var(--ash); }
.footer-url{ color: var(--bone-faint); }

/* ---------- Modals ---------- */
.modal-backdrop{ position: fixed; inset:0; background: rgba(6,4,3,.75); display:none; align-items:center; justify-content:center; z-index: 1000; padding: 20px; }
.modal-backdrop.open{ display:flex; }
.modal{
  display:none; background: var(--panel-raised); border: 1px solid var(--gold); border-radius: var(--radius);
  max-width: 420px; width:100%; padding: 22px 24px;
  box-shadow: 0 12px 60px rgba(0,0,0,.6), 0 0 30px var(--gold-glow);
}
.modal.modal-wide{ max-width: 560px; }
.modal.open{ display:block; }
.modal-title{ font-family: var(--font-display); text-transform:uppercase; letter-spacing:1px; margin:0 0 10px; font-size:20px; color: var(--gold-bright); }
.modal-title-blood{ color: var(--blood-bright); }
.modal-body{ font-family: var(--font-body); font-size: 14px; color: var(--bone); line-height:1.5; margin: 0 0 6px; }
.modal-actions{ display:flex; justify-content:flex-end; gap: 10px; margin-top: 18px; }
.modal-note{ font-family: var(--font-mono); font-size: 11px; color: var(--gold-bright); min-height: 14px; }

.modal-team-list{ display:flex; flex-direction:column; gap:6px; max-height: 320px; overflow-y:auto; margin-top: 10px; }
.modal-team-row{ display:flex; align-items:center; gap:10px; padding: 8px 10px; border:1px solid var(--ash); border-radius: var(--radius); cursor:pointer; font-family: var(--font-body); font-size:13px; background: var(--panel); }
.modal-team-row:hover{ border-color: var(--blood-bright); }
.modal-team-row .icon{ width:26px; height:26px; border-radius:50%; overflow:hidden; background: var(--void); border:1px solid var(--ash); flex:0 0 auto; }
.modal-team-row .icon img{ width:100%; height:100%; object-fit:contain; }

.copy-row{ display:flex; gap:8px; }
.copy-row input{ flex:1; font-family: var(--font-mono); font-size: 12px; color: var(--bone); background: var(--void); border:1px solid var(--ash); border-radius: var(--radius); padding: 10px 12px; }
.copy-row input::placeholder{ color: var(--bone-faint); }

.modal-share canvas{ width:100%; height:auto; border-radius: var(--radius); border:1px solid var(--ash); }

button:focus-visible, input:focus-visible, .team-card:focus-visible{ outline: 2px solid var(--gold-bright); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
