body {
    background-image: url('/images/background.png');
    background-repeat: repeat;
    background-position: center;
    background-size: 250px;
    overflow: hidden;
}

a {
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.habbo-avatar {
    max-width: 100%;
    max-height: 140px;
    width: auto;
    object-fit: contain;
}

#landing {
    position: fixed;
    inset: 0;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem 0;
    overflow: hidden;
    transform: none;
}

#landing > .row {
    width: 100%;
}

.landing-card {
    margin-top: auto;
    margin-bottom: auto;
}

.habbo-avatar-frame {
    display: flex;
    width: 180px;
    height: 180px;
    max-width: 100%;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 50%;
    background: #eef3fb;
}

.habbo-avatar-frame .habbo-avatar {
    width: auto;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
}

#landing,
#settings,
#gameEnded {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#statsDiv {
    max-height: 90vh;
    overflow-y: auto;
}

/* canvas */

canvas {
    display: block;
    max-width: 100%;
    background-color: #fff;
    cursor: crosshair;
}

#gameZone {
    position: fixed;
    z-index: 1;
    top: 50%;
    left: 50%;
    width: min(1480px, calc(100vw - 40px));
    max-width: none;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    transform: translate(-50%, -50%);
}

#gameZone .game-layout {
    display: grid;
    grid-template-columns: minmax(160px, .75fr) minmax(0, 2.4fr) minmax(160px, .75fr);
    gap: 14px;
    align-items: start;
}

#gameZone .game-players,
#gameZone .game-board,
#gameZone .game-chat {
    width: auto;
    min-width: 0;
    padding-right: 0;
    padding-left: 0;
}

#gameZone .game-board {
    max-width: 900px;
    margin: 0 auto;
}

#sketchpad,
#tools {
    width: 100%;
}

#gameZone .game-chat {
    overflow: hidden;
}

/* colors */

.color {
    display: inline-block;
    height: 25px;
    width: 25px;
}

.selected-color {
    display: inline-block;
    height: 50px;
    width: 50px;
    background-color: #000;
}

.white {
    background-color: #fff;
}

.black {
    background-color: #000;
}

.grey1 {
    background-color: #c1c1c1;
}

.grey2 {
    background-color: rgb(76, 76, 76);
}

.red1 {
    background-color: rgb(239, 19, 11);
}

.red2 {
    background-color: rgb(116, 11, 7);
}

.orange1 {
    background-color: rgb(255, 113, 0);
}

.orange2 {
    background-color: rgb(194, 56, 0);
}

.yellow1 {
    background-color: rgb(255, 228, 0);
}

.yellow2 {
    background-color: rgb(232, 162, 0);
}

.green1 {
    background-color: rgb(0, 204, 0);
}

.green2 {
    background-color: rgb(0, 85, 16);
}

.skyblue1 {
    background-color: rgb(0, 178, 255);
}

.skyblue2 {
    background-color: rgb(0, 86, 158);
}

.blue1 {
    background-color: rgb(35, 31, 211);
}

.blue2 {
    background-color: rgb(14, 8, 101);
}

.purple1 {
    background-color: rgb(163, 0, 186);
}

.purple2 {
    background-color: rgb(85, 0, 105);
}

.pink1 {
    background-color: rgb(211, 124, 170);
}

.pink2 {
    background-color: rgb(167, 85, 116);
}

.brown1 {
    background-color: rgb(160, 82, 45);
}

.brown2 {
    background-color: rgb(99, 48, 13);
}

/* players */
div.players div.row:nth-of-type(2n+1) {
    background-color: rgba(207, 204, 204, 0.973);
}

div.players div.row:nth-of-type(2n) {
    background-color: #fff;
}

/* chat */
.messages {
    overflow-y: auto;
    height: 25em;
    scroll-behavior: smooth;
}

.messages p:nth-of-type(2n) {
    background-color: rgba(207, 204, 204, 0.973);
}

.correct {
    color: #0f5132;
    background-color: #d1e7dd !important;
    border-color: #badbcc;
}

.close {
    color: #664d03;
    background-color: #fff3cd !important;
    border-color: #ffecb5;
}

@media (max-width: 992px) {
    .messages {
        height: 5em;
    }
}

/* Private room lobby */
#settings {
    width: min(1160px, calc(100vw - 32px));
    max-width: none;
    max-height: calc(100vh - 32px);
    overflow: hidden;
    color: #26334c;
}

.lobby-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(280px, .8fr);
    gap: 20px;
    align-items: stretch;
}

.lobby-main {
    display: grid;
    gap: 16px;
}

.lobby-settings-card,
.invite-card,
.lobby-players-card {
    border: 1px solid rgba(255, 255, 255, .82);
    border-radius: 20px;
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 18px 48px rgba(13, 38, 88, .24);
}

