:root {
    --sq: 65px;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
}

/* ============================================================
   Games page — restyled from /memo chess/19 mar my version
   ============================================================ */
body.page-games {
    background-color: #f5f5f5;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ============================================================
   Home page — uses the same visual language as games/puzzles
   (Segoe UI, navy #223A8A, white cards on grey, soft shadows).
   ============================================================ */
body.page-home {
    background-color: #f5f5f5;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #2c3e50;
}

/* Navbar: matches games.html (logo image + Memo Chess text, navy links) */
body.page-home .navbar {
    background-color: #f5f5f5;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

body.page-home .navbar .logo {
    display: flex;
    align-items: center;
    color: #223A8A;
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
}

body.page-home .navbar .logo img {
    width: 40px;
    height: 40px;
    margin-right: 10px;
    border-radius: 8px;
    object-fit: cover;
    display: block;
}

body.page-home .navbar .logo span {
    color: #223A8A;
}

body.page-home .nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

body.page-home .nav-links a {
    color: #223A8A;
    text-decoration: none;
    font-weight: 500;
    font-size: 1.1rem;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

body.page-home .nav-links a:hover {
    background-color: #e5e7eb;
}

body.page-home .nav-links a.active,
body.page-home .nav-links a.active:hover {
    background-color: #223A8A;
    color: #ffffff;
}

/* Home page main content */
body.page-home .home-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem 1.5rem;
}

/* Hero — two-column: text on the left, demo video on the right */
body.page-home .hero-section {
    margin-bottom: 3rem;
    padding: 3rem 0;
}

body.page-home .hero-content {
    display: flex;
    align-items: center;
    gap: 8rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

body.page-home .hero-text {
    flex: 1;
    text-align: left;
}

body.page-home .hero-video {
    flex: 1;
    text-align: center;
}

body.page-home .hero-title {
    font-size: 2.5rem;
    font-weight: 400;
    color: #223A8A;
    margin: 0 0 1.5rem 0;
}

body.page-home .hero-subtitle {
    font-size: 1.15rem;
    color: #4b5563;
    line-height: 1.7;
    margin: 0;
}

body.page-home .video-container {
    max-width: 100%;
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    transform: scale(1.2);
}

body.page-home .demo-video {
    width: 100%;
    height: auto;
    display: block;
}

/* Feature cards: Games + Puzzles — fixed 450px each, centered as a pair */
body.page-home .features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 4rem;
    max-width: 1000px;
    width: 100%;
    padding: 3rem 1rem 1rem 1rem;
    margin: 0 auto;
}

body.page-home .feature-card {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 2.5rem;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

body.page-home .feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

body.page-home .feature-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 1.5rem auto;
    display: block;
    object-fit: contain;
}

body.page-home .feature-title {
    font-size: 1.5rem;
    color: #223A8A;
    font-weight: 400;
    margin: 0 0 1.25rem 0;
}

body.page-home .feature-description {
    color: #4b5563;
    line-height: 1.7;
    margin: 0 0 2rem 0;
}

body.page-home .feature-button {
    display: inline-block;
    background: linear-gradient(135deg, #223A8A 0%, #1e40af 100%);
    color: #ffffff;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
}

body.page-home .feature-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

/* Stats */
body.page-home .stats-section {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 3rem 2rem;
    margin-top: 4rem;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 700px;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

body.page-home .stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
}

body.page-home .stat-item {
    color: #2c3e50;
}

body.page-home .stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 400;
    color: #223A8A;
}

body.page-home .stat-label {
    color: #4b5563;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Pricing */
body.page-home .pricing-section {
    margin-bottom: 3rem;
}

body.page-home .pricing-header {
    text-align: center;
    margin-bottom: 3rem;
    margin-top: 6rem;
}

body.page-home .pricing-title {
    font-size: 2.5rem;
    color: #223A8A;
    font-weight: 400;
    margin: 0 0 1rem 0;
}

body.page-home .pricing-subtitle {
    color: #4b5563;
    font-size: 1.15rem;
    max-width: 600px;
    margin: 0 auto;
}

body.page-home .pricing-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    max-width: 800px;
    width: 100%;
    margin: 0 auto 3rem auto;
}

body.page-home .pricing-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-align: center;
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

body.page-home .pricing-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

body.page-home .pricing-card.featured {
    border: 2px solid #223A8A;
    transform: scale(1.05);
}

body.page-home .plan-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: #223A8A;
    color: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 400;
}

body.page-home .plan-name {
    font-size: 1.5rem;
    color: #223A8A;
    font-weight: 400;
    margin: 0 0 0.5rem 0;
}

body.page-home .plan-price {
    font-size: 3rem;
    color: #223A8A;
    font-weight: 400;
    margin-bottom: 0.5rem;
}

body.page-home .plan-period {
    color: #4b5563;
    margin: 0 0 0.25rem 0;
}

body.page-home .plan-tax-note {
    color: #9ca3af;
    font-size: 0.85rem;
    margin: 0 0 2rem 0;
}

body.page-home .plan-features {
    list-style: none;
    padding: 0;
    margin: 0 0 2rem 0;
    margin-top: auto;
}

body.page-home .plan-features li {
    padding: 0.5rem 0;
    color: #2c3e50;
}

body.page-home .plan-features li::before {
    content: "✓";
    color: #27ae60;
    font-weight: 400;
    margin-right: 0.5rem;
}

body.page-home .subscribe-btn {
    width: 100%;
    background: #223A8A;
    color: #ffffff;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 400;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

body.page-home .subscribe-btn:hover:not(:disabled) {
    background: #1e40af;
}

body.page-home .subscribe-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

/* Free tier card */
body.page-home .free-tier {
    background: #ffffff;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin: calc(1.5rem + 80px) auto 3rem;
    width: 550px;
    max-width: 100%;
    box-sizing: border-box;
}

body.page-home .free-tier h3 {
    color: #223A8A;
    margin: 0 0 1.25rem 0;
    text-align: center;
    font-weight: 400;
    font-size: 1.6rem;
}

body.page-home .free-tier ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

body.page-home .free-tier li {
    padding: 0.55rem 0;
    color: #2c3e50;
    font-size: 1.1rem;
}

body.page-home .free-tier li::before {
    content: "✓";
    color: #27ae60;
    font-weight: 400;
    margin-right: 0.5rem;
}

@media (max-width: 768px) {
    body.page-home .pricing-cards {
        grid-template-columns: 1fr;
    }
    body.page-home .pricing-card.featured {
        transform: none;
    }
    body.page-home .pricing-title {
        font-size: 2rem;
    }
}

/* ============================================================
   FAQ — ported verbatim from the 19-mar original (only the navy
   hex is normalized to #223A8A for consistency with the rest of
   the rebuild; structurally and visually identical otherwise).
   ============================================================ */
body.page-home .faq-wrap {
    margin-top: 1rem;
}

body.page-home .faq-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-top: 5rem;
}

body.page-home .faq-title {
    font-size: 2.5rem;
    font-weight: 400;
    color: #223A8A;
    margin: 0 0 1.5rem 0;
}

body.page-home .faq-subtitle {
    font-size: 1.15rem;
    color: #4b5563;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.7;
}

body.page-home .faq-container {
    background: #ffffff;
    border-radius: 12px;
    padding: 3rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-top: 3rem;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

body.page-home .faq-section {
    margin-bottom: 3rem;
}

body.page-home .section-title {
    font-size: 1.8rem;
    font-weight: 400;
    color: #223A8A;
    margin: 0 0 1.5rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid #223A8A;
}

body.page-home .faq-item {
    margin-bottom: 1.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

body.page-home .faq-item:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

body.page-home .faq-question {
    width: 100%;
    background: #f8f9fa;
    padding: 1.5rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 400;
    color: #4b5563;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s ease;
    text-align: left;
}

body.page-home .faq-question:hover {
    background: #e9ecef;
}

body.page-home .faq-icon {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

body.page-home .faq-item.open .faq-icon {
    transform: rotate(180deg);
}

body.page-home .faq-answer {
    padding: 0 1.5rem;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    background: #ffffff;
}

body.page-home .faq-item.open .faq-answer {
    padding: 1.5rem;
    max-height: 500px;
}

body.page-home .faq-answer p {
    line-height: 1.6;
    color: #555;
    margin: 0 0 1rem 0;
}

body.page-home .faq-answer p:last-child {
    margin-bottom: 0;
}

body.page-home .highlight {
    background: #fff3cd;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

body.page-home .code {
    background: #f8f9fa;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: #e74c3c;
}

body.page-home .contact-section {
    background: linear-gradient(135deg, #223A8A, #1e40af);
    color: #ffffff;
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    margin-top: 3rem;
}

body.page-home .contact-title {
    font-size: 1.5rem;
    margin: 0 0 1rem 0;
}

body.page-home .contact-text {
    margin: 0 0 1.5rem 0;
    opacity: 0.9;
}

body.page-home .contact-button {
    display: inline-block;
    background: #ffffff;
    color: #223A8A;
    padding: 1rem 2rem;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

body.page-home .contact-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Mobile */
@media (max-width: 768px) {
    body.page-home .navbar {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }
    body.page-home .navbar .logo {
        font-size: 1.1rem;
    }
    body.page-home .navbar .logo img {
        width: 32px;
        height: 32px;
        margin-right: 6px;
    }
    body.page-home .navbar .logo span {
        display: none;     /* icon-only on mobile, like games/puzzles */
    }
    body.page-home .nav-links {
        gap: 0.25rem;
    }
    body.page-home .nav-links a {
        font-size: 0.85rem;
        padding: 0.35rem 0.5rem;
    }

    body.page-home .home-content {
        padding: 1.5rem 1rem 3rem 1rem;
    }
    body.page-home .hero-section {
        padding: 1.5rem 0 2rem 0;
    }
    body.page-home .hero-content {
        flex-direction: column;
        gap: 2rem;
        padding: 0 1rem;
        text-align: center;
    }
    body.page-home .hero-text {
        text-align: center;
    }
    body.page-home .hero-title {
        font-size: 2rem;
    }
    body.page-home .hero-subtitle {
        font-size: 1rem;
    }
    body.page-home .video-container {
        transform: scale(1);    /* stop the 1.2× zoom — it overflows on phones */
    }
    body.page-home .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    body.page-home .stat-number {
        font-size: 2rem;
    }
    body.page-home .faq-title {
        font-size: 1.6rem;
    }
    body.page-home .faq-question {
        font-size: 0.95rem;
        padding: 0.85rem 1rem;
    }
    body.page-home .faq-answer p {
        padding: 0 1rem;
        font-size: 0.9rem;
    }
}

/* ============================================================
   Profile page — visual language ported from the 19-mar original
   (Segoe UI, navy #223A8A, light-weight headings, large gradient
   avatar, light-grey progress cards with green shimmer bars).
   ============================================================ */
body.page-profile {
    background-color: #f5f5f5;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #1e3a8a;
}

/* Navbar matches games/puzzles/home */
body.page-profile .navbar {
    background-color: #f5f5f5;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

body.page-profile .navbar .logo {
    display: flex;
    align-items: center;
    color: #223A8A;
    font-size: 1.5rem;
    font-weight: normal;
    text-decoration: none;
}

body.page-profile .navbar .logo img {
    width: 40px;
    height: 40px;
    margin-right: 10px;
    border-radius: 8px;
    object-fit: cover;
    display: block;
}

body.page-profile .navbar .logo span {
    color: #223A8A;
}

body.page-profile .nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

body.page-profile .nav-links a {
    color: #223A8A;
    text-decoration: none;
    font-weight: normal;
    font-size: 1.1rem;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

body.page-profile .nav-links a:hover {
    background-color: #e5e7eb;
}

body.page-profile .nav-links a.active {
    background-color: #223A8A;
    color: #ffffff;
}

/* Greeting renders as a centered "profile-header" with the original's title style */
body.page-profile .profile-greeting {
    text-align: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 2rem 3rem 2rem;
}

body.page-profile .profile-greeting h2 {
    font-size: 2.5rem;
    color: #223A8A;
    font-weight: normal;
    margin: 0 0 1rem 0;
}

body.page-profile .profile-subtitle {
    font-size: 1.15rem;
    color: #4b5563;
    max-width: 600px;
    margin: 0 auto;
}

/* Layout: 1fr / 2fr grid like the original's .profile-container */
body.page-profile .profile-layout {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    max-width: 1000px;
    margin: 0 auto;
    padding: 1rem 2rem 3rem 2rem;
}

/* Left card */
body.page-profile .profile-sidebar {
    background: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    height: fit-content;
    align-items: stretch;
    width: auto;
}

/* Big circular avatar with navy gradient */
body.page-profile .profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, #223A8A, #1e40af);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: normal;
    margin: 0 auto 1rem auto;
    box-shadow: none;
}

body.page-profile .profile-email {
    color: #4b5563;
    text-align: center;
    margin: 0 0 1.5rem 0;
    font-size: 1rem;
    word-break: break-all;
}

/* Menu items are text links (not buttons) — active state is just bold + navy */
body.page-profile .profile-menu-item {
    color: #4b5563;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: normal;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
    text-align: center;
    background: transparent;
    border: none;
    border-radius: 0;
    transition: color 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    display: block;
    cursor: pointer;
}

body.page-profile .profile-menu-item:hover {
    color: #374151;
    text-decoration: underline;
    background: transparent;
}

body.page-profile .profile-menu-item.active {
    color: #223A8A;
    font-weight: 600;
    background: transparent;
}

/* Logout / Delete buttons in the sidebar — subtle, full-width, less aggressive */
body.page-profile .profile-sidebar .logout-btn,
body.page-profile .profile-sidebar .delete-btn {
    width: 100%;
    box-sizing: border-box;
    border-radius: 8px;
    padding: 0.65rem 1rem;
    font-weight: normal;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 0.75rem;
}

body.page-profile .profile-sidebar .logout-btn {
    background: #223A8A;
    color: #ffffff;
    border: 1px solid #223A8A;
    margin-top: 2rem;
}

body.page-profile .profile-sidebar .logout-btn:hover {
    background: #1e40af;
}

body.page-profile .profile-sidebar .delete-btn {
    background: transparent;
    color: #c0392b;
    border: 1px solid #f1c2bd;
}

body.page-profile .profile-sidebar .delete-btn:hover {
    background: #fdecea;
    border-color: #c0392b;
}

/* Right side: tab content card matching original .profile-section */
body.page-profile .profile-content {
    flex: 1;
    background: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body.page-profile .profile-content h3 {
    font-size: 1.5rem;
    font-weight: normal;
    color: #223A8A;
    margin: 0 0 1.5rem 0;
}

body.page-profile .profile-content h4 {
    font-size: 1.1rem;
    font-weight: normal;
    color: #223A8A;
    margin: 0 0 0.75rem 0;
}

/* Progress stats — light-grey "progress-item" cards, like the original */
body.page-profile .progress-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

body.page-profile .stat-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
}

body.page-profile .stat-card .stat-label {
    color: #4b5563;
    font-size: 0.9rem;
    margin: 0 0 0.35rem 0;
}

body.page-profile .stat-card .stat-value {
    color: #223A8A;
    font-size: 1.5rem;
    font-weight: normal;
    margin: 0;
}

/* Progress bars — green shimmer gradient, matching the original */
body.page-profile .progress-bars {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1.25rem;
}

body.page-profile .progress-bars + .progress-bars {
    margin-top: 1rem;
}

body.page-profile .progress-bars h4 {
    margin-bottom: 1rem;
}

body.page-profile .progress-row {
    display: grid;
    grid-template-columns: 110px 1fr 70px;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0;
}

body.page-profile .progress-label {
    color: #4b5563;
    font-size: 0.95rem;
    font-weight: normal;
}

body.page-profile .progress-bar {
    height: 12px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

body.page-profile .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #27ae60, #2ecc71);
    border-radius: 10px;
    transition: width 0.6s ease;
    position: relative;
}

body.page-profile .progress-fill::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: profile-shimmer 2s infinite;
}

@keyframes profile-shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

body.page-profile .progress-count {
    color: #27ae60;
    font-size: 1rem;
    font-weight: normal;
    text-align: right;
}

/* Billing tab */
body.page-profile .billing-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

body.page-profile .billing-plan {
    color: #223A8A;
    font-size: 1.15rem;
    font-weight: normal;
}

body.page-profile .billing-status.active {
    color: #27ae60;
    font-weight: normal;
}

body.page-profile .billing-status.inactive {
    color: #c0392b;
    font-weight: normal;
}

/* Payment history table */
body.page-profile .payment-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

body.page-profile .payment-table th,
body.page-profile .payment-table td {
    padding: 0.75rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid #ecf0f1;
}

body.page-profile .payment-table th {
    color: #4b5563;
    font-weight: normal;
    font-size: 0.85rem;
}

/* Mobile */
@media (max-width: 768px) {
    body.page-profile .navbar {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }
    body.page-profile .navbar .logo img {
        width: 32px;
        height: 32px;
        margin-right: 6px;
    }
    body.page-profile .navbar .logo span {
        display: none;
    }
    body.page-profile .nav-links {
        gap: 0.25rem;
    }
    body.page-profile .nav-links a {
        font-size: 0.85rem;
        padding: 0.35rem 0.5rem;
    }
    body.page-profile .profile-greeting {
        padding: 1.25rem 1rem 0 1rem;
    }
    body.page-profile .profile-greeting h2 {
        font-size: 1.9rem;
    }
    body.page-profile .profile-layout {
        grid-template-columns: 1fr;
        padding: 1rem 1rem 3rem 1rem;
    }
    body.page-profile .profile-avatar {
        width: 100px;
        height: 100px;
        font-size: 2.5rem;
    }
    body.page-profile .progress-stats {
        grid-template-columns: 1fr;
    }
    body.page-profile .progress-row {
        grid-template-columns: 80px 1fr 55px;
    }
}

body.page-games .navbar {
    background-color: #f5f5f5;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Logo (image + Memo Chess text) */
body.page-games .navbar .logo {
    display: flex;
    align-items: center;
    color: #223A8A;
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
}

body.page-games .navbar .logo img {
    width: 40px;
    height: 40px;
    margin-right: 10px;
    border-radius: 8px;
    object-fit: cover;
    display: block;
}

body.page-games .navbar .logo span {
    color: #223A8A;
}

/* Nav links */
body.page-games .nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

body.page-games .nav-links a {
    color: #223A8A;
    text-decoration: none;
    font-weight: 500;
    font-size: 1.1rem;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
}

body.page-games .nav-links a:hover {
    background-color: #e5e7eb;
}

body.page-games .nav-links a.active,
body.page-games .nav-links a.active:hover {
    background-color: #223A8A;
    color: #ffffff;
    font-weight: 500;
}

/* Top category tabs — underline-style on the games page */
body.page-games .games-nav {
    gap: 0;
    justify-content: center;
}

body.page-games .games-nav-tab,
body.page-games .games-nav-tab:first-child,
body.page-games .games-nav-tab:last-child {
    flex: 0 1 auto;
    min-width: 110px;
    max-width: 140px;
    padding: 0.6rem 1rem;
    background: transparent;
    color: #7f8c8d;
    font-size: 1.1rem;
    font-weight: 900;
    -webkit-text-stroke: 0.5px currentColor;    /* push past 900 by stroking the glyphs */
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    text-align: center;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
}

body.page-games .games-nav-tab:hover {
    background: transparent;
    color: #223A8A;
}

body.page-games .games-nav-tab.active {
    background: transparent;
    color: #223A8A;
    border-bottom-color: #223A8A;
}

/* -------------------------------------------------------
   Translation of the 19 mar version's styling onto the
   current games.html class names. Color = #223A8A (navy).
   ------------------------------------------------------- */

/* Outer layout — generous side padding, columns spaced like the source */
body.page-games .content {
    padding: 0.5rem 1.5rem 2rem 1.5rem;
    margin-top: 15px;       /* shift everything below the navbar down 15px */
}

body.page-games .games-layout {
    /* 3-column grid with equal outer columns (= panel width) so the board
       column sits in the true horizontal center of the layout. */
    display: grid;
    grid-template-columns: 380px auto 380px;
    column-gap: 2.5rem;
    justify-content: center;
    align-items: start;
    max-width: none;        /* let the grid size itself */
    margin: 0 auto;
    padding-top: 0.5rem;
    transform: translateX(-30px);
}

/* Sidebar is narrower than the panel — push it against the board side
   so the empty space sits on the outer edge, mirroring the panel side. */
body.page-games .games-sidebar {
    justify-self: end;
    margin-right: 10px;     /* extra breathing room between sidebar and board */
}

body.page-games .games-nav {
    margin-bottom: 1.5rem;  /* tab row to board breathing room */
}

/* Sidebar — outer container becomes a white card holding the accordion tabs */
body.page-games .games-sidebar {
    padding: 1.25rem;
    background: #ffffff;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 270px;
    /* Source has sidebar 30px below board top; tabs row + its margin pushes board down ~60px
       in our combined column, so align the sidebar to roughly the board's top. */
    margin-top: 68px;
}

body.page-games .sidebar-panel {
    gap: 1rem;
}

/* Opening family accordion (King's Pawn / Queen's Pawn / …) — the outer accordion
   layer above the per-opening accordions. Mirrors `.sidebar-tab` styling but a touch
   stronger to signal "this is the parent level". */
body.page-games .family-group {
    display: flex;
    flex-direction: column;
}

body.page-games .family-tab {
    background: #ffffff;
    border: 2px solid #adb5bd;
    border-radius: 8px;
    color: #2c3e50;
    font-size: 1.05rem;
    font-weight: 800;
    -webkit-text-stroke: 0.3px currentColor;
    padding: 0.85rem 1rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.2s ease;
}

body.page-games .family-tab:hover {
    background: #e9ecef;
    border-color: #223A8A;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

body.page-games .family-tab.active {
    background: #f1f3f5;
    border-color: #223A8A;
    color: #2c3e50;
}

/* Sub-family accordion tab (Italian, Spanish, …) — thinner, lighter border and
   no shadow so they read as quieter children of the .family-tab above them. */
body.page-games .family-items .sidebar-tab {
    border: 1px solid #e5e7eb;
    box-shadow: none;
}

body.page-games .family-items .sidebar-tab.active {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #2c3e50;
}

body.page-games .family-items {
    display: none;
    flex-direction: column;
    gap: 1rem;
    padding: 0.75rem 0 0 1rem;     /* left indent shows these are nested under the family */
}

body.page-games .family-items.active {
    display: flex;
}

/* Sidebar accordion tab (Easy, Intermediate, …) — white card-button with hover-lift */
body.page-games .sidebar-tab {
    background: #ffffff;
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    color: #2c3e50;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.75rem 1rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

body.page-games .sidebar-tab:hover {
    background: #f8f9fa;
    border-color: #223A8A;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.page-games .sidebar-tab.active {
    background: #e0e7ff;
    border-color: #223A8A;
    color: #1e40af;
    border-radius: 8px;
}

/* Two-line tab label: bold title on top, lighter "under N moves" hint below */
body.page-games .sidebar-tab .tab-label {
    display: block;
    font-size: 1.1rem;
    font-weight: 900;
    -webkit-text-stroke: 0.4px currentColor;
}

body.page-games .sidebar-tab .tab-sub {
    display: block;
    font-size: 0.95rem;
    font-weight: 400;
    color: #7f8c8d;
    margin-top: 8px;
}

body.page-games .sidebar-tab.active .tab-sub {
    color: #4f6ab8;
}

/* Submenu (game list under each tab) — sits below, slides open */
body.page-games .sidebar-items {
    gap: 0.5rem;
    padding-left: 1rem;
    margin-top: 0.5rem;
    background: transparent;
    box-shadow: none;
}

body.page-games .sidebar-items.active {
    display: flex;
}

/* Individual game / puzzle item — transparent pill by default, grey only when
   locked (gated). Slides right on hover. */
body.page-games .sidebar-item {
    background: transparent;
    border: 1px solid #ced4da;
    border-radius: 8px;
    color: #495057;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.75rem;
    text-align: left;
    transition: all 0.2s ease;
    border-left: 1px solid #ced4da; /* override the 3px tracker from the base */
}

/* Gated (locked) items keep the greyish background to signal they're paywalled. */
body.page-games .sidebar-item.locked {
    background: #f5f6f8;
}

body.page-games .sidebar-item:hover {
    background: #dee2e6;
    border-color: #adb5bd;
    color: #495057;
    transform: translateX(5px);
}

body.page-games .sidebar-item.active {
    background: #e0e7ff;
    border: 1px solid #223A8A;
    color: #223A8A;
    font-weight: normal;
    transform: translateX(6px);
    box-shadow: 0 2px 8px rgba(34, 58, 138, 0.2);
    border-left-color: #223A8A;
}

body.page-games .sidebar-item-wrapper:hover .sidebar-item-delete,
body.page-games .sidebar-item-delete {
    background: transparent;
    margin-left: 8px;
}

body.page-games .sidebar-item-delete:hover {
    background: #dee2e6;
}

/* Top tabs — already underlined-style; keep the navy underline */

/* -------------------------------------------------------
   Right side: board frame + mode tray + moves panel
   ------------------------------------------------------- */

/* Board: purple-blue gradient frame around the squares, rounded corners, deep shadow */
body.page-games .board {
    border: none;
    border-radius: 0;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
    background: transparent;
    padding: 0;
    gap: 0;
    overflow: hidden;       /* clip the corner squares so the board radius is visible */
    transform: translateX(7px);
}

body.page-games .square {
    border-radius: 0;       /* square corners — eliminates the coloured "dots" at the gaps */
}

/* Hint highlight — yellow tint on the from-square of the next move. Applied by
   the Hint button (games.html). Same palette as `.square-selected` so it reads
   as "this is the square to act on". Cleared automatically by renderBoard. */
body.page-games .square.square-hint.light {
    background-color: #f7ec5a;
}
body.page-games .square.square-hint.dark {
    background-color: #dac934;
}

/* Mode buttons live in a light-grey "tray" together with the Test button */
body.page-games .game-modes {
    width: 539px;           /* board outer width (524px) + 15px extra */
    box-sizing: border-box;
    gap: 1rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-top: 35px;
    justify-content: center;
    /* Match the board's translateX(7px) so this tray stays centered under
       the board's visual position (transform doesn't affect layout flow). */
    transform: translateX(7px);
}

body.page-games .game-mode-btn,
body.page-games .game-mode-btn:first-child,
body.page-games .game-mode-btn:last-child {
    background: #ffffff;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    color: #495057;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.55rem 1.2rem;
    min-height: 36px;
    min-width: 72px;
    flex: 0 0 auto;
    transition: all 0.2s ease;
}

body.page-games .game-mode-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

body.page-games .game-mode-btn.active {
    background: #223A8A;
    border-color: #1e40af;
    color: #ffffff;
}

body.page-games .game-mode-btn.active:hover {
    background: #1e40af;
    transform: translateY(-1px);
}

/* Test = filled-blue mode pill (looks like the others, opens test mode) */
body.page-games .game-mode-btn[data-mode="test"] {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    border: 2px solid #ee5a24;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}

body.page-games .game-mode-btn[data-mode="test"]:hover {
    background: linear-gradient(135deg, #ee5a24, #d63031);
    border-color: #d63031;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}

/* Exit (test mode) — same red gradient family but darker so it reads as "stop" */
body.page-games #testExitBtn {
    background: linear-gradient(135deg, #d63031, #a71e2e);
    border: 2px solid #a71e2e;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(214, 48, 49, 0.4);
}

body.page-games #testExitBtn:hover {
    background: linear-gradient(135deg, #a71e2e, #8b1538);
    border-color: #8b1538;
    transform: translateY(-1px);
}

/* Board control row — clean pill buttons */
body.page-games .board-controls {
    gap: 0.5rem;
    margin-top: 1rem;
}

body.page-games .board-control-btn {
    background-color: transparent;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    transition: all 0.2s ease;
}

body.page-games .board-control-btn:hover {
    background-color: transparent;
    transform: translateY(-1px);
}

/* Empty-panel placeholder (shown when no game is selected) — sits under the
   board-controls row. Hidden once a game loads. */
body.page-games .game-panel-empty {
    display: none;             /* default: a game is loaded */
    margin-top: 1rem;
    padding: 1rem;
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    background: #f8f9fa;
    border: 1px dashed #d0d4d9;
    border-radius: 8px;
}

/* When no game is loaded, hide everything in the panel except the
   board-controls row and the placeholder. */
body.page-games .game-panel.is-empty .game-panel-toggle,
body.page-games .game-panel.is-empty .game-panel-content,
body.page-games .game-panel.is-empty .play-for,
body.page-games .game-panel.is-empty .game-panel-moves-list,
body.page-games .game-panel.is-empty .puzzle-description,
body.page-games .game-panel.is-empty .hint-btn {
    display: none;
}
body.page-games .game-panel.is-empty .game-panel-empty {
    display: block;
}

/* Right column moves panel — white card */
body.page-games .game-panel {
    background-color: #ffffff;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 1.25rem;
    width: 430px;
    box-sizing: border-box;
    /* Align top with the sidebar / board */
    margin-top: 68px;
    /* Source uses gap: 3.5rem between board and moves; we add the extra here so the
       sidebar-to-board gap can stay tighter than the board-to-panel gap. */
    margin-left: 1rem;
    overflow: visible;
}

body.page-games .game-panel-toggle {
    background: transparent;
    color: #333333;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    height: 45px;
    padding: 0 1rem;
    font-size: 1.05rem;
    font-weight: 500;
    text-align: center;
    /* override the base rule's `display: flex; justify-content: space-between;`
       which would push title to the left and arrow to the right */
    display: block;
    position: relative;             /* anchor for the absolutely-positioned arrow */
    box-shadow: none;
    transition: all 0.2s ease;
}

/* Push the dropdown arrow out of the flow so the title text centers purely on
   the button width, not on (title + arrow). */
body.page-games .game-panel-toggle .toggle-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
}
body.page-games .game-panel-toggle .toggle-icon.open {
    transform: translateY(-50%) rotate(180deg);
}

body.page-games .game-panel-toggle:hover {
    background: transparent;
    border-color: #cccccc;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.page-games .game-panel-content {
    background: #f8f9fa;
    border-radius: 0 0 6px 6px;
    margin-top: 8px;
    padding: 1rem;
}

body.page-games .game-panel-section h4 {
    color: #2c3e50;
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

body.page-games .move-line[data-ply].move-active,
body.page-games .move-half.move-active {
    background: #e0e7ff;
    color: #223A8A;
}

/* Alignment fix: a `.move-line` with direct text (white-has-comment / black-has-comment
   branches in games.html) needs to start at the same x as the inner `.move-half`
   on a two-half line. The flex two-half line has outer padding-left:0 and the half
   has padding-left:6px — match that here. */
body.page-games .move-line:not(:has(.move-half)) {
    padding-left: 6px;
}

/* Lichess-style two-column layout for moves with no white comment: white and black
   each take exactly half of the line. Comment-bearing moves (which use direct text
   on the line) keep the existing single-block layout. */
body.page-games .move-line:has(.move-half) {
    display: flex;
    gap: 0;
    padding: 4px 0;         /* drop horizontal padding — the halves cover the full width */
}

body.page-games .move-line .move-half {
    flex: 0 0 50%;
    width: 50%;
    box-sizing: border-box;
    padding: 2px 6px;       /* internal text inset inside each clickable half */
}

body.page-games .puzzle-description,
body.page-games .game-panel-moves-list {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: none;
}

body.page-games .hint-btn {
    background-color: #ffffff;
    color: #495057;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-weight: 600;
    /* Override base full-width: keep it compact and centered in the panel */
    display: block;
    width: auto;
    margin: 12px auto 0 auto;
    padding: 7px 18px;
    font-size: 0.9rem;
}

body.page-games .hint-btn::before {
    content: "💡 ";
}

body.page-games .hint-btn:hover {
    background-color: #f1f3f5;
    border-color: #adb5bd;
}

/* Custom-game form picks up the same card language as the panel */
body.page-games .custom-form-header {
    background: #ffffff;
    color: #2c3e50;
    border-bottom: 1px solid #e5e7eb;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
}

body.page-games .custom-form-fields,
body.page-games .custom-form-moves-list {
    background: #ffffff;
    box-shadow: none;
}

body.page-games .custom-form-fields input,
body.page-games .custom-form-fields textarea,
body.page-games .move-comment-input {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}

body.page-games .custom-form-fields input:focus,
body.page-games .custom-form-fields textarea:focus,
body.page-games .move-comment-input:focus {
    border-color: #223A8A;
    box-shadow: 0 0 0 2px rgba(34, 58, 138, 0.15);
}

body.page-games .custom-form-actions .primary-btn,
body.page-games .custom-form-actions .cancel-btn {
    flex: 1;
    width: auto;          /* override the global .primary-btn width:100% */
    margin-top: 0;        /* override the global .primary-btn margin-top:10px */
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    color: #ffffff;
    cursor: pointer;
}

body.page-games .custom-form-actions .primary-btn {
    background: #223A8A;
}

body.page-games .custom-form-actions .primary-btn:hover {
    background: #1e40af;
}

body.page-games .custom-form-actions .cancel-btn {
    background: #95a5a6;
}

body.page-games .custom-form-actions .cancel-btn:hover {
    background: #7f8c8d;
}

/* Hamburger button — hidden on desktop, shown on mobile. Sits at the left edge
   of the navbar and toggles the off-canvas sidebar drawer. */
body.page-games .hamburger {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin-right: 8px;
    flex-direction: column;
    gap: 4px;
}
body.page-games .hamburger span {
    display: block;
    width: 24px;
    height: 3px;
    background: #223A8A;
    border-radius: 2px;
}

/* Off-canvas drawer backdrop — covers the page behind the sidebar when drawer is open */
body.page-games .drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 998;
}
body.page-games.drawer-open .drawer-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* ============================================================
   Responsive — scale the whole games page uniformly down for smaller
   laptop monitors. We use the `zoom` property (supported in Chrome,
   Edge, Safari, and Firefox 126+) so layout flow shrinks with the
   visuals rather than leaving dead space, and proportions are
   preserved exactly (navbar, board, sidebar, panel, gaps, fonts all
   scale together).
   Breakpoints:
     ≥ 1500px:  full size                (e.g. 1920px)
     1300–1499: zoom 0.92                (e.g. 1440px, 1366px)
     1150–1299: zoom 0.82                (e.g. 1280px)
     1024–1149: zoom 0.74                (small laptops)
     ≤  768px : mobile layout (separate ruleset below)
   Also at < 1500px we tighten the gap between the board and the mode
   tray below it (35px → 27px), since at smaller scales the original
   gap looks proportionally larger than intended.
   ============================================================ */
@media (max-width: 1499px) and (min-width: 769px) {
    body.page-games {
        zoom: 0.92;
    }
    body.page-games .game-modes {
        margin-top: 27px;       /* 35px - 8px */
    }
}

@media (max-width: 1299px) and (min-width: 769px) {
    body.page-games {
        zoom: 0.82;
    }
}

@media (max-width: 1149px) and (min-width: 769px) {
    body.page-games {
        zoom: 0.74;
    }
}

/* ============================================================
   Mobile layout — phones and small tablets (≤ 768px).
   Single column: navbar with hamburger → board (fills width) → mode
   buttons → right panel stacked below. The left sidebar becomes an
   off-canvas drawer toggled by the hamburger.
   ============================================================ */
@media (max-width: 768px) {
    /* Disable laptop scaling — we're using a real responsive layout here */
    body.page-games {
        zoom: 1;
        --sq: calc((100vw - 24px) / 8);   /* board fills viewport width minus 12px each side */
    }

    /* Navbar: compact. Hamburger is detached from the navbar flow and rendered
       as a floating action button (FAB) in the bottom-right corner. */
    body.page-games .navbar {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }
    body.page-games .hamburger {
        display: flex;
        position: fixed;
        bottom: 18px;
        right: 18px;
        margin: 0;
        padding: 0;
        width: 56px;
        height: 56px;
        background: #223A8A;
        border: none;
        border-radius: 50%;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
        align-items: center;
        justify-content: center;
        gap: 5px;
        z-index: 950;                       /* below drawer (999), above content */
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    body.page-games .hamburger:active {
        transform: scale(0.95);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    }
    body.page-games .hamburger span {
        background: #ffffff;                /* white bars on navy circle */
        width: 22px;
        height: 2.5px;
    }
    /* Hide the FAB while the drawer is open so it doesn't sit over the open menu */
    body.page-games.drawer-open .hamburger {
        opacity: 0;
        pointer-events: none;
    }
    body.page-games .navbar .logo {
        font-size: 1.1rem;
        flex: 0 0 auto;
        min-width: 0;
    }
    body.page-games .navbar .logo img {
        width: 32px;
        height: 32px;
        margin-right: 0;
    }
    /* Hide the "Memo Chess" text next to the logo — only the icon shows on mobile */
    body.page-games .navbar .logo span {
        display: none;
    }
    body.page-games .nav-links {
        gap: 0.25rem;
    }
    body.page-games .nav-links a {
        font-size: 0.85rem;
        padding: 0.35rem 0.5rem;
    }

    /* Content + layout: single column, board first */
    body.page-games .content {
        padding: 0.5rem 12px 2rem 12px;
        margin-top: 8px;
    }
    body.page-games .games-layout {
        display: block;
        max-width: none;
        margin: 0;
        padding-top: 0;
        transform: none;
    }

    /* Sidebar becomes off-canvas drawer */
    body.page-games .games-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 290px;
        max-width: 85vw;
        margin: 0;
        margin-right: 0;
        padding: 1rem;
        border-radius: 0;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 999;
        justify-self: auto;
    }
    body.page-games.drawer-open .games-sidebar {
        transform: translateX(0);
    }

    /* Top category tabs (By Difficulty / Openings / By GMs / Custom) — wrap to two
       rows or stay tight if they fit. */
    body.page-games .games-nav {
        margin-bottom: 0.75rem;
        flex-wrap: wrap;
        gap: 0;
        justify-content: center;
    }
    body.page-games .games-nav-tab,
    body.page-games .games-nav-tab:first-child,
    body.page-games .games-nav-tab:last-child {
        flex: 1 1 auto;
        min-width: 72px;
        max-width: none;
        font-size: 0.95rem;
        padding: 0.45rem 0.5rem;
    }

    /* Board: full width, no horizontal shift */
    body.page-games .board {
        transform: none;
        margin: 0 auto;
    }

    /* Mode tray (Normal/Black/Checkers/Empty/Test/Exit): full width, no shift */
    body.page-games .game-modes {
        width: 100%;
        margin-top: 12px;
        transform: none;
        padding: 0.6rem;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    body.page-games .game-mode-btn,
    body.page-games .game-mode-btn:first-child,
    body.page-games .game-mode-btn:last-child {
        flex: 1 1 calc(33% - 0.5rem);
        min-width: 0;
        padding: 0.5rem 0.6rem;
        font-size: 0.8rem;
    }

    /* Right panel: stack below the board, full width */
    body.page-games .game-panel {
        width: 100%;
        margin-top: 1.25rem;
        margin-left: 0;
        padding: 1rem;
    }
}

/* Modals (only when triggered from the games page) */
body.page-games .modal-content {
    border-radius: 12px;
}

body.page-games .modal-content h3 {
    color: #2c3e50;
}

body.page-games .modal-content input:focus {
    border-color: #223A8A;
    box-shadow: 0 0 0 2px rgba(34, 58, 138, 0.15);
}

body.page-games .primary-btn {
    background-color: #223A8A;
}

body.page-games .primary-btn:hover {
    background-color: #1e40af;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #333;
    padding: 0.5rem 1rem;
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.nav-links a {
    color: white;
    text-decoration: none;
    padding: 0.5rem;
}

.nav-links a:hover {
    background-color: #555;
    border-radius: 4px;
}

.nav-links a.active {
    font-weight: bold;
}

.logo {
    color: white;
    font-weight: bold;
}

.content {
    padding: 2rem;
}

/* Pricing section */
.pricing-section {
    text-align: center;
    max-width: 700px;
    margin: 2rem auto;
}

.pricing-subtitle {
    color: #555;
    font-size: 16px;
    margin-bottom: 24px;
}

.pricing-cards {
    display: flex;
    gap: 24px;
    justify-content: center;
}

.pricing-card {
    position: relative;
    flex: 1;
    max-width: 280px;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 32px 24px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.pricing-card.featured {
    border: 2px solid #007bff;
}

.pricing-card .badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: #007bff;
    color: white;
    font-size: 12px;
    font-weight: bold;
    padding: 4px 12px;
    border-radius: 12px;
}

.pricing-card h3 {
    margin: 0 0 12px;
    font-size: 18px;
}

.pricing-card .price {
    font-size: 36px;
    font-weight: bold;
    color: #333;
}

.pricing-card .price span {
    font-size: 16px;
    font-weight: normal;
    color: #888;
}

.pricing-card p {
    color: #666;
    font-size: 14px;
    margin: 12px 0 20px;
}

/* Free tier */
.free-tier {
    margin-top: 40px;
    padding: 24px;
    background: #f8f9fa;
    border-radius: 12px;
    text-align: left;
}

.free-tier h3 {
    margin: 0 0 12px;
    font-size: 16px;
    color: #333;
}

.free-tier ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.free-tier li {
    padding: 6px 0;
    font-size: 14px;
    color: #555;
}

.free-tier li::before {
    content: "✓ ";
    color: #28a745;
    font-weight: bold;
}

/* Logout button */
.logout-btn {
    padding: 10px 24px;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    margin-top: 16px;
}

.logout-btn:hover {
    background-color: #b02a37;
}

/* Delete account button */
.delete-btn {
    padding: 10px 24px;
    background-color: transparent;
    color: #dc3545;
    border: 1px solid #dc3545;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    margin-top: 12px;
}

.delete-btn:hover {
    background-color: #dc3545;
    color: white;
}

/* Profile link in navbar — signed-in indicator. Inherits the standard
   nav-link styling (color, padding, hover/active background) from the
   per-page `body.page-* .nav-links a` rules so it matches Home/Games/Puzzles. */

/* Profile greeting */
.profile-greeting {
    padding: 24px 2rem 0;
    max-width: 800px;
    margin: 0 auto;
}

.profile-greeting h2 {
    margin: 0;
    font-size: 24px;
    color: #333;
}

/* Profile layout */
.profile-layout {
    display: flex;
    gap: 40px;
    padding: 24px 2rem;
    max-width: 800px;
    margin: 0 auto;
}

.profile-sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 240px;
    padding: 24px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    align-self: flex-start;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: #007bff;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 12px;
}

.profile-email {
    font-size: 14px;
    color: #555;
    margin: 0 0 20px;
    word-break: break-all;
    text-align: center;
}

.profile-menu-item {
    width: 100%;
    padding: 10px 0;
    text-align: center;
    color: #333;
    text-decoration: none;
    font-size: 15px;
    border-top: 1px solid #eee;
}

.profile-menu-item:hover {
    color: #007bff;
}

.profile-menu-item.active {
    color: #007bff;
    font-weight: bold;
}

.profile-sidebar .logout-btn,
.profile-sidebar .delete-btn {
    width: 100%;
    margin-top: 12px;
}

.profile-content {
    flex: 1;
}

.profile-content h3 {
    margin: 0 0 16px;
    font-size: 18px;
    color: #333;
}

.billing-container {
    padding: 24px;
    border-radius: 12px;
    background: #fff;
}

/* Progress section */
.progress-container {
    padding: 24px;
    margin-bottom: 24px;
    border: none;
    border-radius: 12px;
    box-shadow: none;
    background: #fff;
}

.progress-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    flex: 1;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
}

.stat-label {
    margin: 0 0 6px;
    font-size: 13px;
    color: #888;
}

.stat-value {
    margin: 0;
    font-size: 22px;
    font-weight: bold;
    color: #333;
}

.progress-bars + .progress-bars {
    margin-top: 24px;
}

.progress-bars h4 {
    margin: 0 0 12px;
    font-size: 15px;
    color: #333;
}

.progress-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.progress-row:last-child {
    margin-bottom: 0;
}

.progress-label {
    width: 100px;
    font-size: 14px;
    color: #555;
}

.progress-bar {
    flex: 1;
    height: 10px;
    background: #eee;
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #28a745;
    border-radius: 5px;
    transition: width 0.3s ease;
}

.progress-count {
    width: 60px;
    text-align: right;
    font-size: 13px;
    color: #666;
}

/* Billing card */
.billing-card {
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
}

.billing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.billing-plan {
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

.billing-status {
    font-size: 13px;
    font-weight: bold;
    padding: 4px 10px;
    border-radius: 12px;
}

.billing-status.active {
    background-color: #d4edda;
    color: #28a745;
}

.billing-status.inactive {
    background-color: #f8d7da;
    color: #dc3545;
}

.billing-amount {
    font-size: 15px;
    color: #333;
    margin: 0 0 8px;
}

.billing-next {
    font-size: 14px;
    color: #666;
    margin: 0 0 20px;
}

.cancel-btn {
    padding: 8px 16px;
    background: transparent;
    color: #dc3545;
    border: 1px solid #dc3545;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

.cancel-btn:hover {
    background-color: #dc3545;
    color: white;
}

/* Payment history */
.payment-history-section {
    margin-top: 24px;
}

.payment-history-section h3 {
    margin: 0 0 16px;
    font-size: 18px;
    color: #333;
}

.payment-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.payment-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 13px;
    color: #888;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
}

.payment-table td {
    padding: 12px 16px;
    font-size: 14px;
    color: #333;
    border-bottom: 1px solid #eee;
}

.payment-table tr:last-child td {
    border-bottom: none;
}

.invoice-link {
    color: #007bff;
    text-decoration: none;
    font-size: 14px;
}

.invoice-link:hover {
    text-decoration: underline;
}

.load-more-btn {
    margin-top: 16px;
    padding: 8px 16px;
    background: transparent;
    color: #007bff;
    border: 1px solid #007bff;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

.load-more-btn:hover:not(:disabled) {
    background-color: #007bff;
    color: white;
}

.load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Reset password page */
.reset-page {
    display: flex;
    justify-content: center;
    align-items: center;
    height: calc(100vh - 50px);
}

.reset-box {
    width: 100%;
    max-width: 400px;
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.reset-box h3 {
    margin: 0 0 20px 0;
    font-size: 20px;
}

.reset-box input {
    width: 100%;
    padding: 10px 12px;
    margin: 10px 0;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
}

.reset-box input:focus {
    outline: none;
    border-color: #007bff;
}

/* Chess board */
/* Games nav tabs */
.games-nav {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 16px;
    width: 100%;
}

.games-nav-tab {
    flex: 1;
    padding: 8px 20px;
    border: none;
    background: #e9ecef;
    color: #555;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.games-nav-tab:first-child {
    border-radius: 8px 0 0 8px;
}

.games-nav-tab:last-child {
    border-radius: 0 8px 8px 0;
}

.games-nav-tab:hover {
    background: #dee2e6;
}

.games-nav-tab.active {
    background: #333;
    color: #fff;
}

/* Games layout — sidebar + board */
.games-layout {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 24px;
    margin-top: 16px;
}

.games-sidebar {
    width: 200px;
    flex-shrink: 0;
    margin-top: 53px;
}

.sidebar-panel {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.sidebar-group {
    display: flex;
    flex-direction: column;
}

.sidebar-tab {
    padding: 10px 14px;
    border: none;
    background: #f0f0f0;
    color: #555;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-tab:hover {
    background: #e2e2e2;
}

.sidebar-tab.active {
    background: #333;
    color: #fff;
    border-radius: 6px 6px 0 0;
}

.sidebar-items {
    display: none;
    flex-direction: column;
}

.sidebar-items.active {
    display: flex;
}

.sidebar-item {
    padding: 8px 14px 8px 24px;
    border: none;
    background: #f8f8f8;
    color: #555;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    border-left: 3px solid transparent;
}

.sidebar-item:last-child {
    border-radius: 0 0 6px 6px;
}

.sidebar-item:hover {
    background: #eee;
}

.sidebar-item.active {
    background: #e8e8e8;
    color: #333;
    font-weight: 600;
    border-left-color: #333;
}

/* Completed (green check after the label) — applied by sidebar code in games.html / puzzles.html */
.sidebar-item.completed {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-item.completed::after {
    content: "✓";
    color: #28a745;
    font-weight: bold;
    font-size: 16px;
    flex-shrink: 0;
}

/* Locked (lock icon after the label) — applied when user is not subscribed */
.sidebar-item.locked {
    position: relative;
    padding-right: 30px;
    color: #999;
}

.sidebar-item.locked::after {
    content: "🔒";
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    line-height: 1;
}

.sidebar-item-wrapper {
    display: flex;
    align-items: stretch;
}

.sidebar-item-wrapper .sidebar-item {
    flex: 1;
    min-width: 0;
}

.sidebar-item-delete {
    display: flex;
    align-items: center;
    padding: 0 8px;
    background: #f8f8f8;
    color: #bbb;
    font-size: 16px;
    cursor: pointer;
    transition: color 0.12s ease, background 0.12s ease;
}

.sidebar-item-delete:hover {
    color: #c0392b;
    background: #eee;
}

.board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

/* Game panel — right of the board */
.game-panel {
    width: 280px;
    flex-shrink: 0;
    flex-grow: 0;
    align-self: flex-start;
    overflow: hidden;
    margin-top: 53px;
}

.game-panel-toggle {
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: #f0f0f0;
    color: #555;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.15s ease;
}

.game-panel-toggle:hover {
    background: #e2e2e2;
}

.toggle-icon {
    font-size: 12px;
    display: inline-block;
    transition: transform 0.2s ease;
}

.toggle-icon.open {
    transform: rotate(180deg);
}

.game-panel-content {
    background: #f8f8f8;
    border-radius: 0 0 6px 6px;
    padding: 12px 14px;
}

.game-panel-section {
    margin-bottom: 12px;
}

.game-panel-section:last-child {
    margin-bottom: 0;
}

.game-panel-section h4 {
    margin: 0 0 4px;
    font-size: 13px;
    color: #333;
}

.game-panel-value,
.game-panel-moves {
    font-size: 13px;
    color: #666;
}

.move-line {
    padding: 4px 6px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1rem;
    font-weight: 400;
    color: #111827;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.1s ease;
    /* Preserve the leading space in padded move numbers (" 1." vs "10.") so
       monospace alignment keeps the dots and SAN in a clean column. */
    white-space: pre;
}


.move-line[data-ply]:hover {
    background: #f1f3f5;
}

.move-line[data-ply].move-active {
    background: #e0e7ff;
    color: #1e3a8a;
}

.move-half {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 6px;
    font-family: 'Courier New', Courier, monospace;
    white-space: pre;
}

.move-half:hover {
    background: #f1f3f5;
}

.move-half.move-active {
    background: #e0e7ff;
    color: #1e3a8a;
    border-radius: 6px;
}

.move-half.move-hidden {
    visibility: hidden;
}

.move-comment {
    padding: 4px 10px 5px 10px;
    font-size: 14px;
    color: #374151;
    line-height: 1.3;
    background: #f8f9fa;
    border-radius: 4px;
    margin: 4px 0 6px 4px;
}

/* Play for — radio buttons */
.play-for {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 26px;
    margin-bottom: 26px;
    font-size: 15px;
    color: #555;
}

.play-for-label {
    font-weight: 600;
    color: #333;
}

.play-for label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

/* Board controls — 6 buttons in a row */
.board-controls {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 8px;
}

.board-control-btn {
    padding: 8px;
    border: none;
    background: #f0f0f0;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.board-control-btn:hover {
    background: #e2e2e2;
}

.board-control-btn img {
    width: 20px;
    height: 20px;
}

.icon-flipped {
    transform: rotate(180deg);
}

.puzzle-description {
    padding: 12px 16px;
    font-size: 15px;
    color: #444;
    line-height: 1.55;
    background: #f8f8f8;
    border-radius: 6px;
    margin-bottom: 8px;
}

/* Title bar on puzzles uses the same selector as the games' Game Info toggle,
   but here it's a passive label — drop the button-style border + hover. */
body.page-games #puzzleTitleBar {
    border: none;
    box-shadow: none;
    cursor: default;
}

body.page-games #puzzleTitleBar:hover {
    background: transparent;
    transform: none;
    box-shadow: none;
}

.puzzle-description .desc-line {
    margin: 0 0 4px 0;
}

.puzzle-description .desc-line:last-child {
    margin-bottom: 0;
}

.puzzle-description .desc-piece-label {
    font-weight: 600;
    color: #1f2937;
}

.puzzle-description .desc-turn {
    margin-top: 6px;
    font-style: italic;
}

.puzzle-description .desc-empty-note {
    margin-top: 8px;
    font-size: 13px;
    font-style: italic;
    color: #1e3a8a;
}

.game-panel-moves-list {
    margin-top: 8px;
    min-height: 80px;
    max-height: 300px;
    overflow-y: auto;
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 8px 10px;
}

.hint-btn {
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    border: none;
    background: #333;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.hint-btn:hover {
    background: #555;
}

/* Custom game form */
.custom-form-header {
    padding: 10px 14px;
    background: #f0f0f0;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    border-radius: 6px 6px 0 0;
}

.custom-form-fields {
    padding: 12px 14px;
    background: #f8f8f8;
}

.custom-form-fields label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    margin-top: 8px;
}

.custom-form-fields label:first-child {
    margin-top: 0;
}

.custom-form-fields input,
.custom-form-fields textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    box-sizing: border-box;
}

.custom-form-fields input:focus,
.custom-form-fields textarea:focus {
    outline: none;
    border-color: #999;
}

.custom-form-moves-list {
    margin-top: 8px;
    min-height: 60px;
    max-height: 300px;
    overflow-y: auto;
    background: #f8f8f8;
    border-radius: 0 0 6px 6px;
    padding: 6px 10px;
    font-size: 13px;
    color: #444;
}

.move-comment-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 4px;
    font-size: 14px;
    line-height: 1;
    color: #aaa;
    cursor: pointer;
    border-radius: 6px;
    vertical-align: middle;
}

.move-comment-btn:hover {
    color: #555;
    background: #e8e8e8;
}

.move-comment-input {
    display: block;
    width: 100%;
    padding: 6px 8px;
    margin: 4px 0 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}

.move-comment-input:focus {
    outline: none;
    border-color: #999;
}

.custom-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.custom-form-actions .primary-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: #333;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
}

.custom-form-actions .primary-btn:hover {
    background: #555;
}

.custom-form-actions .cancel-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid #ccc;
    background: #fff;
    color: #555;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
}

.custom-form-actions .cancel-btn:hover {
    background: #f0f0f0;
}

.board {
    display: grid;
    grid-template-columns: repeat(8, var(--sq, 80px));
    grid-template-rows: repeat(8, var(--sq, 80px));
    border: 2px solid #333;
}

/* Game modes — below the board */
.game-modes {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 12px;
    width: 100%;
}

.game-mode-btn {
    flex: 1;
    padding: 8px 0;
    border: none;
    background: #e9ecef;
    color: #555;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.game-mode-btn:first-child {
    border-radius: 8px 0 0 8px;
}

.game-mode-btn:last-child {
    border-radius: 0 8px 8px 0;
}

.game-mode-btn:hover {
    background: #dee2e6;
}

.game-mode-btn.active {
    background: #333;
    color: #fff;
}

/* Board resize handle — inside bottom-right square */
.board-resize-handle {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    cursor: nwse-resize;
    opacity: 0.3;
    transition: opacity 0.15s ease;
    z-index: 10;
}

.board-resize-handle:hover {
    opacity: 0.7;
}

.board-resize-handle::before {
    content: "";
    display: block;
    width: 8px;
    height: 8px;
    border-right: 2px solid #555;
    border-bottom: 2px solid #555;
}

.square {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.square.light {
    background-color: #f0d9b5;
}

.square.dark {
    background-color: #b58863;
}

/* Board coordinates */
.coord {
    position: absolute;
    font-size: 13px;
    font-weight: 700;
    pointer-events: none;
    user-select: none;
}

.coord-rank {
    top: 2px;
    right: 3px;
}

.coord-file {
    bottom: 2px;
    left: 3px;
}

.coord-light {
    color: #f0d9b5;
}

.coord-dark {
    color: #b58863;
}

.piece-img {
    width: 85%;
    height: 85%;
    user-select: none;
    cursor: grab;
    transition: transform 0.1s ease, opacity 0.1s ease;
}

/* In empty / test mode the piece is visibility:hidden, so it doesn't catch
   pointer events — the cursor falls through to the square underneath.
   Have the square show the grab cursor whenever it contains a piece. */
.square:has(.piece-img) {
    cursor: grab;
}

/* Piece fades slightly on its origin square while dragging */
.piece-img.piece-lifting {
    opacity: 0.4;
    cursor: grabbing;
}

/* While any piece is lifted, force the grabbing cursor everywhere —
   the ghost has pointer-events:none, so without this the cursor falls
   through to the square underneath (which is cursor: pointer). */
body:has(.piece-img.piece-lifting),
body:has(.piece-img.piece-lifting) * {
    cursor: grabbing !important;
}

/* Empty visual mode — piece still exists for game logic but hidden */
.piece-invisible {
    visibility: hidden !important;
}

/* Ghost piece follows cursor while dragging */
.piece-ghost {
    position: fixed;
    width: var(--sq, 80px);
    height: var(--sq, 80px);
    pointer-events: none;
    z-index: 1000;
    transform: translate(-50%, -50%);
    filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.45));
}

/* Selected / origin square — yellow tint */
.square.square-selected.light {
    background-color: #f7ec5a;
}

.square.square-selected.dark {
    background-color: #dac934;
}

/* Last played move — muted olive/yellow-green tint on from/to squares */
.square.square-last-move.light {
    background-color: #c9d36a;
}

.square.square-last-move.dark {
    background-color: #9ba445;
}

/* Generic hover — same yellow as the selected state, applied to any square.
   Placed after last-move so hover lights it up, before drag-hover so the green
   legal-target tint still wins during a drag. */
.square.light:hover {
    background-color: #f7ec5a;
}

.square.dark:hover {
    background-color: #dac934;
}

/* Drag hover on legal square — green tint */
.square.square-drag-hover.light {
    background-color: #aad86e;
}

.square.square-drag-hover.dark {
    background-color: #8cbf4a;
}

/* Move hint dot — empty square */
.move-hint {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.15);
    pointer-events: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Move hint ring — capture square */
.move-hint-capture {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: 5px solid rgba(0, 0, 0, 0.15);
    background: transparent;
    pointer-events: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
}

/* King in check — red glow on the piece itself */
.piece-in-check {
    filter: drop-shadow(0 0 10px rgba(255, 0, 0, 0.8)) drop-shadow(0 0 20px rgba(255, 0, 0, 0.4));
}

/* Promotion picker overlay */
.promo-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1500;
}

/* Promotion picker */
.promo-picker {
    position: fixed;
    z-index: 1600;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    border-radius: 4px;
    overflow: hidden;
}

.promo-option {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    cursor: pointer;
    padding: 6px;
    aspect-ratio: 1;
}

.promo-option:hover {
    background: #d4edda;
}

.promo-option img {
    width: 54px;
    height: 54px;
}

/* =========================================================
   TEST-MODE COMPLETION BADGE
   ========================================================= */
.completion-badge {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: #ffffff;
    color: #2c3e50;
    padding: 2.5rem 3rem;
    border-radius: 12px;
    box-shadow: 0 12px 24px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
    text-align: center;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    border: 2px solid #e8f5e8;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 400px;
    backdrop-filter: blur(20px);
}

.completion-badge.show {
    transform: translate(-50%, -50%) scale(1);
}

.completion-badge .badge-icon {
    margin-bottom: 1.5rem;
    text-align: center;
    animation: badge-bounce 1s infinite;
    filter: drop-shadow(0 2px 4px rgba(40, 167, 69, 0.2));
}

.completion-badge .badge-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: #2c3e50;
    letter-spacing: -0.5px;
}

.completion-badge .badge-subtitle {
    font-size: 1rem;
    color: #7f8c8d;
    margin-bottom: 2rem;
    line-height: 1.5;
    font-weight: 400;
}

.completion-badge .badge-close {
    background: linear-gradient(135deg, #1e3a8a, #1e40af);
    border: 2px solid #1e3a8a;
    color: white;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s ease;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.completion-badge .badge-close:hover {
    background: linear-gradient(135deg, #1e40af, #1e3a8a);
    border-color: #1e40af;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.badge-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(44, 62, 80, 0.85);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.badge-overlay.show {
    opacity: 1;
    pointer-events: all;
}

@keyframes badge-bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    pointer-events: none;
    z-index: 9999;
}

@keyframes confetti-fall {
    0%   { transform: translateY(0) rotate(0deg);     opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

