/* Lotería Kids: English Edition — Responsive Kid-Friendly Styles */
:root {
  --bg: #fff8ee;
  --bg-pattern: #ffe9cf;
  --surface: #ffffff;
  --ink: #222645;
  --muted: #5d6487;
  --primary: #ff5e62;
  --primary-dark: #d94145;
  --secondary: #3b82f6;
  --secondary-dark: #2563eb;
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --success: #10b981;
  --success-dark: #059669;
  --purple: #8b5cf6;
  --purple-dark: #6d28d9;
  --radius: 20px;
  --shadow: 0 10px 26px rgba(34, 38, 69, 0.10);
  --shadow-sm: 0 4px 12px rgba(34, 38, 69, 0.08);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: 'Nunito', 'Fredoka', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(var(--bg-pattern) 2px, transparent 2px),
    radial-gradient(var(--bg-pattern) 2px, var(--bg) 2px);
  background-size: 36px 36px;
  background-position: 0 0, 18px 18px;
  min-height: 100vh;
}

h1, h2, h3, .font-display {
  font-family: 'Fredoka', 'Nunito', system-ui, sans-serif;
  margin: 0;
}

.hidden {
  display: none !important;
}

/* Confetti canvas */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
}

/* App container */
.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 16px 32px;
}

/* Header */
.top-hero {
  text-align: center;
  padding: 14px 12px 18px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #ff6b6b, #ff9f43);
  color: #fff;
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.4px;
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.35);
  margin-bottom: 10px;
}

.top-hero h1 {
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1.1;
  color: var(--ink);
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.9);
}

.top-hero h1 span {
  color: var(--primary);
}

.top-hero p {
  margin: 8px auto 0;
  max-width: 600px;
  color: var(--muted);
  font-size: 1.02rem;
  font-weight: 600;
}

/* Cards / Panels */
.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 3px solid rgba(34, 38, 69, 0.06);
  min-width: 0;
  max-width: 100%;
}

/* Profile Bar */
.profile-card {
  max-width: 720px;
  margin: 0 auto 20px;
}

.profile-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

.input-group {
  flex: 1 1 220px;
}

.input-group label {
  display: block;
  font-weight: 800;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--muted);
}

.text-input, .select-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2.5px solid #e2e8f0;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  background: #f8fafc;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.text-input:focus, .select-input:focus {
  border-color: var(--secondary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.avatar-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.avatar-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 2.5px solid #e2e8f0;
  background: #f8fafc;
  font-size: 1.35rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
}

.avatar-btn:hover {
  transform: scale(1.08);
}

.avatar-btn.active {
  border-color: var(--primary);
  background: #fff0f0;
  transform: scale(1.1);
  box-shadow: 0 4px 10px rgba(255, 94, 98, 0.25);
}

/* Mode Grid on Home */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  max-width: 980px;
  margin: 0 auto 20px;
}

.mode-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  position: relative;
  overflow: hidden;
}

.mode-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 6px;
}

.mode-card h2 {
  font-size: 1.3rem;
}

.mode-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.4;
}

/* Chunky 3D Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 1.02rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, filter 0.15s;
  color: #fff;
  text-decoration: none;
  user-select: none;
}

.btn:active {
  transform: translateY(3px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--primary);
  box-shadow: 0 5px 0 var(--primary-dark);
}
.btn-primary:active { box-shadow: 0 2px 0 var(--primary-dark); }

.btn-secondary {
  background: var(--secondary);
  box-shadow: 0 5px 0 var(--secondary-dark);
}
.btn-secondary:active { box-shadow: 0 2px 0 var(--secondary-dark); }

.btn-success {
  background: var(--success);
  box-shadow: 0 5px 0 var(--success-dark);
}
.btn-success:active { box-shadow: 0 2px 0 var(--success-dark); }

.btn-accent {
  background: var(--accent);
  box-shadow: 0 5px 0 var(--accent-dark);
}
.btn-accent:active { box-shadow: 0 2px 0 var(--accent-dark); }

.btn-purple {
  background: var(--purple);
  box-shadow: 0 5px 0 var(--purple-dark);
}
.btn-purple:active { box-shadow: 0 2px 0 var(--purple-dark); }

.btn-ghost {
  background: #f1f5f9;
  color: var(--ink);
  box-shadow: 0 4px 0 #cbd5e1;
}
.btn-ghost:active { box-shadow: 0 1px 0 #cbd5e1; }

.btn-sm {
  padding: 8px 12px;
  font-size: 0.88rem;
  border-radius: 11px;
}

.btn-block {
  width: 100%;
}

/* Settings Grid */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.code-input {
  text-transform: uppercase;
  letter-spacing: 5px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 900;
}

/* Home Footer / Explorer Banner */
.explorer-banner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: linear-gradient(135deg, #eef2ff, #fdf2f8);
  border-color: #e0e7ff;
}

