/* ================================================================
 *  Memory Game — Main Stylesheet
 *  Kiosk 1080 × 1920 vertical  |  Touch-first  |  No scroll
 * ================================================================ */

/* ---- Google Font ---- */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800;900&display=swap');

/* ================================================================
 *  CSS Variables / Design Tokens (BBVA Theme)
 * ================================================================ */
:root {
  --color-bg-dark:      #001935;        /* BBVA Deep Navy */
  --color-surface:      rgba(255, 255, 255, 0.08);
  --color-surface-hover:rgba(255, 255, 255, 0.15);
  --color-glass:        rgba(0, 44, 92, 0.45);
  --color-glass-border: rgba(91, 190, 255, 0.3);
  --color-text:         #ffffff;
  --color-text-muted:   rgba(255, 255, 255, 0.7);
  --color-accent:       #1464A5;        /* BBVA Blue */
  --color-accent-bright:#5BBEFF;        /* BBVA Sky/Cyan Glow */
  --color-accent-glow:  rgba(91, 190, 255, 0.5);
  --color-gold:         #00e6b8;        /* Vibrant turquoise match accent */
  --color-gold-glow:    rgba(0, 230, 184, 0.5);
  --color-danger:       #f87171;
  --color-success:      #34d399;

  --font-main:          'Outfit', system-ui, sans-serif;

  --radius-sm:   8px;
  --radius-md:  14px;
  --radius-lg:  20px;
  --radius-xl:  28px;

  --shadow-card: 0 8px 32px rgba(0, 15, 35, 0.6);
  --shadow-glow: 0 0 24px var(--color-accent-glow);

  --transition-fast:   0.25s ease;
  --transition-medium: 0.4s ease;
  --transition-slow:   0.6s cubic-bezier(0.23, 1, 0.32, 1);

  --card-gap:    14px;
  --grid-pad:    30px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-main);
  font-size: 18px;
  color: var(--color-text);
  background: var(--color-bg-dark);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;          /* prevent double-tap zoom */
}

img {
  display: block;
  max-width: 100%;
  pointer-events: none;                /* prevent drag on kiosk */
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

/* ================================================================
 *  Screens (state-driven visibility)
 * ================================================================ */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-medium), visibility 0s var(--transition-medium);
  z-index: 1;
}

.screen.active {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--transition-medium), visibility 0s 0s;
}

/* ================================================================
 *  Admin tap zone (top-left hidden)
 * ================================================================ */
#admin-tap-zone {
  position: fixed;
  top: 0;
  left: 0;
  width: 100px;
  height: 100px;
  z-index: 1000;
  /* invisible */
}

/* ================================================================
 *  Floating logo
 * ================================================================ */
.floating-logo {
  height: 120px;
  width: auto;
  max-width: 500px;
  object-fit: contain;
  filter: drop-shadow(0 6px 24px rgba(0, 25, 53, 0.7));
  pointer-events: none;
  flex-shrink: 0;
}

/* ================================================================
 *  S T A N D B Y   (Slideshow)
 * ================================================================ */
#standby-screen {
  background: var(--color-bg-dark);
  justify-content: center;
}

#slideshow-container {
  position: absolute;
  inset: 0;
}

.slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 1.5s ease;
}

.slide.active {
  opacity: 1;
}

.touch-prompt {
  position: absolute;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--color-text);
  text-shadow: 0 2px 12px rgba(0,0,0,0.7);
  letter-spacing: 0.05em;
  opacity: 0.85;
  animation: pulse-opacity 2.5s ease-in-out infinite;
  z-index: 2;
  text-align: center;
  padding: 14px 32px;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-glass-border);
}

@keyframes pulse-opacity {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}

/* ================================================================
 *  W E L C O M E
 * ================================================================ */
#welcome-screen {
  justify-content: center;
  gap: 40px;
}

#welcome-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: -1;
}

#welcome-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(10, 10, 20, 0.3) 0%,
    rgba(10, 10, 20, 0.6) 100%
  );
}

#welcome-screen .floating-logo {
  height: 120px;
  max-width: 420px;
  z-index: 1;
}

#welcome-title {
  font-size: 2.4rem;
  font-weight: 800;
  text-align: center;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
  z-index: 1;
  padding: 0 40px;
  line-height: 1.2;
}

.btn-play {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 26px 80px;
  border-radius: var(--radius-xl);
  color: #fff;
  background: linear-gradient(135deg, #1464A5, #5BBEFF);
  box-shadow:
    0 0 40px var(--color-accent-glow),
    0 8px 24px rgba(0, 25, 53, 0.5);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  z-index: 1;
  animation: btn-glow 2.5s ease-in-out infinite;
  text-transform: uppercase;
}

.btn-play:active {
  transform: scale(0.95);
  box-shadow:
    0 0 20px var(--color-accent-glow),
    0 4px 12px rgba(0, 0, 0, 0.3);
}

@keyframes btn-glow {
  0%, 100% {
    box-shadow:
      0 0 30px var(--color-accent-glow),
      0 8px 24px rgba(0, 0, 0, 0.35);
  }
  50% {
    box-shadow:
      0 0 60px var(--color-accent-glow),
      0 8px 32px rgba(0, 0, 0, 0.4);
  }
}

/* ================================================================
 *  G A M E   S C R E E N
 * ================================================================ */
#game-screen {
  background-size: cover;
  background-position: center;
  padding: 30px var(--grid-pad) 20px;
  gap: 0;
}

/* Overlay to darken background behind cards */
#game-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(10, 10, 20, 0.45) 0%,
    rgba(10, 10, 20, 0.65) 100%
  );
  z-index: 0;
}

#game-screen > * {
  position: relative;
  z-index: 1;
}

