/* ── Tiro Libre — HUD & chrome ─────────────────────────────── */

:root {
  --ink: #f5efe6;
  --gold: #ffc83d;
  --dim: rgba(245, 239, 230, .55);
}

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

html, body {
  margin: 0;
  height: 100%;
  background: #0d1220;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}

#c {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* HUD layer — clicks pass through except on real controls */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }

#title {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: calc(18px + env(safe-area-inset-left));
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 5px;
  opacity: .45;
}

#scorewrap {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

#score {
  font-size: clamp(44px, 9vmin, 82px);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 4px 24px rgba(0, 0, 0, .55);
}

#score.pop { animation: pop .22s ease-out; }
@keyframes pop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

#record {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2.5px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  transition: color .3s;
}
#record.lit { color: var(--gold); text-shadow: 0 0 18px rgba(255, 200, 61, .45); }

#fire {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  left: calc(50% + clamp(56px, 12vmin, 110px));
  display: none;
  align-items: center;
  gap: 4px;
  font-size: clamp(18px, 4vmin, 26px);
  font-weight: 900;
  color: #ffb03d;
  text-shadow: 0 0 16px rgba(255, 140, 40, .6);
  animation: firePulse 1s ease-in-out infinite;
}
#fire.on { display: flex; }
#fireN { font-size: .72em; }
@keyframes firePulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}

#snd {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(14px + env(safe-area-inset-right));
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 21px;
  background: rgba(255, 255, 255, .08);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--ink);
  font-size: 19px;
  cursor: pointer;
  pointer-events: auto;
  transition: background .2s, transform .1s;
}
#snd:active { transform: scale(.92); }
#snd.off { opacity: .5; }

#hint {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transform: translate(-50%, -100%);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--dim);
  text-transform: uppercase;
  white-space: nowrap;
  transition: opacity .5s;
}
#hint.hide { opacity: 0; }
#hintArrow {
  font-size: 30px;
  color: var(--ink);
  animation: arrowGo 1.4s ease-in-out infinite;
}
@keyframes arrowGo {
  0%   { transform: translate(0, 0); opacity: .35; }
  55%  { transform: translate(16px, -16px); opacity: 1; }
  100% { transform: translate(16px, -16px); opacity: 0; }
}

#toast {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(26px, 6.5vmin, 54px);
  font-weight: 900;
  letter-spacing: 1px;
  white-space: nowrap;
  text-shadow: 0 6px 30px rgba(0, 0, 0, .6);
  opacity: 0;
}
#toast.show { animation: toastIn 1.6s ease-out forwards; }
#toast.gold { color: var(--gold); text-shadow: 0 0 34px rgba(255, 200, 61, .55), 0 6px 30px rgba(0,0,0,.6); }
@keyframes toastIn {
  0%   { opacity: 0; transform: translateX(-50%) scale(.6); }
  12%  { opacity: 1; transform: translateX(-50%) scale(1.06); }
  20%  { transform: translateX(-50%) scale(1); }
  78%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(1); }
}

#flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 32%, rgba(255, 205, 80, .5), rgba(255, 205, 80, 0) 62%);
  opacity: 0;
}
#flash.go { animation: flashOut .55s ease-out; }
@keyframes flashOut {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

.nojs {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  #fire, #hintArrow { animation: none; }
}
