/* ==========================================================================
   Recuerdos — "Cantina Neon"
   Warm charcoal + terracotta/amber, grain texture, bold type
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Archivo+Black&family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400&display=swap');

:root {
  --bg-deep:     #141210;
  --bg:          #1c1917;
  --bg-card:     #262220;
  --bg-elevated: #302c28;
  --bg-input:    #1a1816;

  --accent:       #d4622b;
  --accent-light: #e8844f;
  --accent-glow:  rgba(212, 98, 43, 0.35);
  --amber:        #d4a72c;
  --amber-glow:   rgba(212, 167, 44, 0.25);

  --text:        #f0e6d8;
  --text-dim:    #a89a8a;
  --text-faint:  #6b5f53;

  --success:     #4a9e6b;
  --success-bg:  rgba(74, 158, 107, 0.15);
  --danger:      #c44a3f;
  --danger-bg:   rgba(196, 74, 63, 0.15);
  --warning:     #d4a72c;
  --warning-bg:  rgba(212, 167, 44, 0.15);

  --radius:    14px;
  --radius-sm: 8px;
  --radius-lg: 20px;

  --font-display: 'Archivo Black', sans-serif;
  --font-body:    'DM Sans', sans-serif;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  font-weight: 400;
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Grain overlay for atmosphere */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

/* Warm ambient glow at top */
body::after {
  content: '';
  position: fixed;
  top: -40%;
  left: 50%;
  translate: -50% 0;
  width: 120%;
  height: 60%;
  background: radial-gradient(ellipse at center, var(--accent-glow) 0%, transparent 65%);
  pointer-events: none;
  z-index: -1;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
}

.hidden { display: none !important; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400; /* Archivo Black is already black weight */
  letter-spacing: -0.01em;
  line-height: 1.15;
}

/* ---- Entrance animations ---- */
@keyframes fadeUp {
  from { opacity: 0; translate: 0 16px; }
  to   { opacity: 1; translate: 0 0; }
}

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

@keyframes scaleIn {
  from { opacity: 0; scale: 0.92; }
  to   { opacity: 1; scale: 1; }
}

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50%      { box-shadow: 0 0 20px 4px var(--accent-glow); }
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.7; }
}

@keyframes slideDown {
  from { opacity: 0; translate: 0 -10px; }
  to   { opacity: 1; translate: 0 0; }
}

@keyframes bounceIn {
  0%   { opacity: 0; scale: 0.3; }
  50%  { scale: 1.05; }
  70%  { scale: 0.95; }
  100% { opacity: 1; scale: 1; }
}

@keyframes crownBounce {
  0%, 100% { translate: 0 0; }
  25%      { translate: 0 -6px; rotate: -5deg; }
  75%      { translate: 0 -6px; rotate: 5deg; }
}

/* ==========================================================================
   AUTH PAGES (Login / Register)
   ========================================================================== */

.auth-card {
  max-width: 400px;
  margin: min(15vh, 100px) auto 0;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-lg);
  padding: 48px 40px 40px;
  text-align: center;
  animation: fadeUp 0.6s var(--ease-out) both;
  position: relative;
  overflow: hidden;
}

/* Decorative top border glow */
.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--amber), var(--accent), transparent);
  border-radius: 2px;
}

.auth-card h1 {
  font-size: 2.8rem;
  color: var(--text);
  margin-bottom: 2px;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 32px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
}

.error {
  background: var(--danger-bg);
  border: 1px solid rgba(196, 74, 63, 0.3);
  border-left: 3px solid var(--danger);
  color: #e8a49e;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.9rem;
  text-align: left;
  animation: slideDown 0.3s var(--ease-out);
}

form input[type="text"],
form input[type="password"] {
  display: block;
  width: 100%;
  padding: 15px 18px;
  margin-bottom: 14px;
  background: var(--bg-input);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}

form input::placeholder {
  color: var(--text-faint);
}

form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ---- Buttons ---- */
.btn, button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 15px 28px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s var(--ease-out);
  position: relative;
  letter-spacing: 0.02em;
}

.btn:hover, button[type="submit"]:hover {
  background: var(--accent-light);
  translate: 0 -1px;
  box-shadow: 0 6px 20px -4px var(--accent-glow);
}

