* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  background: #0b1d33;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: #fff;
}

#game,
#game canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden {
  display: none !important;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

#scoreBox {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(14px + env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  text-shadow: 0 2px 8px rgba(0, 20, 50, 0.7);
}

#scoreBox span {
  font-size: clamp(26px, 7vw, 40px);
  font-weight: 800;
  line-height: 1;
}

#scoreBox small,
#speedBox small {
  font-size: 11px;
  letter-spacing: 2px;
  opacity: 0.8;
}

#coinBox {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(14px + env(safe-area-inset-right));
  font-size: clamp(20px, 6vw, 30px);
  font-weight: 800;
  text-shadow: 0 2px 8px rgba(0, 20, 50, 0.7);
}

#livesBox {
  position: absolute;
  top: calc(52px + env(safe-area-inset-top));
  right: calc(14px + env(safe-area-inset-right));
  font-size: clamp(16px, 5vw, 24px);
  filter: drop-shadow(0 2px 4px rgba(0, 20, 50, 0.7));
}

#speedBox {
  position: absolute;
  bottom: calc(14px + env(safe-area-inset-bottom));
  left: calc(14px + env(safe-area-inset-left));
  display: flex;
  align-items: baseline;
  gap: 6px;
  text-shadow: 0 2px 8px rgba(0, 20, 50, 0.7);
}

#speedBox span {
  font-size: clamp(22px, 6vw, 34px);
  font-weight: 800;
}

#combo {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff9f1c, #ff4757);
  font-weight: 900;
  font-size: clamp(14px, 4.5vw, 20px);
  letter-spacing: 1px;
  box-shadow: 0 4px 16px rgba(255, 71, 87, 0.5);
}

#flash {
  position: absolute;
  top: 32%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(22px, 7vw, 42px);
  font-weight: 900;
  letter-spacing: 1px;
  color: #ffd23f;
  text-shadow: 0 3px 12px rgba(0, 20, 50, 0.8);
  opacity: 0;
  white-space: nowrap;
}

#flash.pop {
  animation: pop 0.9s ease-out forwards;
}

@keyframes pop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.5); }
  20% { opacity: 1; transform: translateX(-50%) scale(1.15); }
  40% { transform: translateX(-50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-30px) scale(1); }
}

/* ---------- Telas ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 18, 36, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  overflow-y: auto;
  padding: 20px;
}

.panel {
  text-align: center;
  max-width: 420px;
  width: 100%;
  padding: 28px 22px;
  border-radius: 24px;
  background: rgba(10, 28, 52, 0.75);
  border: 1px solid rgba(140, 190, 255, 0.25);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

h1 {
  font-size: clamp(38px, 11vw, 58px);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #ffffff, #8ec5ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
}

h2 {
  font-size: clamp(24px, 7vw, 34px);
  font-weight: 900;
  letter-spacing: 2px;
}

h3 {
  margin-top: 16px;
  font-size: 15px;
  letter-spacing: 3px;
  opacity: 0.85;
}

.tag {
  margin-top: 8px;
  font-size: 15px;
  opacity: 0.9;
}

.best {
  margin-top: 10px;
  font-weight: 700;
  color: #ffd23f;
  min-height: 20px;
}

.big {
  display: block;
  width: 100%;
  margin: 18px auto 6px;
  padding: 16px 20px;
  font-size: clamp(18px, 5.5vw, 24px);
  font-weight: 900;
  letter-spacing: 2px;
  color: #062341;
  background: linear-gradient(135deg, #ffd23f, #ff9f1c);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 159, 28, 0.4);
}

.big:active {
  transform: scale(0.97);
}

.hint {
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.7;
  opacity: 0.75;
}

.final {
  margin: 14px 0 4px;
  display: flex;
  flex-direction: column;
}

.final span {
  font-size: clamp(44px, 13vw, 68px);
  font-weight: 900;
  color: #ffd23f;
  line-height: 1;
}

.final small {
  letter-spacing: 3px;
  opacity: 0.75;
}

#newRecord {
  margin: 8px 0;
  font-weight: 900;
  color: #2ed573;
  font-size: 18px;
  animation: pulse 1s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

#saveRow {
  display: flex;
  gap: 8px;
  margin: 14px 0 4px;
}

#nameInput {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(140, 190, 255, 0.4);
  border-radius: 12px;
  outline: none;
}

#saveRow button {
  padding: 12px 18px;
  font-weight: 900;
  color: #062341;
  background: #2ed573;
  border: none;
  border-radius: 12px;
  cursor: pointer;
}

#ladder {
  list-style: none;
  margin: 10px 0 4px;
  text-align: left;
}

#ladder li {
  display: flex;
  justify-content: space-between;
  padding: 7px 12px;
  margin: 4px 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  font-weight: 700;
  font-size: 14px;
}

#ladder li:first-child {
  background: rgba(255, 210, 63, 0.18);
  color: #ffd23f;
}

#ladder .lname::before {
  content: attr(data-pos) '. ';
  opacity: 0.6;
}

/* ---------- Yeti ---------- */
#yetiWarn {
  position: absolute;
  top: calc(64px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, #b3001b, #ff2222);
  font-weight: 900;
  font-size: clamp(18px, 5.5vw, 28px);
  letter-spacing: 2px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 24px rgba(255, 34, 34, 0.55);
  animation: yetiPulse 0.8s ease-in-out infinite alternate;
  white-space: nowrap;
}

#yetiWarn.close {
  animation-duration: 0.28s;
  background: linear-gradient(135deg, #ff2222, #ff7b00);
}

@keyframes yetiPulse {
  from { transform: translateX(-50%) scale(1); }
  to { transform: translateX(-50%) scale(1.12); }
}

/* ---------- Mute ---------- */
#muteBtn {
  position: fixed;
  bottom: calc(14px + env(safe-area-inset-bottom));
  right: calc(14px + env(safe-area-inset-right));
  z-index: 20;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(140, 190, 255, 0.35);
  background: rgba(10, 28, 52, 0.6);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

#muteBtn:active {
  transform: scale(0.92);
}

/* ---------- Créditos ---------- */
.credit {
  margin-top: 12px;
  font-size: 11px;
  letter-spacing: 1px;
  opacity: 0.5;
}
