/* =====================================================================
   Lazos — hoja de estilos
   Tema oscuro, paneles de cristal y acentos neón. Nada de fuentes ni
   imágenes externas: todo lo que se ve sale de aquí o del canvas.
   ===================================================================== */

:root {
  --bg: #070912;
  --ink: #e9edf7;
  --muted: #8b93ac;
  --dim: #5f6680;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --violet: #8b6bff;
  --cyan: #35d6f0;
  --pink: #ff4d7e;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* {
  box-sizing: border-box;
}

/* Los elementos con `hidden` tienen que desaparecer de verdad: cualquier
   regla propia que fije `display` (por ejemplo .btn) pisa la del navegador. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 680px at 12% -12%, rgba(124, 92, 255, 0.22), transparent 62%),
    radial-gradient(900px 620px at 102% 4%, rgba(53, 214, 240, 0.13), transparent 58%),
    radial-gradient(760px 760px at 50% 122%, rgba(255, 77, 126, 0.1), transparent 62%),
    linear-gradient(180deg, #080a15 0%, #05060c 72%, #04040a 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  overflow: hidden;
}

button {
  font-family: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

svg {
  display: block;
}

/* ---------------------------------------------------------------------
   Estructura
   --------------------------------------------------------------------- */

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.ambient__blob {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
  will-change: transform;
}

.ambient__blob--violet {
  width: 46vmax;
  height: 46vmax;
  left: -14vmax;
  top: -16vmax;
  background: radial-gradient(circle, rgba(124, 92, 255, 0.55), transparent 68%);
  animation: drift1 34s ease-in-out infinite alternate;
}

.ambient__blob--cyan {
  width: 38vmax;
  height: 38vmax;
  right: -12vmax;
  top: 6vmax;
  background: radial-gradient(circle, rgba(53, 214, 240, 0.4), transparent 68%);
  animation: drift2 42s ease-in-out infinite alternate;
}

.ambient__blob--pink {
  width: 42vmax;
  height: 42vmax;
  left: 12vmax;
  bottom: -6vmax;
  background: radial-gradient(circle, rgba(255, 88, 133, 0.42), transparent 66%);
  animation: drift1 38s ease-in-out infinite alternate-reverse;
}

@keyframes drift1 {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(6vmax, 5vmax, 0) scale(1.12); }
}

@keyframes drift2 {
  from { transform: translate3d(0, 0, 0) scale(1.05); }
  to { transform: translate3d(-5vmax, 7vmax, 0) scale(0.94); }
}

#app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: grid;
  /* Sin esto la columna crece con el contenido y la cabecera se sale en
     pantallas estrechas. */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px clamp(10px, 2.6vw, 22px);
  min-height: 58px;
  transition: opacity 0.3s var(--ease);
}

.hud {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 2px;
}

.hud__title {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud__sub {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  font-variant-numeric: tabular-nums;
}

.hud__word {
  color: var(--dim);
  margin-left: 4px;
}

.hud__sub {
  white-space: nowrap;
  overflow: hidden;
}

/* Burbuja de la primera partida, flotando sobre el tablero. */
.coach {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(20, 24, 40, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 16px 40px -18px rgba(0, 0, 0, 0.95);
  font-size: 13px;
  font-weight: 550;
  color: var(--ink);
  pointer-events: none;
  z-index: 5;
  animation: coachIn 0.4s var(--ease);
  max-width: min(92vw, 380px);
  text-align: center;
}

.coach[hidden] {
  display: none;
}

.coach__pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
  flex: none;
  animation: float 1.6s var(--ease) infinite;
}

@keyframes coachIn {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.hud__sep {
  color: var(--dim);
}

#hud-pairs.bump {
  animation: bump 0.45s var(--ease);
}

@keyframes bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.22); color: #fff; }
  100% { transform: scale(1); }
}

.toolbar {
  display: flex;
  gap: 6px;
}

.icon-btn {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  color: var(--ink);
  transition: background 0.18s var(--ease), transform 0.12s var(--ease),
    opacity 0.18s var(--ease);
}

