:root {
  color-scheme: light;
  --ink: #261d12;
  --muted: #6f5a39;
  --sky: #8fd7ff;
  --sky-deep: #3a9ed8;
  --grass: #5eb66b;
  --stone: #d7d1bd;
  --stone-dark: #75684e;
  --paper: #fff2c7;
  --paper-deep: #f1ca72;
  --gold: #d99a28;
  --red: #c94d3f;
  --blue: #315fba;
  --green: #2f8f54;
  --shadow: rgba(60, 34, 12, 0.22);
  font-family: "Trebuchet MS", "Microsoft YaHei", Arial, sans-serif;
  background: var(--sky);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(255, 248, 222, 0.08), rgba(95, 60, 18, 0.16)),
    url("./assets/racecourse-bg.png") center top / cover fixed no-repeat;
  position: relative;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 10px;
  min-height: 100vh;
  position: relative;
}

.hero {
  min-height: 100vh;
  display: grid;
  align-content: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
}

.title-block {
  position: relative;
  padding: 12px 2px;
  text-shadow:
    2px 0 0 #fff7d9,
    -2px 0 0 #fff7d9,
    0 2px 0 #fff7d9,
    0 -2px 0 #fff7d9,
    3px 5px 0 rgba(65, 39, 13, 0.36);
}

.title-block h1,
.topbar h2,
.royal-board h2 {
  margin: 0;
  letter-spacing: 0;
}

.title-block h1 {
  font-size: clamp(2.25rem, 10vw, 5rem);
  line-height: 0.95;
}

.version-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  padding: 5px 8px;
  border: 2px solid #6d4515;
  background: rgba(255, 247, 217, 0.92);
  color: #5f3e15;
  font-size: 0.72rem;
  font-weight: 900;
  box-shadow: 0 3px 0 rgba(65, 39, 13, 0.25);
}

.subtitle,
.muted {
  color: var(--muted);
}

.subtitle {
  margin: 8px 0 0;
  font-size: 1.05rem;
  font-weight: 900;
  color: #3f2a12;
}

.eyebrow {
  margin: 0 0 5px;
  color: #73521d;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.panel,
.horse-card,
.bet-dock,
.topbar {
  border: 3px solid var(--stone-dark);
  background: rgba(255, 242, 199, 0.96);
  box-shadow: 0 6px 0 var(--shadow), inset 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.panel {
  padding: 14px;
}

.command-panel {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 800;
}

input {
  width: 100%;
  border: 3px solid var(--stone-dark);
  border-radius: 0;
  padding: 12px;
  background: #fff8df;
  color: var(--ink);
}

input[type="radio"],
input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: #d99a28;
}

.mode-select {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 10px;
  border: 3px solid rgba(117, 104, 78, 0.72);
  background: rgba(255, 248, 223, 0.6);
}

.mode-select legend {
  padding: 0 6px;
  font-weight: 900;
  color: #5f3e15;
}

.mode-option {
  grid-template-columns: auto 1fr;
  align-items: center;
  padding: 8px;
  border: 2px solid rgba(117, 104, 78, 0.42);
  background: rgba(255, 255, 255, 0.42);
}

.mode-option small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
}

.primary-button,
.secondary-button,
.danger-button,
.chip {
  min-height: 42px;
  border: 3px solid #523d1f;
  border-radius: 0;
  font-weight: 900;
  color: #1f160b;
  box-shadow: 0 4px 0 rgba(65, 39, 13, 0.3);
}

