/* ---------- tokens ---------- */
:root {
  --felt: #1F3A32;
  --felt-deep: #16281F;
  --card-face: #F3ECDC;
  --card-face-dim: #E7DFCB;
  --ink: #241F19;
  --ink-soft: #5B5346;
  --cream: #F3ECDC;
  --cream-muted: #C9C0A9;
  --gold: #C9A24B;
  --gold-deep: #9C7C34;
  --error: #B54545;
  --radius-card: 14px;
  --font-display: "Fraunces", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% -10%, #2A4A40 0%, var(--felt) 45%, var(--felt-deep) 100%);
  color: var(--cream);
  font-family: var(--font-body);
}

button { font-family: inherit; color: inherit; }
a { color: inherit; }

/* ---------- ad bar (top) ---------- */
.ad-bar {
  flex: 0 0 auto;
  position: relative;
  background: var(--felt-deep);
  border-bottom: 1px solid rgba(243, 236, 220, 0.14);
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: min-height 0.15s ease;
}

.ad-bar.is-collapsed {
  min-height: 22px;
}

.ad-bar.is-collapsed .ad-bar__slot {
  display: none;
}

.ad-bar__slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px 40px;
}

.ad-bar__label {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--cream-muted);
}

.chrome-collapse {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--cream-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 4px 8px;
}

.chrome-collapse:hover { color: var(--cream); }

.chrome-collapse--deck { display: none; }

.ad-bar .chrome-collapse {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
}

/* ---------- masthead ---------- */
.masthead {
  flex: 0 0 auto;
  padding: 24px 32px 16px;
  text-align: center;
}

.masthead__title {
  font-family: var(--font-display);
  font-weight: 650;
  font-size: clamp(28px, 4vw, 38px);
  margin: 0 0 6px;
  letter-spacing: 0.01em;
}

.masthead__subtitle {
  margin: 0;
  color: var(--cream-muted);
  font-size: 15px;
}

/* ---------- playfield: side rail + briefing (center) + deck (right) ---------- */
.playfield {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: auto 1fr 296px;
  gap: 0;
}

/* ---------- side rail (left) ---------- */
.side-rail {
  grid-column: 1;
  position: relative;
  width: 150px;
  border-right: 1px solid rgba(243, 236, 220, 0.14);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  transition: width 0.15s ease, padding 0.15s ease;
}

.side-rail.is-collapsed {
  width: 34px;
  padding: 20px 6px;
}

.side-rail.is-collapsed .side-rail__nav,
.side-rail.is-collapsed .side-rail__sponsor {
  display: none;
}

.chrome-collapse--rail {
  align-self: flex-end;
}

.side-rail__nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13.5px;
}

.side-rail__nav a {
  text-decoration: none;
  color: var(--cream-muted);
}

.side-rail__nav a:hover { color: var(--cream); text-decoration: underline; }

.side-rail__sponsor {
  border-top: 1px solid rgba(243, 236, 220, 0.14);
  padding-top: 14px;
  font-size: 12px;
  color: var(--cream-muted);
}

.side-rail__sponsor-label {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
}

.side-rail__sponsor-text {
  margin: 0;
  line-height: 1.4;
}

.briefing-panel {
  grid-column: 2;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 28px 28px;
}

.briefing-empty {
  height: 100%;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--cream-muted);
  font-size: 15px;
}

.briefing-empty.is-hidden { display: none; }

.briefing {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 900px;
  margin: 0 auto;
}

/* dossier blocks */
.dossier {
  background: var(--card-face);
  color: var(--ink);
  border-radius: 10px;
  border-left: 6px solid var(--accent, var(--gold));
  padding: 18px 20px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

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

.dossier__icon {
  width: 20px;
  height: 20px;
  color: var(--accent, var(--gold));
  flex: 0 0 auto;
}

.dossier__icon svg { width: 100%; height: 100%; }

.dossier__label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  flex: 1 1 auto;
}

.dossier__status {
  font-size: 13px;
  color: var(--ink-soft);
}

