/* =========================
   Design tokens 
   ========================= */
:root {
  /* Colors */
  --bg: #ffffff;
  --brand: #000000;
  --muted: #cacaca;
  --muted-text: #a3a3a3;
  --accent: #adecd9;
  --card-bg: #cacaca;
  --card-hover: #2d2d2e;
  --footer-bg: #1d1d1d;
  --frame: #1d1d1d;

  /* Metrics */
  --radius: 8px;
  --border-width: 2px;
  --gap: 1rem;

  /* Typography */
  --base-font-size: 16px;
  --scale-1: 1rem;        /* 16px */
  --scale-2: 1.2rem;      /* 19.2px */
  --scale-3: 1.3rem;      /* ~20.8px */
  --scale-4: 1.7rem;      /* 27.2px */
  --scale-5: 2rem;        /* 32px */
  --scale-6: 5rem;        /* 80px */
  --scale-7: 8rem;        /* 128px */

  /* Effects */
  --shadow: 0 1px 4px rgba(0,0,0,0.25);
  --focus-ring: 3px solid rgba(173,236,217,0.6);
}

/* ------------------------------------------------------------------
   Base / Resets
------------------------------------------------------------------ */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: var(--bg);
  color: var(--brand);
  line-height: 1.4;
  font-size: var(--base-font-size);
}

.container {
  max-width: min(976px, 95%);
  margin: 0 auto;
  padding: 0 1rem;
}

img { max-width: 100%; height: auto; display: block; }
button, a.btn { cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* Accessibility utilities */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* Focus handling */
:focus:not(:focus-visible) { outline: none; }

/* Explicit reset for card anchors*/
a.card,
.card { text-decoration: none; color: inherit; display: inline-block; }

.card:focus-visible,
a.card:focus-visible,
.btn:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 3px;
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 0 0 6px rgba(173,236,217,0.12);
}

/* ------------------------------------------------------------------
   Header
------------------------------------------------------------------ */
header.navbar {
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem; 
  display: flex;
  justify-content: space-between;
  align-items: center;     
}

/* ------------------------------------------------------------------
   Footer
------------------------------------------------------------------ */
.site-footer {
  background: var(--footer-bg);
  padding: 2rem 0;
  text-align: center;
}

.site-footer p {
  font-size: var(--scale-1);
  font-weight: 700;
  color: var(--muted-text);
  margin: 0;
}

/* ------------------------------------------------------------------
   Common Elements & Utilities
------------------------------------------------------------------ */
.divider {
  height: 2px;
  background: var(--brand);
  margin: 3rem 0;
}

/* Decorative Boxes */
.design-boxes { margin-top: -1rem; }
.design-boxes .box {
  width: 100%;
  background: var(--brand);
  margin: 6px 0;
}

/* Design Boxes height */
.h-4 { height: 4px; }
.h-8 { height: 8px; }
.h-13 { height: 13px; }
.h-23 { height: 23px; }
.h-41 { height: 41px; }
.h-104 { height: 104px; }

/* ------------------------------------------------------------------
   INDEX PAGE
------------------------------------------------------------------ */

/* Hero Section */
.hero { 
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 40vh; }

.hero .feedback {
  font-size: var(--scale-6);
  font-weight: 700;
}

.hero .title {
  font-size: var(--scale-7);
  font-weight: 800;
}

.tagline {
  font-size: var(--scale-1);
  font-weight: 500;
}

/* Features Section */

.features h3 {
  font-weight: 550;
  font-size: var(--scale-4);
}

.features p {
  font-size: var(--scale-2);
}


/* Second Hero Section */
.hero-alt {
  background: var(--brand);
  margin: 4rem 0;
  padding: 4rem 0;
  text-align: center;
  color: var(--bg);
}

.hero-alt h2 {
  font-size: var(--scale-6);
  font-weight: 800;
  color: var(--bg);
  margin-bottom: var(--scale-4);
}

.hero-alt p {
  font-size: var(--scale-2);
  color: var(--bg);
  margin: 0 auto;
  max-width: 600px;
}

/* Call to Action */
.cta {margin-bottom: 4rem;}

/* ------------------------------------------------------------------
   SIZE / THEME / SPEED PAGES
------------------------------------------------------------------ */
/* Base Card */
.card {
  padding: 1.2rem 1rem;
  border-radius: var(--radius);
  border: var(--border-width) solid var(--frame);
  background: var(--card-bg);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease, color 0.12s ease;
  font-size: var(--scale-2);
}

/* Hover states use :hover and :focus-visible to avoid hiding keyboard focus */
.card:hover,
.card:focus-visible { background: var(--card-hover); color: rgb(201,201,201); transform: translateY(-2px); }

.card strong {
  display: block;
  font-size: var(--scale-4)
}

.card p {
  margin: 0;
  font-size: var(--scale-1);      
  text-align: center;
  font-style: italic;   
}

.card--size,
.card--speed {
  max-width: 400px; 
  width: 100%; 
}

/* ------------------------------------------------------------------
   GAMEPLAY PAGES
------------------------------------------------------------------ */
.game-container {
  margin: 2rem auto 4rem;
  text-align: center;
}

.hud-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  max-width: 650px;
  margin: 0 auto 1.5rem;
  padding: 0 1rem;
}

.scoreboard {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  font-size: var(--scale-1);
  text-align: left;
  line-height: 3;
  font-weight: 500;
}