.primary-button {
  background: linear-gradient(#ffe083, var(--gold));
}

.secondary-button,
.chip {
  background: #fff7d9;
}

.danger-button {
  min-height: 36px;
  padding: 5px 8px;
  background: #fff1df;
  color: #7b2119;
  border-color: #7b2119;
  white-space: nowrap;
}

.mini-button {
  min-height: 36px;
  padding: 5px 8px;
  white-space: nowrap;
}

.primary-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.wide {
  width: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 6px 8px;
  background: rgba(255, 231, 160, 0.96);
  backdrop-filter: blur(2px);
}

.topbar h2 {
  font-size: 1.42rem;
  line-height: 1.05;
  white-space: nowrap;
}

.round-badge,
.odds,
.mode-badge {
  background: var(--gold);
  border: 3px solid #6d4515;
  padding: 5px 7px;
  font-weight: 900;
  white-space: nowrap;
}

.mode-badge,
.topbar-mode {
  display: inline-block;
  margin: 8px 0 0;
}

.topbar-mode {
  display: block;
  margin: 0 0 2px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #5f3e15;
  font-size: 0.68rem;
  line-height: 1;
  font-weight: 900;
}

.topbar-actions {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 6px;
}

.arena-layout,
.betting-layout,
.result-layout {
  display: grid;
  gap: 10px;
}

.royal-board {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.35), transparent),
    var(--paper-deep);
}

.winner-odds {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 7px;
  border: 2px solid rgba(109, 69, 21, 0.82);
  background: rgba(255, 247, 217, 0.86);
  color: #5f3e15;
  font-size: 0.58em;
  vertical-align: middle;
  box-shadow: 0 3px 0 rgba(65, 39, 13, 0.18);
}

.player-list {
  display: grid;
  gap: 8px;
}

.player-row,
.settlement-row,
.ranking li {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.42);
  border: 2px solid rgba(117, 104, 78, 0.35);
}

.player-row em {
  color: var(--muted);
  font-style: normal;
  font-size: 0.82rem;
}

.player-row small,
.ranking small {
  color: var(--muted);
  font-size: 0.76rem;
}

.horse-grid {
  display: grid;
  gap: 8px;
}

.horse-card {
  padding: 8px;
  background: #fff1bf;
}

.horse-card.selected {
  outline: 4px solid var(--blue);
  background: #fff6d8;
}

.horse-card__head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  row-gap: 4px;
}

.portrait,
.horse-sprite {
  display: block;
  image-rendering: pixelated;
  background-position: 0 50%;
  background-repeat: no-repeat;
  background-size: 500% 100%;
  animation: horse-gallop 0.55s infinite;
}

.portrait {
  width: 76px;
  height: 36px;
  border: 3px solid #1a3470;
  background-color: #cdeeff;
}

.horse-sprite {
  width: 92px;
  height: 38px;
  filter: drop-shadow(2px 3px 0 rgba(65, 39, 13, 0.35));
}

.horse-skin-1 { background-image: url("./assets/horse-run-brown-sheet.png"); }
.horse-skin-2 { background-image: url("./assets/horse-run-white-sheet.png"); }
.horse-skin-3 { background-image: url("./assets/horse-run-black-sheet.png"); }

.racer-skin-horse-1 {
  background-image: url("./assets/horse-run-brown-sheet.png");
}

.racer-skin-horse-2 {
  background-image: url("./assets/horse-run-white-sheet.png");
}

.racer-skin-horse-3 {
  background-image: url("./assets/horse-run-black-sheet.png");
}

.racer-skin-donkey-1 { background-image: url("./assets/racers/donkey-gpt-sheet.png"); }
.racer-skin-deer-1 { background-image: url("./assets/racers/deer-gpt-sheet.png"); }
.racer-skin-goat-1 { background-image: url("./assets/racers/goat-gpt-sheet.png"); }
.racer-skin-ostrich-1 { background-image: url("./assets/racers/ostrich-gpt-sheet.png"); }
.racer-skin-camel-1 { background-image: url("./assets/racers/camel-gpt-sheet.png"); }
.racer-skin-boar-1 { background-image: url("./assets/racers/boar-gpt-sheet.png"); }
.racer-skin-rabbit-1 { background-image: url("./assets/racers/rabbit-gpt-sheet.png"); }
.racer-skin-turtle-1 { background-image: url("./assets/racers/turtle-gpt-sheet.png"); }
.racer-skin-penguin-1 { background-image: url("./assets/racers/penguin-gpt-sheet.png"); }
.racer-skin-mecha-1 { background-image: url("./assets/racers/mecha-gpt-sheet.png"); }

