/* ============================================================
   ABEJA PROGRAMADORA – Hoja de estilos principal
   Estética: cartoon, dulce, infantil, colores miel y jardín
   ============================================================ */

/* ---------- RESET ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

:root {
  /* Paleta principal */
  --honey-1: #ffd166;
  --honey-2: #ffb703;
  --honey-3: #fb8500;
  --sky-1:   #a2d2ff;
  --sky-2:   #6bb6ff;
  --grass-1: #b7e4c7;
  --grass-2: #74c69d;
  --grass-3: #40916c;
  --coral-1: #ff8fa3;
  --coral-2: #ff5d8f;
  --grape-1: #b8a1e3;
  --grape-2: #7b5ea7;
  --cream:   #fff8e7;
  --ink:     #3b2f2f;
  --ink-soft:#6b5a4e;

  /* Sombras */
  --shadow-sm: 0 3px 8px rgba(0,0,0,.10);
  --shadow-md: 0 8px 20px rgba(0,0,0,.12);
  --shadow-lg: 0 18px 40px rgba(0,0,0,.18);
  --shadow-in: inset 0 3px 0 rgba(255,255,255,.55), inset 0 -4px 8px rgba(0,0,0,.08);

  /* Radios */
  --r-sm: 14px;
  --r-md: 22px;
  --r-lg: 32px;
  --r-xl: 44px;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Baloo 2', 'Fredoka', 'Segoe UI', 'Comic Sans MS', sans-serif;
  color: var(--ink);
  background: linear-gradient(170deg, #cdeefd 0%, #eafbf0 45%, #fff4d6 100%);
}

/* Evita el zoom por doble toque en móvil */
button { touch-action: manipulation; }

/* ---------- DECORACIÓN DE FONDO ---------- */
.bg-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.cloud {
  position: absolute;
  font-size: 90px;
  opacity: .55;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.06));
  animation: cloud-drift 32s linear infinite;
}
.cloud-1 { top: 6%;  left: -10%;  animation-duration: 38s; font-size: 110px; }
.cloud-2 { top: 22%; left: -20%;  animation-duration: 52s; animation-delay: -12s; }
.cloud-3 { top: 12%; left: -30%;  animation-duration: 64s; animation-delay: -25s; font-size: 130px; }

@keyframes cloud-drift {
  from { transform: translateX(0); }
  to   { transform: translateX(140vw); }
}

.flower {
  position: absolute;
  font-size: 42px;
  opacity: .35;
  animation: flower-sway 4.5s ease-in-out infinite;
}
.flower-1 { bottom: 6%;  left: 4%;   animation-delay: .2s; }
.flower-2 { bottom: 12%; left: 14%;  animation-delay: .9s; font-size: 34px; }
.flower-3 { bottom: 8%;  right: 5%;  animation-delay: .5s; font-size: 38px; }
.flower-4 { bottom: 18%; right: 15%; animation-delay: 1.3s; font-size: 30px; }

@keyframes flower-sway {
  0%,100% { transform: rotate(-6deg) translateY(0); }
  50%     { transform: rotate(6deg)  translateY(-6px); }
}

.bee-decor {
  position: absolute;
  font-size: 34px;
  opacity: .45;
  animation: bee-float 7s ease-in-out infinite;
}
.bee-decor-1 { top: 30%; right: 8%;  animation-delay: .4s; }
.bee-decor-2 { top: 60%; left: 3%;   animation-delay: 1.8s; font-size: 26px; }

@keyframes bee-float {
  0%,100% { transform: translate(0,0) rotate(-8deg); }
  50%     { transform: translate(-14px,-18px) rotate(8deg); }
}

/* ---------- CONTENEDOR PRINCIPAL ---------- */
.game-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  max-width: 1920px;
  max-height: 1080px;
  margin: 0 auto;
  padding: 14px 18px 18px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

/* ============ HEADER ============ */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  border-radius: var(--r-lg);
  background:
    linear-gradient(120deg, #fff4d6 0%, #ffe6b3 55%, #ffd6a5 100%);
  box-shadow: var(--shadow-md), inset 0 -3px 0 rgba(0,0,0,.06);
  position: relative;
  overflow: hidden;
}

