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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  position: fixed;
  background: #160b10;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  font-family: Verdana, Geneva, sans-serif;
  color: #fff;
}

#stage {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 60px rgba(0,0,0,.8);
}

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

.hidden { display: none !important; }

/* ===== Overlays de efecto ===== */
#vignette {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(200,20,20,.55) 100%);
  transition: opacity .15s;
}
#flash {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: #fff;
}

/* ===== HUD ===== */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#hudTop {
  position: absolute; top: max(10px, env(safe-area-inset-top)); left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
#hudScore {
  font-family: 'Arial Black', Impact, sans-serif;
  font-size: clamp(28px, 7vh, 44px);
  color: #ffd23e;
  text-shadow: 0 3px 0 #7a1f2b, 0 5px 8px rgba(0,0,0,.5);
  line-height: 1;
}
#hudSub { font-size: clamp(12px, 2.2vh, 16px); font-weight: bold; text-shadow: 0 2px 3px rgba(0,0,0,.7); display: flex; gap: 8px; align-items: center; }
#hudSub .sep { opacity: .6; }
#hudHamWrap { display: inline-flex; align-items: center; gap: 3px; }
#hudBest { font-size: clamp(10px, 1.8vh, 13px); opacity: .85; font-weight: bold; text-shadow: 0 1px 2px rgba(0,0,0,.7); }

.iconBtn {
  position: absolute; top: max(10px, env(safe-area-inset-top));
  width: 40px; height: 40px; border-radius: 12px;
  border: 2px solid rgba(255,255,255,.35);
  background: rgba(60,10,20,.55); color: #fff;
  pointer-events: auto; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.iconBtn:active { transform: scale(.92); }
#btnPause { right: 10px; }
#btnMute { left: 10px; }
.iconBtn svg { width: 22px; height: 22px; }

.ico { display: inline-flex; width: 1.1em; height: 1.1em; vertical-align: -0.15em; }
.ico svg { width: 100%; height: 100%; }

/* Indicadores de potenciadores */
#pwrs {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(max(10px, env(safe-area-inset-top)) + 92px);
  display: flex; gap: 6px;
}
.pwr {
  width: 64px; padding: 4px 5px 5px; border-radius: 10px;
  background: rgba(40,8,16,.6); border: 2px solid rgba(255,255,255,.25);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 9px; font-weight: bold;
}
.pwr .ico { width: 18px; height: 18px; }
.pwr .bar { width: 100%; height: 4px; border-radius: 2px; background: rgba(255,255,255,.2); overflow: hidden; }
.pwr .bar i { display: block; height: 100%; background: #ffd23e; border-radius: 2px; }

/* ===== Toast y splash ===== */
#toast {
  position: absolute; top: 24%; left: 50%; transform: translateX(-50%);
  font-family: 'Arial Black', Impact, sans-serif;
  font-size: clamp(18px, 4vh, 28px); color: #fff;
  text-shadow: 0 3px 0 #7a1f2b, 0 5px 10px rgba(0,0,0,.6);
  z-index: 6; pointer-events: none; text-align: center; white-space: nowrap;
}
#toast.pop { animation: toastPop 1.6s ease forwards; }
@keyframes toastPop {
  0% { opacity: 0; transform: translateX(-50%) scale(.5); }
  12% { opacity: 1; transform: translateX(-50%) scale(1.15); }
  22% { transform: translateX(-50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-24px); }
}
#splash {
  position: absolute; top: 38%; left: 50%; transform: translate(-50%,-50%);
  font-family: 'Arial Black', Impact, sans-serif;
  font-size: clamp(34px, 8vh, 56px); color: #ffd23e;
  text-shadow: 0 4px 0 #7a1f2b, 0 8px 14px rgba(0,0,0,.6);
  z-index: 6; pointer-events: none; white-space: nowrap;
}
#splash.pop { animation: splashPop .95s ease forwards; }
@keyframes splashPop {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(.3) rotate(-6deg); }
  25% { opacity: 1; transform: translate(-50%,-50%) scale(1.1) rotate(2deg); }
  70% { opacity: 1; transform: translate(-50%,-50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(1.3); }
}