.btn:active, button[type="submit"]:active {
  translate: 0 0;
  box-shadow: none;
}

button[type="submit"] {
  width: 100%;
  margin-top: 4px;
}

.btn-small {
  padding: 8px 18px;
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.btn-small:hover {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
  translate: none;
}

.btn-large {
  padding: 20px 36px;
  font-size: 1.15rem;
  width: 100%;
  border-radius: var(--radius);
  animation: pulseGlow 2.5s ease-in-out infinite;
}

.btn-large:hover {
  animation: none;
}

.btn-primary {
  background: var(--accent);
}

.alt-link {
  margin-top: 24px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.alt-link a {
  color: var(--accent-light);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.alt-link a:hover {
  border-bottom-color: var(--accent-light);
}

/* ==========================================================================
   LOBBY
   ========================================================================== */

.lobby {
  animation: fadeUp 0.5s var(--ease-out) both;
}

.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.lobby-header h1 {
  font-size: 1.6rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-dim);
  font-weight: 500;
}

.create-room {
  margin-bottom: 36px;
}

.inline-form {
  display: flex;
  gap: 10px;
}

.inline-form input {
  flex: 1;
}

.inline-form .btn {
  white-space: nowrap;
  flex-shrink: 0;
}

.lobby h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-bottom: 16px;
}

.empty-state {
  text-align: center;
  color: var(--text-faint);
  padding: 48px 20px;
  font-size: 0.95rem;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
}

.room-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.room-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius);
  padding: 18px 22px;
  transition: border-color 0.2s, background 0.2s;
  animation: fadeUp 0.4s var(--ease-out) both;
}

.room-card:nth-child(1) { animation-delay: 0s; }
.room-card:nth-child(2) { animation-delay: 0.05s; }
.room-card:nth-child(3) { animation-delay: 0.1s; }
.room-card:nth-child(4) { animation-delay: 0.15s; }
.room-card:nth-child(5) { animation-delay: 0.2s; }

.room-card:hover {
  border-color: rgba(255, 255, 255, 0.08);
  background: var(--bg-elevated);
}

.room-info h3 {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-waiting {
  background: var(--warning-bg);
  color: var(--amber);
  border: 1px solid rgba(212, 167, 44, 0.2);
}

.badge-playing {
  background: rgba(212, 98, 43, 0.15);
  color: var(--accent-light);
  border: 1px solid rgba(212, 98, 43, 0.2);
}

.badge-finished {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-faint);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.player-count {
  color: var(--text-faint);
  font-size: 0.82rem;
  margin-left: 10px;
}

/* ==========================================================================
   ROOM (Waiting / Game / Game Over)
   ========================================================================== */

.room {
  animation: fadeUp 0.5s var(--ease-out) both;
}

.room-header {
  margin-bottom: 28px;
}

.back-link {
  color: var(--text-faint);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-block;
  margin-bottom: 8px;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--text-dim);
}

.room-header h1 {
  font-size: 1.8rem;
}

/* ---- Player list (waiting & scoreboard) ---- */
.player-list, .score-list {
  list-style: none;
  margin: 12px 0;
}

.player-list li, .score-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-weight: 500;
  animation: fadeUp 0.35s var(--ease-out) both;
}

.player-list li:nth-child(1),
.score-list li:nth-child(1) { animation-delay: 0s; }
.player-list li:nth-child(2),
.score-list li:nth-child(2) { animation-delay: 0.04s; }
.player-list li:nth-child(3),
.score-list li:nth-child(3) { animation-delay: 0.08s; }
.player-list li:nth-child(4),
.score-list li:nth-child(4) { animation-delay: 0.12s; }

#waiting-area h2 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.waiting-text {
  color: var(--text-faint);
  text-align: center;
  padding: 28px;
  font-style: italic;
}

/* ---- Game HUD ---- */
.game-hud {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
  animation: slideDown 0.4s var(--ease-out) both;
}

.round-info {
  font-family: var(--font-display);
  font-size: 0.9rem;
  white-space: nowrap;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.timer-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--amber), var(--accent-light));
  border-radius: 3px;
  transition: width 0.05s linear;
  box-shadow: 0 0 8px var(--accent-glow);
}

