/* ====================================================================
   Ficha Vikingo - Estilos Modernos y Adaptativos para Educación Infantil
   ==================================================================== */

:root {
  --primary-color: #3b82f6;
  --primary-dark: #1d4ed8;
  --wood-dark: #78350f;
  --wood-light: #b45309;
  --gold: #f59e0b;
  --gold-light: #fde68a;
  --bg-gradient-top: #0f172a;
  --bg-gradient-bottom: #1e293b;
  --card-bg: rgba(255, 255, 255, 0.95);
  --text-dark: #1e293b;
  --font-family: 'Fredoka', 'Quicksand', 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --shadow-button: 0 5px 0 rgba(0,0,0,0.25), 0 8px 15px rgba(0,0,0,0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family);
  background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
  color: #fff;
  touch-action: none;
}

#app-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ----------------------------------------------------
   VISTA 1: MENU PRINCIPAL DE FICHAS
   ---------------------------------------------------- */
#menu-view {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 16px 24px;
  overflow-y: auto;
  align-items: center;
  animation: fadeIn 0.35s ease-out;
}

.menu-header {
  width: 100%;
  max-width: 1100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.title-container {
  display: flex;
  align-items: center;
  gap: 14px;
}

.app-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.menu-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--gold-light);
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  letter-spacing: 0.5px;
}

.menu-subtitle {
  font-size: 0.95rem;
  color: #cbd5e1;
  font-weight: 500;
}

.header-actions {
  display: flex;
  gap: 10px;
}

/* Cuadrícula de tarjetas de fichas */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 1100px;
  padding-bottom: 24px;
}

.sheet-card {
  background: var(--card-bg);
  color: var(--text-dark);
  border-radius: var(--radius-lg);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.18s ease;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
  border: 3px solid #e2e8f0;
  position: relative;
  overflow: hidden;
}

.sheet-card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
  border-color: var(--gold);
}

.sheet-card:active {
  transform: scale(0.97);
}

.sheet-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #2563eb;
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 4px 10px;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  z-index: 2;
}

.card-thumb-canvas {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  background: #f1f5f9;
  object-fit: cover;
  border: 1px solid #cbd5e1;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-top: 10px;
  text-align: center;
  color: #0f172a;
}

.card-tag {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  margin-top: 2px;
}

.sheet-card.special-card {
  border: 3px solid var(--gold);
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

.sheet-card.special-card .sheet-badge {
  background: #d97706;
}

/* ----------------------------------------------------
   VISTA 2: AREA DE TRABAJO DE LA FICHA (CANVAS)
   ---------------------------------------------------- */
#game-view {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Barra superior de la ficha */
.top-nav {
  height: 60px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  z-index: 10;
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-center {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-indicator {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--gold-light);
  background: rgba(255, 255, 255, 0.12);
  padding: 6px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Lienzo interactivo central */
.canvas-wrapper {
  flex: 1;
  width: 100%;
  height: calc(100% - 150px);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  overflow: hidden;
}

#sheet-canvas {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  border-radius: var(--radius-md);
  background: #ffffff;
  cursor: crosshair;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Barra inferior de herramientas (HUD) */
.tools-hud {
  height: 84px;
  width: 100%;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  border-top: 2px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 10;
  gap: 8px;
}

/* Grupo de colores */
.palette-group {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  padding: 4px 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid rgba(255,255,255,0.4);
  transition: transform 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  transform: scale(1.22);
  border-color: #ffffff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 4px 8px rgba(0,0,0,0.4);
}

/* Grupo de pinceles / grosores */
.brush-sizes {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 8px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.size-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.size-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.size-btn.active {
  background: var(--primary-color);
  border-color: #ffffff;
  box-shadow: 0 0 8px var(--primary-color);
}

.size-dot {
  background: #ffffff;
  border-radius: 50%;
}

/* Bandeja de Sellos / Pegatinas */
.stickers-group {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 8px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.sticker-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid transparent;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.sticker-btn:hover {
  transform: scale(1.18);
  background: rgba(255, 255, 255, 0.25);
}

.sticker-btn.active {
  transform: scale(1.22);
  background: var(--gold);
  border-color: #ffffff;
  box-shadow: 0 0 10px var(--gold);
}

/* Botones de acción táctiles para niños */
.btn-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: none;
  font-family: var(--font-family);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  color: #fff;
  transition: transform 0.12s ease, filter 0.12s ease;
  box-shadow: var(--shadow-button);
}

.btn-action:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
}

.btn-action:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.25);
}

.btn-back {
  background: #64748b;
}

.btn-home {
  background: #3b82f6;
}

.btn-nav {
  background: #f59e0b;
  width: 48px;
  padding: 0;
  font-size: 1.3rem;
  border-radius: 50%;
}

.btn-camera {
  background: #10b981;
}

.btn-stars {
  background: #d97706;
  color: #fff;
}

.btn-undo {
  background: #8b5cf6;
}

.btn-eraser {
  background: #ec4899;
}

.btn-eraser.active {
  outline: 3px solid #fff;
  filter: brightness(1.2);
  box-shadow: 0 0 12px #ec4899;
}

.btn-clear {
  background: #ef4444;
}

.btn-voice {
  background: #06b6d4;
  animation: pulseGentle 2s infinite ease-in-out;
}

.btn-voice.speaking {
  animation: pulseFast 0.8s infinite ease-in-out;
  background: #0284c7;
}

/* Modal de Felicitación / Celebración */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 4px solid var(--gold);
  border-radius: var(--radius-lg);
  padding: 32px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.6);
  transform: scale(0.8);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
  max-width: 440px;
}

.modal-overlay.show .modal-content {
  transform: scale(1);
}

.stars-row {
  display: flex;
  gap: 12px;
  font-size: 3rem;
  animation: pulseGentle 1.2s infinite ease-in-out;
}

.modal-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--gold-light);
}

.modal-text {
  font-size: 1.1rem;
  color: #e2e8f0;
  line-height: 1.4;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

/* Confeti */
#confetti-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

/* Toast de notificación amigable */
.toast-msg {
  position: absolute;
  top: 75px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(16, 185, 129, 0.95);
  color: white;
  padding: 12px 26px;
  border-radius: var(--radius-lg);
  font-weight: 800;
  font-size: 1.15rem;
  box-shadow: 0 8px 25px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 200;
  text-align: center;
}

.toast-msg.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes pulseGentle {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes pulseFast {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

@media (max-width: 950px) {
  .tools-hud {
    height: auto;
    flex-wrap: wrap;
    padding: 8px 12px;
    justify-content: center;
  }
  .color-swatch {
    width: 30px;
    height: 30px;
  }
  .size-btn, .sticker-btn {
    width: 32px;
    height: 32px;
  }
  .btn-action {
    height: 42px;
    font-size: 0.85rem;
    padding: 0 10px;
  }
  .top-nav {
    height: 50px;
  }
}