@keyframes horse-gallop {
  0%, 19.99% { background-position-x: 0%; }
  20%, 39.99% { background-position-x: 25%; }
  40%, 59.99% { background-position-x: 50%; }
  60%, 79.99% { background-position-x: 75%; }
  80%, 100% { background-position-x: 100%; }
}

.horse-card h3,
.panel h3 {
  margin: 0;
}

.arcana-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 2px solid rgba(117, 104, 78, 0.32);
}

.card-draw-screen {
  min-height: calc(100vh - 126px);
  display: grid;
  align-content: center;
  gap: 18px;
  padding: 16px 4px 28px;
}

.card-draw-title {
  text-align: center;
  color: #111;
  text-shadow:
    2px 0 0 #fff7d9,
    -2px 0 0 #fff7d9,
    0 2px 0 #fff7d9,
    0 -2px 0 #fff7d9,
    2px 3px 0 rgba(65, 39, 13, 0.32);
}

.card-draw-title .muted,
.card-draw-title .eyebrow {
  color: #111;
}

.card-draw-title h2 {
  margin: 0;
  font-size: clamp(1.7rem, 7vw, 3rem);
}

.tarot-choice {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  perspective: 900px;
}

.tarot-pick {
  display: grid;
  gap: 6px;
  justify-items: center;
  text-align: center;
}

.tarot-pick > strong,
.tarot-pick > small {
  padding: 3px 8px;
  border: 2px solid rgba(104, 68, 23, 0.72);
  background: rgba(255, 247, 217, 0.88);
  box-shadow: 0 2px 0 rgba(65, 39, 13, 0.18);
}

.tarot-pick > small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.draw-choice {
  width: min(680px, 100%);
  margin: 0 auto;
  grid-template-columns: repeat(2, minmax(140px, 260px));
  justify-content: center;
  gap: clamp(12px, 4vw, 28px);
}

.draw-counts {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.draw-counts span {
  padding: 6px 10px;
  border: 2px solid #6d4515;
  background: rgba(255, 247, 217, 0.86);
  font-weight: 900;
}

.tarot-card {
  position: relative;
  aspect-ratio: 2 / 3;
  min-height: 210px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 12px 8px;
  border: 0;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.75), transparent 22%),
    linear-gradient(135deg, #fff6d8, #dca843);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  color: #2b1a08;
  text-align: center;
  font-weight: 900;
  image-rendering: pixelated;
  box-shadow: 0 6px 0 rgba(65, 39, 13, 0.32), inset 0 0 0 3px rgba(255, 255, 255, 0.28);
}

.tarot-front.chance {
  background-image: url("./assets/cards/card-chance-face.png");
  color: #2b1a08;
  text-shadow: 1px 1px 0 rgba(255, 248, 223, 0.45);
}

.tarot-card::before,
.tarot-card::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px solid rgba(104, 68, 23, 0.7);
  pointer-events: none;
}

.tarot-card::after {
  inset: 16px;
  border-style: dotted;
  opacity: 0.8;
}

.tarot-card::before,
.tarot-card::after {
  display: none;
}

.tarot-back {
  width: 100%;
  min-height: 240px;
  transform-style: preserve-3d;
  animation: none;
  background-color: transparent;
  box-shadow: none;
}

.tarot-back.chance {
  background-image: url("./assets/cards/card-chance-back.png");
}

.tarot-back:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tarot-back:hover {
  transform: none;
  filter: brightness(1.04);
}

.card-reveal-screen {
  min-height: calc(100vh - 96px);
  display: grid;
  place-items: center;
  padding: 16px 4px 28px;
}