.game-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 8% 30%, rgba(255,255,255,.55) 0%, transparent 35%),
    radial-gradient(circle at 92% 70%, rgba(255,255,255,.35) 0%, transparent 40%);
  pointer-events: none;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 1;
}

.logo-badge {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--honey-1), var(--honey-3));
  display: grid;
  place-items: center;
  box-shadow: 0 6px 0 #d97706, 0 10px 18px rgba(251,133,0,.35);
  animation: logo-bounce 2.4s ease-in-out infinite;
}

@keyframes logo-bounce {
  0%,100% { transform: translateY(0) rotate(-4deg); }
  50%     { transform: translateY(-4px) rotate(4deg); }
}

.logo-emoji {
  font-size: 34px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.2));
}

.logo-text h1 {
  font-family: 'Fredoka', 'Baloo 2', sans-serif;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--ink);
  line-height: 1;
}
.logo-text h1 span {
  background: linear-gradient(90deg, var(--honey-3), var(--coral-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.logo-text p {
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 500;
  margin-top: 3px;
}

/* HUD */
.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1;
}

.hud-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.7);
  box-shadow: var(--shadow-sm), inset 0 -2px 0 rgba(0,0,0,.05);
  backdrop-filter: blur(6px);
  min-width: 96px;
}

.hud-icon { font-size: 22px; }

.hud-info {
  display: flex;
  flex-direction: column;
  line-height: 1;
}
.hud-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .6px;
}
.hud-value {
  font-family: 'Fredoka', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

.hud-level  { background: linear-gradient(145deg, #fff1c9, #ffe08a); }
.hud-stars  { background: linear-gradient(145deg, #ffe0f0, #ffc2e0); }
.hud-moves  { background: linear-gradient(145deg, #d6f2ff, #a9e2ff); }

.icon-btn {
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  background: linear-gradient(145deg, #ffffff, #ffe8b0);
  box-shadow: 0 4px 0 #d9a441, 0 6px 14px rgba(0,0,0,.15);
  transition: transform .12s ease, box-shadow .12s ease, filter .2s ease;
  display: grid;
  place-items: center;
}
.icon-btn:hover { filter: brightness(1.05); }
.icon-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #d9a441, 0 3px 8px rgba(0,0,0,.15);
}
.icon-btn.muted {
  filter: grayscale(.7) opacity(.65);
}

/* ============ MAIN ============ */
.game-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 16px;
  min-height: 0;
}

/* ---------- TABLERO ---------- */
.board-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: var(--r-lg);
  background:
    linear-gradient(160deg, rgba(255,255,255,.75), rgba(255,255,255,.55)),
    linear-gradient(160deg, var(--grass-1), #ffffff);
  box-shadow: var(--shadow-md), inset 0 -3px 0 rgba(0,0,0,.05);
  backdrop-filter: blur(8px);
  min-height: 0;
}

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

.board-heading {
  font-family: 'Fredoka', sans-serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--grass-3);
  display: flex;
  align-items: center;
  gap: 8px;
}
.board-heading-icon {
  font-size: 26px;
  animation: pulse-flower 2.2s ease-in-out infinite;
}
@keyframes pulse-flower {
  0%,100% { transform: scale(1) rotate(-4deg); }
  50%     { transform: scale(1.15) rotate(4deg); }
}

.status-bar {
  font-size: 15px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  background: linear-gradient(145deg, #fff7d6, #ffe8a1);
  color: var(--ink);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.06);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.status-bar.running {
  background: linear-gradient(145deg, #d4f6d9, #9be5a6);
  animation: pulse-status 1s ease-in-out infinite;
}
.status-bar.error {
  background: linear-gradient(145deg, #ffdad6, #ffb3ab);
}
@keyframes pulse-status {
  0%,100% { opacity: 1; }
  50%     { opacity: .65; }
}

.board-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 6px;
}

/* GRID 6x6 */
.grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 8px;
  width: min(100%, 78vh);
  aspect-ratio: 1 / 1;
  padding: 14px;
  border-radius: var(--r-md);
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.4), transparent 40%),
    linear-gradient(160deg, var(--grass-2), var(--grass-3));
  box-shadow:
    var(--shadow-lg),
    inset 0 -6px 0 rgba(0,0,0,.15),
    inset 0 4px 0 rgba(255,255,255,.3);
  position: relative;
}

/* Celdas */
.cell {
  position: relative;
  border-radius: var(--r-sm);
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,.55), transparent 55%),
    linear-gradient(145deg, #e9ffd9, #b7e4c7);
  box-shadow:
    inset 0 -3px 0 rgba(0,0,0,.08),
    inset 0 2px 0 rgba(255,255,255,.6),
    0 2px 4px rgba(0,0,0,.06);
  transition: background .3s ease, transform .2s ease, box-shadow .3s ease;
}

.cell.highlight {
  background:
    radial-gradient(circle at 40% 30%, rgba(255,255,255,.8), transparent 55%),
    linear-gradient(145deg, #fff5b8, #ffd93d);
  transform: scale(1.05);
  box-shadow: 0 0 18px rgba(255,193,7,.75), inset 0 -3px 0 rgba(0,0,0,.1);
  z-index: 2;
}

.cell.visited {
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,.5), transparent 55%),
    linear-gradient(145deg, #cdeffd, #91d5f3);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.08), inset 0 2px 0 rgba(255,255,255,.5);
}

.cell.goal {
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,.8), transparent 55%),
    linear-gradient(145deg, #ffe9a8, #ffb703);
  box-shadow:
    0 0 22px rgba(255,183,3,.7),
    inset 0 -3px 0 rgba(0,0,0,.1),
    inset 0 2px 0 rgba(255,255,255,.65);
  animation: goal-glow 2s ease-in-out infinite;
}

@keyframes goal-glow {
  0%,100% { box-shadow: 0 0 20px rgba(255,183,3,.55), inset 0 -3px 0 rgba(0,0,0,.1), inset 0 2px 0 rgba(255,255,255,.65); }
  50%     { box-shadow: 0 0 32px rgba(255,183,3,.95), inset 0 -3px 0 rgba(0,0,0,.1), inset 0 2px 0 rgba(255,255,255,.65); }
}

.cell.goal::after {
  content: '🌸';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  font-size: clamp(20px, 3.4vw, 40px);
  animation: flower-pulse 1.6s ease-in-out infinite;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.2));
}
@keyframes flower-pulse {
  0%,100% { transform: translate(-50%,-50%) scale(1) rotate(-4deg); }
  50%     { transform: translate(-50%,-50%) scale(1.18) rotate(4deg); }
}

