* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Inter', system-ui, -apple-system, sans-serif;
    background: linear-gradient(145deg, #0f0c29, #302b63, #24243e);
    color: #e8e8f0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#lobby {
    text-align: center;
    padding: 50px 30px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

#lobby h1 {
    font-size: 2.4em;
    margin-bottom: 35px;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(to right, #f0e6d0, #d4b896);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
}

#join-section {
    margin-top: 18px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

button {
    background: linear-gradient(145deg, #3a2d7a, #2a1f5e);
    color: #e8e8f0;
    border: none;
    padding: 13px 30px;
    font-size: 0.95em;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.25s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
    letter-spacing: 0.3px;
}

button:hover {
    background: linear-gradient(145deg, #4f3fa0, #3a2d7a);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79, 63, 160, 0.4);
}

button:active {
    transform: translateY(0);
    transition-duration: 0.05s;
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

input {
    background: rgba(255, 255, 255, 0.07);
    color: #e8e8f0;
    border: 2px solid rgba(255, 255, 255, 0.12);
    padding: 12px 18px;
    font-size: 0.95em;
    border-radius: 12px;
    outline: none;
    width: 200px;
    font-family: inherit;
    transition: border-color 0.2s;
}

input:focus {
    border-color: #7c6fd4;
}

input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

#game-header {
    display: flex;
    justify-content: space-between;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    margin-bottom: 14px;
    font-size: 0.88em;
    border: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(8px);
}

#share-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    margin-bottom: 14px;
    word-break: break-all;
    font-size: 0.88em;
    flex-wrap: wrap;
    border: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(8px);
}

#share-link-text {
    flex: 1;
    min-width: 0;
    font-family: 'Courier New', monospace;
    color: #b8b0d8;
}

#share-link button {
    padding: 9px 18px;
    font-size: 0.82em;
    white-space: nowrap;
}

#board-container {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}

#board {
    container-type: inline-size;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    max-width: 680px;
    min-width: 0;
    touch-action: none;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 12px 50px rgba(0, 0, 0, 0.5);
}

.square {
    aspect-ratio: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10cqi;
    cursor: pointer;
    user-select: none;
    position: relative;
}

#app {
    width: 100%;
    max-width: 1460px;
    padding: 10px;
}

.square.light { background: #f0d9b5; }
.square.dark { background: #b58863; }

.square.selected {
    background: #7fc47f !important;
}

.square.last-move {
    box-shadow: inset 0 0 0 3px #5a9fd4 !important;
}



.square.legal-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 50%;
}

.square.legal-capture {
    box-shadow: inset 0 0 0 4px rgba(0, 0, 0, 0.25);
}

.square.check {
    background: radial-gradient(ellipse at center, rgba(220, 50, 50, 0.85) 0%, rgba(200, 40, 40, 0.5) 40%, transparent 70%) !important;
}

.piece.white-king { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.piece.white-queen { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.piece.white-rook { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.piece.white-bishop { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.piece.white-knight { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.piece.white-pawn { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.piece.black-king { color: #1a1a1a; text-shadow: 0 1px 2px rgba(255,255,255,0.1); }
.piece.black-queen { color: #1a1a1a; text-shadow: 0 1px 2px rgba(255,255,255,0.1); }
.piece.black-rook { color: #1a1a1a; text-shadow: 0 1px 2px rgba(255,255,255,0.1); }
.piece.black-bishop { color: #1a1a1a; text-shadow: 0 1px 2px rgba(255,255,255,0.1); }
.piece.black-knight { color: #1a1a1a; text-shadow: 0 1px 2px rgba(255,255,255,0.1); }
.piece.black-pawn { color: #1a1a1a; text-shadow: 0 1px 2px rgba(255,255,255,0.1); }

#game-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

#status-display {
    font-size: 0.95em;
    padding: 10px 22px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(8px);
    min-height: 42px;
    display: flex;
    align-items: center;
}

#move-history {
    font-family: 'Courier New', monospace;
    font-size: 0.8em;
    max-height: 80px;
    overflow-y: auto;
    width: 100%;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

#move-history::-webkit-scrollbar {
    width: 4px;
}

#move-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

#move-history .move-number {
    color: rgba(255, 255, 255, 0.3);
    margin-right: 3px;
}

#game-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

#game-actions button {
    padding: 10px 22px;
    font-size: 0.85em;
}

#game-over-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(6px);
}

#modal-content {
    background: linear-gradient(145deg, #1e1a3a, #151230);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 45px 50px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
}

#modal-content h2 {
    margin-bottom: 12px;
    font-size: 2em;
    font-weight: 700;
}

#modal-content p {
    margin-bottom: 28px;
    font-size: 1.05em;
    color: rgba(255, 255, 255, 0.6);
}

#modal-content button {
    margin: 0 6px;
}

@media (max-width: 500px) {
    .square { font-size: 2em; }
    #lobby h1 { font-size: 1.6em; }
    #lobby { padding: 30px 20px; }
    #modal-content { padding: 30px 24px; }
}
