:root {
    --primary-color: #0c1c3e;
    /* Deep Corporate Navy */
    --secondary-color: #1a3c6e;
    --accent-color: #008080;
    /* Teal accent */
    --gold-accent: #d4af37;
    --text-color: #333333;
    --text-light: #666666;
    --white: #ffffff;
    --bg-light: #f4f7f6;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    --transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    background-color: var(--white);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--primary-color);
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

/* Layout Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

section {
    padding: 1.5rem 0;
}

.app-header {
    margin: 2rem 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 3rem;
    background: linear-gradient(135deg, var(--white) 30%, var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.lead-text {
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
    opacity: 0.9;
    line-height: 1.6;
}

.setup-box {
    margin-bottom: 3rem;
}

.setup-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    text-align: left;
    margin-top: 3rem;
    padding-top: 3rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.info-card h3 {
    font-size: 1.2rem;
    color: var(--accent-color);
    margin-bottom: 0.8rem;
}

.info-card p {
    font-size: 0.9rem;
    opacity: 0.8;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .setup-info-grid {
        grid-template-columns: 1fr;
    }
}

/* Navbar */
nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    padding: 1.5rem 0;
    transition: var(--transition);
}

nav.scrolled {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 0;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    /* Prevent bunching */
    width: 100%;
}

.logo img {
    height: 50px;
    transition: var(--transition);
}

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

.nav-links a {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--white);
    letter-spacing: 0.5px;
    position: relative;
}

nav.scrolled .nav-links a {
    color: var(--primary-color);
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-color);
    transition: var(--transition);
}

.nav-links a:hover::after {
    width: 100%;
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--white);
    min-width: 220px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    border-radius: 12px;
    overflow: hidden;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0;
    margin-top: 10px;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.dropdown-content::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background-color: var(--white);
    z-index: -1;
}

.dropdown-content a {
    color: var(--text-color) !important;
    padding: 12px 20px;
    text-decoration: none;
    display: block;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.dropdown-content a:hover {
    background-color: var(--bg-light);
    color: var(--accent-color) !important;
}

.dropdown:hover .dropdown-content {
    display: block;
    opacity: 1;
    pointer-events: auto;
    /* Reset transform to keep it centered but animate opacity */
    transform: translateX(-50%) translateY(0);
}

.dropdown:hover .dropbtn {
    color: var(--accent-color);
}


/* Hamburger Menu */
.hamburger {
    display: none;
    cursor: pointer;
    width: 30px;
    height: 20px;
    position: relative;
    z-index: 1002;
}

.hamburger span {
    display: block;
    position: absolute;
    height: 2px;
    width: 100%;
    background: var(--white);
    border-radius: 2px;
    opacity: 1;
    left: 0;
    transform: rotate(0deg);
    transition: .25s ease-in-out;
}

.hamburger span:nth-child(1) {
    top: 0px;
}

.hamburger span:nth-child(2) {
    top: 9px;
}

.hamburger span:nth-child(3) {
    top: 18px;
}

/* Hamburger Animation when Active */
nav.scrolled .hamburger span {
    background: var(--primary-color);
}

.hamburger.active span:nth-child(1) {
    top: 9px;
    transform: rotate(135deg);
    background: var(--primary-color);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
    left: -60px;
}

.hamburger.active span:nth-child(3) {
    top: 9px;
    transform: rotate(-135deg);
    background: var(--primary-color);
}

/* Mobile Nav Overlay */
.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(15px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    overflow-y: auto;
}

/* Ensure mobile overlay is completely hidden on desktop to prevent interference */
@media (min-width: 769px) {
    .mobile-nav-overlay {
        display: none !important;
    }
}

.mobile-nav-overlay.active {
    opacity: 1;
    pointer-events: auto;
}


.mobile-nav-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.mobile-nav-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 100%;
    padding: 0 2rem;
}

.mobile-nav-links a {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 600;
    padding: 1.5rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    width: 100%;
    text-align: center;
    transition: color 0.3s ease, background-color 0.3s ease;
}

.mobile-nav-links a:hover {
    color: var(--accent-color);
    background-color: rgba(0, 0, 0, 0.02);
}

.close-btn {
    position: absolute;
    top: 2rem;
    right: 2rem;
    font-size: 3rem;
    cursor: pointer;
    color: var(--primary-color);
    line-height: 1;
    padding: 0.5rem;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: var(--accent-color);
}