/* Board */
.board {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 1rem;
  display: grid;
  gap: 15px;
  justify-content: center;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* JS will set data-size attribute on .board */
.board[data-size="4"] { grid-template-columns: repeat(4, 1fr); max-width: 650px; }
.board[data-size="6"] { grid-template-columns: repeat(6, 1fr); max-width: 650px; }
.board[data-size="8"] { grid-template-columns: repeat(8, 1fr); max-width: 750px; }

/* ------------------------------------------------------------------
   Game Cards
------------------------------------------------------------------ */
.game-card {
  aspect-ratio: 1 / 1;
  position: relative;
  overflow: hidden;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: calc(var(--radius) * 1.5);
  perspective: 800px;
  transition: transform 0.12s ease, box-shadow 0.18s ease;
}

/* flip animation */
.card-inner {
  display: block;
  width: 100%;
  height: 100%;
  transition: transform var(--card-flip-duration, 400ms) ease;
  transform-style: preserve-3d;
  border-radius: inherit;
}

/* front & back faces */
.game-card .card-front,
.game-card .card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: inherit;
}

/* front face */
.game-card .card-front {
  background: var(--card-bg, #e0e0e0);
  border: 2px solid var(--frame, #1d1d1d);
  transition: background 0.2s ease, transform 0.12s ease, box-shadow 0.18s ease;
}

/* back face */
.game-card .card-back {
  background: #ffffff;
  transform: rotateY(180deg);
  border: 2px solid var(--frame, #1d1d1d);
}

/* hover + focus interactions */
.game-card:hover .card-front,
.game-card:focus-visible .card-front {
  background: var(--card-hover, #2d2d2e);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 0 10px rgba(173, 236, 217, 0.5);
}

.game-card:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 4px;
}

/* flipping & matching states */
.game-card.is-revealed .card-inner {
  transform: rotateY(180deg);
}

.game-card.is-matched {
  opacity: 0.6;
  transform: scale(0.98);
  pointer-events: none;
}

.game-card, .btn, .card {
  -webkit-tap-highlight-color: transparent;
}

/* ------------------------------------------------------------------
   RESULTS PAGE
------------------------------------------------------------------ */
.stats {
  max-width: 900px;
  margin: 0 auto;
  text-transform: capitalize;
}

.results-button {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin: 3rem 0;
}

.results-button {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin: 3rem 0 3rem;
}

/* ------------------------------------------------------------------
   Buttons
------------------------------------------------------------------ */
.btn {
  display: inline-block;
  padding: 0.75rem 2rem;
  font-size: var(--scale-4);
  font-weight: 700;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

/* Variants */
.btn-primary {
  background: var(--brand);
  color: var(--bg);
  border: var(--border-width) solid var(--frame);
}

.btn-primary:hover,
.btn-primary:focus-visible { background: var(--accent) !important; color: #333 !important; transform: translateY(-2px);  border-color: var(--frame) !important; }

.btn-secondary {
  background: var(--muted);
  color: var(--brand);
  border: var(--border-width) solid var(--frame);
}

.btn-secondary:hover,
.btn-secondary:focus-visible { background: #815454 !important; color: #fff; transform: translateY(-2px); }

/* Results page buttons */
.results-button .btn-primary { font-size: var(--scale-5); }
.results-button .btn-secondary { font-size: var(--scale-3); padding: 0.4rem 1.4rem; }

/* cancel button */
.btn-cancel.btn-secondary,
.btn-reset.btn-secondary {
  background: none;
  border: none;
  font-size: 0.9rem;   
  line-height: 1;
  box-shadow: none;
  padding: 0.2rem 0.5rem;
  font-weight: 9;
}

.btn-play {
  color: var(--brand);
  font-size: 1.5rem;
  font-weight: 700;
  background: none;
  border: none;
  box-shadow: none;
}

.btn-play:hover,
.btn-play:focus-visible { color: rgba(0,0,0,0.45); }

.btn-back {
  display: flex;
  justify-content: center;   
  margin-top: 7rem;       
}

/* ------------------------------------------------------------------
   Responsive Styles
------------------------------------------------------------------ */
@media (max-width: 600px) {

  .hero .title {
    font-size: 3rem;
    text-align: center;
  }

  .hero .feedback {
    font-size: 2rem;
    text-align: center;
  }

  .features { grid-template-columns: 1fr; }

  .hero-alt { padding: 4rem 1.5rem; }

  .hero-alt h2 {
    font-size: 1.8rem;
    line-height: 1.3;
    word-break: break-word;
  }

  .card { width: 100%; }

  .stat-row span:last-child { font-size: 2rem; }

  .btn {
    font-size: 1.2rem;
    padding: 0.6rem 1.4rem;
  }

  .game-card,
  .game-card .card-front,
  .game-card .card-back {
    border-radius: 4px !important;
  }
}

/* ------------------------------------------------------------------
   Touch Device Styles
------------------------------------------------------------------ */

/* Touch Device Styles */
@media (hover: none) and (pointer: coarse) {
  .game-card:hover .card-front,
  .btn:hover,
  .card:hover {
    background: inherit !important;
    box-shadow: none !important;
    transform: none !important;
  }

  .game-card:active .card-front,
  .btn:active,
  .card:active {
    filter: brightness(0.9);
    transform: scale(0.97);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
  }
}