:root {
  --bg: #0f3d2e;
  --bg-2: #1b6146;
  --card: #fff8ec;
  --card-2: #f5ead6;
  --ink: #2a2118;
  --muted: #7b6f5f;
  --line: #e6d8bf;
  --red: #e0402a;
  --red-dark: #a92a19;
  --gold: #ffc93c;
  --gold-dark: #c99212;
  --green: #1f9a48;
  --blue: #2a5bd7;
  --shadow: 0 14px 40px rgba(0, 0, 0, .3);
  --radius: 20px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--card);
  background:
    radial-gradient(ellipse at top, var(--bg-2), var(--bg) 65%) fixed,
    var(--bg);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
input { font: inherit; }
a { color: inherit; }

.card {
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- buttons ---------- */
.btn {
  border: 0;
  border-radius: 999px;
  padding: 11px 22px;
  font-weight: 600;
  font-size: 17px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 0 #cdbd9f;
  transition: transform .08s, box-shadow .08s, filter .15s;
  touch-action: manipulation;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 5px 0 #cdbd9f; }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #cdbd9f; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--red); color: #fff; box-shadow: 0 4px 0 var(--red-dark); }
.btn.primary:hover:not(:disabled) { box-shadow: 0 5px 0 var(--red-dark); }
.btn.primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--red-dark); }
.btn.gold { background: var(--gold); color: #3a2a05; box-shadow: 0 4px 0 var(--gold-dark); }
.btn.gold:hover:not(:disabled) { box-shadow: 0 5px 0 var(--gold-dark); }
.btn.gold:active:not(:disabled) { box-shadow: 0 1px 0 var(--gold-dark); }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); text-decoration: underline; padding: 8px 12px; }
.btn.big { font-size: 21px; padding: 14px 28px; width: 100%; }
.btn.small { font-size: 14px; padding: 6px 12px; box-shadow: 0 3px 0 #cdbd9f; }

/* ---------- home ---------- */
.home {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 16px 40px;
}
.site { margin: 0 0 10px; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: #a8d8bf; }
.site a { text-decoration: none; }
.site a:hover { text-decoration: underline; }
.logo { font-size: clamp(42px, 11vw, 64px); margin: 4px 0 2px; font-weight: 700; letter-spacing: .01em; text-shadow: 0 4px 0 rgba(0, 0, 0, .25); }
.logo-horse { display: inline-block; animation: bob 1.1s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-6px) rotate(3deg); } }
.tagline { margin: 4px 0 4px; text-align: center; color: #d9f0e3; font-size: 18px; line-height: 1.35; }
.home-horse { width: 300px; height: 110px; max-width: 100%; }
.home-card { width: 100%; max-width: 420px; padding: 22px 22px 18px; }
.field-label { display: block; font-weight: 600; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.you-row { display: flex; gap: 10px; margin-bottom: 16px; }
.avatar-btn {
  flex: 0 0 auto; width: 52px; height: 52px; border-radius: 16px; border: 2px solid var(--line);
  background: var(--card-2); font-size: 28px; line-height: 1;
}
.avatar-btn:hover { border-color: var(--gold); }
input {
  border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; font-size: 18px;
  background: #fff; color: var(--ink); min-width: 0; width: 100%; outline: none;
}
input:focus { border-color: var(--gold); }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; margin: 18px 0 12px; }
.or::before, .or::after { content: ''; flex: 1; border-top: 1px dashed var(--line); }
.join-row { display: flex; gap: 10px; }
.join-row input { font-size: 24px; letter-spacing: .25em; text-align: center; font-weight: 600; }
.join-row input::placeholder { letter-spacing: normal; font-size: 17px; font-weight: 400; }
.msg { min-height: 1.3em; margin: 12px 0 0; font-size: 15px; color: var(--red-dark); text-align: center; }
.msg.ok { color: var(--green); }
.rules { width: 100%; max-width: 420px; margin-top: 18px; padding: 14px 20px; }
.rules summary { font-weight: 600; cursor: pointer; font-size: 17px; }
.rules ol { padding-left: 20px; margin: 10px 0 4px; line-height: 1.45; font-size: 15px; color: #4a3f33; }
.rules li { margin-bottom: 6px; }
.build { margin-top: 18px; font-size: 12px; color: #7fb59a; }

/* ---------- room ---------- */
.room { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: rgba(10, 42, 31, .92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand-sm { font-weight: 700; font-size: 19px; white-space: nowrap; }
.code-btn {
  border: 0; border-radius: 12px; padding: 6px 12px; background: var(--gold); color: #3a2a05;
  font-weight: 500; font-size: 15px; box-shadow: 0 3px 0 var(--gold-dark); white-space: nowrap;
}
.code-btn b { font-size: 19px; letter-spacing: .12em; margin: 0 2px; }
.code-btn .copy { font-size: 12px; opacity: .8; margin-left: 4px; }
.spacer { flex: 1; }
.icon-btn {
  border: 0; border-radius: 12px; padding: 7px 11px; background: rgba(255, 255, 255, .12); color: #fff; font-size: 16px;
}
.icon-btn:hover { background: rgba(255, 255, 255, .2); }
.status {
  background: #ffb020; color: #3a2405; text-align: center; padding: 8px 12px; font-weight: 600;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { filter: brightness(1.12); } }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  padding: 16px;
  max-width: 1280px;
  margin: 0 auto;
}
.side { display: flex; flex-direction: column; gap: 16px; }
.side-card { padding: 14px 14px 10px; }
.side-card h3 { margin: 0 0 10px; font-size: 17px; display: flex; align-items: center; gap: 6px; }
.count { font-size: 13px; color: var(--muted); font-weight: 500; }

/* players + tallies */
.players { display: flex; flex-direction: column; gap: 8px; }
.player {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 10px; border-radius: 14px; background: var(--card-2);
  position: relative;
}
.player.me { background: #fff1c4; box-shadow: inset 0 0 0 2px var(--gold); }
.player.off { opacity: .55; }
.pav { font-size: 26px; line-height: 1.1; flex: 0 0 auto; }
.pbody { min-width: 0; flex: 1; }
.pname { font-weight: 600; font-size: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; word-break: break-word; }
.tag { font-size: 10px; font-weight: 700; letter-spacing: .06em; padding: 2px 6px; border-radius: 6px; background: var(--ink); color: #fff; }
.tag.host { background: var(--red); }
.tag.you { background: var(--gold); color: #3a2a05; }
.tag.away { background: #9a9080; }
.ptally { font-size: 13px; color: #5c5040; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 2px 10px; }
.ptally b { color: var(--ink); }
.pstatus { font-size: 12.5px; color: var(--muted); margin-top: 3px; display: flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0, 0, 0, .3); flex: 0 0 auto; }
.pedit { border: 0; background: none; padding: 0 2px; font-size: 13px; opacity: .6; }
.pedit:hover { opacity: 1; }
.premove { position: absolute; top: 6px; right: 6px; border: 0; background: rgba(0, 0, 0, .08); border-radius: 8px; font-size: 12px; padding: 2px 7px; color: var(--ink); }

.log { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; font-size: 13.5px; color: #4f4436; }
.log div { padding: 4px 0; border-top: 1px dashed var(--line); line-height: 1.3; }

/* ---------- stage ---------- */
.stage { min-width: 0; }
.panel { padding: 18px; }
.phase-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 4px; }
.phase-head h2 { margin: 0; font-size: 28px; }
.phase-head .sub { color: var(--muted); font-size: 15px; }
.hint { color: var(--muted); font-size: 15px; margin: 2px 0 14px; line-height: 1.35; }

.horses { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.horse-card {
  position: relative; text-align: left; border: 3px solid transparent; border-radius: 18px;
  background: #fff; color: var(--ink); padding: 10px 12px 12px; box-shadow: 0 4px 0 #e2d3b6;
  display: flex; flex-direction: column; gap: 4px; min-height: 100%;
  transition: transform .1s, border-color .15s;
}
.horse-card:hover { transform: translateY(-2px); }
.horse-card.mine { border-color: var(--gold); background: #fff8dc; box-shadow: 0 4px 0 var(--gold-dark); }
.horse-card .num {
  position: absolute; top: 10px; left: 10px; min-width: 32px; height: 32px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 19px;
  border: 1px solid rgba(0, 0, 0, .2);
}
.horse-card canvas { width: 100%; height: 92px; display: block; }
.hname { font-weight: 700; font-size: 18px; line-height: 1.15; word-break: break-word; }
.hmeta { font-size: 12.5px; color: var(--muted); }
.backers { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.backer { font-size: 12.5px; background: var(--card-2); border-radius: 999px; padding: 2px 8px 2px 5px; white-space: nowrap; }
.backer.first { background: #ffe7a3; }
.backer.is-me { outline: 2px solid var(--gold); }
.rename-btn {
  align-self: flex-start; margin-top: 4px; border: 0; border-radius: 999px; padding: 5px 10px; font-size: 13px; font-weight: 600;
  background: var(--ink); color: #fff;
}
.mine-badge { position: absolute; top: 10px; right: 10px; background: var(--gold); color: #3a2a05; font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 7px; letter-spacing: .05em; }

.trackbar {
  margin: 0 0 14px; padding: 10px 14px; border-radius: 16px; background: #e9f5ec; border: 2px dashed #b6dcc0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
}
.trackbar .label { font-weight: 600; }
.trackbar .stepper button { width: 36px; height: 36px; font-size: 20px; }
.trackbar .stepper button:disabled { opacity: .4; }
.trackbar input { width: 74px; text-align: center; font-size: 20px; font-weight: 700; padding: 5px 4px; border-radius: 10px; -moz-appearance: textfield; }
.trackbar input::-webkit-inner-spin-button, .trackbar input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.trackbar .gunit { font-weight: 600; color: var(--muted); margin-left: -4px; }
.trackbar .gcount { font-size: 18px; }
.trackbar .presets { flex-wrap: wrap; }
.trackbar .presets button { font-size: 14px; }
.track-note { flex: 1 1 100%; font-size: 13.5px; color: #4f6b57; }
.trackbar .setrow { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.trackbar .setrow .label { min-width: 78px; }
.trackbar .hcount { min-width: 48px; font-size: 22px; }
.betbar {
  margin-top: 16px; padding: 14px; border-radius: 16px; background: var(--card-2);
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
}
.betbar .label { font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button {
  width: 42px; height: 42px; border-radius: 12px; border: 0; background: #fff; font-size: 22px; font-weight: 700;
  box-shadow: 0 3px 0 #cdbd9f; color: var(--ink);
}
.stepper button:active { transform: translateY(2px); box-shadow: 0 1px 0 #cdbd9f; }
.stepper .amt { min-width: 64px; text-align: center; font-size: 26px; font-weight: 700; }
.stepper .amt small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); margin-top: -4px; }
.quick { display: flex; gap: 6px; }
.quick button { border: 0; border-radius: 10px; padding: 7px 10px; background: #fff; font-weight: 600; color: var(--ink); box-shadow: 0 2px 0 #cdbd9f; }
.quick button.on { background: var(--gold); box-shadow: 0 2px 0 var(--gold-dark); }
input[type=range] { padding: 0; border: 0; accent-color: var(--red); flex: 1 1 160px; min-width: 120px; background: transparent; }
.bet-summary { flex: 1 1 100%; font-size: 15px; color: #4f4436; }
.host-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin-top: 16px; }
.host-row .note { color: var(--muted); font-size: 15px; }
.waiting { color: var(--muted); font-size: 16px; padding: 6px 0; }

/* race */
.race-panel { padding: 14px; }
.track-wrap { position: relative; border-radius: 14px; overflow: hidden; background: #3f9a3a; margin-top: 8px; }
#track { display: block; width: 100%; }
/* gate-stop announcements sit along the top (over the grandstand) so the horses stay visible */
.banner {
  position: absolute; left: 50%; top: 22px; transform: translateX(-50%);
  background: rgba(20, 16, 10, .84); color: #fff; padding: 5px 14px; border-radius: 12px;
  text-align: center; font-weight: 600; font-size: 15px; line-height: 1.3; pointer-events: none;
  width: max-content; max-width: 94%; box-shadow: 0 6px 18px rgba(0, 0, 0, .3); opacity: 0; transition: opacity .2s;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0 14px;
}
.banner.show { opacity: 1; }
.banner .big { font-size: 16px; }
.banner .boost { color: #ffe14d; }
.banner .setback { color: #a9c9ff; }
/* the winner announcement can go big in the middle: the race is over */
.banner.win { top: 50%; transform: translate(-50%, -50%); padding: 10px 20px; flex-direction: column; font-size: 17px; }
.banner.win .big { font-size: 24px; }
.countdown {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column;
  font-size: clamp(56px, 14vw, 110px); font-weight: 700; color: #fff; text-shadow: 0 6px 0 rgba(0, 0, 0, .35);
  pointer-events: none;
}
.countdown small { font-size: 20px; font-weight: 600; text-shadow: 0 2px 0 rgba(0, 0, 0, .4); }
.countdown .pop { animation: pop .5s ease-out; }
@keyframes pop { from { transform: scale(1.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.commentary { margin: 10px 2px 4px; font-size: 17px; font-weight: 600; min-height: 1.4em; color: var(--ink); }
.standings { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 10px; margin-top: 8px; }
.stand { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 12px; background: var(--card-2); font-size: 14.5px; min-width: 0; }
.stand.mine { background: #fff1c4; box-shadow: inset 0 0 0 2px var(--gold); }
.stand .place { font-weight: 700; width: 30px; flex: 0 0 auto; }
.stand .chip { flex: 0 0 auto; min-width: 24px; height: 24px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; border: 1px solid rgba(0, 0, 0, .2); }
.stand .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.stand .who { font-size: 13px; white-space: nowrap; }
.gate-info { font-weight: 600; color: var(--muted); }

/* results */
/* the podium scene: winner up top with the trophy, everyone else sad at the bottom */
.podium-box { position: relative; border-radius: 18px; overflow: hidden; background: #121a42; margin: 6px 0 10px; box-shadow: inset 0 0 0 3px rgba(255, 213, 74, .5); }
.podium-box canvas { display: block; width: 100%; }
.podium-title {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  max-width: 94%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 4px 16px; border-radius: 999px; background: rgba(10, 12, 30, .55);
  color: #ffe27a; font-weight: 700; font-size: 22px; text-shadow: 0 2px 0 rgba(0, 0, 0, .5);
  animation: title-in .6s ease-out;
}
@keyframes title-in { from { transform: translate(-50%, -24px); opacity: 0; } }
.backed { margin: 4px 2px 0; color: #5c4a1c; }
.next-row { margin-top: 10px; }
.big-next { font-size: 20px; padding: 12px 30px; }
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.res-block { background: var(--card-2); border-radius: 16px; padding: 12px 14px; }
.res-block h3 { margin: 0 0 8px; font-size: 17px; }
.order { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; }
.order li { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.order .pl { width: 34px; font-weight: 700; color: var(--muted); }
.order li:first-child .pl { color: var(--gold-dark); }
.payouts { display: flex; flex-direction: column; gap: 5px; font-size: 15px; }
.payout { display: flex; gap: 8px; align-items: center; }
.payout .amt { margin-left: auto; font-weight: 700; white-space: nowrap; }
.payout .amt.win { color: var(--green); }
.payout .amt.lose { color: var(--red-dark); font-weight: 600; }

.penalty { margin-top: 14px; border: 3px solid var(--red); border-radius: 18px; padding: 14px; background: #fff3ef; }
.penalty h3 { margin: 0 0 4px; font-size: 21px; color: var(--red-dark); }
.penalty p { margin: 0 0 10px; color: #6b4a3f; }
.pen-rows { display: flex; flex-direction: column; gap: 6px; }
.pen-row { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 12px; padding: 6px 8px 6px 10px; }
.pen-row .who { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pen-row.off .who { opacity: .6; }
.pen-row .stepper button { width: 36px; height: 36px; font-size: 20px; }
.pen-row .stepper .amt { min-width: 40px; font-size: 21px; }
.pen-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.pen-left { font-weight: 700; font-size: 18px; }
.pen-left.zero { color: var(--green); }
.attacks { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.attack-line { background: #ffe9e3; border-radius: 12px; padding: 8px 12px; font-size: 15px; }
.attack-line.me { background: #ffd2c4; font-weight: 600; }

/* ---------- modal + toasts ---------- */
.modal-root { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(5, 20, 14, .6); }
.modal-root.open { display: flex; }
.modal { width: 100%; max-width: 420px; padding: 22px; text-align: center; animation: pop-in .2s ease-out; max-height: 90vh; overflow-y: auto; }
@keyframes pop-in { from { transform: scale(.9); opacity: 0; } }
.modal h2 { margin: 0 0 8px; font-size: 24px; }
.modal p { margin: 0 0 14px; color: #5c5040; line-height: 1.4; }
.modal .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.modal input { margin-bottom: 4px; }
.avatars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 10px 0; }
.avatars button { font-size: 26px; border: 2px solid var(--line); border-radius: 12px; background: #fff; padding: 6px 0; }
.avatars button.on { border-color: var(--gold); background: #fff1c4; }

/* the styling studio: preview pinned on top, save pinned at the bottom */
.modal.studio { max-width: 580px; text-align: left; padding: 18px; }
.studio h2 { text-align: center; margin-bottom: 6px; }
.studio-stage { position: sticky; top: -18px; z-index: 2; background: var(--card); margin: 0 -18px; padding: 4px 18px 6px; }
.studio-stage canvas { width: 100%; height: 150px; display: block; border-radius: 14px; background: linear-gradient(#a9dcff, #e6f6ff 70%); }
.studio-name { display: flex; gap: 8px; margin: 10px 0; }
.studio-name input { font-weight: 600; }
.studio-tabs { display: flex; gap: 6px; margin: 4px 0 6px; }
.studio-tabs button { flex: 1; border: 0; border-radius: 12px; padding: 9px; font-weight: 600; font-size: 16px; background: var(--card-2); color: var(--ink); }
.studio-tabs button.on { background: var(--ink); color: #fff; }
.studio h4 { margin: 14px 0 6px; font-size: 16px; }
.studio h4 span { font-weight: 500; color: var(--muted); margin-left: 6px; font-size: 14px; }
.swgroup > span { font-size: 12px; color: var(--muted); display: block; margin: 6px 0 3px; }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.sw { width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .18); padding: 0; cursor: pointer; flex: 0 0 auto; }
.sw.on { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--gold); }
.gearlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px; }
.gearbtn { display: flex; align-items: center; gap: 6px; border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 6px 8px; font-size: 13px; color: var(--ink); text-align: left; line-height: 1.15; }
.gearbtn span { font-size: 20px; flex: 0 0 auto; }
.gearbtn.on { border-color: var(--gold); background: #fff1c4; }
.studio-buttons { position: sticky; bottom: -18px; background: var(--card); padding: 10px 0 6px; margin: 10px 0 -6px; border-top: 1px dashed var(--line); }
.attack-modal { background: #fff3ef; border: 4px solid var(--red); animation: shake .55s ease-in-out, pop-in .2s ease-out; }
.attack-modal .boom { font-size: 72px; line-height: 1; margin-bottom: 4px; }
.attack-modal h2 { color: var(--red-dark); font-size: 30px; letter-spacing: .02em; }
.attack-modal .num { font-size: 44px; font-weight: 700; color: var(--red); display: block; }
@keyframes shake {
  10%, 90% { transform: translateX(-4px) rotate(-1deg); }
  20%, 80% { transform: translateX(8px) rotate(1deg); }
  30%, 50%, 70% { transform: translateX(-12px) rotate(-2deg); }
  40%, 60% { transform: translateX(12px) rotate(2deg); }
}
.toasts { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 460px); }
.toast { background: rgba(20, 16, 10, .92); color: #fff; padding: 10px 16px; border-radius: 14px; font-size: 15px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); animation: toast-in .2s ease-out; text-align: center; }
.toast.err { background: #b3261e; }
.toast.good { background: #1f7a3c; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* ---------- phones ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 12px; gap: 14px; }
}
@media (max-width: 600px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand-sm { display: none; }
  .code-btn .copy { display: none; }
  .panel { padding: 14px; }
  .race-panel { padding: 10px; }
  .phase-head h2 { font-size: 23px; }
  .horses { grid-template-columns: 1fr 1fr; gap: 8px; }
  .horse-card { padding: 8px 9px 10px; }
  .horse-card canvas { height: 70px; }
  .horse-card .num { min-width: 27px; height: 27px; font-size: 16px; top: 8px; left: 8px; }
  .hname { font-size: 15.5px; }
  .res-grid { grid-template-columns: 1fr; }
  .podium-title { font-size: 16px; top: 8px; padding: 3px 12px; }
  .big-next { width: 100%; }
  .standings { grid-template-columns: 1fr; }
  .banner { font-size: 13.5px; padding: 4px 10px; gap: 0 10px; top: 20px; flex-wrap: nowrap; white-space: nowrap; }
  .banner .big { font-size: 13.5px; }
  .banner.win { white-space: normal; }
  .banner.win .big { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  .logo-horse, .status { animation: none; }
  .attack-modal { animation: pop-in .2s ease-out; }
}
