/* ==========================================================================
   Erfan Khoshtabkh — Portfolio stylesheet
   1 Tokens · 2 Base · 3 Layout · 4 Components · 5 Pages · 6 Interactive effects
   ========================================================================== */

/* 1. Tokens */
:root {
  --bg: #f7f8fb; --bg-alt: #eef1f7; --surface: #ffffff;
  --text: #0f172a; --text-soft: #475569; --text-faint: #64748b;
  --border: #e2e8f0; --border-strong: #cbd5e1;
  --brand: #4f46e5; --brand-strong: #4338ca; --brand-soft: #eef2ff;
  --accent: #0891b2;
  --code-bg: #0f172a; --code-text: #e2e8f0;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / .06);
  --shadow-md: 0 10px 30px -12px rgb(15 23 42 / .18);
  --radius-s: 8px; --radius-m: 14px; --radius-l: 22px;
  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem;
  --space-5: 1.5rem; --space-6: 2rem; --space-7: 3rem; --space-8: 5rem; --space-9: 7rem;
  --container: 1120px; --header-h: 72px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --font-ui: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --font-fa: 'Vazirmatn', system-ui, sans-serif;
  --font-body: var(--font-ui);
}
:root[data-theme='dark'] {
  --bg: #0b1020; --bg-alt: #101730; --surface: #141c38;
  --text: #e8ecf8; --text-soft: #a5b0cc; --text-faint: #8a96b5;
  --border: #212b4d; --border-strong: #2f3b66;
  --brand: #818cf8; --brand-strong: #a5b4fc; --brand-soft: #1b2250;
  --accent: #22d3ee; --code-bg: #070b18;
  --shadow-md: 0 14px 34px -14px rgb(0 0 0 / .6);
}
html[dir='rtl'] { --font-body: var(--font-fa); }

/* 2. Base */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 1rem/1.7 var(--font-body);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
  transition: background .25s var(--ease), color .25s var(--ease);
}
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
h1, h2, h3 { line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
html[dir='rtl'] h1, html[dir='rtl'] h2, html[dir='rtl'] h3 { letter-spacing: 0; line-height: 1.5; }
html[dir='rtl'] .lang-en, html[dir='ltr'] .lang-fa { display: none !important; }

.skip-link {
  position: absolute; inset-inline-start: var(--space-4); top: -60px; z-index: 400;
  padding: var(--space-2) var(--space-4); background: var(--brand); color: #fff;
  border-radius: var(--radius-s); transition: top .2s;
}
.skip-link:focus { top: var(--space-3); }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* 3. Layout */
.container { width: min(100% - 2 * var(--space-5), var(--container)); margin-inline: auto; }
.section { padding-block: var(--space-8); }
.section--tight { padding-block: var(--space-6); }
.section--alt { background: var(--bg-alt); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-5); }
.two-col { display: grid; grid-template-columns: .8fr 1.2fr; gap: var(--space-7); align-items: start; }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr 1fr; } .two-col { grid-template-columns: 1fr; } }
@media (max-width: 620px) { .grid-3 { grid-template-columns: 1fr; } .section { padding-block: var(--space-7); } }

/* 4. Components */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
}

/* اثر شیشه‌ای روی لایه‌ی پشت هدر، نه خود هدر */
.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); height: var(--header-h); }
.brand { display: flex; align-items: center; gap: var(--space-3); }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; font: 700 .9rem var(--font-mono);
}
.brand-text { display: grid; line-height: 1.2; }
.brand-text small { font: 400 .72rem var(--font-mono); color: var(--text-faint); }
.nav-links { display: flex; gap: var(--space-5); font-weight: 500; font-size: .95rem; }
.nav-links a { position: relative; padding-block: .3em; color: var(--text-soft); transition: color .15s; }
.nav-links a::after {
  content: ''; position: absolute; inset-inline: 0; bottom: -2px; height: 2px;
  background: var(--brand); transform: scaleX(0); transform-origin: left; transition: transform .25s var(--ease);
}
html[dir='rtl'] .nav-links a::after { transform-origin: right; }
.nav-links a:hover, .nav-links a[aria-current='page'] { color: var(--text); }
.nav-links a:hover::after, .nav-links a[aria-current='page']::after { transform: scaleX(1); }
.header-actions { display: flex; align-items: center; gap: var(--space-2); }
.lang-toggle { display: flex; border: 1px solid var(--border-strong); border-radius: 999px; overflow: hidden; font-size: .78rem; font-weight: 600; }
.lang-toggle button { border: 0; background: none; padding: .45em .9em; color: var(--text-soft); }
.lang-toggle button[aria-pressed='true'] { background: var(--brand); color: #fff; }
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--border-strong);
  border-radius: 50%; background: none; color: var(--text-soft); transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--brand); border-color: var(--brand); }
