/* ─────────────────────────────────────────────────
   MEMORY MATCH — style.css
   Aesthetic: Warm dark glass · Syne + DM Sans
   Layout: fixed viewport, sidebar + arena, NO SCROLL
───────────────────────────────────────────────── */

/* ── TOKENS ───────────────────────────────────── */
:root {
  --bg:          #0f0f13;
  --bg2:         #16161d;
  --glass:       rgba(255,255,255,0.045);
  --glass-border:rgba(255,255,255,0.09);
  --glass-hover: rgba(255,255,255,0.07);
  --text:        #ecedf5;
  --text-2:      rgba(236,237,245,0.45);
  --text-3:      rgba(236,237,245,0.22);
  --accent:      #c8a97e;        /* warm gold */
  --accent-dim:  rgba(200,169,126,0.18);
  --accent-glow: rgba(200,169,126,0.25);
  --hi:          #a78bfa;        /* soft violet */
  --hi-dim:      rgba(167,139,250,0.15);
  --gold:        #f0c060;
  --match:       #6ee7b7;
  --match-dim:   rgba(110,231,183,0.15);
  --r-sm:        10px;
  --r:           16px;
  --r-lg:        22px;
  --sidebar-w:   220px;
  --transition:  .25s cubic-bezier(.4,0,.2,1);
}

.light {
  --bg:          #f5f4f0;
  --bg2:         #edecea;
  --glass:       rgba(255,255,255,0.6);
  --glass-border:rgba(0,0,0,0.07);
  --glass-hover: rgba(255,255,255,0.8);
  --text:        #1a1916;
  --text-2:      rgba(26,25,22,0.5);
  --text-3:      rgba(26,25,22,0.2);
  --accent-dim:  rgba(180,140,80,0.12);
  --accent-glow: rgba(180,140,80,0.2);
  --hi-dim:      rgba(120,80,220,0.1);
}

/* ── RESET ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background var(--transition), color var(--transition);
  position: relative;
}

/* ── AMBIENT BLOBS ────────────────────────────── */
.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
  opacity: .55;
  transition: opacity .4s;
}
.blob-a {
  width: 420px; height: 420px;
  background: radial-gradient(circle, #3b2a6e 0%, transparent 70%);
  top: -120px; right: -80px;
}
.blob-b {
  width: 360px; height: 360px;
  background: radial-gradient(circle, #6e3b2a 0%, transparent 70%);
  bottom: -80px; left: 10%;
  opacity: .4;
}
.blob-c {
  width: 280px; height: 280px;
  background: radial-gradient(circle, #2a4a6e 0%, transparent 70%);
  top: 40%; left: 35%;
  opacity: .25;
}
.light .blob { opacity: .18; }

/* ── LAYOUT ───────────────────────────────────── */
.layout {
  position: relative; z-index: 1;
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: 18px;
  gap: 18px;
}

/* ── SIDEBAR ──────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  padding: 22px 18px 18px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  overflow: hidden;
}

/* Brand */
.brand {
  display: flex; align-items: center; gap: 9px;
  margin-bottom: 24px;
}
.brand-icon {
  color: var(--accent);
  font-size: 1.1rem;
  animation: spin 12s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.brand-name {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -.01em;
  color: var(--text);
}

/* Sidebar sections */
.sidebar-section { margin-bottom: 20px; }

.section-label {
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}

/* Difficulty buttons */
.diff-list { display: flex; flex-direction: column; gap: 4px; }

.diff-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: .88rem;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
}
.diff-btn:hover {
  background: var(--glass-hover);
  color: var(--text);
  border-color: var(--glass-border);
}
.diff-btn.active {
  background: var(--accent-dim);
  border-color: rgba(200,169,126,0.3);
  color: var(--accent);
}

.diff-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
  transition: background var(--transition);
}
.diff-btn.active .diff-dot { background: var(--accent); }

.diff-text { flex: 1; }

.diff-tag {
  font-size: .7rem;
  color: var(--text-3);
  font-weight: 400;
}
.diff-btn.active .diff-tag { color: var(--accent); opacity: .7; }

/* Stats */
.stat-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0;
}
.stat-name {
  font-size: .82rem;
  color: var(--text-2);
  font-weight: 400;
}
.stat-val {
  font-family: 'Syne', sans-serif;
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  transition: color .3s;
}
.stat-val.hi  { color: var(--hi); }
.stat-val.gold{ color: var(--gold); }

.thin-divider {
  height: 1px;
  background: var(--glass-border);
  margin: 8px 0;
}

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.restart-btn {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.restart-btn:hover {
  background: var(--accent-dim);
  border-color: rgba(200,169,126,0.3);
  color: var(--accent);
}
.restart-btn svg { flex-shrink: 0; }

.icon-pill {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text-2);
  cursor: pointer;
  font-size: .95rem;
  transition: all var(--transition);
  flex-shrink: 0;
}
.icon-pill:hover {
  background: var(--glass-hover);
  color: var(--text);
}

/* ── ARENA ────────────────────────────────────── */
.arena {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 20px;
}

.grid-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid {
  display: grid;
  /* size is computed by JS to always fit the arena */
  gap: var(--gap, 10px);
}

/* ── CARD ─────────────────────────────────────── */
.card {
  perspective: 800px;
  cursor: pointer;
}

.card-inner {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform .45s cubic-bezier(.4,0,.2,1);
  border-radius: var(--r-sm);
}

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

.card-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
}