.card-reveal-stage {
  display: grid;
  justify-items: center;
  gap: 14px;
  width: min(340px, 88vw);
}

.card-flip {
  width: min(300px, 78vw);
  aspect-ratio: 2 / 3;
  perspective: 1000px;
}

.card-flip__inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  animation: flip-card 1.05s ease both;
}

.card-flip__face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
}

.card-flip__back {
  min-height: 0;
  width: 100%;
  height: 100%;
}

.card-flip__front {
  display: grid;
  transform: rotateY(180deg);
}

.card-flip__front > .tarot-card {
  width: 100%;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
  justify-items: center;
  gap: 9px;
  padding: 118px 66px 126px;
  background-color: transparent;
  box-shadow: none;
}

.card-flip__front .tarot-kicker {
  width: 100%;
  margin: 0;
  color: #3d2a13;
  font-size: 0.74rem;
  line-height: 1.25;
  text-align: center;
  text-shadow: 1px 1px 0 rgba(255, 248, 223, 0.72);
}

.card-flip__front .tarot-title {
  width: 100%;
  color: #1f150b;
  font-size: 1.08rem;
  line-height: 1.22;
  text-align: center;
  text-shadow:
    1px 0 0 rgba(255, 248, 223, 0.86),
    0 1px 0 rgba(255, 248, 223, 0.86),
    1px 2px 0 rgba(99, 60, 19, 0.2);
}

.card-flip__front .tarot-description {
  width: 100%;
  margin: 0;
  color: #2c1c0c;
  font-size: 0.82rem;
  line-height: 1.38;
  text-align: center;
  text-wrap: pretty;
  overflow-wrap: normal;
  word-break: normal;
}

.continue-hint {
  margin: 0;
  padding: 6px 12px;
  border: 2px solid #6d4515;
  background: rgba(255, 247, 217, 0.92);
  color: #1d160c;
  font-weight: 900;
  text-shadow:
    1px 0 0 #fff7d9,
    -1px 0 0 #fff7d9,
    0 1px 0 #fff7d9,
    0 -1px 0 #fff7d9;
  box-shadow: 0 3px 0 rgba(65, 39, 13, 0.24);
}

@keyframes flip-card {
  0%, 28% {
    transform: rotateY(0deg) scale(0.98);
  }
  100% {
    transform: rotateY(180deg) scale(1);
  }
}

.tarot-back.fate,
.tarot-front.fate {
  color: #fff7e5;
  text-shadow: 1px 1px 0 rgba(43, 15, 37, 0.6);
}

.tarot-back.fate {
  background-image: url("./assets/cards/card-fate-back.png");
}

.tarot-front.fate {
  background-image: url("./assets/cards/card-fate-face.png");
  color: #2b1a08;
  text-shadow: 1px 1px 0 rgba(255, 230, 203, 0.45);
}

.tarot-front {
  min-height: 210px;
  padding: 72px 48px 68px;
  animation: none;
}

.tarot-front.compact {
  min-height: 170px;
  aspect-ratio: auto;
  padding: 22px 18px;
  background-image: none;
}

.tarot-front p {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
}

.tarot-front ul {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.72rem;
  line-height: 1.35;
}

.tarot-front strong,
.tarot-back strong,
.tarot-card small,
.tarot-crown {
  position: relative;
  z-index: 1;
}

