/* =====================================================================
   Desafío de Triples 60s — Estilos (mobile-first)
   ===================================================================== */

:root {
  --bg: #120b06;
  --bg-2: #24160c;
  --wood: #c98a4b;
  --orange: #ff7a18;
  --orange-2: #ffb347;
  --text: #fff6ec;
  --muted: #c9b29b;
  --led-red: #ff3b30;
  --led-green: #37ff8b;
  --led-amber: #ffc531;
  --card: rgba(30, 18, 10, .82);
  --line: rgba(255, 200, 140, .18);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(ellipse at 50% -10%, rgba(255, 170, 80, .25), transparent 60%),
    repeating-linear-gradient(90deg, #3a2312 0 46px, #33200f 46px 92px),
    var(--bg);
}

#app { height: 100%; height: 100dvh; max-width: 560px; margin: 0 auto; position: relative; }

/* ---------- Pantallas ---------- */
.screen {
  display: none;
  height: 100%;
  flex-direction: column;
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-b));
  overflow-y: auto;
}
.screen.active { display: flex; animation: aparecer .35s ease; }
@keyframes aparecer { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Registro ---------- */
.hero { text-align: center; margin: 4vh 0 18px; }
.hero-ball { font-size: 64px; animation: bote 1.1s cubic-bezier(.5, 0, .5, 1) infinite alternate; }
@keyframes bote { from { transform: translateY(-14px); } to { transform: translateY(6px) scale(1.06, .94); } }
h1 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(44px, 13vw, 68px);
  line-height: .95;
  margin: 8px 0 6px;
  letter-spacing: 1px;
  text-shadow: 0 4px 0 #000, 0 0 24px rgba(255, 122, 24, .45);
}
h1 span { color: var(--orange); display: block; }
.hero-sub { margin: 0; color: var(--muted); font-weight: 700; }
.hero-sub b { color: var(--orange-2); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  backdrop-filter: blur(6px);
}

