/* ───────── Botes en raya · Conservas Artesanas María Jesús ───────── */

@font-face { font-family: "Google Sans"; src: url("assets/GoogleSans-Regular.woff2") format("woff2");  font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Google Sans"; src: url("assets/GoogleSans-Medium.woff2") format("woff2");   font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Google Sans"; src: url("assets/GoogleSans-SemiBold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Google Sans"; src: url("assets/GoogleSans-Bold.woff2") format("woff2");     font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --copper: #aa652b;      /* cobre del logo */
  --copper-dk: #8a4b1f;   /* para texto pequeño (contraste AA) */
  --bronze: #b8860b;
  --green: #556b2f;
  --red: #b22222;
  --ink: #1f1a15;
  --ink-2: #5a4f44;
  --cream: #fbf5ea;
  --sand: #f5deab;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --font: "Google Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--cream);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; cursor: pointer; }
img { max-width: none; }
[hidden] { display: none !important; }

.app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1100px 620px at 6% 108%, #f6d9bd 0%, transparent 62%),
    radial-gradient(900px 600px at 100% -4%, #dde4cc 0%, transparent 60%),
    linear-gradient(180deg, #fcf7ef, #f7eee0);
}

/* ───────── Barra superior ───────── */
.topbar {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px clamp(16px, 3vw, 36px);
}
.brand { justify-self: start; display: block; }
.brand img { display: block; height: 54px; width: auto; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .5);
  box-shadow: inset 0 0 0 1px rgba(170, 101, 43, .12);
}
.tab {
  padding: 8px 18px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
}
.tab[aria-current="page"] {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 8px -2px rgba(90, 55, 20, .25);
}
.tab.soon { color: #6b5f53; }

.actions { justify-self: end; display: flex; gap: 8px; align-items: center; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 11px 20px;
  font-size: .9rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: transform .25s var(--ease), background .2s, box-shadow .2s, color .2s;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible, .arrow:focus-visible, .link:focus-visible, .cell:focus-visible, input:focus-visible {
  outline: 3px solid var(--copper);
  outline-offset: 3px;
}
.btn-dark { background: var(--ink); color: #f8ead6; }
.btn-dark:hover { background: #3a2e24; }
.btn-ghost { background: rgba(255, 255, 255, .6); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(31, 26, 21, .14); }
.btn-ghost:hover { background: #fff; }
.btn-accent { background: var(--copper-dk); color: #fff; }
.btn-accent:hover { background: #733d16; }
.btn-cta { background: var(--ink); color: #f8ead6; padding: 16px 30px; font-size: 1rem; box-shadow: 0 14px 28px -14px rgba(31, 26, 21, .7); }
.btn-cta:hover { background: var(--copper-dk); transform: translateY(-2px); }
.btn-wide { flex: 1; padding: 14px 18px; }

/* ───────── Zona principal ───────── */
.main { position: relative; flex: 1; min-height: 0; }

.hero {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 5;
  text-align: center;
  padding: clamp(0px, 1.5vh, 20px) 20px 0;
  pointer-events: none;
  transition: opacity .5s ease, transform .9s var(--ease);
}
h1 {
  font-weight: 600;
  font-size: clamp(2.7rem, min(8.4vw, 13vh), 7.4rem);
  letter-spacing: -.045em;
  line-height: .98;
  padding-bottom: .06em;
}
h1 em {
  font-style: normal;
  background: linear-gradient(90deg, #7d4218 0%, #aa652b 48%, #c4921c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.sub {
  margin: clamp(8px, 1.6vh, 16px) auto 0;
  max-width: 30ch;
  font-size: clamp(.95rem, 1.5vw, 1.2rem);
  line-height: 1.35;
  color: var(--ink-2);
}

.caption {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 0 20px clamp(14px, 3vh, 30px);
  pointer-events: none;
  transition: opacity .5s ease, transform .9s var(--ease);
}
.caption > * { pointer-events: auto; }
.caption-nav { display: flex; align-items: center; gap: clamp(12px, 3vw, 28px); }
.caption-txt { min-width: min(46vw, 250px); text-align: center; display: flex; flex-direction: column; gap: 2px; }
.eyebrow { font-size: .72rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--copper-dk); }
.caption-txt strong { font-size: clamp(1.15rem, 2.4vw, 1.5rem); font-weight: 600; letter-spacing: -.02em; }
.arrow {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .7);
  box-shadow: inset 0 0 0 1px rgba(31, 26, 21, .12);
  transition: transform .25s var(--ease), background .2s;
}
.arrow:hover { background: #fff; transform: scale(1.06); }
.hint { font-size: .78rem; color: var(--ink-2); text-align: center; max-width: 42ch; }

[data-view="game"] .hero    { opacity: 0; transform: translateY(-28px); }
[data-view="game"] .caption { opacity: 0; transform: translateY(28px); pointer-events: none; }
[data-view="game"] .caption > * { pointer-events: none; }

/* ───────── Escenario de botes ───────── */
.stage { position: absolute; inset: 0; z-index: 2; touch-action: pan-y; user-select: none; -webkit-user-select: none; }

.bote {
  --x: 0px; --y: 0px; --r: 0deg; --s: 1; --o: 0; --z: 1;
  position: absolute;
  left: 50%; top: 50%;
  padding: 0; border: 0; background: none;
  transform: translate(-50%, -50%) translate(var(--x), var(--y)) rotate(var(--r)) scale(var(--s));
  transform-origin: 50% 85%;
  opacity: var(--o);
  z-index: var(--z);
  transition: transform .95s var(--ease), opacity .55s ease;
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
}
.bote.is-off { pointer-events: none; }
[data-view="game"] .bote { pointer-events: none; cursor: default; }
.bote:focus-visible { outline: 3px solid var(--copper); outline-offset: 10px; border-radius: 14px; }
.bote-tilt, .bote-float { display: block; width: 100%; height: 100%; transform-origin: 50% 90%; }
.bote-float { animation: bob 6.5s ease-in-out infinite; animation-delay: calc(var(--n, 0) * -.95s); }
.bote img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; -webkit-user-drag: none; }
.bote-shadow {
  position: absolute; left: 6%; right: 6%; bottom: -4%; height: 8%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(70, 40, 12, .42), transparent);
  filter: blur(5px);
  z-index: -1;
  animation: shadow 6.5s ease-in-out infinite;
  animation-delay: calc(var(--n, 0) * -.95s);
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-.8deg); }
  50%      { transform: translateY(-9px) rotate(.9deg); }
}
@keyframes shadow {
  0%, 100% { transform: scaleX(1); opacity: 1; }
  50%      { transform: scaleX(.88); opacity: .75; }
}

.no-anim .bote, .no-anim .tag { transition: none !important; }
.entering .bote { transition-delay: calc(var(--n, 0) * 70ms), calc(var(--n, 0) * 70ms); }

/* Etiquetas laterales (escritorio) */
.tag {
  position: absolute;
  z-index: 6;
  left: 0; top: 0;
  transform: translate(-50%, 0);
  text-align: center;
  display: flex; flex-direction: column; gap: 2px;
  opacity: 0;
  transition: opacity .5s ease;
  pointer-events: none;
}
.tag span { font-size: .72rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--copper-dk); }
.tag strong { font-size: 1.1rem; font-weight: 600; letter-spacing: -.01em; }
[data-view="game"] .tag { opacity: 1; transition-delay: .7s; }
[data-compact="true"] .tag { display: none; }

/* ───────── Tablero ───────── */
.board-wrap {
  position: absolute; inset: 0;
  z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(10px, 2vh, 18px);
  opacity: 0; visibility: hidden;
  transform: translateY(18px) scale(.96);
  transition: opacity .5s ease, transform .9s var(--ease), visibility 0s linear .5s;
  pointer-events: none;
}
[data-view="game"] .board-wrap {
  opacity: 1; visibility: visible; transform: none;
  transition-delay: .45s, .45s, 0s;
}
.board-wrap > * { pointer-events: auto; }
[data-view="select"] .board-wrap > * { pointer-events: none; }

.hud { display: flex; align-items: center; gap: 10px; font-size: .92rem; }
.turn, .streak { padding: 9px 16px; border-radius: 999px; font-weight: 500; line-height: 1; }
.turn { background: rgba(255, 255, 255, .75); box-shadow: inset 0 0 0 1px rgba(170, 101, 43, .14); min-width: 9.5em; text-align: center; }
.turn.is-win  { background: var(--green); color: #fff; }
.turn.is-lose { background: var(--red); color: #fff; }
.turn.is-thinking::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4, end) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75%, 100% { content: "..."; } }
.streak { background: var(--ink); color: #f8ead6; }
.streak b { font-weight: 700; margin-left: 4px; }

.board {
  --B: 420px;
  width: var(--B); height: var(--B);
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  gap: clamp(6px, 1.1vw, 12px);
  padding: clamp(8px, 1.3vw, 14px);
  border-radius: 30px;
  background: rgba(255, 255, 255, .42);
  border: 1px solid rgba(255, 255, 255, .8);
  box-shadow: 0 34px 60px -34px rgba(90, 55, 20, .45), inset 0 1px 0 rgba(255, 255, 255, .9);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.cell {
  position: relative;
  display: grid; place-items: center;
  border: 0;
  border-radius: clamp(12px, 2vw, 22px);
  background: rgba(255, 255, 255, .78);
  box-shadow: inset 0 1px 0 #fff, 0 8px 16px -10px rgba(90, 55, 20, .45);
  overflow: hidden;
  padding: 0;
  transition: transform .3s var(--ease), background .25s, box-shadow .25s, opacity .4s;
  -webkit-tap-highlight-color: transparent;
}
.cell::after {
  content: ""; position: absolute; inset: 14%;
  background: var(--ghost, none) center / contain no-repeat;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.board.can-play .cell:not(.filled) { cursor: pointer; }
.board.can-play .cell:not(.filled):hover { transform: translateY(-2px); background: #fff; }
.board.can-play .cell:not(.filled):hover::after,
.board.can-play .cell:not(.filled):focus-visible::after { opacity: .3; }
.cell:not(.filled) { cursor: default; }
.cell img {
  max-width: 80%; max-height: 90%;
  width: auto; height: auto;
  object-fit: contain;
  filter: drop-shadow(0 8px 8px rgba(70, 40, 12, .28));
  animation: drop .6s var(--ease) both;
  pointer-events: none;
}
@keyframes drop {
  from { opacity: 0; transform: translateY(-45%) scale(1.15) rotate(-10deg); }
  60%  { opacity: 1; }
  to   { opacity: 1; transform: none; }
}
.board.finished .cell:not(.win) { opacity: .55; }
.cell.win {
  background: linear-gradient(160deg, #fff4dc, #f5deab);
  box-shadow: inset 0 0 0 2px var(--bronze), 0 14px 26px -12px rgba(184, 134, 11, .75);
}
.cell.win img { animation: drop .6s var(--ease) both, hop .9s ease-in-out .6s infinite alternate; }
@keyframes hop { to { transform: translateY(-6%) scale(1.06); } }

/* Fichas de jugador (solo móvil) */
.players { display: none; width: var(--B, 100%); max-width: 100%; justify-content: space-between; gap: 10px; }
.chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px 8px 8px; border-radius: 18px;
  background: rgba(255, 255, 255, .65);
  box-shadow: inset 0 0 0 1px rgba(170, 101, 43, .14);
  min-width: 0;
}
.chip-r { padding: 8px 8px 8px 14px; text-align: right; }
.chip img { width: auto; height: 40px; max-width: 34px; object-fit: contain; }
.chip span { display: flex; flex-direction: column; min-width: 0; }
.chip small { font-size: .62rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--copper-dk); }
.chip strong { font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-compact="true"] .players { display: flex; }

/* ───────── Popups ───────── */
dialog { margin: auto; border: 0; padding: 0; background: transparent; max-width: none; max-height: none; color: var(--ink); overflow: visible; }
dialog::backdrop { background: rgba(31, 26, 21, .5); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
dialog[open]::backdrop { animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; } }
.card {
  width: min(92vw, 460px);
  max-height: 92dvh;
  overflow: auto;
  background: linear-gradient(180deg, #fffaf1, #f8ecd9);
  border-radius: 30px;
  padding: clamp(22px, 5vw, 34px);
  box-shadow: 0 50px 90px -30px rgba(0, 0, 0, .55), inset 0 1px 0 #fff;
  text-align: center;
}
dialog[open] .card { animation: pop-in .55s var(--ease) both; }
@keyframes pop-in { from { opacity: 0; transform: translateY(24px) scale(.94); } }

.result-bottles { display: flex; justify-content: center; align-items: flex-end; gap: 14px; height: 108px; margin-bottom: 14px; }
.result-bottles img { height: 100%; width: auto; object-fit: contain; filter: drop-shadow(0 10px 10px rgba(70, 40, 12, .3)); }
.result-bottles img.jump { animation: jump 1.1s var(--ease) infinite alternate; }
.result-bottles img.dim { opacity: .55; transform: rotate(14deg) translateY(8px); }
@keyframes jump { to { transform: translateY(-12px) rotate(3deg); } }

.card h2 { font-size: clamp(1.9rem, 6vw, 2.5rem); font-weight: 600; letter-spacing: -.04em; line-height: 1.05; }
.card h2.is-win { color: var(--copper-dk); }
.card h2.is-lose { color: var(--red); }
.fin-texto { margin: 10px auto 0; max-width: 34ch; color: var(--ink-2); font-size: 1rem; line-height: 1.4; }

.save { margin-top: 22px; padding: 16px; border-radius: 20px; background: rgba(255, 255, 255, .7); box-shadow: inset 0 0 0 1px rgba(170, 101, 43, .16); text-align: left; }
.save label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 10px; }
.save-row { display: flex; gap: 8px; }
.save input {
  flex: 1; min-width: 0;
  padding: 12px 16px; border-radius: 999px; border: 0;
  background: #fff; font: inherit; font-size: 1rem; color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(31, 26, 21, .18);
}
.save input::placeholder { color: #75695c; }
.form-error { margin-top: 10px; font-size: .85rem; font-weight: 500; color: var(--red); }
.btn:disabled { opacity: .6; cursor: progress; }
.saved { margin-top: 22px; padding: 14px 16px; border-radius: 20px; background: rgba(85, 107, 47, .12); box-shadow: inset 0 0 0 1px rgba(85, 107, 47, .3); }
.saved p { font-weight: 500; color: #3f5220; }
.link { margin-top: 6px; background: none; border: 0; padding: 4px; font-weight: 600; color: var(--copper-dk); text-decoration: underline; text-underline-offset: 3px; }

.fin-actions { display: flex; gap: 10px; margin-top: 22px; }

.rank-list { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 8px; text-align: left; counter-reset: pos; }
.rank-list li {
  counter-increment: pos;
  display: grid; grid-template-columns: 2.2rem 1fr auto; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 16px;
  background: rgba(255, 255, 255, .72);
  box-shadow: inset 0 0 0 1px rgba(170, 101, 43, .12);
  font-weight: 500;
}
.rank-list li::before { content: counter(pos); font-weight: 700; color: var(--copper-dk); }
.rank-list li:nth-child(1) { background: linear-gradient(160deg, #fff4dc, #f5deab); box-shadow: inset 0 0 0 1px var(--bronze); }
.rank-list .nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list .racha { font-weight: 700; white-space: nowrap; }
.rank-list li.tuyo { box-shadow: inset 0 0 0 2px var(--copper); }
.rank-vacio { text-align: center !important; display: block !important; padding: 18px !important; color: var(--ink-2); }
.rank-vacio::before { content: none !important; }
.rank-nota { margin-top: 14px; font-size: .78rem; color: var(--ink-2); }

/* ───────── Responsive ───────── */
@media (max-width: 820px) {
  .tabs { display: none; }
  .topbar { grid-template-columns: 1fr auto; padding: 10px 16px; }
  .brand img { height: 44px; }
  .btn { padding: 10px 16px; font-size: .84rem; }
  .btn-cta { padding: 15px 26px; }
  .hint { font-size: .72rem; }
}
@media (max-width: 420px) {
  .save-row { flex-direction: column; }
  .fin-actions { flex-direction: column; }
}
@media (max-height: 640px) {
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bote-float, .bote-shadow, .result-bottles img.jump, .cell.win img { animation: none !important; }
  .bote, .hero, .caption, .board-wrap { transition-duration: .01s !important; transition-delay: 0s !important; }
}
