/* ==========================================================================
   style.css — HUD and menus. Chunky, high-contrast, arcade. Everything
   overlays a full-bleed canvas and stays out of the way while playing.
   ========================================================================== */

:root {
  --ink: #10151f;
  --paper: #fffaf2;
  --red: #ff5d5d;
  --pink: #ff8fb0;
  --sun: #ffd166;
  --mint: #7cf5c4;
  --sky: #4fc3f7;
  --grape: #b388ff;
  --shadow: 0 6px 0 rgba(0, 0, 0, 0.28), 0 14px 30px rgba(0, 0, 0, 0.3);
  --font: 'Trebuchet MS', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #8fd6ff;
  font-family: var(--font);
  color: var(--paper);
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden {
  display: none !important;
}

/* ---------------------------------------------------------------- overlays */

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 90% at 50% 20%, rgba(10, 18, 32, 0.42), rgba(6, 12, 24, 0.82));
  backdrop-filter: blur(3px);
  z-index: 20;
  padding: 20px;
  animation: fadeIn 0.22s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

.card {
  width: min(430px, 100%);
  max-height: 92vh;
  background: linear-gradient(180deg, #1d2740, #141c30);
  border: 3px solid rgba(255, 255, 255, 0.13);
  border-radius: 22px;
  padding: 26px 24px;
  text-align: center;
  box-shadow: var(--shadow);
}

.card.wide {
  width: min(560px, 100%);
}

.card.scroll {
  overflow-y: auto;
  text-align: left;
}

.card > * + * {
  margin-top: 14px;
}

/* ------------------------------------------------------------------- logo */

.logo {
  line-height: 0.92;
  transform: rotate(-2deg);
}

.logo-k,
.logo-c {
  display: block;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.logo-k {
  font-size: clamp(30px, 8vw, 48px);
  color: var(--paper);
  text-shadow: 0 4px 0 #0b1120, 0 0 26px rgba(255, 255, 255, 0.25);
}

.logo-c {
  font-size: clamp(22px, 6vw, 34px);
  color: var(--sun);
  text-shadow: 0 4px 0 #7a3c1e, 0 0 26px rgba(255, 209, 102, 0.4);
}

.tagline {
  color: #b9c6dd;
  font-size: 14px;
  line-height: 1.5;
}

.muted {
  color: #8fa0bd;
  font-size: 13px;
}

h2 {
  font-size: 26px;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 3px 0 #0b1120;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-block;
  width: 100%;
  padding: 13px 18px;
  border: none;
  border-radius: 14px;
  background: #2c3b5c;
  color: var(--paper);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 4px 0 #16203a;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.12s ease;
}

.btn:hover {
  filter: brightness(1.12);
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #16203a;
}

.btn.primary {
  background: linear-gradient(180deg, #ff7a7a, #ff4d4d);
  box-shadow: 0 5px 0 #a52a2a;
}

.btn.primary:active {
  box-shadow: 0 1px 0 #a52a2a;
}

.btn.big {
  font-size: 21px;
  padding: 16px;
}

.btn.danger {
  background: #6b2230;
  box-shadow: 0 4px 0 #3d101a;
}

.btn.small {
  font-size: 12px;
  padding: 9px;
  opacity: 0.8;
}

.btn-row {
  display: flex;
  gap: 10px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 12px;
  background: rgba(12, 20, 36, 0.55);
  color: var(--paper);
  font-size: 15px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

/* ------------------------------------------------------------------ stats */

.stat-row {
  display: flex;
  gap: 10px;
}

.stat {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 13px;
  padding: 11px 6px;
}

.stat span {
  display: block;
  font-size: 24px;
  font-weight: 900;
  color: var(--sun);
}

.stat small {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  letter-spacing: 1px;
  color: #8fa0bd;
}

.big-score {
  font-size: 62px;
  font-weight: 900;
  color: var(--sun);
  text-shadow: 0 5px 0 #7a3c1e;
  line-height: 1;
}

.new-best {
  color: var(--mint);
  font-weight: 900;
  letter-spacing: 2px;
  animation: pop 0.5s ease-out;
}

/* --------------------------------------------------------------- controls */

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 12px;
  font-size: 12px;
  color: #b9c6dd;
  text-align: left;
}

.controls-grid > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key {
  flex: none;
  min-width: 62px;
  padding: 4px 7px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 800;
  font-size: 11px;
  text-align: center;
  color: var(--paper);
}

.help-list {
  list-style: none;
  font-size: 13.5px;
  line-height: 1.6;
  color: #c6d2e6;
}

.help-list li {
  padding: 7px 0 7px 20px;
  position: relative;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.help-list li::before {
  content: '▸';
  position: absolute;
  left: 2px;
  color: var(--sun);
}

.help-list b {
  color: var(--paper);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 11px;
  font-size: 14px;
  cursor: pointer;
}

.row input[type='checkbox'] {
  width: 44px;
  height: 24px;
  appearance: none;
  background: #3a4763;
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}

.row input[type='checkbox']::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}

.row input[type='checkbox']:checked {
  background: var(--mint);
}

.row input[type='checkbox']:checked::after {
  transform: translateX(20px);
}

.row input[type='range'] {
  width: 140px;
  accent-color: var(--sun);
}

.row select {
  background: #3a4763;
  color: var(--paper);
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  font-family: var(--font);
  font-weight: 700;
}

/* ------------------------------------------------------------------ loader */

.loader-track {
  height: 11px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

#loader-fill {
  height: 100%;
  width: 4%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--sun), var(--red));
  transition: width 0.25s ease;
}

/* ========================================================================== */
/*  HUD                                                                       */
/* ========================================================================== */

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

#hud button {
  pointer-events: auto;
}