.icon-btn svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.09);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn.is-confirm {
  background: rgba(255, 190, 70, 0.18);
  border-color: rgba(255, 190, 70, 0.6);
  color: #ffd166;
  animation: pulseWarn 0.9s ease-in-out infinite alternate;
}

@keyframes pulseWarn {
  from { box-shadow: 0 0 0 0 rgba(255, 190, 70, 0.35); }
  to { box-shadow: 0 0 0 6px rgba(255, 190, 70, 0); }
}

.icon-btn:disabled {
  opacity: 0.32;
  cursor: default;
}

.hint__count {
  position: absolute;
  right: -4px;
  bottom: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: linear-gradient(180deg, #9375ff, #6a45f0);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

#stage {
  position: relative;
  min-height: 0;
  padding: 0 clamp(6px, 1.6vw, 18px);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.45s var(--ease), filter 0.45s var(--ease);
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

body[data-screen="menu"] #stage,
body[data-screen="menu"] #topbar,
body[data-screen="menu"] #bottom {
  opacity: 0;
  pointer-events: none;
}

body[data-screen="menu"] #stage {
  opacity: 0.62;
  filter: saturate(0.95);
  transform: scale(1.01);
}

body[data-screen="won"] #stage {
  opacity: 0.5;
  filter: saturate(0.6) blur(1.5px);
}

#bottom {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 16px calc(10px + env(safe-area-inset-bottom));
  transition: opacity 0.3s var(--ease);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  justify-content: center;
  align-items: center;
  max-width: 100%;
  padding: 9px 15px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.9);
}

.chips:empty {
  background: none;
  border: 0;
  padding: 0;
}

.chip {
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--chip, #fff);
  opacity: 0.55;
  transition: opacity 0.2s var(--ease), transform 0.16s var(--ease),
    box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}

.chip:hover {
  transform: scale(1.15);
  opacity: 0.8;
}

.chip--done {
  background: var(--chip);
  opacity: 1;
  box-shadow: 0 0 12px -1px var(--chip);
}

/* ---------------------------------------------------------------------
   Overlay y paneles
   --------------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px
    max(16px, env(safe-area-inset-bottom));
  background: radial-gradient(
      120% 90% at 50% 0%,
      rgba(22, 17, 48, 0.42),
      rgba(4, 5, 12, 0.68) 62%
    );
  backdrop-filter: blur(7px) saturate(1.15);
  -webkit-backdrop-filter: blur(7px) saturate(1.15);
  animation: fadeIn 0.28s var(--ease);
  overflow-y: auto;
}

.overlay[hidden] {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.panel {
  position: relative;
  width: min(430px, 100%);
  padding: clamp(20px, 4vw, 30px);
  border-radius: 28px;
  background: linear-gradient(
    170deg,
    rgba(28, 32, 56, 0.92),
    rgba(12, 14, 26, 0.94)
  );
  border: 1px solid var(--line-strong);
  box-shadow:
    0 40px 90px -30px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 1px 0 rgba(255, 255, 255, 0.1) inset;
  animation: panelIn 0.42s var(--ease);
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.panel[hidden] {
  display: none;
}

/* ------------------------------- Menú -------------------------------- */

.brand {
  text-align: center;
  margin-bottom: 22px;
}

.brand__mark {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin-bottom: 10px;
}

.mark {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  animation: float 3.4s var(--ease) infinite;
}

