html, body {
    margin: 0;
    min-height: 100vh;
    background: #eee4d1;
    font-family: Arial, sans-serif;
    color: #2f2414;
    overscroll-behavior: none;
}



#board {
    touch-action: none;
    position: fixed;
    inset: 0;
    z-index: 0;
}

#overlay {
    position: fixed;
    inset: 0;
    z-index: 10;
    pointer-events: none;
}

.bottomElement {
    position: absolute;
    bottom: 12px;
    /* center horizontally, allow it to be very wide */
    left: 50%;
    transform: translateX(-50%);
    pointer-events: auto;
    align-items: center;
    /* center children */
    display: flex;
    justify-content: center;
}

#bottomBar {
    border-radius: 12px;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.45);
    padding: 12px 16px;
    background: #d8b273;
    border-top: 3px solid #8b5a2b;
    box-sizing: border-box;
    
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 220px;
    max-width: 100%;
    align-items: center;
    width: auto;
}

.errorMessage {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    border: 2px solid #000000;
    background-color: white;
    width: auto;
    text-align: center;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: bold;
    pointer-events: auto;
    /* hidden at first */
    display: none;
    opacity: 1;
    transition: opacity 0.5s ease;
}
#information {
    position: absolute;
    top: 20px;
    right: 20px;
    max-height: calc(100vh - 220px);

    pointer-events: none;
    display: flex;
    flex-direction: row;
}

#informationPanel {
    width: 260px;
    max-height: 100%;
    box-sizing: border-box;

    padding: 14px;

    background: rgba(216, 178, 115, 0.95);
    border-top: 3px solid #8b5a2b;
    border-radius: 12px;

    box-shadow: 0 -4px 15px rgba(0,0,0,0.45);

    pointer-events: auto;

    display: none;
    flex-direction: column;

    overflow: hidden;
    animation: show 0.3s ease;
}

#informationContent {
    min-height: 0;
    min-width: 0;

    overflow-y: auto;
    /* style scroll bar */
    scrollbar-width: thin;
    scrollbar-color: #8b5a2b transparent;
}
.informationButtonContainer {
    pointer-events: none;
    display: flex;
    flex-direction: column;
    margin-top: 30px;
    gap: 16px;
}
.informationButton {
    border: none;
    background: transparent;
    color: #2f2414;
    font-size: 24px;
    animation: show 0.3s ease;
    pointer-events: auto;
    line-height: 1;
    padding-right: 0;
}
/* infomrmation button with active class */
.informationButton.active {
    background: rgba(216, 178, 115, 0.95);
    transform: scale(1.5);
    transition: transform 0.3s ease, background 0.6s ease;
}
#closeLeaderBoardButton {
    border: none;
    background: transparent;
    color: #2f2414;
    /* push to right hand side */
    position: absolute;
    right: 0;
    font-size: 24px;
    pointer-events: auto;
}

@keyframes show {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.informationHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.informationControls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.leaderBoardUser {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.5);
    margin-bottom: 4px;
    /* font */
    font-size: 14px;
    font-weight: bold;
}
.leaderBoardUser.leaderBoardUserFirst {
    background: rgb(251, 183, 35, 0.8);
}
.leaderBoardUser.leaderBoardUserSecond {
    background: rgb(192, 192, 192, 0.8);
}
.leaderBoardUser.leaderBoardUserThird {
    background: rgb(205, 127, 50, 0.8);
}
.leaderBoardUser.leaderBoardUserLoggedIn {
    border: 4px solid #4f3512;
    /* animate border persistently */
    animation: loggedInBorder 5s infinite;
}

@keyframes loggedInBorder {
    0% {
        border-color: #4f3512;
    }
    50% {
        border-color: #ac7328;
    }
    100% {
        border-color: #4f3512;
    }
}

#bottomBar > * {
    pointer-events: auto;
}

button {
    padding: 8px 12px;
    border: 1px solid #999;
    border-radius: 4px;
    cursor: pointer;
}



.letter-value {
    position: absolute;
    right: 3px;
    bottom: 2px;

    font-size: 12px;
    line-height: 1;
    pointer-events: none;
}

#letters h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}
#lettersContainer {
    display: grid;
    grid-auto-flow: column;
    gap: 8px;

    justify-content: start;
    align-content: start;

    background: #b8864b;
    padding: 8px;
    border-radius: 10px;
    border: 2px solid #8b5a2b;

    max-height: 128px;
    overflow-x: auto;
    overflow-y: hidden;

    width: 100%;
    box-sizing: border-box;

    /* style scroll bar */
    scrollbar-width: thin;
    scrollbar-color: #8b5a2b transparent;
    

}

