/* ==========================================================================
   Festivus Hunger Games — the game surfaces (Phase 4)
   Loaded after app.css and auth.css; shares their tokens.

   Mobile-first throughout: a one-handed bid control, a countdown that stays
   readable at arm's length, and prize imagery that scales without ever
   forcing a horizontal scroll.
   ========================================================================== */

:root {
  --gold: #f0b429;
  --fire: #ff6b35;
}

/* ------------------------------ player header ---------------------------- */

.playerbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--bg-elev-2) 0%, var(--bg-elev) 100%);
  border: 1px solid var(--line);
}

.avatar {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 750;
  font-size: 1rem;
  color: #04241b;
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-dim) 100%);
  letter-spacing: 0.02em;
}

.playerbar__main { flex: 1 1 auto; min-width: 0; }

.playerbar__name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playerbar__points {
  margin: 2px 0 0;
  font-size: 1.35rem;
  font-weight: 750;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.playerbar__points small {
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-left: 4px;
}

.playerbar__split {
  margin: 4px 0 0;
  font-size: 0.74rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.playerbar__split b { color: var(--text-dim); font-weight: 650; }

/* -------------------------------- sections ------------------------------- */

.section { margin-top: 22px; }

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section__title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.section__link {
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--accent);
  text-decoration: none;
}

/* ------------------------------ prize cards ------------------------------ */

.prize-grid {
  display: grid;
  gap: 12px;
}

.prize {
  display: block;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}

.prize:active { transform: scale(0.995); }

.prize__media {
  position: relative;
  width: 100%;
  /* A fixed ratio means the card never jumps as images load. */
  aspect-ratio: 16 / 10;
  background: linear-gradient(145deg, var(--bg-elev-2), var(--bg));
  overflow: hidden;
}

.prize__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.prize__placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--line);
}

.prize__placeholder svg { width: 48px; height: 48px; }