/* Components */
.btn {
    display: inline-block;
    padding: 1rem 2.5rem;
    border-radius: 5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: var(--transition);
}

.btn-primary {
    background: var(--accent-color);
    color: var(--white);
}

.btn-primary:hover {
    background: #006666;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.section-title {
    text-align: center;
    margin-bottom: 4rem;
}

.section-title h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    position: relative;
    display: inline-block;
}

.section-title h2::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: var(--accent-color);
}

/* Glassmorphism Section */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 3rem;
    box-shadow: var(--shadow);
    max-width: 100%;
    width: auto;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Standard Mobile Responsive (Global) */
@media (max-width: 768px) {
    .container {
        padding: 0 1.25rem;
    }
}

:root {
    --square-light: #f0d9b5;
    --square-dark: #b58863;
    --select-color: rgba(255, 255, 0, 0.4);
    --valid-move-color: rgba(0, 0, 0, 0.1);
}

body {
    background: var(--primary-dark);
    color: var(--text-light);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 0;
}

.view {
    width: 100%;
    max-width: 1100px;
}

.hidden {
    display: none !important;
}

/* Glass Panel Enhancements */
.glass-panel {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.text-center {
    text-align: center;
}

/* Setup Controls */
.setup-controls {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}

/* Chessboard */
.game-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 3rem;
    max-width: 1000px;
    margin: 0 auto;
}

@media (max-width: 850px) {
    .game-container {
        grid-template-columns: 1fr;
    }
}

.board-wrapper {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.chessboard {
    display: grid;
    grid-template-columns: repeat(8, 60px);
    grid-template-rows: repeat(8, 60px);
    width: 480px;
    height: 480px;
    margin: 0 auto;
    border: 4px solid #333;
    user-select: none;
    box-sizing: content-box;
}

@media (max-width: 500px) {
    .chessboard {
        grid-template-columns: repeat(8, 11.25vw);
        grid-template-rows: repeat(8, 11.25vw);
        width: 90vw;
        height: 90vw;
    }
}

.square {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
    cursor: pointer;
    box-sizing: border-box;
}

.square.light {
    background-color: var(--square-light);
}

.square.dark {
    background-color: var(--square-dark);
}

.square.selected {
    background-color: var(--select-color) !important;
}

.square.valid-move::after {
    content: '';
    width: 25%;
    height: 25%;
    background: var(--valid-move-color);
    border-radius: 50%;
    position: absolute;
}

.piece {
    font-size: 2.5rem;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s ease;
    z-index: 2;
    line-height: 1;
}

.piece.w {
    color: #fff;
    text-shadow: 0 0 2px #000;
}

.piece.b {
    color: #000;
}

@media (max-width: 500px) {
    .piece {
        font-size: 8vw;
    }
}

.piece:hover {
    transform: scale(1.1);
}

/* Game Status */
.game-status {
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.p2p-error {
    background: rgba(255, 68, 68, 0.1);
    color: #ff4444;
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(255, 68, 68, 0.2);
}

.badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.copy-toast {
    background: #4caf50;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    text-align: center;
    animation: fadeInOut 3s forwards;
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.badge.danger {
    background: var(--accent-color);
    color: white;
    animation: pulse 2s infinite;
}

.badge.info {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.badge.info.active {
    background: #4caf50;
    color: white;
    border: none;
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }

    100% {
        opacity: 1;
    }
}

/* Share Box */
.share-box {
    margin-top: 0;
    padding: 1.5rem;
    transition: opacity 0.3s, filter 0.3s;
    width: 100%;
    max-width: 500px;
}

.share-box.inactive {
    opacity: 0.4;
    filter: blur(2px);
    pointer-events: none;
}

.share-box h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--accent-light);
}

.share-box p {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-bottom: 1rem;
}

.copy-input {
    display: flex;
    gap: 0.5rem;
}

.copy-input input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 8px 12px;
    color: #fff;
    font-size: 0.8rem;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-light);
    opacity: 0.6;
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 1.5rem;
    transition: opacity 0.2s;
}

.btn-text:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Save Game UI */
.save-controls {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.saved-games-list {
    margin-top: 2rem;
    text-align: left;
    width: 100%;
}

.saved-game-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.save-input-group {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    max-width: 400px;
}

.save-input-group input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 8px 12px;
    color: #fff;
}

.footer-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: rgba(255, 255, 255, 0.5);
}

.footer-link {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

.footer-link:hover {
    color: var(--accent-light);
}