/* ---------- ABEJA ---------- */
.bee {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 86%;
  height: 86%;
  transform-origin: 50% 55%;
  transform: translate(-50%, -55%) rotate(var(--rot, 0deg));
  transition: transform .45s cubic-bezier(.34, 1.4, .64, 1);
  pointer-events: none;
  z-index: 5;
  filter: drop-shadow(0 5px 5px rgba(0,0,0,.25));
}

.bee svg {
  width: 100%;
  height: 100%;
  display: block;
  animation: bee-hover .8s ease-in-out infinite;
}

@keyframes bee-hover {
  0%,100% { transform: translateY(0) scale(1); }
  50%     { transform: translateY(-3%) scale(1.02); }
}

.bee.turning svg {
  animation: bee-turn-wiggle .5s ease-in-out;
}
@keyframes bee-turn-wiggle {
  0%,100% { transform: rotate(0); }
  50%     { transform: rotate(-8deg) scale(.94); }
}

.bee.celebrating svg {
  animation: bee-celebrate .6s ease-in-out 4;
}
@keyframes bee-celebrate {
  0%,100% { transform: translateY(0) scale(1) rotate(0); }
  25%     { transform: translateY(-16%) scale(1.12) rotate(-12deg); }
  75%     { transform: translateY(-16%) scale(1.12) rotate(12deg); }
}