.icon-btn svg { width: 18px; height: 18px; }
.nav-toggle { display: none; }
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after {
  content: ''; display: block; width: 16px; height: 2px; background: currentColor; position: relative;
}
.nav-toggle span::before { position: absolute; top: -5px; }
.nav-toggle span::after { position: absolute; top: 5px; }
@media (max-width: 860px) {
  .nav-toggle { display: grid; }
  .nav {
    position: fixed; inset: var(--header-h) 0 0; padding: var(--space-5); background: var(--bg);
    opacity: 0; visibility: hidden; transform: translateY(-8px);
    z-index: 45;
    overflow-y: auto;
    transition: opacity .2s var(--ease), transform .2s var(--ease), visibility .2s;
  }
  .nav.is-open { opacity: 1; visibility: visible; transform: none; }
  .nav-links { flex-direction: column; gap: 0; }
  .nav-links a { display: block; padding-block: var(--space-4); border-bottom: 1px solid var(--border); font-size: 1.1rem; }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  padding: .8em 1.5em; border: 1.5px solid transparent; border-radius: var(--radius-s);
  font-weight: 600; font-size: .95rem; white-space: nowrap;
  transition: transform .18s var(--ease), background .18s, border-color .18s, color .18s;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); }
:root[data-theme='dark'] .btn-primary { color: #0b1020; }
.btn-outline { border-color: var(--border-strong); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-ghost { color: var(--brand); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }

.chip {
  display: inline-block; padding: .3em .85em; border-radius: 999px; border: 1px solid var(--border);
  background: var(--brand-soft); color: var(--brand); font: 500 .78rem var(--font-mono);
}
.skill-list { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }
.eyebrow {
  display: inline-flex; align-items: center; gap: .6em; margin-bottom: var(--space-3);
  font: 500 .78rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--brand);
}
.eyebrow::before { content: ''; width: 22px; height: 2px; background: var(--brand); }
html[dir='rtl'] .eyebrow { letter-spacing: 0; text-transform: none; font-family: var(--font-fa); }

.card {
  padding: var(--space-5); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-m); box-shadow: var(--shadow-sm);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.card h3 { margin-bottom: var(--space-2); font-size: 1.15rem; }
.card p { color: var(--text-soft); font-size: .95rem; }
.skill-group { padding: var(--space-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-m); }
.skill-group h3 { font-size: 1rem; }
.skill-group .skill-list { margin-top: var(--space-3); }

.site-footer { padding-block: var(--space-6); border-top: 1px solid var(--border); background: var(--bg-alt); color: var(--text-faint); font-size: .9rem; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-4); }
.social-row { display: flex; gap: var(--space-2); }
.social-row a { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--border-strong); border-radius: 50%; color: var(--text-soft); transition: .15s; }
.social-row a:hover { color: var(--brand); border-color: var(--brand); }
.social-row svg { width: 16px; height: 16px; }

.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.reveal.is-visible { opacity: 1; transform: none; }