/* ==================== LOBBY VIEW ==================== */
.lobby-wrap {
  max-width: 820px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.code-showcase {
  text-align: center;
  background: linear-gradient(135deg, #fff5f5, #fffbeb);
  border: 3px dashed #ff9f43;
}

.big-code {
  font-family: 'Fredoka', monospace;
  font-size: clamp(2.4rem, 8vw, 3.8rem);
  letter-spacing: 10px;
  color: var(--primary);
  margin: 6px 0 12px;
  font-weight: 800;
}

.copy-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.player-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 800;
}

.player-chip.is-me {
  border-color: var(--secondary);
  background: #eff6ff;
}

/* ==================== GAME VIEW ==================== */
.game-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  padding: 10px 14px;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.topbar-left, .topbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.86rem;
}

.pill-code {
  background: #fff0f0;
  color: var(--primary-dark);
}

.pill-pattern {
  background: #eff6ff;
  color: var(--secondary-dark);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

/* Caller Column */
.caller-column {
  display: grid;
  gap: 14px;
  min-width: 0;
  max-width: 100%;
}

.caller-card-panel {
  text-align: center;
  position: relative;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.caller-label {
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.caller-card {
  border-radius: 20px;
  padding: 18px 14px;
  border: 4px solid #fff;
  box-shadow: 0 10px 22px rgba(34, 38, 69, 0.14);
  transition: transform 0.25s ease;
  cursor: pointer;
  position: relative;
}

.caller-card.pop-in {
  animation: cardPop 0.38s cubic-bezier(0.22, 1.25, 0.36, 1);
}

@keyframes cardPop {
  0% { transform: scale(0.84) rotate(-3deg); opacity: 0.4; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.caller-emoji {
  font-size: 4.2rem;
  line-height: 1.1;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.12));
}

.caller-word-en {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.95rem;
  font-weight: 700;
  color: var(--ink);
  margin-top: 6px;
}

.caller-word-es {
  font-size: 1rem;
  font-weight: 800;
  color: rgba(34, 38, 69, 0.72);
  margin-top: 2px;
}

.caller-phrase {
  margin-top: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.72);
  padding: 6px 10px;
  border-radius: 10px;
  color: var(--ink);
}

.caller-progress-wrap {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0 10px;
}

.caller-progress-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  transition: width 0.25s linear;
}

.caller-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Recent Called History */
.history-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  max-width: 100%;
  padding: 4px 2px 6px;
  scrollbar-width: thin;
}

.history-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 4px 8px;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}

/* Players Panel */
.players-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 12px;
  border: 2px solid transparent;
  font-weight: 700;
  font-size: 0.92rem;
}

.player-row.is-me {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.player-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.player-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  font-size: 0.84rem;
  color: var(--muted);
}

/* Reactions */
.reaction-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.reaction-btn {
  border: 2px solid #e2e8f0;
  background: #fff;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s, background 0.12s;
}

.reaction-btn:hover {
  background: #fff8ee;
  transform: scale(1.05);
}

