:root {
  --green-900: #0e2418;
  --green-800: #143524;
  --green-700: #1c4a32;
  --green-500: #2f7a45;
  --gold: #d4b24a;
  --gold-deep: #b48a22;
  --cream: #f4ead3;
  --ink: #142018;
  --paper: rgba(244, 234, 211, 0.94);
  --danger: #a33b2b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, #2a5a3c, transparent 42%),
    linear-gradient(180deg, #143524 0%, #0b1b12 100%);
  color: var(--cream);
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
}

body {
  min-height: 100dvh;
}

#app,
.screen {
  min-height: 100dvh;
}

.screen {
  display: grid;
  place-items: center;
  padding: 1.2rem;
}

.screen[hidden] {
  display: none;
}

.panel {
  width: min(980px, 100%);
  background: var(--paper);
  color: var(--ink);
  border-radius: 28px;
  padding: 1.6rem 1.5rem 1.4rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.welcome-panel,
.finish-panel {
  text-align: center;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--gold-deep);
  font-weight: 700;
}

h1,
h2 {
  margin: 0.25rem 0 0.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(2.1rem, 6vw, 3.4rem);
}

h2 {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
}

.lede,
.hint {
  margin: 0 auto 1.1rem;
  max-width: 42rem;
  line-height: 1.45;
}

.hint {
  color: #3d4a40;
}

.field,
.field-label {
  display: block;
  text-align: left;
  font-weight: 700;
  margin: 0.8rem 0 0.4rem;
}

.field input {
  width: 100%;
  margin-top: 0.35rem;
  border: 2px solid #c9b992;
  border-radius: 14px;
  padding: 0.8rem 0.9rem;
  font-size: 1.1rem;
  font-family: inherit;
}

.field input:focus {
  outline: 3px solid #d4b24a;
  border-color: var(--gold-deep);
}

.error {
  color: var(--danger);
  font-weight: 700;
  margin: 0.3rem 0 0;
}

.pony-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.pony-card {
  border: 3px solid transparent;
  background: #fffaf0;
  border-radius: 20px;
  padding: 0.6rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}

.pony-card strong,
.pony-card span {
  display: block;
}

.pony-card span {
  font-size: 0.92rem;
  color: #4b564e;
}

.pony-card.selected,
.pony-card:focus-visible {
  border-color: var(--gold-deep);
  box-shadow: 0 0 0 4px rgba(212, 178, 74, 0.35);
}

.pony-preview {
  width: 100%;
  height: auto;
  display: block;
  background: linear-gradient(#9fd0ea, #d7ecc8);
  border-radius: 14px;
  margin-bottom: 0.45rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  justify-content: center;
  margin-top: 1.2rem;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.3rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.btn:focus-visible,
.btn-jump:focus-visible,
.pony-card:focus-visible {
  outline: 3px solid #143524;
  outline-offset: 3px;
}

.btn-gold {
  background: linear-gradient(#f0d36a, var(--gold-deep));
  color: #231b08;
}

.btn-ghost {
  background: transparent;
  color: inherit;
  box-shadow: inset 0 0 0 2px currentColor;
}

.bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.8rem;
  align-items: center;
  margin-bottom: 0.6rem;
}

.bar h2 {
  margin: 0;
  text-align: center;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.8rem;
}

.course-card {
  text-align: left;
  border: 0;
  border-radius: 20px;
  padding: 1rem;
  background: #fffaf0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  min-height: 168px;
}

.course-card:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.course-card small {
  display: block;
  color: #586258;
  margin: 0.35rem 0 0.6rem;
  line-height: 1.35;
}

.stars {
  letter-spacing: 0.12em;
  color: var(--gold-deep);
  font-size: 1.2rem;
  margin: 0;
}

.screen-game {
  padding: 0;
  background: #0b1b12;
}

.game-wrap {
  position: relative;
  width: 100%;
  height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
}

#game {
  width: min(100%, 100dvw);
  height: min(100dvh, calc(100dvw * 720 / 1280));
  max-height: 100dvh;
  background: #87c6e6;
  display: block;
  touch-action: none;
}

.hud {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  right: 0.6rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.5rem;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  font-weight: 800;
}

.hud-left,
.hud-right {
  display: flex;
  flex-direction: column;
}

.hud-right {
  text-align: right;
}

.hud-center {
  background: rgba(14, 36, 24, 0.55);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  display: flex;
  gap: 0.8rem;
  align-items: center;
}

.hud-hint {
  position: absolute;
  left: 50%;
  top: 4.2rem;
  transform: translateX(-50%);
  margin: 0;
  background: rgba(14, 36, 24, 0.7);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.92rem;
  pointer-events: none;
}

.btn-pause {
  position: absolute;
  top: 4.4rem;
  right: 0.8rem;
  color: #fff;
}

.btn-jump {
  position: absolute;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: 0;
  background: radial-gradient(circle at 35% 30%, #ffe08a, #b48a22);
  color: #231b08;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  user-select: none;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 18, 12, 0.62);
  display: grid;
  place-items: center;
}

.overlay[hidden] {
  display: none;
}

.mini-panel {
  width: min(420px, calc(100% - 2rem));
  text-align: center;
}

.stats {
  list-style: none;
  padding: 0;
  margin: 0 auto 0.4rem;
  max-width: 26rem;
  text-align: left;
}

.stats li {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px solid #e1d3b0;
}

.score-table {
  display: grid;
  gap: 0.6rem;
}

.score-row,
.score-head {
  display: grid;
  grid-template-columns: 2fr 1.2fr 1fr 1fr;
  gap: 0.5rem;
  padding: 0.7rem 0.8rem;
  background: #fffaf0;
  border-radius: 14px;
}

.score-head {
  font-weight: 800;
  background: #efe3c4;
}

@media (max-width: 720px) {
  .pony-picker,
  .bar,
  .score-row,
  .score-head {
    grid-template-columns: 1fr;
  }

  .hud {
    font-size: 0.86rem;
  }

  .btn-jump {
    width: 96px;
    height: 96px;
  }

  .panel {
    padding: 1.1rem;
    border-radius: 20px;
  }
}