.letter {
    position: relative;
    width:52px;
    height:52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #7a5a2f;
    border-radius: 8px;
    background: linear-gradient(180deg, #f5e3b0 0%, #e2c37b 100%);
    color: #2f2414;
    font-weight: 700;
    font-size:22px;
    box-shadow: 0 2px 0 #a57d43, 0 4px 10px rgba(0, 0, 0, 0.12);
    user-select: none;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.letter.selected {
    background: linear-gradient(180deg, #fff3c9 0%, #d7a53f 100%);
    border-color: #4f3512;
    box-shadow: 0 0 0 2px rgba(79, 53, 18, 0.25), 0 4px 12px rgba(0, 0, 0, 0.18);
    transform: translateY(-2px) scale(1.03);
}

.letter.pending {
    background: linear-gradient(180deg, #ffe8d3 0%, #f3c28b 100%);
    border-color: #b97a2f;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.45), 0 1px 2px rgba(0,0,0,0.16);
    color: #7a4515;
    transform: none;
    cursor: pointer;
    opacity: 0.95;
}
.letter:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 0 #a57d43, 0 6px 14px rgba(0, 0, 0, 0.16);
}

.letter.pending:hover {
    transform: translateY(-1px) scale(1.01);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.45), 0 3px 6px rgba(0,0,0,0.2);
}

.letter.swapping {
    animation: bounce 1s ease-in-out infinite;
    animation-delay: var(--bounce-delay, 0s);
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.letter.pending::after {
    content: "↺";
    position: absolute;
    font-size: 10px;
    left: 3px;
    bottom: 3px;
    opacity: 0.75;
}





#tileInfo {
    position: fixed;
    display: none;
    
    padding: 10px 14px;
    background: rgba(20, 20, 20, 0.95);
    color: white;
    border-radius: 8px;

    pointer-events: none;
    z-index: 9999;
}

.overlayDisplay {
    bottom: 12px;
    right: 12px;
    padding: 8px 12px;
    background: rgba(20, 20, 20, 0.95);
    color: white;
    border-radius: 8px;
    pointer-events: auto;

    width: fit-content;
    min-width: 6%;
    max-width: 10%;
    box-sizing: border-box;

    font-family: monospace;
    font-weight: bold;
    font-size: 20px;
    text-align: center;
}
.coordinateInput {
    width: 0;
    min-width: 0;
    max-width: none;

    padding: 0;
    margin: 0;

    background: transparent;
    border: none;
    outline: none;

    color: inherit;
    font-family: inherit;
    font-weight: inherit;
    font-size: inherit;
    text-align: center;
}

.userHeader,
.globalHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

#userName,
#globalTitle {
    margin: 0;
    font-weight: bold;
    font-size: 20px;
    line-height: 1;
}


.userStats span {
    opacity: 0.7;
}

.userStats strong {
    font-weight: 700;
}


/* auth */
#authContainer {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: radial-gradient(
        circle at center,
        #e9cf94 0%,
        #e2c58a 50%,
        #e9c47a 100%
    );
}
#authPanel {
    background: #d8b273;
    padding: 30px;
    border-radius: 14px;
    border: 3px solid #8b5a2b;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

#showLoginForm,
#showRegisterForm {
    padding: 10px 25px;
    border: none;
    border-radius: 8px 8px 0 0;
    background: #b8864b;
    color: #2f2414;
    font-weight: bold;
}

#authTabs {
    display: flex;
    gap: 4px;
    margin-bottom: 0;
}

#authTabs button {
    padding: 10px 28px;
    border: 3px solid #8b5a2b;
    border-bottom: 0px;
    border-radius: 8px 8px 0 0;
    background: #b8864b;
    color: #4f3512;
    font-weight: bold;
}
#showLoginForm.open,
#showRegisterForm.open {
    background: #d8b273;
    border-bottom-color: #d8b273;
    position: relative;
    z-index: 2;
    margin-bottom: -3px;
}
#loginPanel input,
#registerPanel input {
    width: 100%;
}
#loginPanel input::placeholder,
#registerPanel input::placeholder {
    color: #8b7354;
    opacity: 0.8;
}
#loginPanel,
#registerPanel {
    width: 280px;
    box-sizing: border-box;
}
#loginPanel h2,
#registerPanel h2 {
    margin: 0 0 18px;
}

#authMessage {
    margin-bottom: 16px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 2px solid #8b5a2b;
    background: #f5e3b0;
    color: #4f3512;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    box-sizing: border-box;
}


/* USER STATS INFO */

.userStats {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.userStat {
    display: flex;
    justify-content: space-between;
    align-items: center;

    min-width: 0;
    box-sizing: border-box;

    padding: 10px 12px;

    background: rgba(255, 255, 255, 0.45);
    border-radius: 7px;

    font-size: 14px;
}

.userStat span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.userStat strong {
    flex-shrink: 0;
    margin-left: 10px;

    color: #2f2414;
    font-size: 17px;
}



.textButton {
    padding: 7px 10px;
    border: 1px solid #8b5a2b;
    border-radius: 6px;
    background: rgba(184, 134, 75, 0.7);
    color: #2f2414;
    font-weight: bold;
    cursor: pointer;
}
.textButton:hover {
    background: #b8864b;
}
.textButton:active {
    background: #a8753d;
}
.dropDown {
    padding: 7px 10px;
    border: 1px solid #8b5a2b;
    border-radius: 6px;
    background: rgba(184, 134, 75, 0.7);
    color: #2f2414;
    font-weight: bold;
    /* text center */
    text-align: center;
}