/* 5. Pages */
.hero { position: relative; isolation: isolate; overflow: hidden; padding-block: var(--space-9) var(--space-8); }
.hero::before, .hero::after { content: ''; position: absolute; z-index: -1; border-radius: 50%; filter: blur(70px); opacity: .35; animation: float 14s ease-in-out infinite; }
.hero::before { width: 380px; height: 380px; top: -80px; inset-inline-end: 8%; background: var(--brand); }
.hero::after { width: 300px; height: 300px; bottom: -60px; inset-inline-start: 4%; background: var(--accent); animation-delay: -6s; }
@keyframes float { 50% { transform: translate(24px, -28px) scale(1.08); } }
.hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: var(--space-7); align-items: center; }
@media (max-width: 960px) { .hero-grid { grid-template-columns: 1fr; } .hero { padding-block: var(--space-7); } }
.hero h1 { font-size: clamp(2rem, 1.2rem + 3.2vw, 3.4rem); margin-block: var(--space-2) var(--space-4); }
.accent { background: linear-gradient(90deg, var(--brand), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { max-width: 54ch; margin-bottom: var(--space-5); color: var(--text-soft); font-size: 1.1rem; }
.typing { display: inline-flex; align-items: center; min-height: 1.6em; margin-bottom: var(--space-3); font: 500 1rem var(--font-mono); color: var(--accent); direction: ltr; }
.typing::before { content: '> '; color: var(--text-faint); white-space: pre; }
.typing-cursor { width: 8px; height: 1.1em; margin-inline-start: 3px; background: var(--accent); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.code-card { background: var(--code-bg); color: var(--code-text); border-radius: var(--radius-l); box-shadow: var(--shadow-md); overflow: hidden; text-align: left; }
.code-dots { display: flex; gap: 6px; padding: var(--space-3) var(--space-4); border-bottom: 1px solid rgb(255 255 255 / .08); }
.code-dots i { width: 10px; height: 10px; border-radius: 50%; background: #475569; }
.code-dots i:nth-child(1) { background: #f87171; } .code-dots i:nth-child(2) { background: #fbbf24; } .code-dots i:nth-child(3) { background: #4ade80; }
.code-card pre { margin: 0; padding: var(--space-5); overflow-x: auto; font: 400 .85rem/1.8 var(--font-mono); }
.code-card .k { color: #c4b5fd; font-weight: 400; }
.code-card s { color: #86efac; text-decoration: none; }
.code-card .c { color: #64748b; } .code-card .f { color: #7dd3fc; }
.editor-tabs { display: flex; gap: 2px; padding: var(--space-2) var(--space-3) 0; border-bottom: 1px solid rgb(255 255 255 / .08); }
.editor-tab { padding: .45em .9em; border: 0; border-radius: 8px 8px 0 0; background: none; color: #94a3b8; font: 500 .75rem var(--font-mono); }
.editor-tab[aria-selected='true'] { background: rgb(255 255 255 / .08); color: #fff; }
.editor-panel[hidden] { display: none; }
.editor pre { min-height: 230px; }

.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-m); overflow: hidden; }
.stat-strip li { padding: var(--space-5); border-inline-end: 1px solid var(--border); }
.stat-strip li:last-child { border-inline-end: 0; }
.stat-num { display: block; font: 700 1.5rem var(--font-ui); color: var(--brand); }
.stat-label { color: var(--text-soft); font-size: .85rem; }
@media (max-width: 720px) { .stat-strip { grid-template-columns: 1fr 1fr; } .stat-strip li { border-bottom: 1px solid var(--border); } }

.marquee { overflow: hidden; margin-top: var(--space-6); border-block: 1px solid var(--border); padding-block: var(--space-4); mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); }
.marquee-track { display: flex; width: max-content; gap: var(--space-6); animation: scroll 32s linear infinite; direction: ltr; }
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee-track span { font: 500 1.05rem var(--font-mono); color: var(--text-faint); white-space: nowrap; }
.marquee-track span::before { content: '</> '; color: var(--brand); }
@keyframes scroll { to { transform: translateX(-50%); } }

.section-head { max-width: 640px; margin-bottom: var(--space-6); }
.section-head h2 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.2rem); }
.section-head p { margin-top: var(--space-3); color: var(--text-soft); }
.cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-5); }
.cta h2 { font-size: clamp(1.4rem, 1rem + 1.4vw, 2rem); }
.page-header { padding-block: var(--space-8) var(--space-6); border-bottom: 1px solid var(--border); }
.page-header h1 { margin-block: var(--space-2); font-size: clamp(1.9rem, 1.2rem + 2.6vw, 3rem); }
.page-header p { max-width: 60ch; color: var(--text-soft); font-size: 1.05rem; }

.profile-card { text-align: center; }
.avatar { display: grid; place-items: center; width: 96px; height: 96px; margin: 0 auto var(--space-4); border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; font: 700 1.6rem var(--font-mono); }
.profile-card h2 { font-size: 1.25rem; }
.meta-list { margin-top: var(--space-4); text-align: start; display: grid; gap: var(--space-3); font-size: .9rem; }
.meta-list span { display: block; color: var(--text-faint); font: 500 .7rem var(--font-mono); text-transform: uppercase; }
.meta-list a { color: var(--brand); word-break: break-all; }
.prose { display: grid; gap: var(--space-4); }
.prose h2 { font-size: 1.6rem; }
.prose p { color: var(--text-soft); }

.timeline { max-width: 820px; border-inline-start: 2px solid var(--border-strong); margin-inline: auto; padding-inline-start: var(--space-6); display: grid; gap: var(--space-7); }
.timeline-item { position: relative; }
.timeline-dot { position: absolute; inset-inline-start: calc(-1 * var(--space-6) - 8px); top: 6px; width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 3px solid var(--brand); }
.is-current .timeline-dot { border-color: var(--accent); box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 25%, transparent); }
.timeline-tag { font: 500 .75rem var(--font-mono); color: var(--text-faint); text-transform: uppercase; }
.timeline-item h3 { margin-block: .2em var(--space-3); font-size: 1.25rem; }
.timeline-item ul:not(.skill-list) { display: grid; gap: var(--space-2); }
.timeline-item ul:not(.skill-list) li { position: relative; padding-inline-start: 1.3em; color: var(--text-soft); }
.timeline-item ul:not(.skill-list) li::before { content: '▹'; position: absolute; inset-inline-start: 0; color: var(--brand); }
html[dir='rtl'] .timeline-item ul:not(.skill-list) li::before { content: '◃'; }

.filter-row { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-6); }
.filter-btn { padding: .5em 1.2em; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--text-soft); font-weight: 600; font-size: .85rem; transition: .15s; }
.filter-btn:hover { border-color: var(--brand); }
.filter-btn[aria-pressed='true'] { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-theme='dark'] .filter-btn[aria-pressed='true'] { color: #0b1020; }
.project-card.is-hidden { display: none; }

.contact-info { display: grid; gap: var(--space-5); }
.contact-info li { display: flex; align-items: center; gap: var(--space-4); }
.card-icon { display: grid; place-items: center; flex: none; width: 46px; height: 46px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); }
.card-icon svg { width: 22px; height: 22px; }
.contact-info .label { display: block; color: var(--text-faint); font: 500 .72rem var(--font-mono); text-transform: uppercase; }
.contact-info .value { font-weight: 600; word-break: break-all; }
.contact-info .value:hover { color: var(--brand); }
.form-grid { display: grid; gap: var(--space-4); }
.field label { display: block; margin-bottom: var(--space-2); font-size: .85rem; font-weight: 600; }
.field input, .field textarea { width: 100%; padding: .8em 1em; border: 1.5px solid var(--border-strong); border-radius: var(--radius-s); background: var(--bg); transition: border-color .15s, box-shadow .15s; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.field textarea { min-height: 140px; resize: vertical; }
.form-error { color: #dc2626; font-size: .88rem; }
.form-note { margin-top: var(--space-3); color: var(--text-faint); font-size: .82rem; }
.form-note a { color: var(--brand); }

.playground { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); align-items: stretch; }
@media (max-width: 800px) { .playground { grid-template-columns: 1fr; } }
.pg-demo { display: grid; gap: var(--space-4); align-content: center; justify-items: start; }
.pg-count { font: 700 3rem/1 var(--font-mono); color: var(--brand); }
.pg-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.pg-switch { display: inline-flex; align-items: center; gap: var(--space-3); padding: 0; border: 0; background: none; font-weight: 600; }
.pg-track { width: 46px; height: 26px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .2s; }
.pg-track::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); }
.pg-switch[aria-checked='true'] .pg-track { background: var(--brand); }
.pg-switch[aria-checked='true'] .pg-track::after { transform: translateX(20px); }
html[dir='rtl'] .pg-switch[aria-checked='true'] .pg-track::after { transform: translateX(-20px); }
.pg-role { padding: .4em .9em; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font: 500 .8rem var(--font-mono); }
.pg-role[data-on='true'] { background: var(--brand); color: #fff; }
:root[data-theme='dark'] .pg-role[data-on='true'] { color: #0b1020; }

/* 6. Interactive effects */
.scroll-progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 100; transform: scaleX(0); transform-origin: left; background: linear-gradient(90deg, var(--brand), var(--accent)); }
html[dir='rtl'] .scroll-progress { transform-origin: right; }
.card, .skill-group { position: relative; overflow: hidden; }
.card::before, .skill-group::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(320px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--brand) 16%, transparent), transparent 70%);
}
.card:hover::before, .skill-group:hover::before { opacity: 1; }
.kbd-hint { display: inline-flex; align-items: center; padding: .35em .7em; border: 1px solid var(--border-strong); border-radius: 8px; background: none; color: var(--text-soft); font: 500 .75rem var(--font-mono); }
.kbd-hint:hover { border-color: var(--brand); color: var(--brand); }
@media (max-width: 960px) { .kbd-hint { display: none; } }
.palette { position: fixed; inset: 0; z-index: 200; display: grid; place-items: start center; padding: 14vh var(--space-4) 0; background: rgb(8 12 28 / .55); backdrop-filter: blur(4px); }
.palette[hidden] { display: none; }
.palette-box { width: min(560px, 100%); overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius-m); background: var(--surface); box-shadow: var(--shadow-md); }
.palette-input { width: 100%; padding: 1em 1.2em; border: 0; border-bottom: 1px solid var(--border); background: none; outline: none; font-size: 1rem; }
.palette-list { max-height: 320px; overflow-y: auto; padding: var(--space-2); }
.palette-item { display: flex; justify-content: space-between; width: 100%; padding: .7em 1em; border: 0; border-radius: var(--radius-s); background: none; text-align: start; }
.palette-item[aria-selected='true'] { background: var(--brand-soft); color: var(--brand); }
.palette-item small { color: var(--text-faint); font-family: var(--font-mono); }
.toast { position: fixed; inset-inline: 0; bottom: var(--space-5); z-index: 300; width: max-content; max-width: 90vw; margin-inline: auto; padding: .7em 1.2em; border-radius: 999px; background: var(--text); color: var(--bg); font-weight: 600; font-size: .9rem; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .3s var(--ease); }
.toast.is-on { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .hero::before, .hero::after, .marquee-track { animation: none !important; } }

