/* ===================== RESET & ROOT ===================== */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
:root {
  --gold:        #D4AF37;
  --gold-light:  #F0D060;
  --gold-dark:   #9A7C1A;
  --navy:        #060F1E;
  --navy-mid:    #0D1F3C;
  --navy-lit:    #162A50;
  --cream:       #F5E6C8;
  --cream-dim:   #B8A880;
  --success:     #27AE60;
  --danger:      #E74C3C;
  --easy-clr:    #27AE60;
  --med-clr:     #E67E22;
  --hard-clr:    #C0392B;
  --lgs-clr:     #1ABC9C;
  --yks-clr:     #9B59B6;
}

/* ===================== BASE LAYOUT ===================== */
/* STEP 2 FIX: 100dvh prevents mobile browser chrome from clipping the bottom */
html {
  height: 100dvh;
  font-family: 'Nunito', sans-serif;
  background: var(--navy);
  color: var(--cream);
}
body {
  height: 100dvh;
  overflow: hidden;          /* No page-level scroll ever on mobile */
  font-family: 'Nunito', sans-serif;
  background: var(--navy);
  color: var(--cream);
}

/* ===================== BACKGROUND CANVASES ===================== */
#bgCanvas, #fxCanvas {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
#bgCanvas { z-index: 0; }
#fxCanvas  { z-index: 5; }

.otto-overlay {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background-image:
    repeating-linear-gradient(45deg,  rgba(212,175,55,.04) 0px, rgba(212,175,55,.04) 1px, transparent 1px, transparent 28px),
    repeating-linear-gradient(-45deg, rgba(212,175,55,.04) 0px, rgba(212,175,55,.04) 1px, transparent 1px, transparent 28px);
}

.mosque-footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 100px; z-index: 1; pointer-events: none;
}

/* ===================== SCREENS — MOBILE DEFAULT ===================== */
/* Mobile: every screen is fixed/full-viewport, no scroll */
.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.screen.hidden { display: none !important; }

/* ===================== BACK BUTTON ===================== */
#backBtn {
  display: none; align-items: center; gap: 5px;
  padding: 6px 14px;
  background: rgba(212,175,55,.1);
  border: 1px solid rgba(212,175,55,.35);
  border-radius: 30px; cursor: pointer;
  color: var(--gold); font-family: 'Nunito', sans-serif;
  font-size: clamp(.72rem, 2vw, .88rem); font-weight: 700;
  transition: all .25s ease;
  white-space: nowrap; flex-shrink: 0;
  position: relative; z-index: 1;
  pointer-events: auto;
}
#backBtn.visible { display: flex; }
#backBtn:hover { background: rgba(212,175,55,.22); transform: translateX(-2px); }

/* ===================== INTRO SCREEN ===================== */
#introScreen {
  text-align: center;
  gap: 0;
  padding: 20px;
}
.intro-crescent {
  font-size: clamp(3rem, 8vw, 5rem); line-height: 1;
  animation: floatBob 4s ease-in-out infinite;
  filter: drop-shadow(0 0 25px rgba(212,175,55,.8));
  margin-bottom: 12px;
}
.intro-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(1.8rem, 6vw, 4rem);
  font-weight: 900; line-height: 1.05;
  background: linear-gradient(135deg, #9A7C1A 0%, #D4AF37 30%, #F0D060 55%, #D4AF37 75%, #9A7C1A 100%);
  background-size: 300% 300%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmerGold 4s linear infinite;
  margin-bottom: 6px;
}
.intro-tagline {
  font-size: clamp(.75rem, 2vw, 1rem);
  color: var(--cream-dim); letter-spacing: 4px;
  text-transform: uppercase; margin-bottom: 16px;
}
.divider {
  display: flex; align-items: center; gap: 12px;
  max-width: 340px; margin: 0 auto 16px;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(to right, transparent, var(--gold), transparent);
}
.divider span { color: var(--gold); font-size: 1.2rem; }
.intro-desc {
  max-width: 420px; font-size: clamp(.8rem, 2vw, .95rem); line-height: 1.7;
  color: var(--cream-dim); margin-bottom: 30px;
}
.intro-desc strong { color: var(--gold); }

