/* HOOD DERBY v3 — «программка скачек»: дневной ипподром на бумаге.
   Бумага программки, чернильная зелень, красный шёлк, дерево-плакатный
   дисплей (Rye). Классы-контракт с app.js и inline-скриптами сохранены. */
:root {
  --paper:  #ede4cc;   /* фон — бумага программки */
  --paper2: #f8f2e2;   /* панели — свежий лист */
  --ink:    #23281d;   /* чернила */
  --green:  #1e5c3f;   /* гоночная зелень: деньги, рост, ok */
  --green2: #174a32;
  --red:    #c43b2b;   /* красный шёлк: действия, live */
  --red2:   #a92f22;
  --dim:    #6e6853;   /* вторичный текст */
  --line:   #c9bc9c;   /* линейки */
  --turf:   #1e5c3f;   /* .status.ok */
  --rose:   #c43b2b;   /* .status.err */
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
::selection { background: var(--green); color: var(--paper2); }
body {
  margin: 0;
  color: var(--ink);
  font: 15px/1.65 "Archivo", system-ui, sans-serif;
  background:
    radial-gradient(900px 420px at 50% -80px, rgba(255, 255, 255, .5), transparent 70%),
    var(--paper);
}
img { image-rendering: pixelated; max-width: 100%; height: auto; }
a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--red); }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 20px 90px; }
.mono { font-family: "IBM Plex Mono", monospace; }

/* ---------- лента статуса (верх страницы) ---------- */
.ribbon {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 9px 16px;
  background: var(--green2); color: var(--paper);
  font: 12.5px/1.4 "IBM Plex Mono", monospace; letter-spacing: .04em;
  border-bottom: 3px solid var(--ink);
  text-align: center;
}
.dot { width: 9px; height: 9px; flex: none; background: var(--paper);
  opacity: .55; border-radius: 0; }
.dot.live { background: #ff5a41; opacity: 1;
  box-shadow: 0 0 8px rgba(255, 90, 65, .8); }
@media (prefers-reduced-motion: no-preference) {
  .dot.live { animation: pulse 1.6s infinite; }
  @keyframes pulse { 50% { opacity: .35; } }
}

/* ---------- мастхед: афиша ---------- */
.masthead {
  position: relative; text-align: center;
  padding: 44px 0 0;
}
.masthead .shoe { width: 34px; height: 34px; }
.masthead h1 {
  font-family: "Rye", serif; font-weight: 400;
  font-size: clamp(36px, 8vw, 58px); line-height: 1.05;
  margin: 10px 0 0; letter-spacing: .02em;
  color: var(--ink);
  text-shadow: 3px 3px 0 rgba(196, 59, 43, .28);
}
.masthead .tag {
  margin: 12px 0 0; color: var(--dim);
  font: 13px "IBM Plex Mono", monospace; letter-spacing: .06em;
  text-transform: uppercase;
}
.head-pot {
  display: inline-block; margin-top: 18px;
  background: var(--green); color: var(--paper);
  border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
  padding: 10px 18px 11px;
  font: 12px "IBM Plex Mono", monospace; letter-spacing: .08em;
}
.head-pot b {
  font-size: 19px; font-weight: 600; letter-spacing: .02em;
  color: #ffd98a; margin: 0 4px;
}
#wallet {
  position: absolute; top: 14px; right: 0;
}
@media (max-width: 620px) {
  #wallet { position: static; margin-top: 18px; }
  .masthead { padding-top: 26px; }
}

/* ---------- кнопки: печатный штамп ---------- */
.btn {
  font: 800 12px "Archivo", sans-serif; letter-spacing: .1em;
  text-transform: uppercase;
  padding: 12px 18px; cursor: pointer;
  background: var(--red); color: var(--paper2);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}