#game-screen .floating-logo {
  height: 90px;
  margin-bottom: 16px;
}

/* ---- Stats bar ---- */
#stats-bar {
  display: flex;
  justify-content: center;
  gap: 40px;
  padding: 12px 36px;
  margin-bottom: 20px;
  border-radius: var(--radius-lg);
  background: var(--color-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--color-glass-border);
  width: fit-content;
}

.stat {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.stat-icon {
  font-size: 1.4rem;
}

/* ---- 4×4 Grid ---- */
#game-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 980px;
  flex: 1;
  min-height: 0;  /* allow grid to shrink */
  padding: 10px 0;
  margin: 0 auto;
}

/* ---- Card ---- */
.card {
  perspective: 1200px;
  cursor: pointer;
  border-radius: var(--radius-md);
  position: relative;
  width: 100%;
  height: 100%;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform var(--transition-slow);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 20, 50, 0.5);
}

.card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(91, 190, 255, 0.3);
  box-sizing: border-box;
}

.card-facedown {
  background: #00142e;
}

.card-facedown img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--radius-md) - 2px);
}

.card-faceup {
  transform: rotateY(180deg);
  background: #001229;
  border-color: rgba(91, 190, 255, 0.6);
}

.card-faceup img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--radius-md) - 2px);
}

/* Matched glow effect */
.card.matched .card-face {
  border-color: #00E6B8;
  box-shadow:
    0 0 24px rgba(0, 230, 184, 0.6),
    inset 0 0 12px rgba(0, 230, 184, 0.3);
}

.card.matched .card-inner {
  animation: match-pop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes match-pop {
  0%   { transform: rotateY(180deg) scale(1); }
  50%  { transform: rotateY(180deg) scale(1.08); }
  100% { transform: rotateY(180deg) scale(1); }
}

/* Mismatch shake (applied via flipBack) */
.card.shake .card-inner {
  animation: card-shake 0.4s ease;
}

@keyframes card-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

/* ---- Standby button (relocated to top right corner) ---- */
.btn-standby {
  position: absolute;
  top: 28px;
  right: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-size: 1.4rem;
  background: var(--color-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-glass-border);
  color: var(--color-text);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.btn-standby:active {
  background: var(--color-surface-hover);
  transform: scale(0.92);
}

/* ---- Small discrete Fullscreen button (relocated to top right area) ---- */
.btn-fullscreen {
  position: fixed;
  top: 28px;
  right: 96px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 1.3rem;
  background: var(--color-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-glass-border);
  color: var(--color-text);
  z-index: 1000;
  opacity: 0.35;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.btn-fullscreen:active {
  opacity: 0.95;
  background: var(--color-surface-hover);
  transform: scale(0.92);
}

/* Screen camera shake on match */
.screen-camera-shake {
  animation: camera-shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes camera-shake {
  0%, 100% { transform: translate(0, 0) scale(1); }
  20%      { transform: translate(-8px, 6px) scale(1.008); }
  40%      { transform: translate(8px, -6px) scale(1.008); }
  60%      { transform: translate(-5px, 3px) scale(1.004); }
  80%      { transform: translate(5px, -3px) scale(1.002); }
}

/* ================================================================
 *  W I N   O V E R L A Y
 * ================================================================ */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-medium), visibility 0s var(--transition-medium);
}

.overlay.visible {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--transition-medium), visibility 0s 0s;
}

#win-overlay {
  background: rgba(10, 10, 20, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

#confetti-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  border-radius: 3px;
  opacity: 0;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0%   { transform: translateY(-10vh) rotate(0deg);    opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg);  opacity: 0; }
}

.win-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  z-index: 1;
  padding: 0 40px;
  animation: win-entrance 0.6s ease backwards;
  animation-delay: 0.2s;
}

@keyframes win-entrance {
  0% { opacity: 0; transform: scale(0.8) translateY(30px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

#win-title {
  font-size: 3.2rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--color-gold), #fbbf24, var(--color-gold));
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  text-align: center;
  line-height: 1.1;
  text-shadow: none;
}

#win-message {
  font-size: 1.4rem;
  color: var(--color-text-muted);
  text-align: center;
}

.win-stats {
  display: flex;
  gap: 48px;
}

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

.win-stat-value {
  font-size: 3rem;
  font-weight: 900;
  color: var(--color-text);
}

.win-stat-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

#win-overlay .btn-play {
  margin-top: 16px;
  font-size: 1.5rem;
  padding: 22px 60px;
}

/* ================================================================
 *  P I N   M O D A L
 * ================================================================ */
#pin-modal {
  background: rgba(10, 10, 20, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 100;
}

.pin-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.pin-content h2 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-text);
}

#pin-display {
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: 0.5em;
  color: var(--color-accent);
  min-width: 200px;
  text-align: center;
}

#pin-display.shake {
  animation: card-shake 0.5s ease;
  color: var(--color-danger);
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  max-width: 320px;
}

.pin-btn {
  width: 88px;
  height: 88px;
  border-radius: var(--radius-md);
  font-size: 2rem;
  font-weight: 700;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-glass-border);
  transition: background var(--transition-fast), transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pin-btn:active {
  background: var(--color-surface-hover);
  transform: scale(0.93);
}

.pin-btn.pin-action {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.pin-btn.pin-action.cancel-btn {
  color: var(--color-danger);
}

/* ================================================================
 *  A D M I N   P A N E L   (overlay — styles in admin.css)
 * ================================================================ */
#admin-panel {
  z-index: 90;
  background: rgba(10, 10, 20, 0.96);
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
}

/* ================================================================
 *  Utility animations
 * ================================================================ */
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0); }
}
