* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #bcd9f2;
  font-family: "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* the mountain takes every finger itself: no scrolling, no zooming */
canvas { display: block; position: fixed; inset: 0; touch-action: none; }

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

.hidden { display: none !important; }

/* ---------- one player's part of the screen ---------- */

#views { position: fixed; inset: 0; pointer-events: none; z-index: 5; }

.view { position: absolute; overflow: hidden; }
.view + .view { box-shadow: 0 0 0 2px rgba(10, 20, 40, 0.8); }

.view .info {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  padding: 8px 14px 10px;
  border-radius: 14px;
  background: rgba(12, 24, 44, 0.62);
  backdrop-filter: blur(4px);
}

.view .who { font-size: 11px; letter-spacing: 2.5px; font-weight: 700; opacity: 0.9; }
.view .clock { font-size: 32px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.view .sub { font-size: 12px; letter-spacing: 1px; opacity: 0.9; }
.view .place { font-size: 14px; font-weight: 700; color: #ffd94a; }

.view .toast {
  position: absolute;
  top: 26%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(22px, 5vw, 38px);
  font-weight: 800;
  letter-spacing: 2px;
  text-shadow: 0 2px 10px rgba(0, 20, 50, 0.7);
  opacity: 0;
  transition: opacity 0.25s;
}

.view .toast.on { opacity: 1; }

.view .tip {
  position: absolute;
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 10px));
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13px;
  letter-spacing: 2px;
  text-shadow: 0 1px 6px rgba(0, 20, 50, 0.8);
}

/* pops up in the middle of the screen when you have hugged a tree */
.view .respawn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  padding: 18px 34px;
  border: 0;
  border-radius: 18px;
  background: #e5383b;
  box-shadow: 0 6px 0 #9d1c1f;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 3px;
  animation: pop 0.25s ease-out;
}

@keyframes pop {
  from { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
}

#fade {
  position: fixed;
  inset: 0;
  z-index: 6;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s;
}

#fade.on { opacity: 1; transition: none; }

/* ---------- sound ---------- */

#topRight {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 30;
}

#soundBtn {
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: rgba(12, 24, 44, 0.55);
  font-size: 12px;
  letter-spacing: 2px;
  padding: 8px 12px;
  min-height: 44px;
  backdrop-filter: blur(4px);
}

#soundBtn[aria-pressed="true"] { background: rgba(255, 255, 255, 0.92); color: #14294a; }

/* ---------- cards ---------- */

.card {
  position: fixed;
  z-index: 20;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  overflow-y: auto;
  padding: 22px 22px 24px;
  border-radius: 24px;
  background: rgba(12, 24, 44, 0.82);
  backdrop-filter: blur(8px);
  text-align: center;
}

h1, h2 { margin: 0 0 6px; letter-spacing: 6px; }
h1 { font-size: clamp(34px, 9vw, 54px); }
h2 { font-size: 26px; }

.tag { margin: 4px 0 14px; font-size: 16px; }
.tag b { color: #ffd94a; }
.note { margin: 10px 0 0; font-size: 14px; opacity: 0.85; }

.keys { margin: 14px auto 6px; padding: 0; list-style: none; font-size: 14px; line-height: 1.7; opacity: 0.92; }
.keys b { color: #9fd6ff; }

.buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 12px; }

.big {
  padding: 13px 20px;
  border: 0;
  border-radius: 14px;
  background: #ffd94a;
  box-shadow: 0 5px 0 #c79a00;
  color: #14294a;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1.5px;
}

.big:active { transform: translateY(3px); box-shadow: 0 2px 0 #c79a00; }
.big.plain { background: rgba(255, 255, 255, 0.16); box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35); color: #fff; }

/* ---------- the trails ---------- */

#trailList { display: grid; gap: 8px; }

.trail {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  text-align: left;
}

.trail.on { border-color: #ffd94a; background: rgba(255, 217, 74, 0.16); }
.trail.locked { opacity: 0.45; }
.trail .diamond { width: 42px; font-size: 18px; text-align: center; color: #111; text-shadow: 0 0 2px #fff, 0 0 2px #fff; }
.trail .name { flex: 1; font-size: 17px; font-weight: 700; }
.trail .best { font-size: 13px; font-variant-numeric: tabular-nums; opacity: 0.9; }

/* ---------- the shop ---------- */

.closeBtn {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  font-size: 26px;
  line-height: 1;
}

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  text-align: left;
}

.item .icon { font-size: 30px; }
.item .words { flex: 1; }
.item .name { font-size: 17px; font-weight: 700; }
.item .what { font-size: 13px; opacity: 0.85; }
.item button { min-width: 96px; padding: 10px 12px; font-size: 14px; }
.item button:disabled { opacity: 0.45; }

/* ---------- playing online ---------- */

.field { display: block; font-size: 12px; letter-spacing: 2px; font-weight: 700; }

#online input {
  font: inherit;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  color: #14294a;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: #fff;
  -webkit-user-select: text;
  user-select: text;
}

#nameIn { display: block; width: min(260px, 100%); margin: 6px auto 0; }
#codeIn { width: 130px; letter-spacing: 6px; text-transform: uppercase; }

#codeBig {
  margin: 4px auto 12px;
  font-size: clamp(44px, 13vw, 68px);
  font-weight: 800;
  letter-spacing: 14px;
  text-indent: 14px;
  color: #ffd94a;
  -webkit-user-select: text;
  user-select: text;
}

#lobbyPlayers, #endResults { display: grid; gap: 6px; }

.racer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  text-align: left;
  font-size: 17px;
  font-weight: 700;
}

.racer i { width: 16px; height: 16px; border-radius: 50%; }
.racer span { flex: 1; }
.racer small { font-size: 12px; letter-spacing: 1.5px; opacity: 0.85; font-variant-numeric: tabular-nums; }

#lobbyTrail { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }
#lobbyTrail .big { padding: 8px 14px; }
#lobbyTrailName { min-width: 170px; font-size: 18px; font-weight: 700; }
#endResults { margin-top: 10px; }

.big:disabled { opacity: 0.45; }