.lobby-settings-card,
.lobby-players-card {
    padding: clamp(20px, 3vw, 32px);
}

.lobby-heading,
.players-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.lobby-heading h1,
.players-heading h2,
.invite-card h2 {
    margin: 0;
    color: #1e2d47;
    font-size: clamp(1.55rem, 3vw, 2rem);
    font-weight: 750;
}

.lobby-eyebrow {
    margin: 0 0 4px;
    color: #6680a6;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .14em;
}

.lobby-lock {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 14px;
    background: #edf4ff;
    font-size: 1.2rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.setting-field {
    display: grid;
    gap: 6px;
    color: #53647e;
    font-size: .82rem;
    font-weight: 700;
}

.setting-field .form-select {
    min-height: 44px;
    border-color: #dce4ef;
    border-radius: 10px;
    color: #24334d;
    font-weight: 600;
}

.setting-field .form-select:focus,
.custom-words-panel .form-control:focus {
    border-color: #78a9ff;
    box-shadow: 0 0 0 .2rem rgba(13, 110, 253, .12);
}

.custom-words-panel {
    display: grid;
    gap: 8px;
    margin-top: 18px;
    color: #53647e;
    font-size: .82rem;
    font-weight: 700;
}

.custom-words-panel small {
    margin-left: 5px;
    color: #8a98ac;
    font-weight: 400;
}

.custom-words-panel textarea {
    min-height: 78px;
    resize: vertical;
    border-color: #dce4ef;
    border-radius: 10px;
}

.probability-label {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
}

.probability-label span {
    color: #1769df;
}

.lobby-start {
    min-height: 48px;
    margin-top: 18px;
    border-radius: 11px;
    box-shadow: 0 7px 16px rgba(13, 110, 253, .2);
    font-weight: 700;
}

.invite-card {
    display: grid;
    grid-template-columns: 1fr minmax(260px, 1.3fr);
    gap: 20px;
    align-items: center;
    padding: 18px 24px;
}

.invite-card h2 {
    font-size: 1.1rem;
}

.invite-card .form-control {
    min-width: 0;
    border-color: #dce4ef;
    font-size: .82rem;
}

.lobby-players-card {
    display: flex;
    min-height: 100%;
    flex-direction: column;
    color: #fff;
    background: linear-gradient(155deg, #214d91 0%, #153d7c 100%);
    border-color: rgba(255, 255, 255, .25);
}

.lobby-players-card .lobby-eyebrow {
    color: #a9c8ff;
}

.lobby-players-card h2 {
    color: #fff;
}

.player-count {
    display: flex;
    gap: 4px;
    align-items: baseline;
    padding: 7px 11px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 999px;
    background: rgba(255, 255, 255, .12);
    font-size: .9rem;
}

.player-count b {
    color: #fff;
}

.lobby-player-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
    min-height: 180px;
    max-height: min(48vh, 430px);
    overflow-y: auto;
    padding: 4px 2px 12px;
}

.lobby-player {
    display: flex;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 14px;
    background: rgba(255, 255, 255, .09);
    animation-duration: .45s;
}

.lobby-player-portrait {
    display: grid;
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    place-items: center;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, .84);
    border-radius: 50%;
    background: #e8f0ff;
    box-shadow: 0 5px 14px rgba(0, 0, 0, .2);
}