/* ===================== BUTTONS ===================== */
.btn-gold {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 15px 45px;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold), var(--gold-light));
  background-size: 200%;
  color: var(--navy); font-family: 'Cinzel', serif;
  font-size: clamp(.9rem, 2.5vw, 1.1rem); font-weight: 700;
  border: none; border-radius: 60px; cursor: pointer;
  letter-spacing: 2px; text-transform: uppercase;
  box-shadow: 0 0 35px rgba(212,175,55,.4), 0 10px 30px rgba(0,0,0,.5);
  transition: all .35s ease; position: relative; overflow: hidden;
  animation: shimmerGold 3s linear infinite;
}
.btn-gold:hover { transform: translateY(-3px) scale(1.02); }
.btn-gold:active { transform: scale(.97); }
.btn-outline {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 28px;
  background: transparent;
  color: var(--gold); font-family: 'Cinzel', serif;
  font-size: clamp(.8rem, 2vw, .9rem); font-weight: 700;
  border: 2px solid var(--gold);
  border-radius: 50px; cursor: pointer;
  letter-spacing: 1px; transition: all .3s ease;
}
.btn-outline:hover { background: rgba(212,175,55,.12); transform: translateY(-2px); }

/* ===================== LEVEL/CATEGORY SCREEN — MOBILE ===================== */
#levelScreen {
  padding: 0;
  overflow: hidden;
}

.screen-header {
  flex-shrink: 0;
  text-align: center;
  padding: 14px 20px 8px;
  width: 100%;
}
.screen-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(1.1rem, 3.5vw, 1.8rem); font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(212,175,55,.4);
  margin-bottom: 2px;
}
.screen-sub { color: var(--cream-dim); font-size: clamp(.7rem, 2vw, .85rem); }

/* 5-card grid: fills all remaining vertical space (mobile default) */
.levels-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding: 10px 14px 12px;
  width: 100%;
  min-height: 0;
}

.level-card {
  background: linear-gradient(150deg, var(--navy-mid), var(--navy-lit));
  border: 1.5px solid rgba(212,175,55,.22);
  border-radius: 16px;
  padding: 10px 8px;
  cursor: pointer; text-align: center; position: relative;
  overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  transition: all .35s cubic-bezier(.175,.885,.32,1.275);
  min-height: 0;
}
.level-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--lc); border-radius: 16px 16px 0 0;
}
.level-card:hover {
  transform: translateY(-6px) scale(1.03);
  border-color: var(--lc);
  box-shadow: 0 16px 40px rgba(0,0,0,.5), 0 0 20px color-mix(in srgb, var(--lc) 30%, transparent);
}
.level-card[data-lvl="easy"]   { --lc: var(--easy-clr); }
.level-card[data-lvl="medium"] { --lc: var(--med-clr);  }
.level-card[data-lvl="hard"]   { --lc: var(--hard-clr); }
.level-card[data-lvl="lgs"]    { --lc: var(--lgs-clr);  }
.level-card[data-lvl="yks"]    { --lc: var(--yks-clr);  }

.lc-icon {
  font-size: clamp(1.4rem, 3.5vw, 2.8rem);
  display: block;
  animation: floatBob 3.5s ease-in-out infinite;
  line-height: 1;
}
.level-card:nth-child(2) .lc-icon { animation-delay: .5s; }
.level-card:nth-child(3) .lc-icon { animation-delay: 1s; }
.level-card:nth-child(4) .lc-icon { animation-delay: 1.5s; }
.level-card:nth-child(5) .lc-icon { animation-delay: 2s; }

