* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b2a3d;
  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;
  touch-action: manipulation;   /* no double-tap zoom on the buttons */
}

/* the ocean is the look-around surface — the page itself never pans or zooms */
canvas { display: block; touch-action: none; }

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

#bestBox {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: max(20px, env(safe-area-inset-left));
  text-shadow: 0 2px 10px rgba(0, 30, 50, 0.75);
}

#bestBox .label {
  font-size: 12px;
  letter-spacing: 2.5px;
  opacity: 0.8;
}

#best {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.05;
}

#soundBtn {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  pointer-events: auto;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(4, 40, 62, 0.35);
  color: #fff;
  font: inherit;
  font-size: 12px;
  letter-spacing: 2px;
  padding: 8px 12px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}

#soundBtn:hover { border-color: #fff; }
#soundBtn[aria-pressed="true"] { background: rgba(255, 255, 255, 0.9); color: #05304a; }

/* the live ride clock, only visible while standing */
#timerBox {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 76px;
  font-weight: 700;
  letter-spacing: -2px;
  text-shadow: 0 4px 24px rgba(0, 25, 45, 0.8);
  opacity: 0;
  transition: opacity 0.2s;
}

#timerBox.on { opacity: 1; }
#timerBox .unit { font-size: 30px; opacity: 0.75; margin-left: 3px; }

#message {
  position: absolute;
  bottom: 14%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 3px;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 3px 16px rgba(0, 25, 45, 0.85);
  opacity: 0;
  transition: opacity 0.25s;
}

#message.on { opacity: 1; }

/* ---------- start card ---------- */

#start {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: linear-gradient(180deg, #7ec6ea 0%, #2b86b8 55%, #0d4a70 100%);
  text-align: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  /* the key list is long — on a short screen it scrolls instead of clipping */
  justify-content: flex-start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* auto margins centre it when it fits and let it scroll from the top when it doesn't */
#start > :first-child { margin-top: auto; }
#start > :last-child { margin-bottom: auto; }

#start.hidden { display: none; }

#start h1 {
  margin: 0;
  font-size: clamp(44px, 11vw, 96px);
  letter-spacing: 4px;
  text-shadow: 0 6px 0 rgba(3, 46, 74, 0.45);
}

.tag {
  margin: 2px 0 22px;
  font-size: 17px;
  letter-spacing: 2px;
  opacity: 0.95;
}

.keys {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  font-size: 15px;
  line-height: 2;
  opacity: 0.95;
}

.keys b {
  display: inline-block;
  min-width: 30px;
  padding: 1px 7px;
  margin-right: 8px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.9);
  color: #0d4a70;
  font-size: 13px;
}

.note {
  max-width: 380px;
  margin: 0 0 26px;
  font-size: 14px;
  line-height: 1.5;
  opacity: 0.85;
}

#startBtn {
  cursor: pointer;
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #0d4a70;
  background: #fff;
  border: none;
  border-radius: 999px;
  padding: 15px 42px;
  box-shadow: 0 6px 0 rgba(3, 46, 74, 0.4);
  /* stays in reach at the bottom while the key list scrolls past */
  position: sticky;
  bottom: 12px;
  flex-shrink: 0;
}

#startBtn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(3, 46, 74, 0.4); }

/* ---------- coins ---------- */

.coinLabel { margin-top: 10px; }

#coins {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.05;
  color: #ffd84d;
}

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

#shop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background: rgba(6, 44, 68, 0.93);
  backdrop-filter: blur(6px);
  text-align: center;
}

#shop.hidden { display: none; }

#shop h2 {
  margin: 0;
  font-size: 40px;
  letter-spacing: 6px;
}

.shopCoins {
  margin: 0 0 10px;
  font-size: 15px;
  letter-spacing: 1px;
  opacity: 0.9;
}

.shopCoins b { color: #ffd84d; font-size: 19px; }

.item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 26px;
  width: min(420px, 100%);
  padding: 14px 18px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 14px;
  text-align: left;
}

.item .name { font-size: 18px; font-weight: 700; }
.item .desc { font-size: 13px; opacity: 0.8; margin-top: 2px; }

.buy {
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #0d4a70;
  background: #ffd84d;
  border: none;
  border-radius: 999px;
  padding: 11px 20px;
  min-width: 92px;
}

.buy:disabled { cursor: default; }

/* can't afford it yet */
.buy.short {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.55);
}

/* already bought */
.buy.owned { background: #3ddc97; color: #05304a; }

#shopClose {
  margin-top: 12px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #fff;
  background: none;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  padding: 11px 24px;
}

#shopClose:hover { border-color: #fff; }

#shopHint {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  letter-spacing: 2px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(4, 40, 62, 0.45);
  text-shadow: 0 2px 8px rgba(0, 25, 45, 0.7);
  opacity: 0;
  transition: opacity 0.25s;
}

#shopHint.on { opacity: 1; }
#shopHint b { color: #ffd84d; }

#clock {
  margin-top: 10px;
  font-size: 15px;
  letter-spacing: 1px;
  opacity: 0.85;
}

/* ---------- iPad / touch ---------- */

/* key names on a keyboard, button names on a touch screen */
body:not(.touch) .touchOnly { display: none; }
body.touch .keyOnly { display: none; }

#touch {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  display: none;
}

body.touch.playing #touch { display: block; }

/* the stick sits clear of the bottom-left corner, where the site's back link goes */
#stick {
  position: absolute;
  left: calc(28px + env(safe-area-inset-left));
  bottom: calc(78px + env(safe-area-inset-bottom));
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(4, 40, 62, 0.35);
  backdrop-filter: blur(4px);
  pointer-events: auto;
  touch-action: none;
}

#knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 0 rgba(3, 46, 74, 0.4);
  pointer-events: none;
}

.tbtn {
  position: absolute;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(4, 40, 62, 0.35);
  backdrop-filter: blur(4px);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 0;
  pointer-events: auto;
  touch-action: none;
}

.tbtn.down { background: rgba(255, 255, 255, 0.9); color: #05304a; }

#standBtn {
  right: calc(24px + env(safe-area-inset-right));
  bottom: calc(28px + env(safe-area-inset-bottom));
  width: 98px;
  height: 98px;
  font-size: 15px;
}

/* a wave has you — this is the moment to stand */
#standBtn.ready {
  background: #ffd84d;
  border-color: #ffd84d;
  color: #0d4a70;
  animation: standPulse 0.6s ease-in-out infinite alternate;
}

@keyframes standPulse {
  from { transform: scale(1); }
  to { transform: scale(1.1); }
}

#duckBtn {
  right: calc(138px + env(safe-area-inset-right));
  bottom: calc(28px + env(safe-area-inset-bottom));
}

#fastBtn {
  right: calc(34px + env(safe-area-inset-right));
  bottom: calc(140px + env(safe-area-inset-bottom));
}

/* only there while you are stood on the sand */
#shopBtn {
  right: calc(24px + env(safe-area-inset-right));
  bottom: calc(236px + env(safe-area-inset-bottom));
  width: auto;
  height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  color: #ffd84d;
  display: none;
}

#shopBtn.on { display: block; }

/* the sound pill and shop buttons grow to a comfortable thumb size */
body.touch #soundBtn { min-height: 44px; padding: 12px 18px; }
body.touch .buy,
body.touch #shopClose { min-height: 48px; }