.tarot-crown {
  width: 34px;
  height: 24px;
  background:
    linear-gradient(135deg, transparent 0 22%, #7a4a12 22% 35%, transparent 35% 42%, #7a4a12 42% 58%, transparent 58% 65%, #7a4a12 65% 78%, transparent 78%),
    linear-gradient(#ffde70, #c8871e);
  clip-path: polygon(0 100%, 8% 40%, 28% 70%, 50% 20%, 72% 70%, 92% 40%, 100% 100%);
  box-shadow: 0 3px 0 rgba(65, 39, 13, 0.24);
}

.draw-choice .tarot-crown,
.tarot-front:not(.compact) .tarot-crown {
  display: none;
}

.card-ticket {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 2px solid #6d4515;
  background: rgba(255, 247, 217, 0.86);
}

.card-ticket.fate {
  border-color: #7b2145;
  background: rgba(255, 231, 239, 0.9);
}

.card-ticket strong,
.card-ticket small {
  display: block;
}

.card-ticket small {
  color: var(--muted);
  overflow: hidden;
  display: -webkit-box;
  font-size: 0.68rem;
  line-height: 1.3;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.card-ticket .eyebrow {
  margin-bottom: 1px;
  font-size: 0.64rem;
}

.card-ticket .tarot-crown {
  width: 26px;
  height: 18px;
}

.notice-backdrop,
.hold-preview-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(26, 18, 10, 0.34);
}

.round-notice,
.hold-preview {
  width: min(520px, 100%);
  border: 3px solid #6d4515;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.36), transparent 40%),
    #fff2c7;
  box-shadow: 0 7px 0 rgba(65, 39, 13, 0.3), inset 0 0 0 3px rgba(255, 255, 255, 0.36);
  color: var(--ink);
}

.round-notice {
  padding: 18px;
  text-align: center;
}

.round-notice h2,
.hold-preview h3 {
  margin: 0 0 10px;
  line-height: 1.16;
}

.round-notice p,
.hold-preview p {
  margin: 0 0 9px;
  color: #3c2a16;
  font-weight: 800;
  line-height: 1.42;
}

.round-notice strong {
  display: inline-block;
  margin-top: 4px;
  padding: 5px 10px;
  border: 2px solid #6d4515;
  background: rgba(255, 247, 217, 0.92);
  box-shadow: 0 3px 0 rgba(65, 39, 13, 0.22);
}

.hold-preview-layer {
  z-index: 40;
  pointer-events: auto;
  background: rgba(26, 18, 10, 0.34);
}

.hold-preview {
  padding: 12px;
  max-height: min(70vh, 440px);
  overflow: auto;
  text-align: left;
}

.hold-preview hr {
  margin: 8px 0;
  border: 0;
  border-top: 2px dashed rgba(117, 104, 78, 0.42);
}

@keyframes card-idle {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -4px; }
}

@keyframes card-reveal {
  0% {
    opacity: 1;
    transform: rotateY(90deg) scale(0.94);
  }
  100% {
    opacity: 1;
    transform: rotateY(0) scale(1);
  }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-top: 7px;
}

.stats-grid span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-height: 30px;
  padding: 4px 6px;
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid rgba(117, 104, 78, 0.28);
}

.stats-grid small {
  color: var(--muted);
}

.rumor {
  margin: 7px 0 0;
  color: #5d4522;
}

.bet-dock {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: grid;
  gap: 7px;
  margin-top: 8px;
  padding: 8px;
  background: rgba(255, 231, 160, 0.98);
  backdrop-filter: blur(2px);
}

.bet-command-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.bet-command-copy {
  min-width: 0;
}