.dossier__status.is-ready { color: #2F6B3D; }
.dossier__status.is-error { color: var(--error); }

.dossier__body { font-size: 14.5px; line-height: 1.6; }
.dossier__body h3 { font-family: var(--font-display); font-size: 16px; margin: 16px 0 6px; }
.dossier__body h3:first-child { margin-top: 0; }
.dossier__body p { margin: 0 0 10px; }
.dossier__body ul { margin: 0 0 12px; padding-left: 20px; }
.dossier__body li { margin-bottom: 4px; }
.dossier__body a { color: #2C4A6E; text-decoration: underline; text-decoration-color: rgba(44, 74, 110, 0.35); }
.dossier__body a:hover { text-decoration-color: currentColor; }
.dossier.is-error .dossier__body { color: var(--error); font-style: italic; }

.dossier__error-text {
  margin: 0 0 12px;
}

.dossier__retry {
  appearance: none;
  border: 1px solid var(--error);
  background: transparent;
  color: var(--error);
  border-radius: 8px;
  padding: 6px 16px;
  font-family: var(--font-body);
  font-size: 13px;
  font-style: normal;
  cursor: pointer;
}

.dossier__retry:hover { background: rgba(181, 69, 69, 0.1); }

/* ---------- deck panel (right) ---------- */
.deck-panel {
  grid-column: 3;
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid rgba(243, 236, 220, 0.14);
  padding: 16px 16px 20px;
}

.deck-panel__label {
  font-family: var(--font-display);
  font-weight: 560;
  font-size: 15px;
  margin: 0 0 12px;
  color: var(--cream-muted);
  text-align: center;
}

.deck {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

/* ---------- card (shared look, deck + hand) ---------- */
.card {
  appearance: none;
  border: none;
  cursor: pointer;
  width: 100%;
  aspect-ratio: 4 / 5;
  background: var(--card-face);
  color: var(--ink);
  border-radius: var(--radius-card);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  transition: transform 0.15s ease;
}

.deck .card:nth-child(odd)  { transform: rotate(-1.4deg); }
.deck .card:nth-child(even) { transform: rotate(1.4deg); }
.deck .card:hover, .deck .card:focus-visible { transform: rotate(0deg) translateY(-5px) scale(1.05); }

.card__icon { width: 24px; height: 24px; color: var(--accent, var(--gold-deep)); }
.card__icon svg { width: 100%; height: 100%; }
.card__label { font-family: var(--font-display); font-weight: 600; font-size: 12.5px; line-height: 1.15; }
.card__blurb { font-size: 10px; color: var(--ink-soft); line-height: 1.25; }
.card.is-selected { opacity: 0.45; }
.card:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ---------- hand bar (bottom), collapsible, starts collapsed ---------- */
.hand-bar {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(22, 40, 31, 0.4), var(--felt-deep) 30%);
  border-top: 1px solid rgba(243, 236, 220, 0.14);
}

.hand-bar__handle {
  width: 100%;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--cream-muted);
  cursor: pointer;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 13px;
}

.hand-bar__handle:hover { color: var(--cream); }

.hand-bar__chevron {
  display: inline-block;
  font-size: 10px;
  transition: transform 0.15s ease;
}

.hand-bar.is-collapsed .hand-bar__chevron { transform: rotate(180deg); }

.hand-bar__body {
  padding: 4px 20px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-height: 260px;
  overflow: hidden;
  transition: max-height 0.15s ease, padding 0.15s ease;
}

.hand-bar.is-collapsed .hand-bar__body {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.hand {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 10px;
  min-height: 90px;
  max-height: 140px;
  overflow-y: auto;
  padding: 4px;
}

.hand__empty { color: var(--cream-muted); font-size: 13.5px; align-self: center; }

.hand-card {
  width: 84px;
  aspect-ratio: 4 / 5;
  background: var(--card-face);
  color: var(--ink);
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  position: relative;
}

.hand-card:nth-child(odd)  { transform: rotate(-2deg); }
.hand-card:nth-child(even) { transform: rotate(2deg); }
.hand-card__icon { width: 16px; height: 16px; color: var(--accent, var(--gold-deep)); }
.hand-card__icon svg { width: 100%; height: 100%; }
.hand-card__label { font-family: var(--font-display); font-size: 11px; font-weight: 600; line-height: 1.1; }

.hand-card__remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: var(--ink);
  color: var(--cream);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.deal-button {
  appearance: none;
  border: none;
  cursor: pointer;
  padding: 10px 38px;
  border-radius: 999px;
  background: linear-gradient(180deg, #DFC172, var(--gold) 55%, var(--gold-deep));
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 15px;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.deal-button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4); }
.deal-button:disabled { opacity: 0.4; cursor: not-allowed; }
.deal-button:focus-visible { outline: 2px solid var(--cream); outline-offset: 3px; }

.hand-estimate { margin: 0; font-size: 12px; color: var(--cream-muted); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .playfield { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }

  .side-rail {
    grid-column: 1; grid-row: 1;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid rgba(243, 236, 220, 0.14);
    width: auto;
  }
  .side-rail.is-collapsed { height: 0; padding: 0; }
  .side-rail__nav { flex-direction: row; gap: 16px; }
  .side-rail__sponsor { border-top: none; border-left: 1px solid rgba(243,236,220,0.14); padding: 0 0 0 14px; }
  .chrome-collapse--rail { display: none; } /* simplest on mobile: always visible or use hand-bar-style handle if needed */

  .deck-panel {
    grid-column: 1; grid-row: 2;
    border-left: none;
    border-bottom: 1px solid rgba(243, 236, 220, 0.14);
    overflow-x: auto;
    overflow-y: hidden;
    padding: 12px 14px;
    position: relative;
  }
  .deck-panel__label { display: none; }
  .deck { display: flex; flex-direction: row; justify-content: flex-start; }
  .deck .card { flex: 0 0 auto; width: 132px; }

  .chrome-collapse--deck {
    display: flex;
    position: absolute;
    top: 6px;
    right: 10px;
    z-index: 2;
  }
  .deck-panel.is-collapsed {
    padding: 8px 40px 8px 14px;
    overflow: hidden;
  }
  .deck-panel.is-collapsed .deck { display: none; }

  .briefing-panel {
    grid-column: 1; grid-row: 3;
    /* The hand bar is sticky and lives outside .playfield entirely, so its
       expanded height (handle + up to 260px of body) isn't accounted for
       by the grid's own sizing on narrow viewports where vertical space is
       tight. Without this, dealt briefing content gets visually covered by
       the hand bar the moment it expands. 340px covers the handle plus the
       body's max-height plus a safety margin. */
    padding-bottom: 340px;
  }
}

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

/* =====================================================================
   Simple pages (About, Contact, Privacy, Terms, 404, 500)
   ===================================================================== */

.simple-page {
  align-items: stretch;
}

.simple-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid rgba(243, 236, 220, 0.14);
}

.simple-header__brand {
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 20px;
  text-decoration: none;
  color: var(--cream);
}

.simple-header__nav { display: flex; gap: 20px; font-size: 14px; }
.simple-header__nav a { text-decoration: none; color: var(--cream-muted); }
.simple-header__nav a:hover { color: var(--cream); }

.simple-content {
  flex: 1 1 auto;
  padding: 40px 24px 60px;
  display: flex;
  justify-content: center;
}

.prose {
  max-width: 680px;
  width: 100%;
  background: var(--card-face);
  color: var(--ink);
  border-radius: 12px;
  padding: 36px 40px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  line-height: 1.65;
}

.prose h1 {
  font-family: var(--font-display);
  font-size: 30px;
  margin: 0 0 18px;
}

.prose h2 {
  font-family: var(--font-display);
  font-size: 19px;
  margin: 28px 0 8px;
}

.prose p { margin: 0 0 14px; }
.prose ul { margin: 0 0 14px; padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose a { color: #2C4A6E; text-decoration: underline; }

.prose__flag {
  background: #FBEFD6;
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13.5px;
  color: var(--ink-soft);
  margin-bottom: 24px;
}

.prose__note { font-size: 13px; color: var(--ink-soft); font-style: italic; }

.donate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin: 24px 0;
}
.donate-entry {
  background: var(--card-face);
  border: 1px solid var(--gold-deep);
  border-radius: var(--radius-card);
  padding: 20px;
  text-align: center;
}
.donate-entry h2 {
  font-family: var(--font-display);
  font-size: 17px;
  margin: 0 0 14px;
  color: var(--ink);
}
.donate-entry__qr {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}
.donate-entry__qr img, .donate-entry__qr canvas {
  border-radius: 6px;
}
.donate-entry__address {
  font-family: monospace;
  font-size: 12.5px;
  color: var(--ink-soft);
  word-break: break-all;
  margin: 0;
}

.prose--center { text-align: center; }

.simple-footer {
  flex: 0 0 auto;
  text-align: center;
  padding: 20px;
  font-size: 12.5px;
  color: var(--cream-muted);
  border-top: 1px solid rgba(243, 236, 220, 0.14);
}

.simple-footer nav { margin-top: 6px; }
.simple-footer a { color: var(--cream-muted); text-decoration: none; }
.simple-footer a:hover { text-decoration: underline; }
