/* Juego: los 18 hoyos de La Llorea */
:root {
  --verde: #0d3b2e;
  --verde2: #14543f;
  --crema: #f6f3ea;
  --texto: #18221e;
  --suave: #5c6b64;
  --panel: rgba(250, 248, 242, 0.94);
  --borde: rgba(13, 59, 46, 0.15);
  --sombra: 0 6px 22px rgba(0, 0, 0, 0.22);
  --azul: #1e88e5;
  --r: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #cfe3f2; color: var(--texto);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#escena { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#capa { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* Marcador */
#marcador { position: fixed; top: 0; left: 0; right: 0; z-index: 5; display: flex; gap: 8px; align-items: stretch;
  padding: calc(10px + env(safe-area-inset-top)) 12px 0; pointer-events: none; }
.tarjeta { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--r); box-shadow: var(--sombra);
  padding: 8px 14px; display: flex; align-items: center; gap: 10px; pointer-events: auto; }
.tarjeta .tit { display: flex; flex-direction: column; line-height: 1.15; }
.tarjeta small { color: var(--suave); font-size: 13.5px; }
.hoyo-info .num { width: 38px; height: 38px; border-radius: 50%; background: var(--verde); color: #fff; font-weight: 800;
  font-size: 20px; display: grid; place-items: center; flex: none; }
.hoyo-info b { font-size: 18px; color: var(--verde); }
.golpes-info { flex-direction: column; justify-content: center; gap: 0; margin: 0 auto; min-width: 170px; text-align: center; }
.golpes-info .grande { font-size: 24px; font-weight: 800; color: var(--verde); line-height: 1.1; }
.viento-info b { font-size: 18px; }
.brujula { width: 42px; height: 42px; border-radius: 50%; background: #fff; border: 2px solid var(--verde); display: grid; place-items: center; flex: none; }
.brujula .flecha { display: block; font-size: 24px; line-height: 1; color: var(--azul); transition: transform .3s; }
.redondo { width: 50px; justify-content: center; font-size: 22px; padding: 0; }
.menu { position: fixed; top: calc(70px + env(safe-area-inset-top)); right: 12px; z-index: 9; background: var(--crema);
  border-radius: 14px; box-shadow: var(--sombra); padding: 6px; display: grid; gap: 4px; width: 250px; pointer-events: auto; }
.menu button, .menu a { text-align: left; background: transparent; border: 0; padding: 12px 14px; border-radius: 10px;
  font-size: 16px; color: var(--verde); text-decoration: none; font-weight: 600; }
.menu button:hover, .menu a:hover { background: #fff; }

.etiqueta-nivel { position: fixed; left: 12px; top: calc(76px + env(safe-area-inset-top)); z-index: 4; background: var(--verde);
  color: #fff; border-radius: 999px; padding: 4px 12px; font-size: 13.5px; font-weight: 700; box-shadow: var(--sombra); }

/* Avisos */
.aviso { position: fixed; left: 50%; top: 24%; transform: translateX(-50%); z-index: 6; background: rgba(13, 59, 46, 0.92);
  color: #fff; border-radius: 16px; padding: 14px 22px; font-size: 19px; font-weight: 600; text-align: center;
  max-width: min(92vw, 560px); box-shadow: var(--sombra); pointer-events: none; }
.aviso.malo { background: rgba(160, 40, 30, 0.93); }
/* Guía flotante: paso a paso, encima del juego (que se sigue viendo detrás) */
.guia-fondo { position: fixed; inset: 0; z-index: 30; background: rgba(8, 30, 22, 0.38); display: flex; padding: 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom)); overflow: auto; }
.guia { margin: auto; width: min(92vw, 560px); max-height: calc(100dvh - 2rem); display: flex; flex-direction: column; gap: 0.8em;
  background: rgba(250, 248, 242, 0.97); border-radius: 1.3rem; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.32); padding: 1.1em 1.2em; }
