/* Cloudhoof — alpine UI: pine green, parchment, bell gold */

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #16261f;
  color: #f4efe2;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
:root { --gold: #ffcf33; --pine: #1f3a2d; --ink: #14201a; --line: rgba(255, 220, 140, .3); }

#game {
  position: fixed; inset: 0; width: 100%; height: 100%;
  display: block; touch-action: none; z-index: 0;
}

/* ── corner tools ────────────────────────────────────────────────── */
#corner {
  position: fixed; z-index: 30; display: flex; gap: 6px;
  top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right));
}
#corner button, #audioToggle {
  width: 38px; height: 38px; border-radius: 11px; cursor: pointer;
  background: rgba(20, 32, 26, .8); color: #fff3d0; font-size: 17px; font-weight: 800;
  border: 1px solid var(--line);
}
#corner button:hover, #audioToggle:hover { background: rgba(40, 66, 50, .92); }

/* ── HUD ─────────────────────────────────────────────────────────── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
.hud-left {
  position: absolute; top: calc(8px + env(safe-area-inset-top));
  left: calc(10px + env(safe-area-inset-left));
  text-shadow: 0 2px 0 rgba(0, 0, 0, .5), 0 0 12px rgba(0, 0, 0, .4);
}
.hud-level { font-size: 13px; font-weight: 800; letter-spacing: .04em; color: #ffe9b0; }
.hud-clock { font-size: 30px; font-weight: 900; line-height: 1.05; font-variant-numeric: tabular-nums; }
.hud-par { font-size: 12px; font-weight: 700; margin-left: 8px; color: #d8e6d0; }
.hud-par.over { color: #ffb4a0; }
.hud-mid {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%); display: flex; align-items: center; gap: 12px;
  padding: 5px 12px; border-radius: 14px; background: rgba(20, 32, 26, .7);
  border: 1px solid var(--line); font-weight: 800; font-size: 15px; white-space: nowrap;
}
.hud-bells { display: inline-flex; gap: 4px; }
.hud-bells i {
  width: 17px; height: 17px; border-radius: 50% 50% 42% 42%; display: inline-block;
  background: rgba(255, 255, 255, .13); border: 2px solid rgba(255, 220, 140, .45);
}
.hud-bells i.on { background: var(--gold); border-color: #fff3b0; box-shadow: 0 0 10px rgba(255, 207, 51, .8); }
.hud-dew b, .hud-keys b { font-variant-numeric: tabular-nums; }
.hud-state { font-size: 13px; }
.hud-state .st { padding: 1px 7px; border-radius: 8px; margin-left: 2px; }
.hud-state .st.clover { background: #2f8a3f; }
.hud-state .st.dazed { background: #c2452f; animation: pulse .45s ease-in-out infinite alternate; }
.hud-state .st.nobutt { background: rgba(255, 255, 255, .16); color: #cfd8cc; }
@keyframes pulse { to { transform: scale(1.1); } }

.hud-strip {
  position: absolute; top: calc(54px + env(safe-area-inset-top));
  right: calc(10px + env(safe-area-inset-right));
  display: flex; flex-direction: column; gap: 3px; width: 190px;
}
.strip-row {
  display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 9px; background: rgba(20, 32, 26, .74);
  border: 1px solid rgba(255, 255, 255, .1); font-size: 12px; font-weight: 700;
  position: relative; overflow: hidden;
}
.strip-row.me { border-color: var(--gold); background: rgba(58, 74, 30, .84); }
.strip-row.gone { opacity: .5; }
.strip-row .bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--c, #fff); }
.strip-row .pos { font-weight: 900; color: #ffe9b0; }
.strip-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strip-row .tm { font-variant-numeric: tabular-nums; color: #d8e6d0; }
.strip-row .ttl { font-size: 9px; opacity: .85; margin-left: 4px; }

.hud-count {
  position: absolute; left: 50%; top: 36%; transform: translate(-50%, -50%);
  font-size: 110px; font-weight: 900; color: #fff; opacity: 0;
  text-shadow: 0 6px 0 rgba(0, 0, 0, .35), 0 0 40px rgba(255, 207, 51, .7);
}
.hud-count.on { opacity: 1; animation: pop .9s ease-out; }
@keyframes pop { 0% { transform: translate(-50%, -50%) scale(1.7); opacity: 0; }
  25% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1); } }
.hud-ready {
  position: absolute; left: 50%; top: 24%; transform: translateX(-50%);
  padding: 10px 18px; border-radius: 14px; background: rgba(20, 32, 26, .86);
  border: 1px solid var(--gold); font-size: 16px; font-weight: 800; text-align: center;
  display: none; max-width: 88vw;
}
.hud-ready.on { display: block; }
.hud-ready small { display: block; font-weight: 600; color: #d8e6d0; margin-top: 3px; font-size: 12px; }
.hud-toast {
  position: absolute; left: 50%; top: calc(64px + env(safe-area-inset-top));
  transform: translateX(-50%); padding: 7px 16px; border-radius: 12px; opacity: 0;
  background: rgba(20, 32, 26, .9); border: 1px solid var(--line); font-weight: 700;
  font-size: 14px; transition: opacity .25s; max-width: 86vw; text-align: center;
}
.hud-toast.on { opacity: 1; }
.hud-toast.bad { border-color: #ff8a70; color: #ffd9cf; }

.hud-watch {
  position: absolute; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%); pointer-events: auto; text-align: center;
  padding: 8px 12px; border-radius: 14px; background: rgba(20, 32, 26, .86);
  border: 1px solid var(--line);
}
.watch-label { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.watch-row { display: flex; gap: 6px; justify-content: center; }
.ghost-btn {
  min-height: 36px; padding: 6px 12px; border-radius: 10px; cursor: pointer;
  background: rgba(255, 255, 255, .1); color: #f4efe2; border: 1px solid var(--line);
  font-weight: 700; font-size: 13px;
}

#hudAudioWrap {
  position: absolute; pointer-events: auto; display: flex; align-items: center; gap: 6px;
  left: calc(10px + env(safe-area-inset-left)); top: calc(76px + env(safe-area-inset-top));
}
#hudAudio { display: none; max-width: calc(100vw - 60px); }
#hudAudioWrap.open #hudAudio { display: block; }
#hudAudio .mps-audio { flex-wrap: nowrap; padding: 4px 8px; background: rgba(20, 32, 26, .9); }
#hudAudio .mps-audio-slider { width: 76px; flex: 0 0 76px; }
#hudAudio .mps-audio-btn { min-height: 30px; padding: 5px 8px; }
/* web/style.css pins .volume-slider position:fixed top:12px — undo it here
   so a slider can never land in the corner of the screen. */