form label { display: block; font-weight: 800; font-size: 14px; margin: 4px 0 6px; color: var(--muted); }
form input, form select {
  width: 100%;
  font: inherit;
  font-size: 18px;               /* >=16px evita el zoom automático en iOS */
  padding: 13px 14px;
  margin-bottom: 14px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: rgba(0, 0, 0, .35);
  color: var(--text);
  outline: none;
}
form input:focus, form select:focus { border-color: var(--orange); }
form select { cursor: pointer; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%;
  background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
form select option, form select optgroup { background: #1a120c; color: var(--text); }
[hidden] { display: none !important; }
.form-error { color: #ff8a80; min-height: 1.2em; margin: 0 0 8px; font-weight: 700; font-size: 14px; }

.btn {
  display: block;
  width: 100%;
  font: inherit;
  font-weight: 900;
  font-size: 19px;
  padding: 15px;
  border-radius: 14px;
  border: 0;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: .5px;
  transition: transform .08s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn + .btn { margin-top: 10px; }
.btn-primary {
  background: linear-gradient(180deg, var(--orange-2), var(--orange));
  color: #2a1203;
  box-shadow: 0 5px 0 #a8460a, 0 10px 20px rgba(255, 122, 24, .35);
}
.btn-ghost { background: transparent; color: var(--text); border: 2px solid var(--line); }

.howto { text-align: center; color: var(--muted); font-size: 14px; line-height: 1.5; margin-top: 18px; }
kbd { background: #000; border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; font-size: 12px; }

/* ---------- Juego ---------- */
#screen-juego { padding: 8px 10px; padding-bottom: calc(10px + var(--safe-b)); gap: 8px; overflow: hidden; }

.scoreboard {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 6px;
  background: linear-gradient(180deg, #1b1b1f, #0b0b0d);
  border: 3px solid #3b3b42;
  border-radius: 14px;
  padding: 6px;
  box-shadow: inset 0 0 0 2px #000, 0 6px 16px rgba(0, 0, 0, .6);
  flex: 0 0 auto;
}
.sb-cell { display: flex; flex-direction: column; align-items: center; background: #050505; border-radius: 8px; padding: 4px 2px 6px; }
.sb-label { font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; color: #9a9aa5; }
.sb-led { font-family: 'Orbitron', monospace; font-weight: 900; font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sb-led small { font-size: .6em; }
.sb-led.big { font-size: 40px; }
.led-red   { color: var(--led-red);   text-shadow: 0 0 10px rgba(255, 59, 48, .8); }
.led-green { color: var(--led-green); text-shadow: 0 0 10px rgba(55, 255, 139, .7); }
.led-amber { color: var(--led-amber); text-shadow: 0 0 10px rgba(255, 197, 49, .7); font-size: 20px; }
.sb-led.pop { animation: pop .35s ease; }
@keyframes pop { 40% { transform: scale(1.35); } }
.sb-timer.warning .sb-led { animation: parpadeo .5s steps(2) infinite; }
@keyframes parpadeo { 50% { opacity: .35; } }

.canvas-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
canvas {
  display: block;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .6);
  touch-action: none;
  cursor: pointer;
}
.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 120px;
  color: #fff;
  text-shadow: 0 6px 0 #000, 0 0 40px var(--orange);
}
.countdown.tick { animation: tick .8s ease-out; }
@keyframes tick { from { transform: scale(1.8); opacity: 0; } 30% { opacity: 1; } to { transform: scale(1); opacity: .9; } }

.controls { display: flex; gap: 10px; align-items: stretch; flex: 0 0 auto; }
.btn-shoot {
  position: relative;
  overflow: hidden;
  flex: 1;
  min-height: 84px;
  border: 0;
  border-radius: 20px;
  background: radial-gradient(circle at 50% 30%, #ff9d4d, #e85d04 60%, #a83c00);
  color: #fff;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 40px;
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: 0 7px 0 #6e2600, 0 12px 24px rgba(232, 93, 4, .45);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  transition: transform .06s, box-shadow .06s;
}
.btn-shoot:active, .btn-shoot.pressed { transform: translateY(5px); box-shadow: 0 2px 0 #6e2600, 0 6px 12px rgba(232, 93, 4, .4); }
.btn-shoot:disabled { filter: grayscale(.7) brightness(.7); }
.shoot-ball { font-size: 38px; }
.shoot-text { text-shadow: 0 3px 0 rgba(0, 0, 0, .35); }
/* Barra de recarga (cooldown) */
.shoot-cooldown {
  position: absolute;
  left: 0; bottom: 0;
  height: 6px;
  width: 100%;
  background: rgba(255, 255, 255, .85);
  transform-origin: left;
  transform: scaleX(0);
}
.btn-icon {
  width: 60px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: rgba(0, 0, 0, .4);
  font-size: 24px;
  cursor: pointer;
}

/* ---------- Resultado / Ranking ---------- */
#screen-ranking { gap: 12px; }
.result-card { text-align: center; }
.result-label { margin: 0; font-family: 'Bebas Neue', sans-serif; font-size: 34px; color: var(--orange-2); letter-spacing: 1px; }
.result-player { margin: 0 0 12px; color: var(--muted); font-weight: 800; word-break: break-word; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.result-stats div { background: rgba(0, 0, 0, .35); border-radius: 12px; padding: 10px 4px; }
.result-stats b { display: block; font-family: 'Orbitron', monospace; font-size: 28px; color: var(--led-green); }
.result-stats span { font-size: 12px; color: var(--muted); font-weight: 800; text-transform: uppercase; }
.result-msg { margin: 12px 0 0; font-weight: 800; min-height: 1.3em; }

.ranking-card h2 { margin: 0 0 10px; font-family: 'Bebas Neue', sans-serif; font-size: 30px; letter-spacing: 1px; }
.table-wrap { overflow-x: auto; }
table.ranking { width: 100%; border-collapse: collapse; font-size: 15px; }
.ranking th { text-align: left; font-size: 11px; text-transform: uppercase; color: var(--muted); padding: 6px; border-bottom: 1px solid var(--line); }
.ranking td { padding: 8px 6px; border-bottom: 1px solid rgba(255, 255, 255, .06); vertical-align: middle; }
.ranking td:nth-child(1) { width: 34px; font-weight: 900; color: var(--orange-2); }
.ranking td:nth-child(3), .ranking td:nth-child(4),
.ranking th:nth-child(3), .ranking th:nth-child(4) { text-align: right; font-variant-numeric: tabular-nums; }
.ranking td:nth-child(3) { font-family: 'Orbitron', monospace; color: var(--led-green); font-weight: 900; }
.ranking .jug { font-weight: 800; word-break: break-word; }
.ranking .eq { display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
.ranking tr.me td { background: rgba(255, 122, 24, .22); }
.ranking tr.me td:first-child { border-radius: 8px 0 0 8px; }
.ranking tr.me td:last-child { border-radius: 0 8px 8px 0; }
.muted { color: var(--muted); text-align: center !important; }

.actions { margin-top: auto; }

@media (min-width: 700px) and (min-height: 700px) {
  .btn-shoot { min-height: 96px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