.guia-cabeza { display: flex; align-items: center; justify-content: space-between; gap: 0.8em; flex-wrap: wrap; }
.guia-paso { font-weight: 700; color: var(--suave); font-size: 0.95rem; }
.guia-omitir { min-height: 44px; padding: 0.4em 1.2em; border-radius: 999px; border: 2px solid var(--verde); background: #fff;
  color: var(--verde); font-weight: 800; font-size: 1.05rem; }
.guia-cuerpo { overflow: auto; background: #fff; border: 2px solid #f2c618; border-radius: 1rem; padding: 0.9em 1.1em; }
.guia-cuerpo h2 { margin: 0 0 0.5em; font-size: 1.35rem; color: var(--verde); line-height: 1.25; }
.guia-cuerpo ol { margin: 0; padding-left: 1.4em; display: grid; gap: 0.7em; }
.guia-cuerpo li { font-size: 1.08rem; line-height: 1.45; overflow-wrap: break-word; }
.guia-puntos { display: flex; justify-content: center; gap: 0.5em; }
.guia-puntos i { width: 0.65em; height: 0.65em; border-radius: 50%; background: #cfd8d3; }
.guia-puntos i.si { background: var(--verde); }
.guia-botones { display: flex; gap: 0.6em; flex-wrap: wrap; }
.guia-botones button { flex: 1 1 8em; min-height: 52px; border-radius: 1rem; font-size: 1.15rem; font-weight: 800; padding: 0.5em 1em; }
.guia-ant { background: #fff; color: var(--verde); border: 2px solid var(--verde); }
.guia-sig { background: var(--verde); color: #fff; border: 0; }

/* Círculo para tirar desde la bola */
.zona-tiro { position: fixed; z-index: 3; width: 130px; height: 130px; margin: -65px 0 0 -65px; border-radius: 50%;
  border: 3px dashed rgba(255, 255, 255, 0.9); pointer-events: none; display: grid; place-items: end center;
  animation: latido 1.6s ease-in-out infinite; }
.zona-tiro span { transform: translateY(34px); background: rgba(13, 59, 46, 0.85); color: #fff; border-radius: 999px;
  padding: 4px 12px; font-size: 14px; font-weight: 700; white-space: nowrap; }
@keyframes latido { 0%, 100% { transform: scale(1); opacity: .95; } 50% { transform: scale(1.08); opacity: .7; } }
@media (prefers-reduced-motion: reduce) { .zona-tiro { animation: none; } }

/* Panel del golpe: aguja y fuerza */
/* arriba, para que el dedo que tira (abajo) no lo tape ni lo tape la goma */
.panel-golpe { position: fixed; left: 50%; transform: translateX(-50%); top: calc(118px + env(safe-area-inset-top)); z-index: 5;
  width: min(92vw, 440px); background: var(--panel); border-radius: var(--r); box-shadow: var(--sombra); padding: 12px 16px;
  display: grid; gap: 10px; pointer-events: none; }
.aguja-barra { position: relative; height: 26px; border-radius: 13px; overflow: hidden;
  background: linear-gradient(90deg, #d84a3a, #f2c618 30%, #f2c618 70%, #d84a3a); }
.aguja-centro { position: absolute; top: 0; bottom: 0; left: 50%; background: #2e9d4a; border-left: 2px solid #fff; border-right: 2px solid #fff; }
.aguja { position: absolute; top: -2px; bottom: -2px; left: 50%; width: 6px; margin-left: -3px; background: #111; border-radius: 3px; box-shadow: 0 0 0 2px #fff; }
.aguja-texto, .fuerza-texto { text-align: center; font-weight: 700; font-size: 16px; margin-top: 3px; }
.fuerza-barra { position: relative; height: 18px; border-radius: 9px; background: #dfe5e1; overflow: hidden; }
.fuerza-relleno { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #2e9d4a, #f2c618 75%, #d84a3a); }
.fuerza-ideal { position: absolute; top: -2px; bottom: -2px; width: 4px; margin-left: -2px; background: var(--azul); box-shadow: 0 0 0 2px #fff; }

/* Palo */
.caja-palo { position: fixed; left: 12px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 5; display: flex; gap: 6px; align-items: stretch; }
.palo-btn, .flechita { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--r); box-shadow: var(--sombra); }
.palo-btn { display: flex; flex-direction: column; padding: 8px 16px; min-width: 150px; text-align: left; line-height: 1.2; }
.palo-btn b { font-size: 18px; color: var(--verde); }
.palo-btn small { color: var(--suave); font-size: 13.5px; }
.flechita { width: 46px; font-size: 26px; font-weight: 700; color: var(--verde); }
.lista-palos { position: fixed; left: 12px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 8; background: var(--crema);
  border-radius: var(--r); box-shadow: var(--sombra); padding: 8px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px;
  width: min(92vw, 380px); max-height: 60vh; overflow: auto; }
.lista-palos button { border: 1px solid var(--borde); background: #fff; border-radius: 12px; padding: 10px 12px; text-align: left;
  display: flex; justify-content: space-between; gap: 8px; font-size: 15.5px; }
.lista-palos button[aria-pressed="true"] { background: var(--verde); color: #fff; }
.lista-palos p { grid-column: 1 / -1; margin: 2px 4px 4px; color: var(--suave); font-size: 14px; }

/* Mapa del hoyo */
.mini { position: fixed; right: 12px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 5; padding: 0; border: 3px solid #fff;
  border-radius: 14px; overflow: hidden; box-shadow: var(--sombra); background: #4a6a2b; width: 150px; height: 220px; }
.mini canvas { width: 100%; height: 100%; display: block; }
.mini small { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(13, 59, 46, 0.8); color: #fff; font-size: 12px; padding: 2px 0; }

/* Fiesta */
.fiesta { position: fixed; left: 50%; top: 30%; transform: translate(-50%, -50%); z-index: 6; text-align: center; pointer-events: none;
  color: #fff; text-shadow: 0 3px 12px rgba(0,0,0,.55); animation: salta .7s cubic-bezier(.2,1.6,.4,1); }
.fiesta b { display: block; font-size: clamp(48px, 10vw, 96px); font-weight: 900; }
.fiesta small { font-size: 20px; font-weight: 600; }
@keyframes salta { from { transform: translate(-50%, -50%) scale(.3); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

/* Ventanas */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(8, 30, 22, 0.55); display: flex; padding: 16px; overflow: auto; }
.caja-modal { margin: auto; background: var(--crema); border-radius: 22px; box-shadow: var(--sombra); padding: 22px 24px; width: min(100%, 620px); }
.caja-modal h1 { margin: 0 0 4px; font-size: 26px; color: var(--verde); }
.caja-modal h2 { margin: 18px 0 8px; font-size: 18px; color: var(--verde); }
.caja-modal .sub { margin: 0; color: var(--suave); }
.caja-modal .nota { margin: -4px 0 8px; color: var(--suave); font-size: 14.5px; }
.niveles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.nivel { text-align: left; background: #fff; border: 3px solid var(--borde); border-radius: 16px; padding: 12px 14px; display: flex;
  flex-direction: column; gap: 4px; }
.nivel b { font-size: 21px; color: var(--verde); }
.nivel span { font-size: 14.5px; color: #33423b; }
.nivel[aria-checked="true"] { border-color: var(--verde); background: #e8f3ec; box-shadow: inset 0 0 0 2px var(--verde); }
.barras { display: flex; flex-wrap: wrap; gap: 8px; }
.barras button { display: flex; align-items: center; gap: 8px; background: #fff; border: 2px solid var(--borde); border-radius: 999px;
  padding: 9px 14px; font-size: 15.5px; min-height: 46px; }
.barras button i { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,.35); display: inline-block; }
.barras button[aria-pressed="true"] { border-color: var(--verde); background: #e8f3ec; font-weight: 700; }
.cargando { display: flex; align-items: center; gap: 8px; margin: 18px 0 8px; color: var(--suave); }
.cargando.listo { display: none; }
.rueda { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #cfd8d3; border-top-color: var(--verde); animation: gira 0.9s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.principal { display: block; width: 100%; margin-top: 16px; background: var(--verde); color: #fff; border: 0; border-radius: 16px;
  padding: 16px; font-size: 21px; font-weight: 800; }
.principal:disabled { opacity: .5; cursor: wait; }
.secundario { display: block; text-align: center; margin-top: 10px; background: #fff; color: var(--verde); border: 2px solid var(--verde);
  border-radius: 16px; padding: 13px; font-size: 18px; font-weight: 700; text-decoration: none; }
.enlace { display: block; margin: 12px auto 0; background: none; border: 0; color: var(--verde); text-decoration: underline; font-size: 15.5px; }
.pie { margin: 14px 0 0; text-align: center; }
.pie a { color: var(--verde); }
.resultado { text-align: center; width: min(100%, 460px); }
.res-nombre { margin: 0; font-size: 46px; font-weight: 900; color: var(--verde); }
.res-expl { margin: 4px 0 14px; color: var(--suave); font-size: 16px; }
.res-datos { display: flex; justify-content: center; gap: 12px; }
.res-datos div { background: #fff; border-radius: 14px; padding: 10px 14px; min-width: 92px; display: flex; flex-direction: column; }
.res-datos b { font-size: 30px; color: var(--verde); }
.res-datos small { color: var(--suave); }

/* Pantallas estrechas (móvil en vertical) */
@media (max-width: 700px) {
  #marcador { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .tarjeta { padding: 6px 10px; gap: 8px; }
  .hoyo-info .tit small, .viento-info .tit small { display: none; }
  .hoyo-info .num { width: 32px; height: 32px; font-size: 17px; }
  .hoyo-info b, .viento-info b { font-size: 15px; }
  .golpes-info { min-width: 0; flex: 1; }
  .golpes-info .grande { font-size: 19px; }
  .brujula { width: 34px; height: 34px; }
  .redondo { width: 44px; }
  .panel-golpe { top: calc(112px + env(safe-area-inset-top)); }
}
/* móvil en vertical: en el hoyo solo el número; el resto cabe en una línea */
@media (max-width: 480px) {
  .hoyo-info .tit { display: none; }
  .hoyo-info { padding: 6px; }
  .viento-info .tit b { font-size: 14px; white-space: nowrap; }
  .golpes-info { padding: 6px 8px; }
  .golpes-info .grande { font-size: 17px; white-space: nowrap; }
  .golpes-info small { font-size: 12px; white-space: nowrap; }
  .etiqueta-nivel { top: calc(64px + env(safe-area-inset-top)); }
  .niveles { grid-template-columns: 1fr; }
  .nivel { min-height: 0; }
  .mini { width: 104px; height: 150px; bottom: calc(84px + env(safe-area-inset-bottom)); }
  .caja-palo { bottom: calc(14px + env(safe-area-inset-bottom)); }
  .palo-btn { min-width: 120px; padding: 6px 12px; }
  .lista-palos { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

/* Pantalla de inicio: qué jugar */
.inicio { width: min(100%, 680px); }
.modos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.modo { background: #fff; border: 3px solid var(--borde); border-radius: 16px; padding: 12px 10px; display: flex; flex-direction: column;
  align-items: center; gap: 2px; min-height: 64px; text-align: center; }
.modo b { font-size: 20px; color: var(--verde); }
.modo span { font-size: 14px; color: var(--suave); }
.modo[aria-checked="true"], .nueve-btn[aria-checked="true"] { border-color: var(--verde); background: #e8f3ec; box-shadow: inset 0 0 0 2px var(--verde); }
.hoyos { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; margin-top: 10px; }
.hoyo-btn { background: #fff; border: 2px solid var(--borde); border-radius: 12px; padding: 6px 2px; display: flex; flex-direction: column;
  align-items: center; line-height: 1.15; min-height: 62px; }
.hoyo-btn b { font-size: 20px; color: var(--verde); }
.hoyo-btn span { font-size: 12.5px; font-weight: 600; }
.hoyo-btn small { font-size: 11.5px; color: var(--suave); }
.hoyo-btn[aria-checked="true"] { background: var(--verde); border-color: var(--verde); }
.hoyo-btn[aria-checked="true"] b, .hoyo-btn[aria-checked="true"] span, .hoyo-btn[aria-checked="true"] small { color: #fff; }
.nueves { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.nueve-btn { background: #fff; border: 3px solid var(--borde); border-radius: 16px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; text-align: left; }
.nueve-btn b { font-size: 19px; color: var(--verde); }
.nueve-btn span { font-size: 14px; color: var(--suave); }
.detalle { margin: 8px 2px 0; color: #33423b; font-size: 15px; }
.guardada { background: #fffbe6; border: 2px solid #f2c618; border-radius: 16px; padding: 14px 16px; margin-bottom: 6px; }
.guardada p { margin: 0 0 4px; font-size: 16px; }
.guardada-botones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.principal.pequeno, .secundario.pequeno { margin-top: 8px; padding: 12px; font-size: 18px; width: 100%; }
button.secundario { width: 100%; font: inherit; font-size: 18px; font-weight: 700; }

/* Resultado del hoyo */
.res-hoyo { margin: 0; color: var(--suave); font-weight: 700; }
.res-lleva { margin: 14px 0 0; font-size: 16.5px; }

/* Tarjeta de golpes */
.caja-tarjeta { width: min(100%, 760px); }
.tar-resumen { margin: 4px 0 12px; font-size: 18px; }
.tarjeta-scroll { overflow-x: auto; margin-bottom: 10px; border-radius: 12px; }
.tabla-tarjeta { width: 100%; border-collapse: collapse; background: #fff; font-size: 16px; text-align: center; min-width: 520px; }
.tabla-tarjeta th, .tabla-tarjeta td { border: 1px solid #dfe5e1; padding: 6px 4px; }
.tabla-tarjeta th:first-child { text-align: left; padding-left: 10px; color: var(--suave); font-weight: 600; background: #f6f3ea; }
.tabla-tarjeta tr:first-child th { background: var(--verde); color: #fff; }
.tabla-tarjeta tr:first-child th:first-child { background: var(--verde); color: #fff; }
.tabla-tarjeta .metros td { color: var(--suave); font-size: 13px; }
.tabla-tarjeta .golpes td { font-weight: 800; font-size: 18px; }
.tabla-tarjeta .dif td { font-size: 13.5px; color: var(--suave); }
.tabla-tarjeta .tot { background: #eef4f0; font-weight: 800; }
.tabla-tarjeta td.ahora { outline: 3px solid #f2c618; outline-offset: -3px; }
.tabla-tarjeta td.bajo, .tarjeta-leyenda i.bajo { background: #d7ecff; }
.tabla-tarjeta td.par, .tarjeta-leyenda i.par { background: #e3f4e6; }
.tabla-tarjeta td.bogey, .tarjeta-leyenda i.bogey { background: #fff1c9; }
.tabla-tarjeta td.mas, .tarjeta-leyenda i.mas { background: #fbd9d3; }
.tarjeta-total { font-size: 18px; margin: 6px 0; }
.tarjeta-leyenda { margin: 4px 0; color: var(--suave); font-size: 14px; }
.tarjeta-leyenda i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin: 0 2px 0 8px; border: 1px solid #ccd; }

@media (max-width: 700px) {
  .hoyos { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 480px) {
  .modos { grid-template-columns: 1fr; }
  .modo { flex-direction: row; justify-content: space-between; min-height: 52px; }
  .nueves, .guardada-botones { grid-template-columns: 1fr; }
  .hoyos { grid-template-columns: repeat(3, 1fr); }
  .guia-fondo { padding: 0.5rem; }
  .guia { width: 100%; max-height: calc(100dvh - 1rem); }
}
/* el botón de jugar siempre a mano aunque la pantalla de inicio no quepa entera */
.inicio #btnJugar { position: sticky; bottom: 0; z-index: 1; box-shadow: 0 -6px 18px rgba(246, 243, 234, 0.95), 0 6px 18px rgba(0, 0, 0, 0.25); }