/* ---------- Tech Match game (به انتهای style.css اضافه کن) ---------- */
.game {
  max-width: 560px;
  margin-inline: auto;
}

.game-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.game-stat {
  display: grid;
  line-height: 1.3;
}

.game-stat span {
  color: var(--text-faint);
  font: 500 .72rem var(--font-mono);
  text-transform: uppercase;
}

.game-stat strong {
  font: 700 1.3rem var(--font-mono);
  color: var(--brand);
}

.game-restart {
  padding: .55em 1.1em;
  font-size: .85rem;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}

.game-card {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: none;
  perspective: 600px;
}

.game-card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform .45s var(--ease);
}

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

.game-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 4px;
  border-radius: var(--radius-m);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  text-align: center;
}

.game-front {
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff;
  font: 700 1.3rem var(--font-mono);
  box-shadow: var(--shadow-sm);
}

.game-back {
  transform: rotateY(180deg);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  color: var(--text);
  font: 600 clamp(.62rem, 2.4vw, .85rem) var(--font-mono);
  word-break: break-word;
}

.game-card.is-matched .game-back {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
}

.game-card:hover:not(.is-flipped):not(.is-matched) .game-front {
  filter: brightness(1.1);
}

.game-card:disabled {
  cursor: default;
}

.game-msg {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-m);
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .game-card-inner {
    transition: none;
  }
}