/* ===== Tutorial ===== */
#tut { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.tutCard {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 16%;
  width: 82%;
  background: rgba(40,8,16,.82); border: 2px solid rgba(255,210,62,.6);
  border-radius: 14px; padding: 12px 14px;
  font-size: clamp(13px, 2.4vh, 17px); font-weight: bold; text-align: center;
  animation: tutIn .35s ease;
}
.tutKeys {
  display: inline-block; margin-right: 8px; padding: 2px 10px;
  background: #ffd23e; color: #5a1220; border-radius: 8px;
  font-family: 'Arial Black', Impact, sans-serif;
}
@keyframes tutIn { from { opacity: 0; transform: translateX(-50%) translateY(14px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ===== Paneles ===== */
.panel {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 20px;
  background: linear-gradient(180deg, rgba(70,12,26,.88) 0%, rgba(30,6,14,.92) 100%);
  text-align: center;
}
.panelTitle {
  font-family: 'Arial Black', Impact, sans-serif;
  font-size: clamp(26px, 5.5vh, 40px); color: #ffd23e;
  text-shadow: 0 3px 0 #7a1f2b, 0 6px 10px rgba(0,0,0,.5);
}

#bunting { position: absolute; top: 0; left: 0; right: 0; height: 30px; display: flex; justify-content: center; gap: 4px; overflow: hidden; }
#bunting span { width: 22px; height: 26px; clip-path: polygon(0 0, 100% 0, 50% 100%); flex: 0 0 auto; }

#title { display: flex; flex-direction: column; line-height: .95; margin-top: 10px; }
#titleTop, #titleBot {
  font-family: 'Arial Black', Impact, sans-serif;
  font-size: clamp(44px, 11vh, 84px);
  background: linear-gradient(180deg, #ffe27a 20%, #ff9d2e 60%, #ff6a3d 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #7a1f2b) drop-shadow(0 8px 12px rgba(0,0,0,.55));
}
#titleBot { letter-spacing: .08em; }
#menuSub { font-size: clamp(12px, 2.2vh, 16px); opacity: .9; font-weight: bold; }
#menuBest { font-size: clamp(12px, 2.2vh, 15px); color: #ffd23e; font-weight: bold; }

.bigBtn {
  font-family: 'Arial Black', Impact, sans-serif;
  font-size: clamp(20px, 4.2vh, 30px);
  padding: 14px 42px; border-radius: 18px; cursor: pointer;
  color: #fff; background: linear-gradient(180deg, #b02840, #7a1f2b);
  border: 3px solid #ffd23e;
  box-shadow: 0 6px 0 #4d1018, 0 10px 16px rgba(0,0,0,.5);
  pointer-events: auto;
}
.bigBtn:active { transform: translateY(4px); box-shadow: 0 2px 0 #4d1018; }
.midBtn {
  font-family: 'Arial Black', Impact, sans-serif;
  font-size: clamp(13px, 2.6vh, 18px);
  padding: 10px 22px; border-radius: 14px; cursor: pointer;
  color: #ffd23e; background: rgba(30,60,110,.85);
  border: 2px solid rgba(255,255,255,.4);
  box-shadow: 0 4px 0 #0e1f3d;
  display: inline-flex; align-items: center; gap: 8px;
  pointer-events: auto;
}
.midBtn:active { transform: translateY(3px); box-shadow: 0 1px 0 #0e1f3d; }
.miniBtn {
  font-size: 11px; font-weight: bold; padding: 5px 10px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.4); background: rgba(255,255,255,.12); color: #fff; cursor: pointer;
}

#menuHelp { font-size: clamp(10px, 1.9vh, 13px); opacity: .75; line-height: 1.6; }

/* Color selector para la camiseta */
#colorSection {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin: 8px 0;
}
#colorLabel {
  font-size: clamp(12px, 2vh, 15px);
  font-weight: bold;
  color: #ffd23e;
  text-shadow: 0 2px 0 #7a1f2b;
}
#colorButtons {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
}
.colorBtn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.3);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  pointer-events: auto;
  box-shadow: 0 0 0 rgba(255,210,62,0);
}
.colorBtn:hover {
  transform: scale(1.1);
}
.colorBtn.active {
  border-color: #ffd23e;
  box-shadow: 0 0 12px rgba(255,210,62,.8), inset 0 0 8px rgba(255,255,255,.3);
  transform: scale(1.15);
}
.colorBtn:active {
  transform: scale(1.05);
}