.lobby-player-head {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lobby-player-name {
    max-width: 100%;
    margin: 0;
    overflow: hidden;
    color: #fff;
    font-size: .86rem;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lobby-waiting {
    margin: auto 0 0;
    padding-top: 20px;
    color: #c4d7fa;
    font-size: .8rem;
    text-align: center;
}

.room-error-toast {
    position: fixed;
    z-index: 2000;
    top: 20px;
    left: 50%;
    max-width: calc(100vw - 32px);
    padding: 12px 18px;
    transform: translateX(-50%);
    border: 1px solid #f3b2b2;
    border-radius: 12px;
    background: #fff1f1;
    box-shadow: 0 8px 30px rgba(16, 35, 70, .2);
    color: #8d2424;
    font-weight: 650;
    text-align: center;
}

@media (max-width: 767.98px) {
    body {
        overflow: auto;
    }

    #landing {
        overflow-y: auto;
    }

    #settings {
        position: absolute;
        top: 16px;
        left: 50%;
        width: calc(100vw - 24px);
        max-height: calc(100vh - 32px);
        overflow-x: hidden;
        overflow-y: auto;
        transform: translateX(-50%);
    }

    #gameZone {
        position: relative;
        top: auto;
        left: auto;
        width: calc(100vw - 24px);
        max-height: none;
        margin: 16px auto;
        transform: none;
    }

    #gameZone .game-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    #gameZone .game-players {
        order: 2;
    }

    #gameZone .game-board {
        order: 1;
    }

    #gameZone .game-chat {
        order: 3;
        margin-top: 0 !important;
    }

    .lobby-shell {
        grid-template-columns: 1fr;
    }

    .lobby-players-card {
        min-height: 250px;
    }

    .invite-card {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

@media (max-width: 430px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

/* In-game layout and live leaderboard */
#gameZone > .alert {
    margin-bottom: 14px;
    border: 1px solid rgba(255, 255, 255, .55);
    border-radius: 15px !important;
    background: rgba(230, 248, 255, .96);
    box-shadow: 0 10px 28px rgba(10, 35, 78, .16);
}

.game-section-title {
    margin: 0 0 10px;
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: .02em;
    text-shadow: 0 2px 8px rgba(5, 25, 58, .35);
}

.game-players .players {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.game-player-card {
    position: relative;
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
    padding: 9px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 14px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 5px 16px rgba(8, 31, 73, .15);
    transition: background-color .2s ease, border-color .2s ease, transform .2s ease;
}

.game-player-card.current-leader {
    padding-right: 58px;
    border-color: #ffd66b;
    background: #fff8df;
}

.game-player-card.current-leader::after {
    position: absolute;
    top: 50%;
    right: 9px;
    padding: 4px 6px;
    transform: translateY(-50%);
    border-radius: 999px;
    background: #ffd66b;
    color: #533b00;
    content: 'LEAD';
    font-size: .58rem;
    font-weight: 900;
    letter-spacing: .05em;
}

.game-player-avatar {
    display: grid;
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    place-items: center;
    overflow: hidden;
    border: 2px solid #d9e7fb;
    border-radius: 50%;
    background: #edf3fc;
}

.game-player-head {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.game-player-details {
    min-width: 0;
}

.game-player-name,
.game-player-score {
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-player-name {
    color: #253650;
    font-size: .86rem;
    font-weight: 750;
}

.game-player-score {
    color: #6c7c94;
    font-size: .76rem;
    font-weight: 600;
}

.leader-announcement {
    margin: 0 auto 12px;
    padding: 10px 16px;
    border: 1px solid rgba(255, 222, 130, .8);
    border-radius: 12px;
    background: linear-gradient(100deg, #fff5c7, #fffdf2);
    box-shadow: 0 8px 20px rgba(9, 34, 76, .18);
    color: #594100;
    font-weight: 800;
    text-align: center;
}

#sketchpad {
    overflow: hidden;
    border: 4px solid rgba(255, 255, 255, .94);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 14px 34px rgba(8, 28, 66, .26);
}

#sketchpad canvas {
    border-radius: 10px;
}

#tools {
    align-items: center;
    gap: 8px 0;
    margin: 10px 0 0;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, .85);
    border-radius: 14px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 8px 22px rgba(8, 28, 66, .18);
}

#tools .selected-color {
    width: 42px;
    height: 42px;
    border: 3px solid #e2e9f3;
    border-radius: 10px;
}

#tools .color {
    width: 20px;
    height: 20px;
    margin: 2px;
    border: 1px solid rgba(21, 42, 74, .12);
    border-radius: 6px;
    transition: transform .12s ease;
}

#tools .color:hover {
    transform: scale(1.18);
}

#tools img[role="button"] {
    max-width: 34px;
    max-height: 34px;
    margin: 2px;
    object-fit: contain;
}

#tools #giveHint {
    border-radius: 9px;
    font-size: .82rem;
    font-weight: 750;
}

#tools .tool-icon-button {
    display: inline-grid;
    width: 36px;
    height: 36px;
    margin: 2px;
    padding: 4px;
    place-items: center;
    border: 1px solid #dce4ef;
    border-radius: 9px;
    background: #fff;
    vertical-align: middle;
}

#tools .tool-icon-button img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

#tools .tool-icon-button:disabled {
    cursor: not-allowed;
    opacity: .4;
}

#gameZone .game-chat {
    display: flex;
    min-height: 360px;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: 15px;
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 10px 28px rgba(8, 28, 66, .2);
}

#gameZone .messages {
    height: clamp(250px, 48vh, 520px);
    flex: 1 1 auto;
    padding: 8px;
}

#gameZone #sendMessage .form-control {
    border-color: #dce4ef;
    border-radius: 10px;
}

.chat-mode {
    padding: 10px 12px;
    border-bottom: 1px solid #e5eaf1;
    background: #f3f6fb;
    color: #566780;
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .03em;
}

.chat-mode-solved {
    border-bottom-color: #b7e6c6;
    background: #e3f8e9;
    color: #256642;
}

.messages .chat-solved {
    color: #276943;
    background: #e3f8e9 !important;
}

@media (max-width: 767.98px) {
    #gameZone .game-players .players {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    }

    #gameZone .game-chat {
        min-height: 250px;
    }
}