/* Back */
.card-back-face {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  transition: border-color var(--transition), background var(--transition);
}
.card-back-face::after {
  content: '';
  width: 28%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--text-3);
  transition: background var(--transition);
}

.card:not(.flipped):not(.matched):hover .card-back-face {
  background: var(--glass-hover);
  border-color: rgba(200,169,126,0.35);
}
.card:not(.flipped):not(.matched):hover .card-back-face::after {
  background: var(--accent);
}

/* Front */
.card-front-face {
  background: var(--glass-hover);
  border: 1px solid var(--glass-border);
  transform: rotateY(180deg);
  font-size: var(--emoji-size, 1.6rem);
  line-height: 1;
}

.card.matched .card-front-face {
  background: var(--match-dim);
  border-color: rgba(110,231,183,0.4);
}
.card.matched {
  animation: matchPop .35s cubic-bezier(.34,1.56,.64,1);
}
@keyframes matchPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.card.shake .card-inner {
  animation: shakeCard .4s ease;
}
@keyframes shakeCard {
  0%,100% { transform: rotateY(180deg); }
  25%     { transform: rotateY(180deg) translateX(-5px) rotate(-1.5deg); }
  75%     { transform: rotateY(180deg) translateX(5px)  rotate(1.5deg); }
}

/* ── SCORE FLOAT ──────────────────────────────── */
.score-float {
  position: fixed;
  pointer-events: none;
  font-family: 'Syne', sans-serif;
  font-size: .9rem;
  font-weight: 700;
  color: var(--match);
  z-index: 300;
  animation: floatUp .85s ease forwards;
}
@keyframes floatUp {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-52px) scale(.85); }
}

/* ── OVERLAY ──────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10,10,15,.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
}
.overlay.show { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  padding: 40px 36px 32px;
  width: min(420px, 90vw);
  text-align: center;
  box-shadow: 0 32px 80px rgba(0,0,0,.55);
  animation: modalRise .4s cubic-bezier(.34,1.3,.64,1);
}
@keyframes modalRise {
  from { transform: translateY(24px) scale(.96); opacity: 0; }
  to   { transform: translateY(0) scale(1);      opacity: 1; }
}

.modal-top { margin-bottom: 28px; }

.modal-emoji {
  display: block;
  font-size: 2rem;
  color: var(--accent);
  margin-bottom: 14px;
  animation: spin 8s linear infinite;
}

.modal-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
  margin-bottom: 6px;
}

.modal-new-best {
  font-size: .8rem;
  font-weight: 500;
  letter-spacing: .06em;
  color: var(--gold);
  text-transform: uppercase;
  display: none;
}

.modal-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
}
.ms {
  flex: 1;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-sm);
  padding: 14px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.ms.hi { border-color: rgba(167,139,250,0.25); background: var(--hi-dim); }
.ms-v {
  font-family: 'Syne', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}
.ms.hi .ms-v { color: var(--hi); }
.ms-l {
  font-size: .65rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.cta {
  display: block; width: 100%;
  padding: 14px;
  border-radius: var(--r-sm);
  background: var(--accent);
  border: none;
  color: #0f0f13;
  font-family: 'DM Sans', sans-serif;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  margin-bottom: 12px;
}
.cta:hover { opacity: .85; transform: scale(1.02); }

.modal-close {
  background: none; border: none;
  color: var(--text-3);
  font-size: .78rem;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  letter-spacing: .06em;
  text-transform: uppercase;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text-2); }

/* ── MOBILE ───────────────────────────────────── */
@media (max-width: 600px) {
  .layout {
    flex-direction: column;
    padding: 12px;
    gap: 10px;
  }
  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 14px;
    gap: 0;
    align-items: center;
  }
  .brand { margin-bottom: 0; margin-right: auto; }
  .sidebar-section:first-of-type { order: 3; width: 100%; margin-bottom: 0; margin-top: 10px; }
  .sidebar-section:last-of-type  { display: none; } /* hide stats on mobile — they're tiny */
  .diff-list { flex-direction: row; gap: 6px; }
  .diff-tag  { display: none; }
  .sidebar-footer { order: 2; margin: 0; }
  .arena { flex: 1; border-radius: var(--r); }
}