#saveMsg, #rankMsg { font-size: 11px; min-height: 14px; color: #ffb0a0; }

/* Game over */
#overTitle {
  font-family: 'Arial Black', Impact, sans-serif;
  font-size: clamp(30px, 6.5vh, 48px); color: #ff5a4a;
  text-shadow: 0 3px 0 #4d1018, 0 6px 12px rgba(0,0,0,.6);
  animation: overShake .5s ease;
}
@keyframes overShake { 0%,100%{transform:rotate(0)} 20%{transform:rotate(-3deg) scale(1.05)} 40%{transform:rotate(3deg)} 60%{transform:rotate(-2deg)} 80%{transform:rotate(2deg)} }
#overCause { font-size: clamp(12px, 2.3vh, 16px); font-weight: bold; opacity: .9; }
#overScore {
  font-family: 'Arial Black', Impact, sans-serif;
  font-size: clamp(40px, 9vh, 68px); color: #ffd23e; line-height: 1;
  text-shadow: 0 4px 0 #7a1f2b, 0 7px 12px rgba(0,0,0,.55);
}
#overStats { font-size: clamp(12px, 2.3vh, 16px); font-weight: bold; }
#overBest { font-size: clamp(11px, 2vh, 14px); opacity: .85; }
#newRecord {
  font-family: 'Arial Black', Impact, sans-serif; color: #8fe388;
  font-size: clamp(15px, 3vh, 22px); animation: recordPulse .8s ease infinite alternate;
}
@keyframes recordPulse { from { transform: scale(1); } to { transform: scale(1.12); } }
#saveRow { display: flex; flex-direction: column; gap: 6px; width: 82%; max-width: 340px; }

/* Ranking */
#rankList { width: 88%; max-width: 380px; max-height: 80vh; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; }
.rankRow {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.09); border-radius: 10px; padding: 7px 12px;
  font-size: clamp(12px, 2.2vh, 15px); font-weight: bold;
  border: 2px solid transparent;
}
.rankRow .pos { width: 56px; text-align: center; font-family: 'Arial Black', Impact, sans-serif; }
.rankRow .nm { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rankRow .pt { color: #ffd23e; font-family: 'Arial Black', Impact, sans-serif; }
.rankRow.r1 { background: linear-gradient(90deg, rgba(255,210,62,.35), rgba(255,210,62,.12)); border-color: #ffd23e; }
.rankRow.r2 { background: linear-gradient(90deg, rgba(200,200,220,.3), rgba(200,200,220,.1)); border-color: #c8c8dc; }
.rankRow.r3 { background: linear-gradient(90deg, rgba(205,127,50,.32), rgba(205,127,50,.1)); border-color: #cd7f32; }
.rankRow.me { outline: 3px solid #8fe388; }

#cubataBanner {
  width: 90%; max-width: 380px;
  background: linear-gradient(135deg, #ffb400, #ff5a3c);
  border: 3px solid #fff; border-radius: 16px; padding: 12px 14px;
  animation: cubataBounce .7s ease infinite alternate;
  box-shadow: 0 0 26px rgba(255,190,40,.8);
}
#cubataTxt { font-family: 'Arial Black', Impact, sans-serif; font-size: clamp(13px, 2.6vh, 18px); color: #4d1018; text-shadow: 0 1px 0 rgba(255,255,255,.5); }
@keyframes cubataBounce { from { transform: scale(1) rotate(-1deg); } to { transform: scale(1.05) rotate(1deg); } }

/* Confetti celebración */
#confettiBox { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 20; }
.confetti { position: absolute; top: -16px; width: 8px; height: 13px; border-radius: 2px; animation: confettiFall linear forwards; }
@keyframes confettiFall {
  to { transform: translateY(115%) rotate(720deg); opacity: .9; }
}