.prize__badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.prize__badge--live { background: color-mix(in srgb, var(--fire) 88%, transparent); color: #26120a; }
.prize__badge--soon { background: color-mix(in srgb, var(--bg) 78%, transparent); color: var(--text-dim); }
.prize__badge--won  { background: color-mix(in srgb, var(--gold) 88%, transparent); color: #2a1c00; }

.prize__body { padding: 12px 14px 14px; }

.prize__name {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
}

.prize__sub {
  margin: 3px 0 0;
  font-size: 0.8rem;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prize__row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.prize__bid { min-width: 0; }

.prize__bid-label {
  display: block;
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.prize__bid-value {
  display: block;
  font-size: 1.15rem;
  font-weight: 750;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.prize__leader {
  font-size: 0.74rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* -------------------------------- countdown ------------------------------ */

.countdown {
  display: flex;
  gap: 5px;
  font-variant-numeric: tabular-nums;
}

.countdown__unit {
  min-width: 38px;
  padding: 5px 4px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  text-align: center;
}

.countdown__value {
  display: block;
  font-size: 1rem;
  font-weight: 750;
  line-height: 1.1;
}

.countdown__label {
  display: block;
  font-size: 0.54rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* The final two minutes: modest, not frantic. */
.countdown--urgent .countdown__unit {
  border-color: color-mix(in srgb, var(--fire) 60%, transparent);
  background: color-mix(in srgb, var(--fire) 14%, var(--bg));
}
.countdown--urgent .countdown__value { color: var(--fire); }

@media (prefers-reduced-motion: no-preference) {
  .countdown--urgent { animation: pulse 2s ease-in-out infinite; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.74; }
}

.countdown--ended .countdown__value { color: var(--text-faint); }

/* ----------------------------- prize detail ------------------------------ */

.detail__media {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elev);
  border: 1px solid var(--line);
}

.detail__title {
  margin: 14px 0 0;
  font-size: 1.5rem;
  font-weight: 750;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.detail__desc {
  margin: 8px 0 0;
  font-size: 0.9rem;
  color: var(--text-dim);
  white-space: pre-wrap;
}

.pricebox {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--line);
}

.pricebox__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pricebox__amount {
  font-size: 2rem;
  font-weight: 750;
  color: var(--gold);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.pricebox__leader {
  margin: 6px 0 0;
  font-size: 0.84rem;
  color: var(--text-dim);
}

.pricebox__leader b { color: var(--text); }

.pricebox__you {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}

.pricebox__stat-label {
  display: block;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.pricebox__stat-value {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------- bidding -------------------------------- */

.bidbar {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
}

.bidbar__quick {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.bidbar__quick .btn {
  flex: 1 1 auto;
  min-width: 72px;
  min-height: 44px;
}

.bidbar__amount {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.bidbar__input {
  flex: 1 1 auto;
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  min-height: var(--tap);
  padding: 0 14px;
  text-align: center;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  width: 100%;
  appearance: none;
  font-variant-numeric: tabular-nums;
}

.bidbar__input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.bidbar__step {
  flex: 0 0 auto;
  width: 48px;
  min-height: var(--tap);
  font-size: 1.3rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.bidbar__hint {
  margin: 0 0 10px;
  font-size: 0.74rem;
  color: var(--text-faint);
  text-align: center;
}

/* --------------------------- confirmation sheet -------------------------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgb(0 0 0 / 0.55);
  padding: 0;
}

.sheet__panel {
  width: 100%;
  max-width: 520px;
  /* Never taller than the viewport, even with a keyboard open. */
  max-height: 86dvh;
  overflow-y: auto;
  padding: 20px 16px calc(20px + var(--safe-bottom));
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-bottom: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .sheet__panel { animation: sheet-up 180ms ease-out; }
}

@keyframes sheet-up {
  from { transform: translateY(12%); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}

.sheet__title {
  margin: 0 0 6px;
  font-size: 1.1rem;
  font-weight: 700;
}

.sheet__body {
  margin: 0 0 16px;
  font-size: 0.92rem;
  color: var(--text-dim);
}

.sheet__body strong { color: var(--gold); }

.sheet__actions { display: flex; gap: 10px; }
.sheet__actions .btn { flex: 1 1 0; }

/* ------------------------------- activity -------------------------------- */

.activity { display: flex; flex-direction: column; }

.activity__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.84rem;
}

.activity__row:last-child { border-bottom: 0; }

.activity__text { min-width: 0; }
.activity__text b { font-weight: 650; }

.activity__row--extend {
  background: color-mix(in srgb, var(--fire) 10%, transparent);
  color: #ffd9c7;
}

.activity__amount {
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.activity__when {
  font-size: 0.7rem;
  color: var(--text-faint);
  white-space: nowrap;
}

/* ------------------------------ overtime flag ---------------------------- */

.overtime {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 650;
  color: #ffd9c7;
  background: color-mix(in srgb, var(--fire) 18%, var(--bg-elev));
  border: 1px solid color-mix(in srgb, var(--fire) 45%, transparent);
}

/* -------------------------------- winner --------------------------------- */

.winner {
  margin-top: 16px;
  padding: 22px 18px;
  border-radius: var(--radius);
  text-align: center;
  background: linear-gradient(170deg, color-mix(in srgb, var(--gold) 20%, var(--bg-elev)) 0%, var(--bg-elev) 100%);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
}

.winner__crown { font-size: 2.4rem; line-height: 1; }

.winner__headline {
  margin: 8px 0 0;
  font-size: 1.4rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  color: var(--gold);
}

.winner__name { margin: 6px 0 0; font-size: 1.05rem; font-weight: 700; }

.winner__amount {
  margin: 10px 0 0;
  font-size: 0.86rem;
  color: var(--text-dim);
}

.winner__amount b {
  display: block;
  font-size: 1.35rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------ leaderboard ------------------------------ */

.board { display: flex; flex-direction: column; }

.board__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.board__row:last-child { border-bottom: 0; }

.board__rank {
  flex: 0 0 auto;
  width: 28px;
  text-align: center;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
}

.board__row--1 .board__rank { color: var(--gold); }
.board__row--2 .board__rank { color: #c6d3d0; }
.board__row--3 .board__rank { color: #cf9b6a; }

.board__main { flex: 1 1 auto; min-width: 0; }

.board__name {
  margin: 0;
  font-weight: 650;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board__meta { margin: 2px 0 0; font-size: 0.72rem; color: var(--text-faint); }

.board__earned {
  flex: 0 0 auto;
  text-align: right;
  font-weight: 750;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.board__earned small {
  display: block;
  font-size: 0.58rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* --------------------------------- admin --------------------------------- */

.admin-prize {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.admin-prize:last-child { border-bottom: 0; }
.admin-prize__main { flex: 1 1 auto; min-width: 0; }
.admin-prize__name { margin: 0; font-size: 0.9rem; font-weight: 650; }
.admin-prize__meta { margin: 2px 0 0; font-size: 0.72rem; color: var(--text-faint); }

.admin-prize__actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 520px) {
  .admin-prize { flex-wrap: wrap; }
  .admin-prize__main { flex: 1 1 100%; }
  .admin-prize__actions { flex: 1 1 100%; justify-content: flex-start; margin-top: 6px; }
}

.field--inline { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@media (max-width: 420px) {
  .field--inline { grid-template-columns: 1fr; }
}

/* ------------------------------ accepted flash --------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .flash-accepted { animation: accepted 700ms ease-out; }
}

@keyframes accepted {
  0% { transform: scale(1); }
  35% { transform: scale(1.04); color: var(--accent); }
  100% { transform: scale(1); }
}

/* A polite live region: present for screen readers, invisible on screen. */
.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;
}