.reaction-feed {
  min-height: 26px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.reaction-toast {
  background: #222645;
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  animation: fadeSlide 0.25s ease;
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== LOTERÍA BOARD ==================== */
.board-panel {
  padding: 16px;
  min-width: 0;
  max-width: 100%;
}

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

.loteria-grid {
  display: grid;
  gap: 10px;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}

.loteria-grid.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.loteria-grid.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.loteria-cell {
  position: relative;
  aspect-ratio: 4 / 4.5;
  border-radius: 16px;
  border: 3.5px solid #ffffff;
  box-shadow: 0 6px 14px rgba(34, 38, 69, 0.11);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.14s, box-shadow 0.14s;
  overflow: hidden;
  text-align: center;
}

.loteria-cell:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 18px rgba(34, 38, 69, 0.15);
}

.loteria-cell:active {
  transform: scale(0.96);
}

.cell-emoji {
  font-size: clamp(2rem, 5.2vw, 3.2rem);
  line-height: 1.05;
  transition: transform 0.2s;
}

.cell-word {
  margin-top: 6px;
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(0.82rem, 2.2vw, 1.12rem);
  font-weight: 700;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.85);
  padding: 2px 8px;
  border-radius: 8px;
  max-width: 95%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-es {
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(34, 38, 69, 0.72);
  margin-top: 2px;
}

/* Bean / Frijolito token */
.bean-token {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 8px;
  background: rgba(16, 185, 129, 0.22);
  box-shadow: inset 0 0 0 4px #10b981;
  border-radius: inherit;
  pointer-events: none;
  animation: beanDrop 0.24s cubic-bezier(0.22, 1.4, 0.36, 1);
}

.bean-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fbbf24, #d97706);
  border: 3px solid #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.24);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

@keyframes beanDrop {
  0% { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.loteria-cell.hint-pulse {
  outline: 4px solid var(--primary);
  outline-offset: 2px;
}

.loteria-cell.shake {
  animation: cellShake 0.32s ease;
}

@keyframes cellShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.loteria-cell.win-cell {
  outline: 5px solid #10b981;
  box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.25);
}

/* Big LOTERIA Button */
.claim-wrap {
  margin-top: 16px;
  text-align: center;
}

.btn-loteria {
  width: 100%;
  max-width: 420px;
  padding: 16px 24px;
  font-size: 1.45rem;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 6px 0 #047857;
}

.btn-loteria.ready-glow {
  background: linear-gradient(135deg, #ff5e62, #ff9966);
  box-shadow: 0 6px 0 #c93b3f, 0 0 24px rgba(255, 94, 98, 0.55);
  animation: pulseWin 1s infinite alternate;
}

@keyframes pulseWin {
  from { transform: scale(1); }
  to { transform: scale(1.04); }
}

/* ==================== MODALS & EXPLORER ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(34, 38, 69, 0.62);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 500;
}

.modal-box {
  background: var(--surface);
  border-radius: 24px;
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  text-align: center;
}

.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 14px;
  text-align: center;
}

.vocab-card {
  border-radius: 14px;
  padding: 10px 6px;
  cursor: pointer;
  border: 2.5px solid #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s;
}

.vocab-card:hover {
  transform: translateY(-2px) scale(1.02);
}

.vocab-card .v-emoji { font-size: 2rem; }
.vocab-card .v-en { font-weight: 800; font-size: 0.92rem; margin-top: 4px; }
.vocab-card .v-es { font-size: 0.76rem; color: rgba(34, 38, 69, 0.72); font-weight: 700; }

/* Toast */
.toast-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.94rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  z-index: 900;
  transition: opacity 0.2s;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
  .mode-grid {
    grid-template-columns: 1fr;
  }
  .game-topbar {
    padding: 7px 10px;
    gap: 6px;
    margin-bottom: 8px;
  }
  .pill {
    padding: 4px 8px;
    font-size: 0.75rem;
  }
  .game-layout {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  /* Flatten caller-column so we can place Caller (1) -> Board (2) -> Players (3) */
  .caller-column {
    display: contents;
  }
  .caller-card-panel {
    order: 1;
    position: sticky;
    top: 4px;
    z-index: 40;
    padding: 8px 10px;
    border-radius: 16px;
    box-shadow: 0 6px 18px rgba(34, 38, 69, 0.16);
  }
  .caller-label {
    font-size: 0.72rem;
    margin-bottom: 4px;
  }
  .caller-card {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    text-align: left;
    gap: 8px 10px;
    padding: 8px 12px;
    border-radius: 14px;
    border-width: 2.5px;
    box-shadow: 0 4px 10px rgba(34, 38, 69, 0.10);
  }
  .caller-emoji {
    font-size: 2.35rem;
  }
  .caller-word-en {
    font-size: 1.35rem;
    margin-top: 0;
    line-height: 1.1;
  }
  .caller-word-es {
    font-size: 0.85rem;
    margin-top: 1px;
  }
  .caller-phrase {
    display: none;
  }
  .caller-progress-wrap {
    height: 5px;
    margin: 7px 0 6px;
  }
  .caller-controls {
    gap: 6px;
  }
  .caller-controls .btn-sm {
    padding: 5px 10px;
    font-size: 0.78rem;
  }
  .caller-card-panel .history-wrap {
    display: none;
  }
  .board-panel {
    order: 2;
    padding: 10px;
  }
  .board-header {
    display: none;
  }
  .loteria-grid {
    gap: 7px;
  }
  .loteria-cell {
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    border-width: 2.5px;
    padding: 4px 3px;
  }
  .cell-emoji {
    font-size: clamp(1.6rem, 7vw, 2.5rem);
  }
  .cell-word {
    margin-top: 3px;
    font-size: clamp(0.72rem, 2.9vw, 0.95rem);
    padding: 1px 6px;
  }
  .cell-es {
    font-size: 0.65rem;
  }
  .claim-wrap {
    margin-top: 10px;
  }
  .btn-loteria {
    padding: 12px 18px;
    font-size: 1.18rem;
  }
  .players-panel {
    order: 3;
  }
}

@media (max-width: 480px) {
  .app-shell {
    padding: 8px 8px 20px;
  }
  .panel {
    padding: 12px;
    border-radius: 14px;
  }
  .caller-card-panel {
    padding: 8px 10px;
  }
  .board-panel {
    padding: 8px;
  }
  .loteria-grid {
    gap: 6px;
  }
  .bean-token {
    padding: 4px;
  }
  .bean-badge {
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
    border-width: 2px;
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
}