.volume-slider { position: static !important; top: auto !important; }

.pause {
  position: absolute; inset: 0; pointer-events: auto; display: grid; place-items: center;
  background: rgba(10, 18, 14, .6); z-index: 20;
}
.pause-card {
  width: min(320px, 88vw); padding: 20px; border-radius: 18px; text-align: center;
  background: #213a2e; border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.pause-card h2 { margin: 0 0 8px; }
.pause-hint { margin: 0 0 10px; line-height: 1.4; }

/* ── touch pad ───────────────────────────────────────────────────── */
#pad { display: none; }
body.touch.playing #pad { display: block; }
.pad-left, .pad-right {
  position: absolute; pointer-events: auto; touch-action: none;
  bottom: calc(14px + env(safe-area-inset-bottom));
}
.pad-left {
  left: calc(10px + env(safe-area-inset-left));
  display: grid; grid-template-columns: 78px 78px; grid-template-rows: 46px 78px 46px;
  gap: 6px; justify-items: center;
}
.pad-right {
  right: calc(10px + env(safe-area-inset-right));
  display: grid; grid-template-columns: 78px 96px; grid-template-rows: 46px 96px;
  gap: 6px; align-items: end; justify-items: center;
}
.pb {
  border-radius: 18px; border: 2px solid rgba(255, 240, 200, .55); color: #fff7e0;
  background: rgba(20, 32, 26, .5); font-weight: 900; font-size: 22px;
  touch-action: none; -webkit-user-select: none; user-select: none; padding: 0;
}
.pb.down { background: rgba(255, 207, 51, .6); color: #201400; transform: scale(.95); }
.pb-up { grid-column: 1 / 3; width: 84px; height: 46px; font-size: 16px; }
.pb-dn { grid-column: 1 / 3; width: 84px; height: 46px; font-size: 16px; }
.pb-l, .pb-r { width: 78px; height: 78px; }
.pb-reset { grid-column: 2; justify-self: end; width: 46px; height: 46px; font-size: 18px; border-radius: 50%; opacity: .8; }
.pb-butt { width: 78px; height: 78px; border-radius: 50%; font-size: 14px; letter-spacing: .04em; }
.pb-jump { width: 96px; height: 96px; border-radius: 50%; font-size: 16px; letter-spacing: .04em;
  background: rgba(196, 72, 60, .55); }

/* ── how to play ─────────────────────────────────────────────────── */
#howOverlay {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(10, 18, 14, .72); padding: 12px; overflow-y: auto;
}
.how-card {
  width: min(560px, 100%); max-height: calc(100vh - 24px); overflow-y: auto;
  padding: 18px 20px; border-radius: 18px; background: #223d30; border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .55);
}
.how-card h2 { margin: 0 0 6px; color: var(--gold); }
.how-lead { margin: 0 0 12px; color: #dfe9d8; font-size: 14px; }
.how-grid { display: grid; gap: 6px; margin-bottom: 12px; }
.how-key { display: flex; align-items: center; gap: 6px; font-size: 14px; flex-wrap: wrap; }
.how-key span { font-weight: 700; }
.how-key i { margin-left: auto; font-style: normal; color: #b9cbb4; font-size: 12px; }
.kc {
  display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 6px;
  border-radius: 7px; background: #f4efe2; color: #1b2a22; font-size: 13px; font-weight: 800;
  box-shadow: 0 2px 0 #9aa594;
}
.how-list { margin: 0 0 10px; padding-left: 18px; font-size: 13.5px; line-height: 1.45; color: #e9f0e3; }
.how-list li { margin-bottom: 5px; }
.how-note { font-size: 13px; color: #cfdcc8; margin: 0 0 12px; }
.danger-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #ff5a3c; }

/* ── the card ────────────────────────────────────────────────────── */
#lobbyOverlay {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  background: linear-gradient(180deg, rgba(22, 38, 31, .55), rgba(22, 38, 31, .9));
  padding: 10px; overflow-y: auto;
}
#lobbyOverlay.hidden { display: none; }
.card {
  width: min(680px, 100%); max-height: calc(100vh - 20px); overflow-y: auto;
  padding: 18px 20px 16px; border-radius: 20px; text-align: center;
  background: linear-gradient(180deg, #264536, #1d3529); border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
}
.card.wide { width: min(860px, 100%); }
.hoof-title {
  margin: 4px 0 8px; font-size: 54px; font-weight: 900; letter-spacing: .04em; line-height: 1;
  color: #fff7e0; text-shadow: 0 4px 0 #14201a;
}
.hoof-title.small { font-size: 32px; }
.title-accent { color: var(--gold); }
.tagline { margin: 0 auto 14px; max-width: 460px; color: #dfe9d8; font-size: 15px; line-height: 1.45; }
input[type=text] {
  width: min(320px, 100%); padding: 12px 14px; border-radius: 12px; font-size: 16px;
  border: 1px solid var(--line); background: #14241c; color: #fff; text-align: center;
  -webkit-user-select: text; user-select: text;
}
button { font-family: inherit; }
.primary {
  display: block; width: min(320px, 100%); margin: 10px auto 0; padding: 13px 16px;
  border-radius: 13px; border: 0; cursor: pointer; font-size: 17px; font-weight: 900;
  background: var(--gold); color: #2a1c00; box-shadow: 0 4px 0 #a37d0d;
}
.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #a37d0d; }
.primary.alt { background: #e9684f; color: #fff; box-shadow: 0 4px 0 #94321f; }
.primary:disabled { opacity: .5; cursor: default; }
.ghost {
  display: block; width: min(320px, 100%); margin: 8px auto 0; padding: 10px 14px;
  border-radius: 12px; cursor: pointer; font-size: 14px; font-weight: 700;
  background: rgba(255, 255, 255, .08); color: #f4efe2; border: 1px solid var(--line);
}
.ghost.slim { width: auto; margin: 0; padding: 7px 12px; }
.ghost:empty { display: none; }
.instructions { margin-top: 14px; font-size: 13px; color: #c5d4be; line-height: 1.6; }
.back-link { display: inline-block; margin-top: 12px; color: #b9d4c0; font-size: 13px; }
.muted { color: #b9cbb4; font-size: 13px; }
.small { font-size: 12px; }
.lobby-audio { display: flex; justify-content: center; margin-bottom: 8px; }
.best-line { font-size: 13px; color: #ffe9b0; margin-bottom: 10px; min-height: 16px; }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: left; margin-bottom: 12px; }
.mode-box { padding: 12px 14px 14px; border-radius: 14px; background: rgba(0, 0, 0, .2);
  border: 1px solid rgba(255, 255, 255, .08); }
.mode-box h3 { margin: 0 0 4px; color: var(--gold); }
.mode-box p { margin: 0 0 6px; font-size: 13px; color: #cfdcc8; }
.mode-box .primary, .mode-box .ghost { width: 100%; }
.heat-count { font-size: 12px; font-weight: 600; color: #b9cbb4; }
.player-list { min-height: 30px; margin: 4px 0 8px; font-size: 14px; }
.player-row { padding: 2px 0; }
.settings-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; font-size: 12px; color: #cfdcc8; }
.settings-row label { display: flex; flex-direction: column; gap: 3px; font-weight: 700; }
.settings-row label.chk { flex-direction: row; align-items: center; gap: 6px; align-self: end; padding-bottom: 6px; }
.settings-row select {
  padding: 7px 8px; border-radius: 9px; background: #14241c; color: #fff;
  border: 1px solid var(--line); font-size: 13px; min-height: 34px;
}
.leaderboard { margin-top: 12px; text-align: left; }
.lb-panel, .lb-card {
  --lb-bg: #1b3126; --lb-fg: #f4efe2; --lb-accent: #ffcf33; --lb-muted: #b9cbb4;
  --lb-line: rgba(255, 220, 140, .22);
}

/* ── the trail map ───────────────────────────────────────────────── */
.map-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.map-head h2 { margin: 0; flex: 1; font-size: 20px; }
.map-stars { font-weight: 800; color: var(--gold); white-space: nowrap; }
.map-scroll { max-height: min(62vh, 560px); overflow-y: auto; border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .08); -webkit-overflow-scrolling: touch; }
.map { display: flex; flex-direction: column-reverse; }
.world {
  position: relative; padding: 10px 12px 14px; text-align: left;
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.world h4 { margin: 0 0 8px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
.world.w1 { background: linear-gradient(180deg, #4e8a4a, #3b6f3d); }
.world.w2 { background: linear-gradient(180deg, #2c3350, #232a44); }
.world.w3 { background: linear-gradient(180deg, #b98a58, #96693c); }
.world.w4 { background: linear-gradient(180deg, #8fa0d6, #6f7fb5); }
.world.w5 { background: linear-gradient(180deg, #4a4778, #33305a); }
.stops { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; position: relative; }
.stops::before {
  content: ""; position: absolute; left: 6%; right: 6%; top: 22px; height: 0;
  border-top: 3px dashed rgba(255, 255, 255, .35);
}
.world:nth-child(even) .stops { direction: rtl; }
.stop {
  position: relative; direction: ltr; display: flex; flex-direction: column; align-items: center;
  gap: 2px; background: none; border: 0; color: #fff; cursor: pointer; padding: 0;
  font-family: inherit;
}
.stop .dot {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; font-size: 15px; background: #f4efe2; color: #1b2a22;
  border: 3px solid #1b2a22; box-shadow: 0 3px 0 rgba(0, 0, 0, .35);
}
.stop.boss .dot { border-radius: 12px; background: #ffd9cf; }
.stop.locked { cursor: default; }
.stop.locked .dot { background: rgba(0, 0, 0, .35); color: rgba(255, 255, 255, .55); border-color: rgba(255, 255, 255, .25); }
.stop.next .dot { background: var(--gold); animation: pulse .7s ease-in-out infinite alternate; }
.stop.sel .dot { outline: 3px solid #fff; outline-offset: 2px; }
.stop .st3 { font-size: 11px; letter-spacing: 1px; height: 14px; color: var(--gold);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .5); }
.stop .st3 .off { color: rgba(255, 255, 255, .3); }
.map-info {
  margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(0, 0, 0, .22);
  text-align: left; font-size: 13.5px; min-height: 86px;
}
.map-info h3 { margin: 0 0 3px; font-size: 16px; color: var(--gold); }
.map-info .row { display: flex; flex-wrap: wrap; gap: 4px 14px; color: #dfe9d8; margin-bottom: 6px; }
.map-info .primary { margin: 6px 0 0; }

/* ── results ─────────────────────────────────────────────────────── */
.solo-stars { display: flex; justify-content: center; gap: 10px; margin: 12px 0 8px; }
.solo-star { width: 110px; padding: 8px 6px; border-radius: 12px; background: rgba(0, 0, 0, .22);
  font-size: 12px; color: #b9cbb4; }
.solo-star b { display: block; font-size: 34px; line-height: 1; color: rgba(255, 255, 255, .22); }
.solo-star.on b { color: var(--gold); text-shadow: 0 0 14px rgba(255, 207, 51, .7); }
.solo-star.on { color: #f4efe2; }
.solo-star.new { outline: 2px solid var(--gold); }
.solo-facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px;
  font-size: 14px; margin-bottom: 4px; }
.solo-facts b { font-variant-numeric: tabular-nums; }
.result-note { min-height: 18px; font-size: 13px; color: #ffe9b0; margin: 4px 0; }
.leg-rows { text-align: left; margin: 8px auto; max-width: 380px; }
.leg-row { display: grid; grid-template-columns: 26px 1fr auto auto; gap: 8px; padding: 4px 8px;
  border-radius: 8px; font-size: 14px; }
.leg-row:nth-child(odd) { background: rgba(0, 0, 0, .18); }
.leg-row.me { outline: 1px solid var(--gold); }
.peers span { font-weight: 700; }
#resultTable, #resultAwards {
  --fs-bg: rgba(0, 0, 0, .2); --fs-fg: #f4efe2; --fs-accent: #ffcf33; --fs-muted: #b9cbb4;
  --fs-line: rgba(255, 220, 140, .22);
}

body.playing #lobbyOverlay { display: none; }
body.playing #howBtn { opacity: .85; }

@media (max-width: 640px) {
  .modes { grid-template-columns: 1fr; }
  .hoof-title { font-size: 40px; }
  .card { padding: 14px 12px; }
  .hud-clock { font-size: 22px; }
  .hud-level { font-size: 11px; }
  .hud-mid { top: calc(52px + env(safe-area-inset-top)); left: calc(10px + env(safe-area-inset-left));
    transform: none; font-size: 13px; gap: 8px; padding: 4px 9px; }
  #hudAudioWrap { top: calc(92px + env(safe-area-inset-top)); }
  .hud-strip { width: 150px; top: calc(52px + env(safe-area-inset-top)); }
  .strip-row { font-size: 11px; padding: 2px 6px; }
  .stop .dot { width: 38px; height: 38px; font-size: 13px; }
  .stops::before { top: 19px; }
  .solo-star { width: 31%; }
  #hudAudio .mps-audio-slider { width: 46px; flex-basis: 46px; }
  #hudAudio .mps-audio { gap: 5px; }
  .hud-count { font-size: 84px; }
}
@media (max-height: 460px) {
  /* a phone on its side: the pad shrinks and goes glassy */
  .pad-left { grid-template-columns: 64px 64px; grid-template-rows: 36px 64px 36px; }
  .pad-right { grid-template-columns: 64px 80px; grid-template-rows: 36px 80px; }
  .pb-l, .pb-r { width: 64px; height: 64px; }
  .pb-up, .pb-dn { width: 70px; height: 36px; }
  .pb-butt { width: 64px; height: 64px; }
  .pb-jump { width: 80px; height: 80px; }
  .pb-reset { width: 36px; height: 36px; }
  .pb { background: rgba(20, 32, 26, .3); }
  .hud-strip { width: 150px; }
  .card { max-height: calc(100vh - 8px); padding: 10px 12px; }
  .hoof-title { font-size: 32px; }
}