.bet-command-copy strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.info-badge-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.info-badge {
  width: 42px;
  height: 58px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  box-shadow: none;
  image-rendering: pixelated;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.info-badge span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.info-badge.event {
  background-image: url("./assets/round-event-badge.png");
}

.info-badge.chance,
.info-badge.fate {
  background-size: contain;
}

.info-badge.chance {
  background-image: url("./assets/cards/card-chance-back.png");
}

.info-badge.fate {
  background-image: url("./assets/cards/card-fate-back.png");
}

.loan-button {
  min-height: 42px;
  border: 3px solid #5f1f19;
  border-radius: 0;
  background: linear-gradient(#ffb1a7, #d85748);
  color: #2b0d09;
  font-weight: 900;
  box-shadow: 0 4px 0 rgba(65, 39, 13, 0.3);
}

.amount-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.bet-dock .primary-button,
.bet-dock .chip {
  min-height: 36px;
}

.chip.active {
  background: var(--blue);
  color: white;
}

.chip.disabled {
  opacity: 0.42;
  filter: grayscale(0.85);
}

.race-stage {
  position: relative;
  display: grid;
  grid-template-rows: repeat(6, 48px);
  gap: 9px;
  padding-right: 28px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.18), transparent 22%, transparent 78%, rgba(70, 36, 10, 0.18)),
    repeating-linear-gradient(180deg, #d99548 0 42px, #c9843f 42px 45px),
    #d99548;
  overflow: hidden;
  contain: layout paint;
}

.finish-line {
  position: absolute;
  right: 10px;
  top: 12px;
  bottom: 12px;
  writing-mode: vertical-rl;
  display: grid;
  place-items: center;
  padding: 4px 2px;
  background: repeating-linear-gradient(0deg, #fff 0 8px, #222 8px 16px);
  color: #e33;
  font-weight: 900;
  text-shadow: 0 1px #fff;
}

.lane {
  position: relative;
  height: 48px;
  border: 2px dashed rgba(73, 45, 18, 0.35);
  background: rgba(255, 225, 154, 0.28);
}

.lane.my-bet-lane {
  border-color: rgba(49, 95, 186, 0.88);
  background:
    linear-gradient(90deg, rgba(49, 95, 186, 0.22), rgba(255, 225, 154, 0.2) 38%),
    rgba(255, 225, 154, 0.34);
  box-shadow: inset 0 0 0 2px rgba(255, 247, 217, 0.72);
}

.lane-label {
  position: absolute;
  left: 6px;
  top: 6px;
  z-index: 1;
  font-weight: 900;
  color: rgba(38, 29, 18, 0.55);
}

.runner {
  position: absolute;
  top: 4px;
  display: flex;
  align-items: center;
  gap: 0;
  max-width: 160px;
  transform: translateX(-4px);
  transition: left 0.22s linear;
  font-size: 0.72rem;
  font-weight: 900;
  white-space: nowrap;
}

.runner-name {
  margin-left: -14px;
  text-shadow: 1px 1px 0 rgba(255, 246, 216, 0.85);
}

.replay-stage .runner {
  transform: translateX(-4px);
}

.replay-stage .runner-name {
  position: absolute;
  right: 78px;
  width: max-content;
  margin-left: 0;
  text-align: right;
}

.replay-stage .horse-sprite {
  animation: none;
  background-position-x: 0%;
}

.battle-log {
  margin-top: 12px;
  height: 208px;
  background: #fff6d8;
  overflow: hidden;
  contain: layout paint;
}

.battle-log p {
  margin: 0 0 8px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.42;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.battle-log.replay-log {
  height: auto;
  max-height: none;
  overflow: visible;
  contain: none;
}

.battle-log.replay-log p {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
}

.settlement-list,
.ranking {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
}

.settlement-row {
  grid-template-columns: 1fr 1.5fr auto;
}

.settlement-row.win strong {
  color: var(--green);
}

.settlement-row.lose strong {
  color: var(--red);
}

.ranking {
  list-style-position: inside;
}

.ranking li {
  grid-template-columns: 1fr auto auto;
}

.result-actions {
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
}

.center {
  text-align: center;
}

.expedition-screen {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding-bottom: 12px;
}

.expedition-heading {
  padding: 8px 4px;
  text-shadow: 1px 1px 0 #fff7d9;
}

.expedition-heading h2,
.expedition-mount-title h3,
.expedition-market-head h2,
.expedition-upgrade-head h2 {
  margin: 0;
}

.expedition-heading p:last-child {
  margin: 5px 0 0;
}

.expedition-candidate-grid,
.expedition-upgrade-grid,
.expedition-market-list,
.expedition-final-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
}

.expedition-candidate-card,
.expedition-upgrade-card {
  display: grid;
  align-content: start;
  gap: 9px;
  min-width: 0;
}

.expedition-mount-title,
.expedition-market-head,
.expedition-upgrade-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.expedition-mount-title {
  justify-content: flex-start;
}

.expedition-mount-sprite {
  flex: 0 0 82px;
  width: 82px;
  height: 50px;
  transform: scale(0.9);
  transform-origin: center;
}

.expedition-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.expedition-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
  padding: 6px 7px;
  border: 2px solid rgba(117, 104, 78, 0.3);
  background: rgba(255, 255, 255, 0.42);
}

.expedition-stat small,
.expedition-racer-row small,
.expedition-wallet small,
.expedition-final-row small {
  color: var(--muted);
}

.expedition-talent {
  display: grid;
  gap: 2px;
  padding: 8px;
  border-left: 5px solid var(--gold);
  background: rgba(255, 248, 223, 0.75);
}

.expedition-talent p,
.expedition-comment,
.expedition-upgrade-card p {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.expedition-comment {
  color: var(--muted);
  font-size: 0.9rem;
}

.expedition-market-head,
.expedition-upgrade-head {
  padding: 10px;
}

.expedition-market-head h2 {
  font-size: 1.25rem;
}

.expedition-wallet {
  display: grid;
  flex: 0 0 auto;
  text-align: right;
}

.expedition-rank-summary {
  max-width: 230px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.25;
}

.expedition-racer-row {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 7px;
  border: 3px solid var(--stone-dark);
  background: rgba(255, 242, 199, 0.96);
  box-shadow: 0 3px 0 var(--shadow);
}

.expedition-racer-row .expedition-mount-sprite {
  width: 70px;
  height: 42px;
  transform: scale(0.78);
}

.expedition-owned {
  border-color: var(--blue) !important;
  background-color: rgba(225, 237, 255, 0.96) !important;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.72), 0 3px 0 var(--shadow);
}

.expedition-racer-name {
  display: grid;
  min-width: 0;
}

.expedition-racer-name strong,
.expedition-racer-name small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.expedition-audience {
  display: grid;
  text-align: right;
  font-size: 0.82rem;
}

.expedition-odds {
  padding: 6px;
  border: 2px solid #805719;
  background: var(--gold);
  font-weight: 900;
}

.expedition-bet-dock {
  position: sticky;
  bottom: 0;
  z-index: 4;
  display: grid;
  gap: 7px;
  padding: 9px;
}

.expedition-option-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.expedition-option-row button {
  min-width: 0;
  padding: 9px 3px;
  border: 3px solid #5f4a2c;
  background: #fff8df;
  font-weight: 900;
}

.expedition-option-row button.selected {
  border-color: #173e89;
  background: #4169bd;
  color: white;
}

.expedition-option-row button:disabled {
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.48;
}

.expedition-breakdown {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.expedition-breakdown div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  border: 2px solid rgba(117, 104, 78, 0.32);
  background: rgba(255, 255, 255, 0.42);
}

.positive { color: var(--green); }
.negative { color: var(--red); }

.expedition-owned-upgrades {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 9px;
  border: 3px solid var(--stone-dark);
  background: rgba(255, 242, 199, 0.94);
}

.expedition-owned-upgrades span {
  padding: 4px 6px;
  border: 2px solid rgba(117, 104, 78, 0.55);
  background: #fff8df;
  font-size: 0.78rem;
}

.expedition-upgrade-card h3 {
  margin: 0;
  font-size: 1.08rem;
}

.expedition-upgrade-detail {
  min-height: 34px;
  padding: 4px 8px;
  font-size: 0.82rem;
}

.expedition-final-list {
  list-style: none;
}

.expedition-final-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 9px;
}