.btn:hover { background: var(--red2); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.ghost { background: var(--paper2); color: var(--ink); }
.btn.ghost:hover { background: #fff; }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- секции ---------- */
section { margin-top: 0; }
#race { margin-top: 46px; }
.sec {
  font-family: "Rye", serif; font-weight: 400; font-size: 25px;
  margin: 0 0 6px; color: var(--ink); letter-spacing: .02em;
}
.sec small {
  font: 13px "IBM Plex Mono", monospace; color: var(--dim);
  letter-spacing: 0; margin-left: 8px;
}
.sub { margin: 0 0 16px; color: var(--dim); font-size: 13.5px; }
.note { color: var(--dim); font-size: 13px; }
.center { text-align: center; }

/* финишный флаг — разделитель */
.divider {
  height: 14px; margin: 58px 0;
  background: repeating-conic-gradient(var(--ink) 0% 25%, transparent 0% 50%);
  background-size: 14px 14px;
  opacity: .14;
}

/* ---------- панель: лист программки ---------- */
.panel {
  background: var(--paper2);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 24px;
}

/* ---------- герой: афиша дня ---------- */
.stage {
  background: var(--paper2);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}
.champ-banner { padding: 32px 24px 26px; text-align: center; }
.champ-banner img.face, .duel .side img {
  width: 168px; height: 168px; background: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 rgba(35, 40, 29, .25);
}
.face-wrap { position: relative; display: inline-block; }
.face-wrap .rosette {
  position: absolute; right: -18px; bottom: -12px; width: 46px; height: 46px;
  filter: drop-shadow(2px 2px 0 rgba(35, 40, 29, .3));
}
.champ-banner .ttl {
  font-family: "Rye", serif; font-weight: 400; font-size: 28px;
  color: var(--green); margin: 18px 0 4px;
}
.duel {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px;
  align-items: center; text-align: center;
  padding: 32px 20px 26px;
}
.duel .side.flip img { transform: scaleX(-1); }
.duel .vs {
  font-family: "Rye", serif; font-size: 44px; color: var(--red);
  text-shadow: 2px 2px 0 rgba(35, 40, 29, .2);
}
.duel .side .nm { margin-top: 12px; font-size: 14px; font-weight: 600; }
@media (max-width: 560px) {
  .champ-banner img.face, .duel .side img { width: 108px; height: 108px; }
  .duel .vs { font-size: 24px; }
}
.rounds { margin: 14px 0 0; padding: 0; list-style: none; font-size: 14px; }
.rounds li {
  padding: 9px 0; border-top: 1px dashed var(--line);
  display: flex; gap: 8px; justify-content: center;
}

/* чип конюшни: шёлк камзола */
.chip { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.chip .sw { width: 14px; height: 14px; position: relative; flex: none;
  border: 1px solid var(--ink); }
.chip .sw i { position: absolute; inset: 0 0 0 50%; }

/* ---------- пара касс: ставка + заявка ---------- */
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; align-items: start; }
@media (max-width: 720px) { .pair { grid-template-columns: 1fr; gap: 46px; } }

/* ---------- формы ---------- */
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
select, input[type="text"], input[type="number"] {
  background: #fffdf6; color: var(--ink);
  border: 2px solid var(--ink); padding: 11px 12px;
  font: 14px "IBM Plex Mono", monospace; min-width: 0;
}
select:hover, input:hover { background: #fff; }
.money { color: var(--green); font-weight: 700;
  font-family: "IBM Plex Mono", monospace; }
.status { min-height: 22px; margin-top: 12px; font-size: 13px; color: var(--dim); }
.status.ok { color: var(--turf); font-weight: 600; }
.status.err { color: var(--rose); font-weight: 600; }

/* ---------- лошади ---------- */
.horses { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px; }
.hcard {
  background: #fffdf6; border: 2px solid var(--ink);
  padding: 8px; text-align: center; cursor: pointer;
  box-shadow: 3px 3px 0 rgba(35, 40, 29, .2);
  transition: transform .06s;
}
.hcard:hover { border-color: var(--red); transform: translate(-1px, -1px); }
.hcard.done { cursor: default; opacity: .75; }
.hcard.done:hover { border-color: var(--ink); transform: none; }
.hcard img { width: 100%; aspect-ratio: 1; background: var(--paper); }
.hcard .id { font: 600 12px "IBM Plex Mono", monospace; margin-top: 7px; }
.hcard .st { font-size: 11px; color: var(--dim); }
.hcard .in { font-size: 11px; color: var(--green); font-weight: 700; }

/* ---------- билеты: корешки со слипа ---------- */
.tickets { width: 100%; border-collapse: collapse;
  font: 13.5px "IBM Plex Mono", monospace; }
.tickets td { padding: 11px 6px; border-top: 2px dashed var(--line); }
.tickets tr:first-child td { border-top: 0; }
.tickets tr:hover td { background: rgba(30, 92, 63, .05); }
.tickets td:last-child { text-align: right; }

/* ---------- футер: мелкий шрифт программки ---------- */
footer {
  margin-top: 90px; padding-top: 22px; border-top: 3px double var(--line);
  font-size: 14.5px; color: var(--dim);
  display: flex; flex-wrap: wrap; gap: 12px 26px; align-items: center;
}
footer .addr {
  width: 100%; margin-top: 14px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  font-size: 12.5px;
}
.copy {
  font: 12.5px "IBM Plex Mono", monospace; cursor: pointer;
  background: transparent; color: var(--dim);
  border: 1px dashed var(--line); padding: 8px 11px;
}
.copy:hover { color: var(--ink); border-color: var(--dim); }
.copy.did { color: var(--green); border-color: var(--green); }

/* ---------- галерея ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; margin-top: 24px; }
.gcard {
  background: var(--paper2); border: 2px solid var(--ink);
  padding: 10px; text-align: center;
  box-shadow: 3px 3px 0 rgba(35, 40, 29, .2);
}
.gcard:hover { border-color: var(--red); }
.gcard.gold { border-color: #b98a2f; box-shadow: 3px 3px 0 #b98a2f; }
.gcard img { background: var(--paper); }
.gcard .nm { font: 600 12px "IBM Plex Mono", monospace; margin-top: 8px; }
.gcard .st { font-size: 11px; color: var(--dim); }

/* ---------- how ---------- */
.step { display: grid; grid-template-columns: 52px 1fr; gap: 16px; margin-top: 30px; }
.step b.n {
  font-family: "Rye", serif; font-weight: 400; color: var(--red);
  font-size: 26px; line-height: 1; padding-top: 2px;
}
.step h3 { margin: 0 0 6px; font-size: 16px; }
.step p { margin: 0; color: var(--dim); font-size: 14px; }
.illo { width: 100%; border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink); margin-top: 30px; }

/* шапка внутренних страниц */
.pagehead { display: flex; align-items: center; gap: 14px; padding: 26px 0 0; }
.pagehead .wordmark {
  font-family: "Rye", serif; font-size: 20px; color: var(--ink);
  text-decoration: none; display: flex; align-items: center; gap: 10px;
}
.pagehead .wordmark img { width: 24px; height: 24px; }
.pagehead .right { margin-left: auto; }