.lc-name {
  font-family: 'Cinzel', serif;
  font-size: clamp(.75rem, 1.8vw, 1.15rem);
  font-weight: 700; color: var(--lc);
  line-height: 1.1;
}
.lc-grade {
  font-size: clamp(.6rem, 1.3vw, .78rem);
  color: var(--cream-dim); letter-spacing: .5px;
}
.lc-stars {
  font-size: clamp(.75rem, 1.5vw, 1rem);
  line-height: 1;
}
.lc-desc {
  font-size: clamp(.58rem, 1.2vw, .76rem);
  color: var(--cream-dim); line-height: 1.4;
  display: none;
}
.lc-badge {
  display: inline-block; padding: 3px 10px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--lc); border-radius: 20px;
  font-size: clamp(.55rem, 1.1vw, .74rem);
  color: var(--lc); font-weight: 700;
  white-space: nowrap;
}

/* Tall screens: show descriptions */
@media (min-height: 700px) {
  .lc-desc { display: block; }
}

/* ===================== GAME SCREEN — SHARED ===================== */
#gameScreen {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  align-items: stretch;
  justify-content: flex-start;
}

/* ── Game Header Bar ── */
.game-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  gap: 6px;
  background: rgba(212,175,55,.07);
  border-bottom: 1px solid rgba(212,175,55,.18);
}
.hdr-center {
  flex: 1; text-align: center; min-width: 0; overflow: hidden;
}
.hdr-stats {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.stat-cell { text-align: center; min-width: 36px; }
.stat-lbl {
  font-size: clamp(.52rem, 1.5vw, .65rem);
  color: var(--cream-dim); text-transform: uppercase; letter-spacing: .8px;
}
.stat-val {
  font-family: 'Cinzel', serif;
  font-size: clamp(.8rem, 2.5vw, 1.2rem);
  font-weight: 700; color: var(--gold); line-height: 1.1;
  transition: color .3s;
}
.stat-val.urgent { color: var(--danger); animation: pulse .5s ease-in-out infinite; }
.game-hdr-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(.62rem, 1.8vw, .85rem);
  color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lvl-tag {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: clamp(.55rem, 1.4vw, .72rem); font-weight: 700; color: #fff;
  background: var(--tag-clr, var(--gold-dark));
  white-space: nowrap;
}

/* ── Progress Bar ── */
.prog-wrap {
  flex-shrink: 0;
  width: 100%; padding: 4px 12px;
  background: rgba(0,0,0,.2);
}
.prog-labels {
  display: flex; justify-content: space-between;
  font-size: clamp(.55rem, 1.2vw, .7rem);
  color: var(--cream-dim); margin-bottom: 3px;
}
.prog-bg { background: rgba(212,175,55,.1); border-radius: 6px; height: 6px; overflow: hidden; }
.prog-fill {
  height: 100%;
  background: linear-gradient(to right, var(--gold-dark), var(--gold), var(--gold-light));
  border-radius: 6px; width: 0%;
  transition: width .5s ease;
  box-shadow: 0 0 8px rgba(212,175,55,.5);
}

/* ── Column Labels ── */
.col-labels-row {
  flex-shrink: 0;
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 5px; padding: 3px 8px 1px;
}
.col-label {
  font-family: 'Cinzel', serif;
  font-size: clamp(.55rem, 1.2vw, .72rem);
  color: var(--gold);
  text-align: center; text-transform: uppercase; letter-spacing: 1.5px;
  opacity: .85;
}

/* ── Card shared states ── */
/* Wrong / Matched */
.match-card.wrong {
  border-color: var(--danger) !important;
  background: rgba(170,30,30,.35) !important;
  animation: shake .45s ease !important;
}
.match-card.matched {
  border-color: var(--success) !important;
  background: rgba(39,174,96,.18) !important;
  pointer-events: none;
  animation: matchOut .6s ease forwards;
}

/* ── Card number badge ── */
.card-num {
  position: absolute; top: 3px; right: 5px;
  font-size: clamp(8px, 1.4vw, 11px);
  color: var(--cream-dim); opacity: .4;
  font-family: 'Cinzel', serif;
  flex-shrink: 0;
}

/* ===================== WIN SCREEN ===================== */
#winScreen { text-align: center; gap: 0; padding: 20px; }
.win-trophy {
  font-size: clamp(3.5rem, 10vw, 6rem); display: block; margin-bottom: 12px;
  animation: trophyPop .8s cubic-bezier(.175,.885,.32,1.275) forwards;
  opacity: 0;
}
.win-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(1.6rem, 5vw, 3rem); font-weight: 900;
  background: linear-gradient(135deg, #9A7C1A, #D4AF37, #F0D060, #D4AF37, #9A7C1A);
  background-size: 300%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmerGold 3s linear infinite; margin-bottom: 8px;
}
.win-sub {
  color: var(--cream-dim);
  font-size: clamp(.8rem, 2vw, 1rem);
  margin-bottom: 24px; line-height: 1.6;
}
.win-stats {
  display: flex; gap: 12px; flex-wrap: wrap;
  justify-content: center; margin-bottom: 24px;
}
.win-stat {
  background: rgba(212,175,55,.07); border: 1px solid rgba(212,175,55,.28);
  border-radius: 14px; padding: 14px 22px; min-width: 110px; text-align: center;
  animation: fadeUp .6s ease forwards; opacity: 0;
}
.win-stat:nth-child(1) { animation-delay: .2s; }
.win-stat:nth-child(2) { animation-delay: .4s; }
.win-stat:nth-child(3) { animation-delay: .6s; }
.ws-icon { font-size: 1.5rem; display: block; margin-bottom: 4px; }
.ws-val {
  font-family: 'Cinzel', serif; font-size: 1.6rem;
  font-weight: 700; color: var(--gold); display: block;
}
.ws-lbl { font-size: .7rem; color: var(--cream-dim); text-transform: uppercase; letter-spacing: 1.5px; }
.win-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ===================== KEYFRAMES ===================== */
@keyframes floatBob {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}
@keyframes shimmerGold {
  0%   { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}
@keyframes selPulse {
  0%, 100% { box-shadow: 0 0 16px rgba(212,175,55,.3); }
  50%       { box-shadow: 0 0 32px rgba(212,175,55,.6); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-7px); }
  40%     { transform: translateX(7px); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(4px); }
}
@keyframes matchOut {
  0%   { opacity: 1; transform: scale(1); }
  40%  { opacity: .7; transform: scale(1.04); }
  100% { opacity: 0; transform: scale(.8); }
}
@keyframes pulse {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.06); }
}
@keyframes trophyPop {
  0%   { transform: scale(0) rotate(-20deg); opacity: 0; }
  60%  { transform: scale(1.15) rotate(5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =================================================================
   MOBILE STYLES (≤ 768px)
   Current compact split-board design — two halves side by side,
   each half is a 2-col × 5-row grid. Fonts use clamp() for density.
   ================================================================= */
@media (max-width: 768px) {

  /* ── STEP 2 FIX: Hide branding title — only level badge shows in header ── */
  .game-hdr-title { display: none; }

  /* ── STEP 3: Disable heavy decorative animations for mobile FPS ── */
  /* Freeze all repeating animations except urgent pulse and matchOut/shake */
  .lc-icon,
  .intro-crescent,
  .win-trophy,
  .level-card:hover { animation: none !important; }

  /* No hover transforms on level cards (touch devices don't need them) */
  .level-card:hover { transform: none !important; box-shadow: none !important; }

  /* GPU-composited, zero-transition cards for smooth scrolling */
  .match-card {
    will-change: transform;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    transition: border-color .15s !important;
    box-shadow: none !important;
  }

  /* Selected: keep visible border highlight, drop costly glow animation */
  .match-card.selected { animation: none !important; }
  .match-card.left-card.selected  { box-shadow: none !important; border-color: var(--gold)    !important; }
  .match-card.right-card.selected { box-shadow: none !important; border-color: #38BDD2        !important; }

  /* Matched: keep the fade-out but no box-shadow cost */
  .match-card.matched { box-shadow: none !important; }

  /* shimmerGold on bg-gradient buttons is expensive — freeze it */
  .btn-gold, .intro-title, .win-title { animation: none !important; }

  /* Star background canvas is already hardware-composited; kill otto-overlay pattern */
  .otto-overlay { display: none; }

  /* Board wrapper — two equal halves side by side */
  #board-wrapper {
    flex: 1;
    display: flex;
    width: 100%;
    gap: 6px;
    padding: 4px 8px 6px;
    min-height: 0;
    box-sizing: border-box;
  }

  /* Each half: 2-col × 5-row compact grid */
  .card-half {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 5px;
    min-height: 0;
    min-width: 0;
  }

  /* Cards — compact, centered text, GPU-accelerated */
  .match-card {
    border-radius: 10px;
    padding: 5px 6px;
    cursor: pointer;
    font-size: clamp(12px, 3.5vw, 16px);
    line-height: 1.3;
    text-align: center;
    position: relative;
    transition: border-color .15s !important; /* only border — no shadow/bg transitions */
    border: 1.5px solid transparent;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    word-break: break-word;
    pointer-events: auto;
    will-change: transform;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }

  /* Left (gold/warm) cards */
  .match-card.left-card {
    background: linear-gradient(145deg, rgba(55,35,5,.97), rgba(80,52,8,.97));
    border-color: rgba(212,175,55,.45);
    color: #F5E6C8;
  }
  .match-card.left-card::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0;
    width: 3px; background: var(--gold); border-radius: 10px 0 0 10px;
    opacity: 0; transition: opacity .2s;
  }

  /* Right (teal/blue) cards */
  .match-card.right-card {
    background: linear-gradient(145deg, rgba(4,28,52,.97), rgba(6,46,78,.97));
    border-color: rgba(56,189,210,.45);
    color: #cde8f5;
  }
  .match-card.right-card::before {
    content: ''; position: absolute; right: 0; top: 0; bottom: 0; left: auto;
    width: 3px; background: #38BDD2; border-radius: 0 10px 10px 0;
    opacity: 0; transition: opacity .2s;
  }

  /* Selected state */
  .match-card.selected { animation: selPulse 1.1s ease-in-out infinite; }
  .match-card.left-card.selected {
    border-color: var(--gold) !important;
    background: linear-gradient(145deg, rgba(120,80,10,.95), rgba(90,60,8,.95)) !important;
    box-shadow: 0 0 22px rgba(212,175,55,.6), 0 0 6px rgba(212,175,55,.4) inset !important;
  }
  .match-card.left-card.selected::before { opacity: 1; }
  .match-card.right-card.selected {
    border-color: #38BDD2 !important;
    background: linear-gradient(145deg, rgba(10,70,115,.95), rgba(8,55,90,.95)) !important;
    box-shadow: 0 0 22px rgba(56,189,210,.6), 0 0 6px rgba(56,189,210,.4) inset !important;
  }
  .match-card.right-card.selected::before { opacity: 1; }

  /* Portrait phone: level cards go to single vertical column */
  @media (orientation: portrait) and (max-width: 600px) {
    .levels-grid {
      grid-template-columns: 1fr;
      grid-template-rows: repeat(5, 1fr);
      padding: 8px 12px 10px;
      gap: 7px;
    }
    .level-card {
      flex-direction: row;
      justify-content: flex-start;
      gap: 12px;
      padding: 8px 14px;
      border-radius: 14px;
      text-align: left;
    }
    .lc-icon {
      font-size: clamp(1.6rem, 7vw, 2.2rem);
      flex-shrink: 0;
      animation: none;
    }
    .level-card-text { display: flex; flex-direction: column; gap: 2px; }
    .lc-name { font-size: clamp(.85rem, 4vw, 1.1rem); }
    .lc-grade { font-size: clamp(.7rem, 3vw, .82rem); }
    .lc-stars { font-size: clamp(.75rem, 3vw, .9rem); }
    .lc-desc { display: none; }
    .lc-badge { font-size: clamp(.62rem, 2.5vw, .75rem); }

    #board-wrapper { gap: 4px; padding: 3px 5px 5px; }
    .card-half { gap: 4px; }
    .match-card {
      font-size: clamp(11px, 3vw, 14px);
      padding: 4px 5px;
      border-radius: 8px;
    }
  }

  /* Landscape mobile: tighten further */
  @media (max-height: 500px) and (orientation: landscape) {
    .levels-grid {
      grid-template-columns: repeat(5, 1fr);
      gap: 6px;
      padding: 6px 10px 8px;
    }
    .lc-desc { display: none; }
    .lc-icon { font-size: 1.4rem; }
    .match-card { font-size: 9px; padding: 3px 4px; }
  }
}

/* =================================================================
   DESKTOP STYLES (≥ 769px)
   Restored original layout: screens scroll naturally, game board
   is a 2-column flex layout (no sub-grid), full-size cards.
   ================================================================= */
@media (min-width: 769px) {

  /* Restore normal document flow — screens scroll, not fixed */
  html, body {
    height: auto;
    overflow: auto;
  }

  .screen {
    position: relative;
    inset: auto;
    min-height: 100dvh;
    overflow: visible;
    padding: 30px 20px 180px;
    justify-content: center;
    align-items: center;
  }

  /* Level select */
  #levelScreen {
    overflow: visible;
    padding: 30px 20px 180px;
  }
  .screen-header {
    padding: 0 0 20px 0;
  }
  .screen-title {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    margin-bottom: 6px;
  }
  .screen-sub {
    font-size: 1rem;
    margin-bottom: 0;
  }

  /* Level cards: horizontal flex row */
  .levels-grid {
    flex: none;
    display: flex;
    flex-wrap: wrap;
    gap: 28px;
    justify-content: center;
    max-width: 1050px;
    width: auto;
    padding: 0;
    min-height: 0;
    grid-template-columns: unset;
  }
  .level-card {
    width: 190px;
    border-radius: 22px;
    padding: 30px 20px 24px;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    border-width: 2px;
    min-height: unset;
  }
  .level-card::before { height: 4px; border-radius: 22px 22px 0 0; }
  .lc-icon   { font-size: 3rem; display: block; animation: floatBob 3.5s ease-in-out infinite; }
  .lc-name   { font-size: 1.2rem; }
  .lc-grade  { font-size: .82rem; margin-bottom: 6px; }
  .lc-stars  { font-size: 1.1rem; margin-bottom: 10px; }
  .lc-desc   { display: block; font-size: .82rem; margin-bottom: 14px; }
  .lc-badge  { font-size: .76rem; padding: 4px 14px; }

  /* Game screen */
  #gameScreen {
    max-width: 1060px;
    width: 100%;
    margin: 0 auto;
    padding: 20px 0 180px;
    justify-content: flex-start;
    align-items: flex-start;
    overflow: visible;
    position: relative;
    min-height: auto;
    inset: auto;
  }

  /* Header bar on desktop */
  .game-header {
    padding: 14px 24px;
    gap: 12px;
    border-radius: 18px;
    margin-bottom: 20px;
    border: 1px solid rgba(212,175,55,.2);
    border-bottom: 1px solid rgba(212,175,55,.2);
  }
  .stat-val { font-size: 1.6rem; }
  .stat-lbl { font-size: .7rem; }
  .game-hdr-title { font-size: 1rem; }
  .lvl-tag { font-size: .78rem; padding: 5px 14px; }

  /* Progress bar */
  .prog-wrap { padding: 0 0 18px 0; background: transparent; }
  .prog-labels { font-size: .78rem; margin-bottom: 6px; }
  .prog-bg { height: 8px; border-radius: 10px; }

  /* Column labels */
  .col-labels-row {
    padding: 0 0 10px 0;
    gap: 10px 20px;
  }
  .col-label { font-size: .78rem; letter-spacing: 2px; margin-bottom: 0; }

  /* Board wrapper: two side-by-side flex columns (original design) */
  #board-wrapper {
    flex: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 20px;
    width: 100%;
    padding: 0;
    min-height: 0;
    height: auto;
    box-sizing: border-box;
  }

  /* Each half: simple flex column — cards stack vertically */
  .card-half {
    display: flex;
    flex-direction: column;
    gap: 10px;
    grid-template-columns: unset;
    grid-template-rows: unset;
    min-height: 0;
    min-width: 0;
    height: auto;
  }

  /* Cards: original sizes, left-aligned text */
  .match-card {
    border-radius: 13px;
    padding: 14px 18px;
    cursor: pointer;
    font-size: .88rem;
    line-height: 1.45;
    text-align: left;
    position: relative;
    overflow: hidden;
    transition: border-color .25s, box-shadow .25s, transform .25s, background .25s;
    border: 2px solid transparent;
    display: block;
    height: auto;
    word-break: normal;
    pointer-events: auto;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }

  /* Left (gold/warm) cards */
  .match-card.left-card {
    background: linear-gradient(145deg, rgba(55,35,5,.95), rgba(75,50,8,.95));
    border-color: rgba(212,175,55,.45);
    color: #F5E6C8;
  }
  .match-card.left-card::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0;
    width: 4px; background: var(--gold); border-radius: 13px 0 0 13px;
    opacity: 0; transition: opacity .25s;
  }
  .match-card.left-card:hover:not(.matched):not(.wrong) {
    border-color: rgba(212,175,55,.9);
    background: linear-gradient(145deg, rgba(75,50,8,.98), rgba(100,68,10,.98));
    transform: translateX(5px);
    box-shadow: -5px 0 22px rgba(212,175,55,.3);
  }

  /* Right (teal/blue) cards */
  .match-card.right-card {
    background: linear-gradient(145deg, rgba(4,30,55,.95), rgba(6,48,80,.95));
    border-color: rgba(56,189,210,.45);
    color: #cde8f5;
  }
  .match-card.right-card::before {
    content: ''; position: absolute; right: 0; top: 0; bottom: 0; left: auto;
    width: 4px; background: #38BDD2; border-radius: 0 13px 13px 0;
    opacity: 0; transition: opacity .25s;
  }
  .match-card.right-card:hover:not(.matched):not(.wrong) {
    border-color: rgba(56,189,210,.9);
    background: linear-gradient(145deg, rgba(6,48,80,.98), rgba(10,70,115,.98));
    transform: translateX(-5px);
    box-shadow: 5px 0 22px rgba(56,189,210,.3);
  }

  /* Selected state on desktop */
  .match-card.selected { animation: selPulse 1.2s ease-in-out infinite; }
  .match-card.left-card.selected {
    border-color: var(--gold) !important;
    background: linear-gradient(145deg, rgba(120,80,10,.9), rgba(90,60,8,.9)) !important;
    box-shadow: 0 0 28px rgba(212,175,55,.6), 0 0 8px rgba(212,175,55,.4) inset;
  }
  .match-card.left-card.selected::before { opacity: 1; }
  .match-card.right-card.selected {
    border-color: #38BDD2 !important;
    background: linear-gradient(145deg, rgba(10,70,115,.9), rgba(8,55,90,.9)) !important;
    box-shadow: 0 0 28px rgba(56,189,210,.6), 0 0 8px rgba(56,189,210,.4) inset;
  }
  .match-card.right-card.selected::before { opacity: 1; }

  /* Card number badge */
  .card-num {
    top: 6px; right: 10px;
    font-size: .65rem;
  }

  /* Win screen adjustments */
  #winScreen { padding: 30px 20px 180px; }
  .win-trophy { font-size: 7rem; margin-bottom: 20px; }
  .win-title { font-size: clamp(2rem, 5vw, 3.8rem); margin-bottom: 10px; }
  .win-sub { font-size: 1.1rem; margin-bottom: 40px; }
  .win-stats { gap: 20px; margin-bottom: 40px; }
  .win-stat { border-radius: 16px; padding: 22px 30px; min-width: 140px; }
  .ws-icon { font-size: 2rem; margin-bottom: 6px; }
  .ws-val { font-size: 2rem; }
  .ws-lbl { font-size: .75rem; }
  .win-btns { gap: 15px; }
}
