*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --amarillo: #ffd54f;
  --amarillo-oscuro: #f9a825;
  --amarillo-claro: #fff9c4;
  --blanco: #ffffff;
  --texto: #5d4037;
  --sombra: rgba(93, 64, 55, 0.15);
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--texto);
  background: linear-gradient(180deg, var(--amarillo-claro) 0%, var(--blanco) 40%, var(--amarillo-claro) 100%);
  background-attachment: fixed;
}

.duck-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 60'%3E%3Cellipse fill='%23f9a825' cx='40' cy='38' rx='28' ry='18'/%3E%3Ccircle fill='%23f9a825' cx='58' cy='22' r='14'/%3E%3Ccircle fill='%235d4037' cx='62' cy='20' r='3'/%3E%3Cellipse fill='%23ff8f00' cx='68' cy='26' rx='8' ry='4'/%3E%3C/svg%3E");
  background-size: 120px 90px;
  z-index: 0;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 920px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.logo-ducks {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.logo-ducks svg {
  width: 56px;
  height: 42px;
  filter: drop-shadow(0 2px 4px var(--sombra));
}

h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  color: var(--amarillo-oscuro);
  text-shadow: 2px 2px 0 var(--blanco), 0 0 20px rgba(249, 168, 37, 0.4);
  letter-spacing: 0.02em;
}

.intro {
  margin: 0 auto;
  max-width: 36rem;
  font-size: 1.1rem;
  line-height: 1.5;
  padding: 0.75rem 1.25rem;
  background: var(--blanco);
  border-radius: 1rem;
  border: 3px solid var(--amarillo);
  box-shadow: 0 4px 12px var(--sombra);
}

.progress-bar {
  margin: 1rem auto 0;
  max-width: 20rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--amarillo-oscuro);
}

.progress-sync {
  margin: 0.35rem auto 0;
  max-width: 22rem;
  min-height: 1.25rem;
  font-size: 0.8rem;
  color: #c62828;
}

.progress-sync.ok {
  color: #2e7d32;
}

.quack-hint {
  margin: 0.5rem auto 0;
  max-width: 22rem;
  font-size: 0.85rem;
  color: var(--texto);
  opacity: 0.85;
  padding: 0.35rem 0.75rem;
  background: var(--amarillo-claro);
  border-radius: 8px;
  border: 1px dashed var(--amarillo-oscuro);
  cursor: pointer;
}

.quack-hint[hidden] {
  display: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  width: min(100%, 640px);
  aspect-ratio: 1;
  margin: 1.5rem auto;
  padding: 8px;
  background: var(--blanco);
  border: 4px solid var(--amarillo-oscuro);
  border-radius: 12px;
  box-shadow: 0 8px 24px var(--sombra);
}

.cell {
  position: relative;
  aspect-ratio: 1;
  background: var(--blanco);
  border: 2px solid var(--amarillo);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.2s, border-color 0.2s;
  min-width: 0;
  padding: 2px;
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.cell:focus-visible {
  outline: 2px solid var(--amarillo-oscuro);
  outline-offset: 2px;
}

.cell:hover:not(.found) {
  transform: scale(1.05);
  border-color: var(--amarillo-oscuro);
  background: var(--amarillo-claro);
}

.cell.found {
  background: var(--amarillo);
  border-color: var(--amarillo-oscuro);
  cursor: pointer;
}

.cell.found:hover {
  background: var(--blanco);
  border-color: var(--amarillo);
}

.cell.secret-pending::after {
  content: "★";
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 0.55rem;
  color: var(--amarillo-oscuro);
  opacity: 0.7;
  pointer-events: none;
}

.cell-plus {
  font-size: clamp(1rem, 3vw, 1.5rem);
  font-weight: 300;
  color: var(--amarillo-oscuro);
  line-height: 1;
  user-select: none;
}

.cell.found .cell-plus {
  display: none;
}

.cell-check {
  display: none;
  font-size: clamp(0.9rem, 2.5vw, 1.2rem);
  color: var(--texto);
}

.cell.found .cell-check {
  display: block;
}

.cell-num {
  position: absolute;
  left: 3px;
  bottom: 2px;
  font-size: clamp(0.45rem, 1.2vw, 0.65rem);
  font-weight: 700;
  color: var(--texto);
  opacity: 0.85;
  line-height: 1;
}

.cell-player {
  display: none;
  width: 100%;
  margin-top: auto;
  padding-bottom: 10px;
}

.cell.found .cell-player {
  display: flex;
  justify-content: center;
  align-items: center;
}

.cell-play-btn {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: var(--blanco);
  color: var(--amarillo-oscuro);
  font-size: 0.65rem;
  cursor: pointer;
  box-shadow: 0 1px 3px var(--sombra);
  line-height: 1;
  padding: 0;
}

.cell-play-btn:hover {
  background: var(--amarillo-claro);
}

.cell-play-btn.is-playing {
  background: var(--amarillo-oscuro);
  color: var(--blanco);
  font-size: 0.55rem;
  letter-spacing: -0.05em;
}

.cell-play-btn.is-playing:hover {
  background: #e65100;
}

.global-player {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  background: var(--blanco);
  border: 3px solid var(--amarillo-oscuro);
  border-radius: 12px;
  box-shadow: 0 4px 16px var(--sombra);
}

.global-player h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  color: var(--amarillo-oscuro);
}

.playlist-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--amarillo);
  color: var(--texto);
  border: 2px solid var(--amarillo-oscuro);
}

.btn:hover {
  background: var(--amarillo-oscuro);
  color: var(--blanco);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.playlist-info {
  font-size: 0.9rem;
  margin: 0;
  min-height: 1.4em;
}

.playlist-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 140px;
  overflow-y: auto;
  font-size: 0.85rem;
}

.playlist-list li {
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--amarillo-claro);
}

.playlist-list li.playing {
  font-weight: 700;
  color: var(--amarillo-oscuro);
}

.playlist-list li button {
  all: unset;
  cursor: pointer;
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.25rem 0;
}

.playlist-list li button:hover {
  color: var(--amarillo-oscuro);
}

.playlist-error {
  color: #c62828;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(93, 64, 55, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal {
  background: var(--blanco);
  border: 4px solid var(--amarillo-oscuro);
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 22rem;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 40px var(--sombra);
}

.modal h3 {
  margin: 0 0 0.5rem;
  color: var(--amarillo-oscuro);
}

.modal p {
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

.modal input {
  width: 4rem;
  font-size: 1.5rem;
  text-align: center;
  padding: 0.35rem;
  border: 2px solid var(--amarillo);
  border-radius: 8px;
  margin-bottom: 1rem;
  text-transform: uppercase;
}

.modal input:focus {
  outline: none;
  border-color: var(--amarillo-oscuro);
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.modal-prize {
  display: none;
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--amarillo-claro);
  border-radius: 8px;
  font-weight: 600;
  color: var(--amarillo-oscuro);
}

.modal-prize.show {
  display: block;
}

.modal-continue {
  margin-top: 1rem;
  width: 100%;
  font-size: 1.05rem;
}

.modal-error {
  color: #c62828;
  font-size: 0.85rem;
  min-height: 1.2em;
  margin: -0.5rem 0 0.5rem;
}

footer {
  text-align: center;
  margin-top: 2rem;
  font-size: 0.8rem;
  opacity: 0.7;
}

@media (max-width: 480px) {
  .grid {
    gap: 2px;
    padding: 4px;
  }

  .cell {
    border-width: 1px;
    border-radius: 4px;
  }
}
