/* Surf Quest — kid-friendly phone surf UI (KOF look) */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0b1a2a;
  color: #fff;
  font-family: system-ui, "Segoe UI", Arial, sans-serif;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body.playing {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

#game-wrap {
  position: relative;
  width: 390px;
  max-width: 100vw;
  height: 700px;
  max-height: 100vh;
  max-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: #0a2740;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  touch-action: none;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  background: #3a8ec4;
  position: relative;
  z-index: 1;
  pointer-events: none;
}

#hud {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  z-index: 40;
  pointer-events: none;
  padding-top: env(safe-area-inset-top, 0);
}

#hud.hidden, .hidden { display: none !important; }

#lives {
  font-size: 1.35rem;
  letter-spacing: 2px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.45));
}

#score-line {
  margin-top: 4px;
  font-size: 0.95rem;
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

#beach-name {
  text-align: right;
  font-size: 0.85rem;
  font-weight: 700;
  color: #cfe8ff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

#progress-wrap {
  margin-top: 6px;
  width: 120px;
  max-width: 36vw;
  height: 10px;
  border-radius: 999px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.25);
  overflow: hidden;
  margin-left: auto;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4fc3f7, #f4c430);
  border-radius: 999px;
  transition: width 0.1s linear;
}

#meters {
  position: absolute;
  left: 10px;
  bottom: 110px;
  z-index: 35;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.meter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meter-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.9;
  width: 42px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.meter-track {
  width: 88px;
  height: 12px;
  border-radius: 999px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.28);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
}

#crest-fill { background: linear-gradient(90deg, #81d4fa, #fff59d); }
#lean-fill { background: linear-gradient(90deg, #80cbc4, #4dd0e1); }

#touch-carve {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 46%;
  z-index: 30;
  touch-action: none;
  background: transparent;
}

#btn-pump {
  position: absolute;
  right: 14px;
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  z-index: 36;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  border: 4px solid #1a1200;
  background: radial-gradient(circle at 35% 30%, #ffe082, #f4c430 55%, #d4a017);
  color: #1a1200;
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 22px rgba(0,0,0,0.45), inset 0 2px 0 rgba(255,255,255,0.45);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

#btn-pump:active,
#btn-pump.pressed {
  transform: scale(0.94);
  background: radial-gradient(circle at 35% 30%, #fff59d, #f4c430 60%, #c49010);
}

#cheer {
  position: absolute;
  top: 28%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  font-size: 1.6rem;
  font-weight: 900;
  color: #fff59d;
  text-shadow: 0 3px 10px rgba(0,0,0,0.55);
  pointer-events: none;
  animation: cheerPop 0.9s ease-out forwards;
}

@keyframes cheerPop {
  0% { opacity: 0; transform: translateX(-50%) translateY(12px) scale(0.8); }
  20% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-28px) scale(1); }
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  padding-top: max(24px, env(safe-area-inset-top, 0px));
  padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  text-align: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen-opaque {
  background: linear-gradient(165deg, #0b2744 0%, #0b1a2a 55%, #123 100%);
}

.screen-dim {
  background: rgba(6, 16, 28, 0.88);
  backdrop-filter: blur(4px);
}

#screen-start {
  background:
    linear-gradient(165deg, rgba(11, 39, 68, 0.92), rgba(11, 26, 42, 0.95)),
    #0b1a2a;
}

.start-brand-logo {
  width: 88px;
  height: auto;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,0.45));
  user-select: none;
  -webkit-user-drag: none;
}

.screen h1 {
  margin: 6px 0 4px;
  font-size: clamp(1.6rem, 6vw, 2rem);
  font-weight: 900;
  text-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

.site {
  margin: 0 0 14px;
  color: #8ec8ff;
  font-size: 0.95rem;
}

.howto {
  margin: 0 0 18px;
  max-width: 320px;
  font-size: 0.98rem;
  line-height: 1.45;
  opacity: 0.95;
}

.howto strong { color: #ffe082; }

.hint {
  margin: 14px 0 0;
  font-size: 0.9rem;
  opacity: 0.85;
  max-width: 300px;
  line-height: 1.4;
}

.win-score {
  font-size: 1.15rem;
  margin: 8px 0 4px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

button.big,
a.btn-link.secondary,
button.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  width: 100%;
  max-width: 280px;
  padding: 12px 20px;
  border-radius: 14px;
  font-size: 1.15rem;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  border: 2px solid transparent;
  -webkit-tap-highlight-color: transparent;
}

button.big {
  background: #f4c430;
  color: #1a1200;
  border-color: rgba(26, 18, 0, 0.35);
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}

button.big:hover,
button.big:focus-visible {
  background: #ffe082;
  outline: none;
}

button.big:active { transform: scale(0.98); }

button.secondary,
a.btn-link.secondary {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-color: rgba(255,255,255,0.28);
}

button.secondary:hover,
button.secondary:focus-visible,
a.btn-link.secondary:hover,
a.btn-link.secondary:focus-visible {
  background: rgba(255,255,255,0.18);
  outline: none;
}

.btn-home-back {
  position: absolute;
  top: max(12px, env(safe-area-inset-top, 0px));
  left: max(12px, env(safe-area-inset-left, 0px));
  z-index: 70;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(12, 28, 48, 0.85);
  border: 2px solid rgba(255,255,255,0.22);
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}

.btn-home-back:hover,
.btn-home-back:focus-visible {
  border-color: #f4c430;
  outline: none;
}

.btn-home-logo {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  object-fit: contain;
}

@media (max-height: 640px) {
  .start-brand-logo { width: 64px; }
  .howto { font-size: 0.9rem; }
  #btn-pump { width: 92px; height: 92px; font-size: 1rem; }
  #meters { bottom: 96px; }
}