.hud-top {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.score-block {
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
}

#score-value {
  font-size: clamp(30px, 6vw, 46px);
  font-weight: 900;
  line-height: 0.95;
  color: #fff;
}

.score-unit {
  font-size: 10px;
  letter-spacing: 3px;
  color: rgba(255, 255, 255, 0.75);
}

.hud-mid {
  display: flex;
  gap: 8px;
  padding-top: 6px;
}

.pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(12, 20, 36, 0.5);
  backdrop-filter: blur(5px);
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 1px;
  color: #fff;
}

.wave-pill {
  color: var(--sun);
}

.cow-pill .cow-ico {
  font-size: 15px;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hearts {
  display: flex;
  gap: 3px;
  font-size: 26px;
  line-height: 1;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
}

.heart {
  color: var(--red);
  transition: transform 0.2s, opacity 0.2s;
}

.heart.gone {
  color: rgba(255, 255, 255, 0.22);
  transform: scale(0.8);
}

/* ----------------------------------------------------------------- combo */

.combo {
  position: absolute;
  top: 92px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  width: 168px;
}

#combo-text {
  font-size: 40px;
  font-weight: 900;
  color: var(--mint);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.45);
  animation: pop 0.25s ease-out;
}

.combo-track {
  height: 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
  margin-top: 2px;
}

#combo-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--mint), var(--sun));
  transition: width 0.1s linear;
}

@keyframes pop {
  from {
    transform: scale(1.7);
  }
}

/* ---------------------------------------------------------------- banner */

.banner {
  position: absolute;
  top: 30%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(28px, 7vw, 54px);
  font-weight: 900;
  letter-spacing: 3px;
  color: #fff;
  text-shadow: 0 5px 0 #10151f, 0 0 34px rgba(255, 209, 102, 0.55);
  pointer-events: none;
}