.timer-fill.timer-warning {
  background: linear-gradient(90deg, var(--danger), #e85d52);
  box-shadow: 0 0 12px rgba(196, 74, 63, 0.4);
  animation: timerPulse 0.5s ease infinite;
}

/* ---- Word display ---- */
.word-display {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 4rem);
  text-align: center;
  padding: 36px 16px;
  color: var(--text);
  animation: scaleIn 0.4s var(--ease-bounce) both;
  position: relative;
}

/* Subtle accent underline */
.word-display::after {
  content: '';
  display: block;
  width: 60px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  margin: 16px auto 0;
  opacity: 0.6;
}

/* ---- Answer choices ---- */
.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.choice-btn {
  padding: 22px 16px;
  background: var(--bg-card);
  border: 2px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
  animation: fadeUp 0.35s var(--ease-out) both;
}

.choice-btn:nth-child(1) { animation-delay: 0.05s; }
.choice-btn:nth-child(2) { animation-delay: 0.1s; }
.choice-btn:nth-child(3) { animation-delay: 0.15s; }
.choice-btn:nth-child(4) { animation-delay: 0.2s; }

.choice-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(212, 98, 43, 0.08);
  translate: 0 -2px;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.4);
}

.choice-btn:active:not(:disabled) {
  translate: 0 0;
  scale: 0.98;
}

.choice-btn.selected {
  border-color: var(--accent);
  background: rgba(212, 98, 43, 0.15);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.choice-btn.correct {
  border-color: var(--success) !important;
  background: var(--success-bg) !important;
  box-shadow: 0 0 0 3px rgba(74, 158, 107, 0.2) !important;
}

.choice-btn.wrong {
  border-color: var(--danger) !important;
  background: var(--danger-bg) !important;
  box-shadow: 0 0 0 3px rgba(196, 74, 63, 0.15) !important;
}

.choice-btn:disabled {
  cursor: default;
  opacity: 0.85;
}

/* ---- Round feedback ---- */
.round-feedback {
  text-align: center;
  padding: 18px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-dim);
  animation: fadeIn 0.3s var(--ease-out);
}

/* ---- Scoreboard ---- */
.scoreboard {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.scoreboard h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-bottom: 10px;
  font-family: var(--font-body);
  font-weight: 700;
}

.score {
  font-family: var(--font-display);
  font-size: 0.95em;
  color: var(--amber);
}

/* ---- Game Over ---- */
#game-over-area {
  text-align: center;
  padding: 48px 0 32px;
  animation: fadeUp 0.6s var(--ease-out) both;
}

#game-over-area h2 {
  font-size: 2.2rem;
  margin-bottom: 32px;
  background: linear-gradient(135deg, var(--accent-light), var(--amber));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.final-scores {
  max-width: 420px;
  margin: 0 auto 32px;
}

.final-scores li {
  font-size: 1.05rem;
}

.final-scores .winner {
  background: rgba(212, 98, 43, 0.1);
  border-color: rgba(212, 98, 43, 0.25);
  position: relative;
}

.final-scores .winner::before {
  content: '\1F451';
  position: absolute;
  left: -8px;
  top: -12px;
  font-size: 1.3rem;
  animation: crownBounce 2s ease-in-out infinite;
}

.final-scores .winner .score {
  color: var(--accent-light);
  font-size: 1.1em;
}

.rank {
  color: var(--text-faint);
  font-weight: 400;
  min-width: 28px;
}

.name {
  flex: 1;
}

/* ==========================================================================
   MOBILE
   ========================================================================== */

@media (max-width: 520px) {
  .container {
    padding: 14px;
  }

  .auth-card {
    margin: 40px 12px 0;
    padding: 36px 24px 32px;
  }

  .auth-card h1 {
    font-size: 2.2rem;
  }

  .word-display {
    padding: 28px 12px;
  }

  .choices {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .choice-btn {
    padding: 20px 16px;
  }

  .inline-form {
    flex-direction: column;
  }

  .inline-form .btn {
    width: 100%;
  }

  .lobby-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .room-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .room-card .btn {
    width: 100%;
  }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