/* Leyenda */
.board-legend {
  display: flex;
  justify-content: center;
  gap: 22px;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot {
  width: 18px; height: 18px;
  border-radius: 6px;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
}
.legend-bee     { background: linear-gradient(145deg, #ffeaa7, #fdc500); }
.legend-flower  { background: linear-gradient(145deg, #ffe9a8, #ffb703); }
.legend-visited { background: linear-gradient(145deg, #cdeffd, #91d5f3); }

/* ============ PANEL DE CONTROLES ============ */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-radius: var(--r-lg);
  background:
    linear-gradient(160deg, rgba(255,255,255,.85), rgba(255,255,255,.65)),
    linear-gradient(160deg, #ffe6f0, #fff);
  box-shadow: var(--shadow-md), inset 0 -3px 0 rgba(0,0,0,.05);
  backdrop-filter: blur(10px);
  min-height: 0;
  overflow: hidden;
}

.panel-section {
  background: rgba(255,255,255,.75);
  border-radius: var(--r-md);
  padding: 12px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.04);
}

.panel-sequence { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel-actions { background: linear-gradient(160deg, #fff8e7, #fff); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}

.section-tip,
.chip-counter {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(145deg, #fff2c0, #ffd93d);
  color: #6b4d00;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,.08);
}

/* ---------- D-PAD ---------- */
.dpad {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
  grid-template-areas:
    "fwd  back"
    "left right";
}

.cmd-forward  { grid-area: fwd; }
.cmd-backward { grid-area: back; }
.cmd-left     { grid-area: left; }
.cmd-right    { grid-area: right; }

.cmd-btn {
  position: relative;
  border: none;
  border-radius: var(--r-sm);
  height: 76px;
  cursor: pointer;
  color: white;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 14px;
  letter-spacing: .3px;
  transition: transform .1s ease, box-shadow .1s ease, filter .2s ease;
  overflow: hidden;
}

.cmd-btn::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 45%;
  background: linear-gradient(180deg, rgba(255,255,255,.35), transparent);
  border-radius: var(--r-sm) var(--r-sm) 50% 50%;
  pointer-events: none;
}

.cmd-icon { font-size: 26px; line-height: 1; }

.cmd-forward  {
  background: linear-gradient(160deg, #7ed957, #3ba94b);
  box-shadow: 0 5px 0 #2c7d38, 0 8px 14px rgba(59,169,75,.3);
}
.cmd-backward {
  background: linear-gradient(160deg, #7cc4ff, #3b8fdd);
  box-shadow: 0 5px 0 #2468a8, 0 8px 14px rgba(59,143,221,.3);
}
.cmd-left {
  background: linear-gradient(160deg, #c79dff, #8e5ee0);
  box-shadow: 0 5px 0 #6340a8, 0 8px 14px rgba(142,94,224,.3);
}
.cmd-right {
  background: linear-gradient(160deg, #ffb84d, #f18f01);
  box-shadow: 0 5px 0 #b46a00, 0 8px 14px rgba(241,143,1,.3);
}

.cmd-btn:hover { filter: brightness(1.06); }
.cmd-btn:active,
.cmd-btn.pressed {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(0,0,0,.25), 0 3px 6px rgba(0,0,0,.2);
}

.cmd-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none !important;
}

/* ---------- SECUENCIA ---------- */
.sequence-box {
  flex: 1;
  min-height: 96px;
  padding: 10px;
  border-radius: var(--r-sm);
  background: linear-gradient(160deg, #fffdf2, #fff4d6);
  border: 2.5px dashed #ffcc66;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: #ffb703 #fff4d6;
}
.sequence-box::-webkit-scrollbar { height: 8px; }
.sequence-box::-webkit-scrollbar-track { background: #fff4d6; border-radius: 8px; }
.sequence-box::-webkit-scrollbar-thumb { background: #ffb703; border-radius: 8px; }

.seq-empty {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #b39a6b;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}
.seq-empty-icon { font-size: 24px; animation: sparkle 1.8s ease-in-out infinite; }
@keyframes sparkle {
  0%,100% { transform: scale(1) rotate(0); opacity: .8; }
  50%     { transform: scale(1.25) rotate(15deg); opacity: 1; }
}

.seq-chip {
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: white;
  border: 2px solid #ffe08a;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  box-shadow: 0 3px 6px rgba(0,0,0,.08);
  animation: chip-in .3s cubic-bezier(.34, 1.4, .64, 1);
  min-width: 62px;
}
.seq-chip .chip-icon { font-size: 20px; line-height: 1; }
.seq-chip .chip-label { font-size: 10px; font-weight: 700; color: var(--ink-soft); }

.seq-chip.executing {
  background: linear-gradient(145deg, #fff3a8, #ffd93d);
  border-color: #fbc02d;
  transform: scale(1.12);
  box-shadow: 0 0 14px rgba(251,192,45,.7);
}
.seq-chip.done {
  opacity: .55;
  filter: grayscale(.4);
  transform: scale(.94);
}

@keyframes chip-in {
  from { transform: scale(.4); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ---------- BOTONES DE ACCIÓN ---------- */
.panel-actions { display: flex; flex-direction: column; gap: 10px; }

.action-btn {
  position: relative;
  border: none;
  border-radius: var(--r-md);
  height: 62px;
  cursor: pointer;
  color: white;
  font-family: 'Fredoka', sans-serif;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform .1s ease, box-shadow .1s ease, filter .2s ease;
  overflow: hidden;
}
.action-btn::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,.3), transparent);
  border-radius: var(--r-md) var(--r-md) 50% 50%;
  pointer-events: none;
}
.action-icon { font-size: 22px; }

.action-go {
  height: 72px;
  font-size: 24px;
  background: linear-gradient(160deg, #58c66b, #2e8b3f);
  box-shadow: 0 6px 0 #1f6229, 0 10px 18px rgba(46,139,63,.35);
}
.action-pause {
  background: linear-gradient(160deg, #ffb84d, #ef6c00);
  box-shadow: 0 5px 0 #b34700, 0 8px 14px rgba(239,108,0,.3);
}
.action-clear {
  background: linear-gradient(160deg, #ff7a7a, #d93434);
  box-shadow: 0 5px 0 #a22020, 0 8px 14px rgba(217,52,52,.3);
}
.action-new {
  background: linear-gradient(160deg, #b28bea, #6e45c1);
  box-shadow: 0 5px 0 #4d2f8c, 0 8px 14px rgba(110,69,193,.3);
  height: 54px;
  font-size: 17px;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-btn:hover { filter: brightness(1.06); }
.action-btn:active,
.action-btn.pressed {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(0,0,0,.3), 0 3px 6px rgba(0,0,0,.2);
}
.action-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none !important;
}

/* ============ OVERLAYS ============ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(40, 25, 15, .35);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s ease;
}
.overlay.show {
  opacity: 1;
  visibility: visible;
}

.overlay-card {
  position: relative;
  width: min(560px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  padding: 32px 30px;
  border-radius: var(--r-lg);
  background:
    radial-gradient(circle at 15% 10%, rgba(255,255,255,.9) 0%, transparent 35%),
    linear-gradient(160deg, #fffbe9, #ffe9b8);
  box-shadow: var(--shadow-lg), inset 0 -4px 0 rgba(0,0,0,.08);
  text-align: center;
  transform: translateY(20px) scale(.92);
  opacity: 0;
  transition: transform .35s cubic-bezier(.34, 1.4, .64, 1), opacity .3s ease;
}
.overlay.show .overlay-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.overlay-emoji {
  font-size: 68px;
  line-height: 1;
  filter: drop-shadow(0 6px 6px rgba(0,0,0,.15));
  animation: hero-bounce 1.8s ease-in-out infinite;
}
@keyframes hero-bounce {
  0%,100% { transform: translateY(0) rotate(-3deg); }
  50%     { transform: translateY(-8px) rotate(3deg); }
}

.overlay-card h2 {
  font-family: 'Fredoka', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  margin: 12px 0 8px;
}

.overlay-sub {
  font-size: 15px;
  color: var(--ink-soft);
  margin-bottom: 18px;
  line-height: 1.5;
}

.overlay-list {
  list-style: none;
  text-align: left;
  display: grid;
  gap: 8px;
  margin: 0 auto 22px;
  max-width: 420px;
}
.overlay-list li {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255,255,255,.7);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 600;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.04);
}
.overlay-list li span { font-size: 20px; }

.primary-btn {
  border: none;
  cursor: pointer;
  padding: 14px 32px;
  border-radius: 999px;
  background: linear-gradient(160deg, #ffb703, #fb8500);
  color: white;
  font-family: 'Fredoka', sans-serif;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .4px;
  box-shadow: 0 6px 0 #b95b00, 0 10px 20px rgba(251,133,0,.4);
  transition: transform .1s ease, box-shadow .1s ease, filter .2s ease;
}
.primary-btn:hover { filter: brightness(1.06); }
.primary-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #b95b00, 0 4px 10px rgba(251,133,0,.4);
}

.close-btn {
  position: absolute;
  top: 12px; right: 12px;
  width: 40px; height: 40px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: rgba(255,255,255,.85);
  box-shadow: 0 3px 0 rgba(0,0,0,.1);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-soft);
}
.close-btn:active { transform: translateY(2px); box-shadow: none; }

/* Ayuda */
.help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}
.help-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  background: rgba(255,255,255,.75);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--ink-soft);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.05);
}
.help-item strong { color: var(--ink); font-size: 14px; }
.help-icon { font-size: 26px; }

.help-tip {
  font-size: 13px;
  color: var(--ink-soft);
  background: #fff4d6;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  margin-bottom: 18px;
}

/* Win */
.win-card { background:
  radial-gradient(circle at 50% 0%, rgba(255,255,255,.9), transparent 45%),
  linear-gradient(160deg, #fff4d6, #ffd6a5);
}

.win-stars {
  display: flex;
  justify-content: center;
  gap: 6px;
  font-size: 38px;
  margin-bottom: 4px;
}
.win-star {
  display: inline-block;
  filter: drop-shadow(0 4px 4px rgba(0,0,0,.15));
  animation: star-pop .5s cubic-bezier(.34, 1.4, .64, 1) backwards;
}
.win-star:nth-child(1) { animation-delay: .15s; }
.win-star:nth-child(2) { animation-delay: .3s; }
.win-star:nth-child(3) { animation-delay: .45s; }

@keyframes star-pop {
  0%   { transform: scale(0) rotate(-90deg); opacity: 0; }
  70%  { transform: scale(1.25) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.win-stars .win-star.hidden { opacity: .2; filter: grayscale(1); animation: none; }

.win-msg {
  font-size: 15px;
  color: var(--ink-soft);
  margin-bottom: 16px;
}

.win-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 22px;
}
.win-stat {
  background: rgba(255,255,255,.8);
  padding: 12px;
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.05);
}
.win-stat-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .6px;
}
.win-stat-value {
  font-family: 'Fredoka', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--honey-3);
}

/* ============ FEEDBACK TOAST ============ */
.feedback-toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(.5);
  padding: 22px 34px;
  border-radius: var(--r-lg);
  background: linear-gradient(160deg, #ffffff, #fff5d6);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: transform .35s cubic-bezier(.34, 1.4, .64, 1), opacity .3s ease;
}
.feedback-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}
.feedback-toast.error {
  background: linear-gradient(160deg, #ffffff, #ffdbdb);
}

.feedback-emoji { font-size: 46px; line-height: 1; }
.feedback-msg {
  font-family: 'Fredoka', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--grass-3);
}
.feedback-toast.error .feedback-msg { color: var(--coral-2); }

/* ============ CONFETI ============ */
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
  overflow: hidden;
}
.confetti {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  will-change: transform, opacity;
  animation: confetti-fall 2.4s ease-in forwards;
}
@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0) scale(1); opacity: 1; }
  100% { transform: translateY(110vh) rotate(900deg) scale(.6); opacity: 0; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Laptops medianas */
@media (max-width: 1400px) {
  .game-main { grid-template-columns: minmax(0, 1fr) 360px; }
  .logo-text h1 { font-size: 26px; }
  .logo-badge { width: 54px; height: 54px; }
  .logo-emoji { font-size: 28px; }
  .cmd-btn { height: 68px; }
  .cmd-icon { font-size: 22px; }
  .action-go { height: 64px; font-size: 21px; }
}

/* Tablets */
@media (max-width: 1024px) {
  .game-wrapper { padding: 10px; gap: 10px; }
  .game-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }
  .board-panel { order: 1; }
  .control-panel { order: 2; }
  .grid { width: min(100%, 72vh); }
  .panel-sequence { min-height: 110px; }
  .hud-card { padding: 6px 10px; min-width: 80px; }
  .hud-value { font-size: 17px; }
  .hud-icon { font-size: 18px; }
}

/* Móviles */
@media (max-width: 640px) {
  .game-wrapper { padding: 8px; gap: 8px; }

  .game-header {
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 8px;
  }
  .logo-text h1 { font-size: 20px; }
  .logo-text p { display: none; }
  .logo-badge { width: 44px; height: 44px; }
  .logo-emoji { font-size: 22px; }

  .hud { flex: 1; justify-content: flex-end; gap: 6px; }
  .hud-card {
    padding: 5px 8px;
    min-width: 0;
    gap: 4px;
  }
  .hud-info { gap: 0; }
  .hud-label { font-size: 9px; }
  .hud-value { font-size: 15px; }
  .hud-icon { font-size: 16px; }
  .icon-btn { width: 42px; height: 42px; font-size: 18px; }

  .board-panel { padding: 10px; }
  .board-heading { font-size: 16px; }
  .board-heading-icon { font-size: 20px; }
  .status-bar { font-size: 12px; padding: 6px 12px; }
  .grid { padding: 8px; gap: 5px; }
  .cell { border-radius: 10px; }
  .board-legend { gap: 12px; font-size: 11px; }
  .legend-dot { width: 14px; height: 14px; font-size: 10px; }

  .control-panel { padding: 10px; gap: 8px; }
  .panel-section { padding: 10px; }
  .panel-title { font-size: 15px; }
  .section-tip { display: none; }

  .dpad { gap: 8px; }
  .cmd-btn {
    height: 62px;
    font-size: 12px;
    border-radius: 14px;
  }
  .cmd-icon { font-size: 20px; }
  .cmd-text { font-size: 11px; }

  .sequence-box { min-height: 80px; padding: 8px; }
  .seq-chip { padding: 5px 8px; min-width: 52px; }
  .seq-chip .chip-icon { font-size: 16px; }
  .seq-chip .chip-label { font-size: 9px; }
  .seq-empty { font-size: 12px; }
  .seq-empty-icon { font-size: 18px; }

  .action-btn { height: 54px; font-size: 16px; border-radius: 16px; }
  .action-go { height: 60px; font-size: 19px; }
  .action-new { height: 46px; font-size: 14px; }
  .action-icon { font-size: 18px; }

  .overlay-card { padding: 24px 18px; }
  .overlay-card h2 { font-size: 22px; }
  .overlay-emoji { font-size: 54px; }
  .primary-btn { padding: 12px 24px; font-size: 16px; }
  .help-grid { grid-template-columns: 1fr; }

  .feedback-msg { font-size: 18px; }
  .feedback-emoji { font-size: 36px; }
  .feedback-toast { padding: 16px 22px; }
}

/* Pantallas muy pequeñas */
@media (max-width: 380px) {
  .logo-text h1 { font-size: 17px; }
  .hud-label { display: none; }
  .hud-value { font-size: 14px; }
  .cmd-btn { height: 56px; }
  .cmd-icon { font-size: 18px; }
  .action-btn { height: 48px; font-size: 14px; }
  .action-go { height: 54px; font-size: 17px; }
}

/* Pizarras grandes (1920x1080) */
@media (min-width: 1600px) and (min-height: 900px) {
  .game-wrapper { padding: 20px 26px 26px; gap: 18px; }
  .logo-text h1 { font-size: 38px; }
  .logo-badge { width: 72px; height: 72px; }
  .logo-emoji { font-size: 40px; }
  .hud-value { font-size: 24px; }
  .hud-icon { font-size: 26px; }
  .cmd-btn { height: 96px; }
  .cmd-icon { font-size: 32px; }
  .cmd-text { font-size: 16px; }
  .action-go { height: 82px; font-size: 26px; }
  .action-btn { height: 68px; font-size: 20px; }
  .action-new { height: 60px; font-size: 18px; }
  .panel-title { font-size: 20px; }
  .board-heading { font-size: 26px; }
  .status-bar { font-size: 17px; }
}

/* Landscape móvil – reduce altura vertical */
@media (max-height: 500px) and (orientation: landscape) {
  .game-main { grid-template-columns: 1fr 300px; grid-template-rows: 1fr; }
  .board-panel { padding: 8px; }
  .board-heading, .board-legend { display: none; }
  .grid { width: min(90vh, 100%); }
  .cmd-btn { height: 52px; }
  .action-btn { height: 44px; font-size: 14px; }
  .action-go { height: 50px; font-size: 17px; }
  .action-new { height: 40px; font-size: 12px; }
}

/* Reducción de movimiento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}