.banner.pulse {
  animation: bannerIn 0.42s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes bannerIn {
  from {
    transform: scale(0.4) rotate(-8deg);
    opacity: 0;
  }
  60% {
    transform: scale(1.14) rotate(2deg);
    opacity: 1;
  }
}

/* ------------------------------------------------------------- power-ups */

.powers {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  top: 92px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

.power-row {
  width: 148px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(12, 20, 36, 0.55);
  backdrop-filter: blur(4px);
}

.power-label {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.4px;
}

.power-track {
  height: 5px;
  margin-top: 4px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.power-fill {
  height: 100%;
  width: 100%;
  border-radius: 3px;
  transition: width 0.1s linear;
}

/* --------------------------------------------------------------- minimap */

.minimap-holder {
  position: absolute;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  border-radius: 14px;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  opacity: 0.9;
}

.minimap {
  display: block;
  width: 148px;
  height: 148px;
}

@media (hover: none) and (pointer: coarse) {
  .minimap {
    width: 96px;
    height: 96px;
  }
}

/* ---------------------------------------------------------------- toasts */

.toasts {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.toast {
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(12, 20, 36, 0.72);
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 1.5px;
  color: #fff;
  animation: toastIn 0.28s ease-out;
  transition: opacity 0.5s, transform 0.5s;
}

.toast.good {
  background: rgba(20, 90, 60, 0.8);
  color: var(--mint);
}

.toast.out {
  opacity: 0;
  transform: translateY(-14px);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

/* ---------------------------------------------------------------- popups */

.popups {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.popup {
  position: absolute;
  top: 0;
  left: 0;
  white-space: nowrap;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 1px;
  color: var(--sun);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.55), 0 0 12px rgba(0, 0, 0, 0.4);
  will-change: transform, opacity;
}

.popup.big {
  font-size: 32px;
  color: var(--red);
}

.popup.small {
  font-size: 16px;
  color: #eaf2ff;
}

.popup.milk {
  color: #cfefff;
  font-size: 18px;
}

.popup.moo {
  color: #ffd9e6;
  font-size: 20px;
  font-style: italic;
}

.popup.chicken {
  color: #ffe066;
  font-size: 24px;
  text-shadow: 0 4px 0 #b35900, 0 0 16px rgba(255, 224, 102, 0.8);
}

.popup.goose {
  color: #ff4d4d;
  font-size: 28px;
  font-style: italic;
  text-shadow: 0 4px 0 #600, 0 0 20px rgba(255, 77, 77, 0.9);
}

/* ------------------------------------------------------------ full-screen fx */

.flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 15;
  mix-blend-mode: screen;
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(115% 85% at 50% 45%, transparent 55%, rgba(6, 12, 24, 0.42) 100%);
}

/* Named for the element, not the concept: a bare `.danger` here would also
   match `.btn.danger` (the QUIT button) and make it invisible. */
.danger-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  background: radial-gradient(90% 70% at 50% 40%, transparent 40%, rgba(255, 40, 40, 0.6) 100%);
  transition: opacity 0.1s linear;
}

/* ---------------------------------------------------------------- touch UI */

.touch-ui {
  display: none;
}

.stick {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.stick.on {
  opacity: 1;
}

.stick-base {
  position: absolute;
  width: 132px;
  height: 132px;
  margin: -66px 0 0 -66px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.32);
  background: rgba(12, 20, 36, 0.3);
}

.stick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
}

.touch-buttons {
  position: absolute;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(28px, env(safe-area-inset-bottom));
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.touch-btn {
  pointer-events: auto;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  font-family: var(--font);
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 1px;
  color: #fff;
  cursor: pointer;
}

.touch-btn.jump {
  width: 96px;
  height: 96px;
  background: rgba(255, 93, 93, 0.72);
}

.touch-btn.slam {
  width: 74px;
  height: 74px;
  background: rgba(79, 195, 247, 0.66);
}

.touch-btn:active {
  transform: scale(0.93);
}

@media (hover: none) and (pointer: coarse) {
  .touch-ui {
    display: block;
  }
  .controls-grid {
    display: none;
  }
  .combo {
    top: 80px;
  }
}

@media (max-width: 480px) {
  .card {
    padding: 20px 16px;
  }
  .stat span {
    font-size: 19px;
  }
  .big-score {
    font-size: 48px;
  }
}

/* ----------------------------------------------------------- overhead timer */
.head-timer {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate(-50%, -100%);
  pointer-events: none;
  font-family: var(--font);
  font-weight: 900;
  font-size: 22px;
  color: #fff;
  background: rgba(234, 88, 12, 0.92);
  border: 3px solid #facc15;
  border-radius: 20px;
  padding: 6px 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4), 0 0 16px rgba(250, 204, 21, 0.6);
  letter-spacing: 1px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.2s ease;
  animation: timerPulse 0.8s infinite alternate ease-in-out;
}

@keyframes timerPulse {
  0% { transform: translate(-50%, -100%) scale(1); }
  100% { transform: translate(-50%, -100%) scale(1.08); }
}