.dot--a { background: #ff4d7e; box-shadow: 0 0 14px #ff4d7e; }
.dot--b { background: #35d6f0; box-shadow: 0 0 14px #35d6f0; animation-delay: 0.35s; }
.dot--c { background: #ffe14d; box-shadow: 0 0 14px #ffe14d; animation-delay: 0.7s; }

@keyframes float {
  0%, 100% { transform: translateY(0); opacity: 0.85; }
  50% { transform: translateY(-7px); opacity: 1; }
}

.logo {
  margin: 0;
  font-size: clamp(38px, 10vw, 54px);
  font-weight: 800;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  line-height: 1;
  background: linear-gradient(100deg, #ffffff 8%, #c3b2ff 36%, #4fe6ff 66%, #ffffff 96%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 24px rgba(124, 92, 255, 0.45));
}

.tagline {
  margin: 10px 0 0;
  font-size: 13.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.tiers {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 14px;
}

.tier {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 3px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  color: var(--muted);
  transition: all 0.2s var(--ease);
}

.tier:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
}

.tier__name {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.tier__meta {
  font-size: 10px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.tier--active {
  background: linear-gradient(180deg, rgba(139, 107, 255, 0.32), rgba(139, 107, 255, 0.1));
  border-color: rgba(139, 107, 255, 0.6);
  color: #fff;
  box-shadow: 0 10px 28px -14px rgba(139, 107, 255, 1);
}

.tier--active .tier__meta {
  color: rgba(255, 255, 255, 0.75);
}

.btn {
  position: relative;
  display: block;
  padding: 15px 20px;
  border-radius: 17px;
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
  transition: transform 0.12s var(--ease), box-shadow 0.2s var(--ease),
    background 0.2s var(--ease), opacity 0.2s var(--ease);
}

.btn--wide {
  width: 100%;
}

.btn:active {
  transform: translateY(1px) scale(0.994);
}

.btn--primary {
  background: linear-gradient(180deg, #9b7dff 0%, #6f49f2 100%);
  color: #fff;
  box-shadow:
    0 20px 44px -20px rgba(124, 92, 255, 1),
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.btn--primary:hover {
  background: linear-gradient(180deg, #a98cff 0%, #7d57ff 100%);
}

.btn__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.btn__label {
  font-size: 17px;
}

.btn__meta {
  font-size: 11.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.72);
  font-variant-numeric: tabular-nums;
}

.play-row {
  display: flex;
  gap: 8px;
}

.play-row .btn--primary {
  flex: 1;
  min-width: 0;
}

.btn--grid {
  flex: none;
  width: 54px;
  display: grid;
  place-items: center;
  padding: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-strong);
  color: var(--ink);
}

.btn--grid svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

.btn--grid:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn--continue {
  margin-top: 9px;
  border-color: rgba(53, 214, 240, 0.4);
  background: rgba(53, 214, 240, 0.09);
}

.btn--continue .btn__label {
  font-size: 15px;
}

.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 9px;
}

.mode {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 13px;
  border-radius: 16px;
  text-align: left;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease),
    transform 0.12s var(--ease);
}

.mode:hover {
  background: rgba(255, 255, 255, 0.08);
}

.mode:active {
  transform: scale(0.985);
}

.mode strong {
  font-size: 14px;
  font-weight: 650;
}

.mode small {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}

.mode__icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-bottom: 3px;
  border-radius: 9px;
  font-size: 14px;
}

.mode__icon--sun {
  background: linear-gradient(180deg, rgba(255, 205, 77, 0.28), rgba(255, 160, 60, 0.1));
  color: #ffd166;
  box-shadow: inset 0 0 0 1px rgba(255, 205, 77, 0.3);
}

.mode__icon--clock {
  background: linear-gradient(180deg, rgba(53, 214, 240, 0.26), rgba(53, 214, 240, 0.08));
  color: #7ee7ff;
  box-shadow: inset 0 0 0 1px rgba(53, 214, 240, 0.32);
}

.mode.is-done {
  border-color: rgba(53, 214, 240, 0.45);
  background: rgba(53, 214, 240, 0.09);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-weight: 550;
  text-align: center;
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.menu-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

.pill {
  padding: 9px 13px;
  text-align: center;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 550;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  transition: all 0.18s var(--ease);
}

.pill:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
}

.pill.is-on {
  color: #d6c9ff;
  border-color: rgba(139, 107, 255, 0.5);
  background: rgba(139, 107, 255, 0.16);
}

/* ----------------------------- Niveles ------------------------------- */

.panel--levels h2 {
  margin: 0 0 14px;
  font-size: 22px;
  text-align: center;
}

.tiers--compact {
  margin-bottom: 12px;
}

.tiers--compact .tier {
  padding: 7px 2px;
}

.tiers--compact .tier__meta {
  display: none;
}

.levels-info {
  margin: 0 0 10px;
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
  min-height: 15px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 8px;
  max-height: 44vh;
  overflow-y: auto;
  padding: 2px 4px 2px 2px;
  margin-bottom: 14px;
  scrollbar-width: thin;
}

.level {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  color: var(--ink);
  transition: background 0.16s var(--ease), transform 0.12s var(--ease),
    border-color 0.16s var(--ease);
}

.level:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.level__n {
  font-size: 14.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.level__stars {
  font-size: 8px;
  letter-spacing: 1.5px;
  color: #ffd166;
  line-height: 1;
}

.level__stars i {
  font-style: normal;
  color: rgba(255, 255, 255, 0.16);
}

.level--next {
  border-color: rgba(139, 107, 255, 0.65);
  background: rgba(139, 107, 255, 0.17);
  box-shadow: 0 8px 22px -14px rgba(139, 107, 255, 1);
}

.level--done .level__n {
  color: #cbb9ff;
}

/* ----------------------------- Victoria ------------------------------ */

.panel--win {
  text-align: center;
}

.win-stars {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 46px;
  line-height: 1;
}

.star {
  color: rgba(255, 255, 255, 0.12);
  display: inline-block;
  animation: starIn 0.5s var(--ease) backwards;
}

.star--on {
  color: #ffd166;
  text-shadow: 0 0 26px rgba(255, 196, 66, 0.75), 0 0 60px rgba(255, 160, 40, 0.35);
}

@keyframes starIn {
  from {
    opacity: 0;
    transform: scale(0.3) rotate(-30deg);
  }
  60% {
    transform: scale(1.16) rotate(4deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.panel--win h2 {
  margin: 6px 0 8px;
  font-size: clamp(24px, 6vw, 30px);
  letter-spacing: -0.01em;
}

.win-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 22px;
}

.win-sub {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.win-actions .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 9px;
}

.win-actions .row--three {
  grid-template-columns: 1fr 1fr 1fr;
}

.win-actions .row--three .btn {
  padding: 15px 8px;
  font-size: 13.5px;
}

/* ----------------------------- Ranking ------------------------------- */

.menu-foot .pill:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.panel--rank h2 {
  margin: 0 0 14px;
  font-size: 22px;
  text-align: center;
}

.rank__name {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--muted);
}

.rank__name span {
  flex: none;
}

.rank__name input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.rank__name input:focus {
  outline: 2px solid var(--cyan);
  outline-offset: 1px;
}

.rank__title {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
}

.rank__list {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 26vh;
  overflow-y: auto;
}

.rank__list li {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 7px 11px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 12.5px;
}

.rank__list li.is-me {
  border: 1px solid rgba(53, 214, 240, 0.45);
  background: rgba(53, 214, 240, 0.1);
}

.rank__pos {
  flex: none;
  width: 18px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.rank__who {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank__mark {
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.rank__empty {
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* ----------------------------- Logros -------------------------------- */

.panel--achievements h2 {
  margin: 0 0 4px;
  font-size: 22px;
  text-align: center;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin: 12px 0 10px;
}

.stat {
  padding: 9px 11px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.stat__value {
  display: block;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat__label {
  font-size: 10.5px;
  color: var(--muted);
}

.ach__count {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.ach-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 48vh;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 14px;
  scrollbar-width: thin;
  mask-image: linear-gradient(180deg, #000 92%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, #000 92%, transparent 100%);
}

.ach {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  opacity: 0.45;
}

.ach--on {
  opacity: 1;
  border-color: rgba(255, 209, 102, 0.35);
  background: rgba(255, 209, 102, 0.08);
}

.ach__icon {
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.06);
}

.ach--on .ach__icon {
  background: rgba(255, 209, 102, 0.16);
}

.ach__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.ach__text strong {
  font-size: 12.5px;
  font-weight: 650;
}

.ach__text small {
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.35;
}

.win-record {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.win-record.is-record {
  color: #ffd166;
  font-weight: 650;
}

/* --------------------------- Contrarreloj ---------------------------- */

.panel--timed {
  text-align: center;
}

.timed__record {
  display: inline-block;
  margin-bottom: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #0b0e18;
  background: linear-gradient(180deg, #ffe08a, #ffbf4a);
  box-shadow: 0 10px 24px -12px rgba(255, 190, 70, 0.9);
}

.panel--timed h2 {
  margin: 0 0 10px;
  font-size: 24px;
}

.timed__score {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--muted);
}

.timed__score strong {
  display: block;
  font-size: 58px;
  line-height: 1;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.timed__meta {
  margin: 6px 0 22px;
  font-size: 13px;
  color: var(--muted);
}

#hud-timer.is-low {
  color: #ff7b8f;
  font-weight: 700;
}

/* ---------------------------- Cómo jugar ----------------------------- */

.panel--howto h2 {
  margin: 0 0 16px;
  font-size: 24px;
  text-align: center;
}

.howto-art {
  display: block;
  width: 100%;
  max-width: 260px;
  margin: 0 auto 18px;
  border-radius: 18px;
  overflow: visible;
}

.art-bg {
  fill: rgba(255, 255, 255, 0.04);
  stroke: rgba(255, 255, 255, 0.08);
}

.art-a {
  fill: none;
  stroke: #ff4d7e;
  stroke-width: 11;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 8px rgba(255, 77, 126, 0.8));
}

.art-b {
  fill: none;
  stroke: #35d6f0;
  stroke-width: 11;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 8px rgba(53, 214, 240, 0.8));
}

.art-dot--a { fill: #ff4d7e; }
.art-dot--b { fill: #35d6f0; }

.rules {
  margin: 0 0 20px;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
}

.rules li::marker {
  color: var(--violet);
  font-weight: 700;
}

.howto-note {
  margin: 0 0 18px;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.howto-note strong {
  color: var(--ink);
  font-weight: 600;
}

.rules strong {
  color: var(--ink);
  font-weight: 600;
}

/* -------------------------------- Toast ------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(74px + env(safe-area-inset-bottom));
  transform: translate(-50%, 14px);
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(20, 24, 40, 0.95);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: 13px;
  font-weight: 550;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  z-index: 30;
  max-width: min(92vw, 420px);
  text-align: center;
}

.toast--on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */

@media (max-width: 380px) {
  .chips {
    gap: 6px;
    padding: 7px 12px;
  }

  .chip {
    width: 17px;
    height: 17px;
  }

  .hud__title {
    font-size: 12.5px;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .toolbar {
    gap: 4px;
  }
}

@media (max-width: 420px) {
  .tier__name {
    font-size: 11.5px;
  }

  .tier__meta {
    font-size: 9px;
  }

  .logo {
    letter-spacing: 0.16em;
    text-indent: 0.16em;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .hud__title {
    font-size: 13.5px;
  }

  .btn {
    padding: 14px 16px;
  }
}

@media (max-height: 640px) {
  .brand {
    margin-bottom: 14px;
  }

  .tagline {
    display: none;
  }

  .logo {
    font-size: 34px;
  }

  .panel {
    padding: 18px;
    border-radius: 22px;
  }

  .howto-art {
    display: none;
  }

  .rules {
    gap: 8px;
    font-size: 12.5px;
  }
}

/* Móvil en horizontal: se aprieta el cromo para que el tablero respire.
   En 844x390 el tablero pasa de 276 a unos 330 px. */
@media (orientation: landscape) and (max-height: 600px) {
  #topbar {
    min-height: 44px;
    padding: 4px 12px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 11px;
  }

  .icon-btn svg {
    width: 18px;
    height: 18px;
  }

  .hud__title {
    font-size: 13px;
  }

  .hud__sub {
    font-size: 11px;
  }

  #stage {
    padding: 0 10px;
  }

  #bottom {
    min-height: 32px;
    padding: 0 12px calc(6px + env(safe-area-inset-bottom));
  }

  .chips {
    padding: 5px 12px;
    gap: 7px;
  }

  .chip {
    width: 16px;
    height: 16px;
  }

  .coach {
    padding: 7px 13px;
    font-size: 12px;
  }
}

/* En escritorio, un pelín de aire alrededor del tablero. */
@media (min-width: 900px) and (min-height: 700px) {
  #stage {
    padding: 0 40px;
  }

  #bottom {
    min-height: 56px;
  }
}

/* ---------------------------------------------------------------------
   Accesibilidad
   --------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
