
/*responsive issues are completely fixed by Gihan Harindra(GihanIT)*/
:root {
  /* Dark theme (default) */
  --vault-blue: #052c6b;
  --vault-blue-rgb: 5, 44, 107;
  --vault-yellow: #ffd23f;
  --muted: #b6c2d8;
  --panel: #0b1730;
  --glass: rgba(255, 255, 255, 0.04);
  --card-back: #0a2340;
  --accent-glow: 0 6px 30px rgba(37, 152, 255, 0.12);
  --accent-glow-intense: 0 8px 35px rgba(37, 152, 255, 0.25);
  --bg-gradient-start: #001021;
  --bg-gradient-end: #021232;
}

/* Light theme variables */
[data-theme="light"] {
  --vault-blue: #1a4d98;
  --vault-blue-rgb: 26, 77, 152;
  --vault-yellow: #ffc107;
  --muted: #2c3e50;
  --panel: #f8f9fa;
  --glass: rgba(0, 0, 0, 0.04);
  --card-back: #e9ecef;
  --accent-glow: 0 6px 30px rgba(37, 152, 255, 0.2);
  --accent-glow-intense: 0 8px 35px rgba(37, 152, 255, 0.35);
  --bg-gradient-start: #f8f9fa;
  --bg-gradient-end: #e9ecef;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  background: radial-gradient(1200px 700px at 10% 10%, rgba(2, 46, 84, 0.5), transparent),
              radial-gradient(900px 500px at 90% 90%, rgba(3, 20, 60, 0.45), transparent),
              linear-gradient(180deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 60%);
  color: var(--muted);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding: 2.4rem;
}

.page-container {
  width: 100%;
}

.app {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 2rem;
  align-items: start;
}

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  padding: 1.6rem;
  box-shadow: var(--accent-glow);
  min-height: 420px;
  position: relative;
  z-index: 50; /* ensure left panel floats above the game area */
}

.panel.leaderboard {
  max-width: 320px;
  margin-left: 0.6rem;
}

.lb-list { margin-top: 0.8rem; display:flex; flex-direction:column; gap:0.45rem }
.lb-row { display:flex; justify-content:space-between; gap:0.6rem; padding:0.45rem; border-radius:8px; background:rgba(255,255,255,0.02); font-size:0.92rem }
.lb-controls { display:flex; gap:0.5rem; margin-top:0.8rem }
.lb-list { min-height: 48px; }
.muted-note { color:var(--muted); font-size:0.85rem }

.brand {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  margin-bottom: 1rem;
}

.vault-badge {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--vault-blue), #123a78);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--vault-yellow);
  font-weight: 700;
  font-family: 'Share Tech Mono', monospace;
  border: 2px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 6px 24px rgba(17, 68, 128, 0.25), inset 0 -8px 20px rgba(0, 0, 0, 0.4);
  font-size: 1.6rem;
}

h1.title {
  font-size: 1.35rem;
  margin: 0;
  color: var(--vault-yellow);
  font-family: 'Share Tech Mono', monospace;
  letter-spacing: 0.08rem;
  text-transform: uppercase;
  font-weight: 700;
}

.subtitle {
  font-size: 0.92rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.score-box {
  margin-top: 1.4rem;
  background: var(--panel);
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  overflow: visible; /* allow stars and small popups to overflow */
  z-index: 60;
}

.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}

.score-row .label {
  font-size: 0.86rem;
  color: var(--muted);
}

.score-big {
  font-weight: 700;
  color: var(--vault-yellow);
  font-size: 1.4rem;
}

.stars {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  position: relative;
  z-index: 70;
}

.star {
  width: 40px;
  height: 32px;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--vault-yellow), #f7c84b);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #00142b;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}

.star--lost {
  opacity: 0.18;
  filter: grayscale(1);
}

.timer-panel {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.timer-value {
  background: linear-gradient(90deg, #021a43, #06254f);
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  color: var(--muted);
  font-family: 'Share Tech Mono', monospace;
}

.timer-bar {
  height: 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  margin-top: 8px;
  overflow: hidden;
  width: 140px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.timer-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--vault-yellow), #f7c84b);
  transition: width 0.6s linear;
}

.controls {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}

.btn.ghost#playDemo {
  background: linear-gradient(90deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border: 1px dashed rgba(255,255,255,0.04);
}

/* confetti canvas covers the main area when active */
#confettiCanvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  display: none;
}

/* accessible focus style for mute button */
#mute:focus, #mute[aria-pressed="true"] {
  outline: 3px solid rgba(255, 210, 63, 0.35);
  outline-offset: 2px;
}

