:root {
  --green: #1C3325;
  --cream: #F5EFE2;
  --orange: #E8743B;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--green);
  color: var(--cream);
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}
#game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1rem; text-align: center; padding: 1.5rem;
  background: rgba(28, 51, 37, .88);
}
.overlay[hidden] { display: none !important; }
.overlay h1 { font-family: 'Fraunces', serif; font-size: clamp(1.8rem, 6vw, 3rem); }
.overlay .tagline { max-width: 36ch; opacity: .92; line-height: 1.5; }

.btn {
  font: inherit; font-weight: 600; font-size: 1.05rem;
  border: none; border-radius: 999px; padding: .9rem 2rem;
  cursor: pointer; background: var(--orange); color: var(--cream);
  text-decoration: none; display: inline-block;
}
.btn.secondary { background: transparent; border: 2px solid var(--cream); }
.btn:active { transform: scale(.97); }

#hud {
  position: fixed; top: max(1rem, env(safe-area-inset-top)); left: 0; right: 0;
  display: flex; justify-content: center; pointer-events: none; z-index: 5;
}
#hud[hidden] { display: none !important; }
#hud .score {
  font-family: 'Fraunces', serif; font-size: 1.6rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .5);
}

#flash {
  position: fixed; bottom: 18%; left: 0; right: 0; z-index: 5;
  text-align: center; pointer-events: none; padding: 0 1rem;
  font-size: 1.05rem; font-weight: 600;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .6);
  opacity: 0; transition: opacity .25s;
}
#flash.show { opacity: 1; }

.best { font-size: .9rem; opacity: .75; }
.record { color: var(--orange); font-weight: 700; }
.record[hidden] { display: none !important; }
.hint { font-size: .85rem; opacity: .7; color: var(--cream); }
.endscore { font-family: 'Fraunces', serif; font-size: clamp(2.2rem, 9vw, 4rem); color: var(--orange); }
.quip { max-width: 38ch; font-size: 1.05rem; line-height: 1.5; }
.cta-note { font-size: .9rem; opacity: .85; max-width: 36ch; }

/* On-screen arrow buttons (touch devices only — see media query below) */
.touch-controls { position: fixed; inset: 0; z-index: 6; pointer-events: none; display: none; }
.ctrl-btn {
  position: absolute;
  width: 4.2rem; height: 4.2rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; line-height: 1; color: var(--cream);
  background: rgba(245, 239, 226, .12);
  border: 2px solid rgba(245, 239, 226, .45);
  border-radius: 50%;
  pointer-events: auto; cursor: pointer;
  touch-action: none; -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.ctrl-btn.pressed {
  background: rgba(232, 116, 59, .55); border-color: var(--orange);
  transform: scale(.94);
}
/* left/right-only games (loď, batoh): one button in each bottom corner */
.ctrl-left  { left:  max(1.1rem, env(safe-area-inset-left));  bottom: max(1.6rem, env(safe-area-inset-bottom)); }
.ctrl-right { right: max(1.1rem, env(safe-area-inset-right)); bottom: max(1.6rem, env(safe-area-inset-bottom)); }
/* full d-pad (tapír): cross in the bottom-left */
.dpad {
  position: absolute;
  left: max(1.1rem, env(safe-area-inset-left));
  bottom: max(1.6rem, env(safe-area-inset-bottom));
  display: grid; gap: .25rem;
  grid-template-columns: repeat(3, 3.6rem);
  grid-template-rows: repeat(3, 3.6rem);
}
.dpad .ctrl-btn { position: static; width: 3.6rem; height: 3.6rem; font-size: 1.4rem; }
.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

@media (hover: none) and (pointer: coarse) {
  .touch-controls { display: block; }
  /* hide the buttons whenever a start/end menu is up */
  body:has(.overlay:not([hidden])) .touch-controls { display: none; }
}

.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); z-index: 20;
  background: var(--cream); color: var(--green);
  padding: .6rem 1.2rem; border-radius: 999px; font-size: .9rem;
  opacity: 0; transition: opacity .3s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* Lead capture na end overlay */
.lead { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: .75rem; align-items: stretch; }
.lead-form { display: flex; flex-direction: column; gap: .6rem; text-align: left; }
.lead-form[hidden] { display: none !important; }
.lead-intro { font-size: .9rem; line-height: 1.45; opacity: .9; text-align: center; }
.lead-input {
  font: inherit; padding: .7rem .9rem; border-radius: 12px;
  border: 1px solid rgba(245, 239, 226, .35); background: rgba(245, 239, 226, .08);
  color: var(--cream);
}
.lead-input::placeholder { color: rgba(245, 239, 226, .55); }
.lead-input:focus { outline: none; border-color: var(--orange); }
.lead-consent { display: flex; gap: .5rem; align-items: flex-start; font-size: .8rem; line-height: 1.4; opacity: .9; }
.lead-consent input { margin-top: .15rem; accent-color: var(--orange); }
.lead-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.lead-status { font-size: .85rem; color: var(--orange); text-align: center; }
.lead-status a { color: var(--cream); }
.lead-status[hidden] { display: none !important; }
.lead-done { font-size: 1rem; text-align: center; }
.lead-done[hidden] { display: none !important; }
#lead-open[hidden] { display: none !important; }
.lead-pdf { margin-top: .6rem; }
