/*  RESET */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* VAR */
:root {
  --ink:      #0d0d0d;
  --paper:    #f4f1eb;
  --accent:   #e84040;
  --soft:     #c8c2b8;
  --border:   rgba(13,13,13,0.12);
  --radius:   4px;
  --mono:     "Pangolin", cursive;
  --display:  "Pangolin", cursive;
}

/* BASE */
html { scroll-behavior: smooth; }

body {
  background-image: url('/fondo.jpg');
  background-size: cover;     
  background-position: center; 
  background-repeat: no-repeat;
  background-attachment: fixed;
  font-family: var(--mono);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* HEADER */
header {
  position: relative; z-index: 1;
  width: 100%;
  max-width: 900px;
  padding: 40px 40px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

header h1 {
  font-family: var(--display);
  font-size: clamp(4rem, 12vw, 8rem);
  letter-spacing: 0.08em;
  line-height: 1;
  color: #f14e2d;
}

.header-label {
  font-family: var(--display);
  font-size: 30px;
  letter-spacing: 0.20em;
}

/* LAYOUT */
.game-container {
  position: relative; z-index: 1;
  width: 100%;
  max-width: 900px;
  padding: 40px;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 150px;
  align-items: start;
}

/* FIGURE */
.figure-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.figure-wrap {
  width: 500px;
  height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

#figure-img {
  width: 500px;
  height: 500px;
  object-fit: contain;
  transition: opacity 0.3s;
}

#figure-svg {
  width: 180px;
  height: 240px;
}

.svg-part {
  display: none;
  animation: drawIn 0.3s ease both;
}

@keyframes drawIn {
  from { opacity: 0; transform: scale(0.8); transform-origin: center; }
  to   { opacity: 1; transform: scale(1); }
}

.error-counter {
  font-family: var(--display);
  font-size: 1.8rem;
  letter-spacing: 0.05em;
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: var(--ink);
}

.error-counter #error-num {
  color: var(--accent);
  font-size: 2.5rem;
  transition: transform 0.2s;
}

.error-counter #error-num.bump {
  animation: bump 0.25s ease;
}

@keyframes bump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.error-sep { color: var(--soft); margin: 0 2px; }

.error-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--soft);
  margin-left: 8px;
}

/* PANEL */
.game-panel {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

/* Letras incorrectas */
.section-label {
  display: block;
  font-size: 15px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.wrong-letters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 32px;
}

.wrong-letter {
  font-family: var(--display);
  font-size: 1.5rem;
  color: var(--accent);
  animation: fadeSlide 0.25s ease both;
  letter-spacing: 0.05em;
}

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

/* Palabra */
.word {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.letter-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.letter-char {
  font-family: var(--display);
  font-size: 2.2rem;
  line-height: 1;
  height: 40px;
  min-width: 24px;
  text-align: center;
  letter-spacing: 0.05em;
  transition: all 0.2s;
}

.letter-char.revealed {
  animation: popIn 0.3s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.8); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.letter-line {
  width: 100%;
  height: 2px;
  background: var(--ink);
}

/* Teclado */
.keyboard {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 520px;
}

.key {
  font-family: var(--display);
  font-size: 1rem;
  letter-spacing: 0.05em;
  width: 40px;
  height: 40px;
  border: 1.5px solid var(--border);
  background: white;
  color: var(--ink);
  cursor: pointer;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  user-select: none;
}

.key:hover:not(:disabled) {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  transform: translateY(-2px);
}

.key:disabled {
  cursor: default;
  opacity: 0.35;
}

.key.correct {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.key.wrong {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
  opacity: 0.5;
}

/* ===== POPUP ===== */
.popup-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(244,241,235,0.85);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.popup-overlay.show { display: flex; }

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

.popup {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 56px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: slideUp 0.35s cubic-bezier(0.34,1.56,0.64,1) both;
  max-width: 400px;
  width: 90%;
}

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

.popup-icon { font-size: 3rem; line-height: 1; }

.popup h2 {
  font-family: var(--display);
  font-size: 2.2rem;
  letter-spacing: 0.05em;
  color: var(--ink);
}

.popup p {
  font-size: 0.82rem;
  color: var(--soft);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

#play-again-btn {
  margin-top: 8px;
  font-family: var(--display);
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  padding: 14px 36px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

#play-again-btn:hover {
  background: var(--accent);
  transform: translateY(-2px);
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.78rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 12px 24px;
  border-radius: var(--radius);
  z-index: 300;
  transition: transform 0.3s ease;
  pointer-events: none;
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 680px) {
  header { padding: 28px 20px 0; }

  .game-container {
    grid-template-columns: 1fr;
    padding: 28px 20px;
    gap: 32px;
  }

  .figure-panel { flex-direction: row; align-items: flex-end; gap: 20px; }
  .figure-wrap { width: 140px; height: 160px; flex-shrink: 0; }

  .key { width: 34px; height: 34px; font-size: 0.9rem; }
  .letter-char { font-size: 1.8rem; }
}