.btn {
  border: none;
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  background: linear-gradient(180deg, var(--vault-yellow), #f0c33a);
  color: #021021;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.btn.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.btn--active {
  background: var(--vault-yellow);
  color: #00142b;
  border-color: transparent;
}

.hint {
  margin-top: 1rem;
  font-size: 0.84rem;
  color: #9fb6d9;
}

.game {
  padding: 1.2rem;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  border: 1px solid rgba(255, 255, 255, 0.03);
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  z-index: 1; /* keep the game under the left panel */
}

.top-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.progress {
  font-family: 'Share Tech Mono', monospace;
  color: var(--muted);
  font-size: 0.9rem;
}

.deck {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 720px;
  padding: 1rem;
  align-content: center;
  justify-items: center;
  justify-content: center;
}

.card {
  width: 140px;
  height: 140px;
  border-radius: 12px;
  perspective: 1000px;
  user-select: none;
  position: relative;
  z-index: 1;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .45s cubic-bezier(.2, .9, .2, 1);
}

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

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.card-back {
  background: linear-gradient(180deg, var(--card-back), #041a37);
  box-shadow: inset 0 -8px 30px rgba(0, 0, 0, 0.6);
}

.card-back .logo {
  font-family: 'Share Tech Mono', monospace;
  color: var(--vault-yellow);
  font-weight: 700;
  font-size: 1.4rem;
}

.card-front {
  transform: rotateY(180deg);
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-front img {
  max-width: 84%;
  max-height: 84%;
  display: block;
  border-radius: 6px;
}

.card.matched .card-inner {
  animation: matchPulse .9s ease-in-out 1;
}

@keyframes matchPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

/* Particle animation for matched cards */
.match-particle {
  position: fixed;
  width: 8px;
  height: 8px;
  background: radial-gradient(circle, var(--vault-yellow), #f7c84b);
  border-radius: 50%;
  pointer-events: none;
  z-index: 1000;
  animation: particleBurst 0.8s ease-out forwards;
  box-shadow: 0 0 8px rgba(255, 210, 63, 0.8);
}

@keyframes particleBurst {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(0);
    opacity: 0;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(1, 6, 12, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

.modal-box {
  background: linear-gradient(180deg, #061a35, #03203d);
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  width: min(580px, 94%);
  color: var(--muted);
  box-shadow: 0 20px 60px rgba(2, 16, 40, 0.7);
}

.modal-box h2 {
  color: var(--vault-yellow);
  font-family: 'Share Tech Mono', monospace;
  margin: 0 0 0.6rem;
}

/* High Scores table styles (inherits Pip-Boy theme) */
#highScoresContainer table th,
#highScoresContainer table td {
  padding: 8px 10px;
}
#highScoresContainer table thead th {
  color: var(--vault-yellow);
  font-family: 'Share Tech Mono', monospace;
  font-weight: 700;
}
#highScoresContainer table tbody tr td {
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.modal-stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.stat-card {
  background: rgba(255, 255, 255, 0.02);
  padding: 0.8rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.02);
  min-width: 120px;
}

.confetti {
  height: 80px;
  margin-top: 0.6rem;
}

.difficulty-btn {
  background: #22304a;
  color: var(--muted);
  border: 1px solid rgba(255,255,255,0.08);
  transition: background 0.2s, color 0.2s;
  cursor: pointer;
}
.difficulty-btn.btn--active {
  background: var(--vault-yellow);
  color: #00142b;
  border-color: transparent;
}

.footer {
  width: 100%;
  max-width: 1100px;
  margin: 3rem auto 0;
  padding: 1rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-family: 'Share Tech Mono', monospace;
  font-weight: 500;
  color: var(--vault-yellow);
  letter-spacing: 0.05rem;
  font-size: 0.9rem;
}

.vault-badge--small {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 1rem;
  background: linear-gradient(180deg, var(--vault-blue), #123a78);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 3px 12px rgba(17, 68, 128, 0.15), inset 0 -4px 10px rgba(0, 0, 0, 0.2);
}

.footer-info {
  color: var(--muted);
  font-size: 0.75rem;
}


@media (max-width: 900px) {
  body {
    padding: 1rem; 
  }
  .app {
    grid-template-columns: 1fr; 
    max-width: 920px;
    margin: 20px auto; 
  }
  .panel {
    order: 2; 
    min-height: auto;
  }
  .game {
    order: 1;
  }
  .deck {
    grid-template-columns: repeat(4, 1fr); 
    gap: 12px;
    padding: 0.5rem; 
    max-width: 100%;
  }
  .card {
    width: min(100%, 120px);
    height: auto;
    aspect-ratio: 1 / 1;
  }
  .page3 {
    margin-bottom: 50px;
  }
  .footer {
    margin-top: 2rem auto 0;
    padding: 1rem 0;
  }
  .star { width: 34px; height: 28px; }
}
@media (max-width: 480px) {
  .deck {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
  .card {
    width: 100%;
  }
  .panel {
    padding: 1rem; 
  }
  .controls {
    flex-direction: column;
  }
  .btn {
    width: 100%;
  }
  .footer {
    padding: 1rem;
    margin-top: 1.5rem auto 0;
  }
  .footer-brand {
    font-size: 0.8rem;
    flex-direction: column;
    gap: 0.3rem;
  }
}