.expedition-final-rank {
  font-size: 1.35rem;
  font-weight: 900;
  text-align: center;
}

.expedition-final-row > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.expedition-final-scores {
  text-align: right;
  font-size: 0.78rem;
}

.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 10;
  margin: 0 auto;
  width: min(520px, calc(100% - 28px));
  padding: 10px 12px;
  border: 3px solid #6d4515;
  background: #fff8df;
  box-shadow: 0 5px 0 var(--shadow);
  font-weight: 800;
}

@media (min-width: 760px) {
  .app {
    padding: 22px;
  }

  .hero {
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 360px);
    align-items: center;
  }

  .title-block {
    grid-row: span 2;
  }

  .betting-layout {
    grid-template-columns: 1fr 280px;
  }

  .horse-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .result-layout,
  .arena-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .royal-board,
  .wide,
  .center {
    grid-column: 1 / -1;
  }

  .bet-dock {
    grid-template-columns: 1fr auto auto;
    align-items: center;
  }

  .expedition-candidate-grid,
  .expedition-upgrade-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .expedition-market-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .expedition-bet-dock {
    grid-template-columns: minmax(180px, 1fr) minmax(300px, 1.5fr) auto;
  }
}

@media (max-width: 480px) {
  .expedition-selection .expedition-heading {
    padding: 2px;
  }

  .expedition-selection .expedition-heading h2 {
    font-size: 1.08rem;
  }

  .expedition-selection .expedition-heading .muted {
    display: none;
  }

  .expedition-candidate-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .expedition-candidate-card {
    gap: 5px;
    min-width: 0;
    padding: 6px;
    overflow-wrap: anywhere;
  }

  .expedition-candidate-card .expedition-mount-title {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 3px;
  }

  .expedition-candidate-card .expedition-mount-sprite {
    width: 78px;
    height: 46px;
    transform: scale(0.9);
    transform-origin: left center;
  }

  .expedition-candidate-card h3 {
    font-size: 0.9rem;
    line-height: 1.05;
    overflow-wrap: anywhere;
  }

  .expedition-candidate-card .expedition-stats {
    gap: 2px;
  }

  .expedition-candidate-card .expedition-stat {
    display: grid;
    justify-items: center;
    gap: 0;
    padding: 2px;
    font-size: 0.72rem;
  }

  .expedition-candidate-card .expedition-stat small {
    font-size: 0.72rem;
  }

  .expedition-candidate-card .expedition-talent {
    gap: 0;
    padding: 4px;
    border-left-width: 3px;
    font-size: 0.72rem;
    line-height: 1.18;
    overflow-wrap: anywhere;
  }

  .expedition-candidate-card .expedition-talent p {
    margin-top: 1px;
    font-size: 0.72rem;
    line-height: 1.12;
    overflow-wrap: anywhere;
  }

  .expedition-candidate-card .expedition-comment {
    margin: 0;
    font-size: 0.72rem;
    line-height: 1.12;
    overflow-wrap: anywhere;
  }

  .expedition-candidate-card .primary-button {
    min-height: 44px;
    padding: 4px 2px;
    font-size: 0.78rem;
  }

  .expedition-racer-row {
    grid-template-columns: 58px minmax(0, 1fr) auto;
    gap: 5px;
  }

  .expedition-racer-row .expedition-mount-sprite {
    width: 58px;
    transform: scale(0.68);
  }

  .expedition-audience {
    display: none;
  }

  .expedition-market-head h2 {
    font-size: 1.05rem;
  }

  .expedition-final-row {
    grid-template-columns: 26px minmax(0, 1fr);
  }

  .expedition-final-scores {
    grid-column: 2;
    grid-template-columns: repeat(2, 1fr);
    text-align: left;
  }
}

@media (min-width: 1040px) {
  .horse-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .lane {
    height: 56px;
  }

  .race-stage {
    grid-template-rows: repeat(6, 56px);
  }
}
