html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    font-family: "Trebuchet MS", "Gill Sans", sans-serif;
    background: #7fe2ff;
    background: linear-gradient(180deg, #7fe2ff 0%, #6ed6fb 58%, #dff6ff 58%, #dff6ff 100%);
}

body {
    position: relative;
}

#gameCanvas {
    display: block;
    width: 100vw;
    height: 100vh;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.scanPanel {
    position: fixed;
    left: 12px;
    bottom: 12px;
    z-index: 5;
}

.rcRoomQrCodeLink {
    display: block;
    border: solid 8px #fff;
    border-radius: 8px;
    color: #fff;
    background-color: #fff;
    box-shadow: 0 0 0 1px #fff;
    text-align: center;
    transition: opacity 1s ease;
    text-decoration: none;
    transform-origin: bottom left;
    transform: scale(0.5);
    -webkit-tap-highlight-color: transparent;
}

.rcTechLabel {
    background-color: #000;
    color: #fff;
    font-family: monospace;
    font-size: 13px;
    font-weight: bold;
    margin: 0 0 8px 0;
    padding: 4px;
    letter-spacing: 0.2em;
}

.rcRoomQrCode {
    width: 150px;
    height: 150px;
}

.rcRoomId {
    background-color: #000;
    color: #fff;
    font-family: monospace;
    font-size: 16px;
    padding: 4px;
    margin: 8px 0 0 0;
    letter-spacing: 0.25em;
}

.topHud {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    inset: 0;
    z-index: 4;
    pointer-events: none;
}

.roundBanner {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    min-width: 0;
    max-width: 520px;
    max-width: calc(100vw - 220px);
    max-width: min(calc(100vw - 220px), 520px);
    padding: 10px 18px;
    border-radius: 999px;
    color: #fff7cf;
    font-size: 22px;
    font-size: clamp(14px, 2vw, 30px);
    font-weight: 900;
    letter-spacing: 0.05em;
    text-align: center;
    text-transform: uppercase;
    background: rgba(53, 33, 11, 0.62);
    box-shadow: 0 8px 30px rgba(42, 21, 5, 0.28);
    text-shadow: 0 3px 0 rgba(56, 33, 0, 0.9);
}

.roundBanner.hidden {
    display: none;
}

.roundBanner.scoreMode {
    max-width: 280px;
    max-width: min(46vw, 280px);
    padding: 8px 18px;
    border-radius: 16px;
    background: rgba(53, 33, 11, 0.62);
    box-shadow: 0 8px 24px rgba(42, 21, 5, 0.22);
    color: #fff9d7;
    font-size: 46px;
    font-size: clamp(36px, 6vw, 54px);
    letter-spacing: 0.02em;
}

.highScoreHud {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 10px 14px;
    border-radius: 16px;
    color: #fff9d7;
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: rgba(53, 33, 11, 0.62);
    box-shadow: 0 8px 24px rgba(42, 21, 5, 0.22);
    text-shadow: 0 2px 0 rgba(56, 33, 0, 0.8);
}

.roster {
    position: absolute;
    top: 70px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 260px;
    max-width: min(32vw, 260px);
}

.rosterCard {
    display: block;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 9px;
    border-radius: 12px;
    color: #fff;
    background: #4f3218;
    background: rgba(55, 36, 18, 0.62);
    box-shadow: 0 8px 18px rgba(31, 18, 6, 0.18);
    white-space: nowrap;
}

.rosterSwatch {
    display: inline-block;
    vertical-align: middle;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.92);
    flex: none;
    margin-right: 10px;
}

.rosterName {
    display: inline-block;
    vertical-align: middle;
    flex: 1;
    width: 132px;
    min-width: 0;
    font-size: 13px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

.rosterScore {
    display: inline-block;
    vertical-align: middle;
    font-size: 16px;
    font-weight: 900;
    color: #ffe877;
    margin-left: 10px;
}

.rosterCard+.rosterCard {
    margin-top: 6px;
}

.rosterCard.eliminated {
    opacity: 0.55;
}

@media (max-width: 900px) {
    .roster {
        top: 70px;
        left: 8px;
        max-width: 210px;
        max-width: min(52vw, 210px);
    }

    .roundBanner {
        top: 8px;
        max-width: 360px;
        max-width: calc(100vw - 168px);
        padding: 8px 14px;
    }

    .roundBanner.scoreMode {
        top: 10px;
        font-size: 38px;
        font-size: clamp(30px, 7vw, 44px);
    }

    .highScoreHud {
        top: 8px;
        right: 8px;
        padding: 8px 10px;
        font-size: 12px;
    }
}

@media (max-width: 560px) {

    .roster {
        top: 70px;
        max-width: 180px;
        max-width: min(54vw, 180px);
        gap: 4px;
    }

    .rosterCard {
        gap: 7px;
        padding: 6px 8px;
    }

    .rosterSwatch {
        width: 14px;
        height: 14px;
        margin-right: 7px;
    }

    .rosterName {
        width: 82px;
        font-size: 11px;
    }

    .rosterScore {
        font-size: 14px;
        margin-left: 7px;
    }

    .roundBanner {
        max-width: calc(100vw - 132px);
        font-size: 12px;
        letter-spacing: 0.03em;
    }

    .roundBanner.scoreMode {
        font-size: 32px;
        font-size: clamp(28px, 9vw, 38px);
    }

    .highScoreHud {
        font-size: 11px;
        letter-spacing: 0.03em;
    }
}

.lean-paint,
.lean-paint body {
    background: #7bd9fb;
}

.lean-paint .roundBanner,
.lean-paint .roundBanner.scoreMode,
.lean-paint .highScoreHud,
.lean-paint .rosterCard {
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.lean-paint .roundBanner,
.lean-paint .roundBanner.scoreMode,
.lean-paint .highScoreHud {
    background: #4a2f15;
}

.lean-paint .rosterCard {
    background: #4f3218;
}

.hidden {
    display: none !important;
}

.editBirdButton {
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 6;
    min-width: 108px;
    min-height: 44px;
    padding: 10px 14px;
    border: 2px solid #fff5cf;
    border-radius: 14px;
    background: #4a2f15;
    color: #fff5cf;
    font: 900 13px "Trebuchet MS", "Gill Sans", sans-serif;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
}

.birdStudio {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    overflow: auto;
    padding: 18px;
    box-sizing: border-box;
    background: rgba(30, 48, 58, 0.88);
    text-align: center;
}

.studioCard {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
    border: 4px solid #4a2f15;
    border-radius: 24px;
    background: #fff9e8;
    color: #432808;
    text-align: left;
}

.studioCard h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.1;
    text-align: center;
}

.studioCard p {
    margin: 8px 0 16px;
    color: #765424;
    font-size: 14px;
    line-height: 1.35;
    text-align: center;
}

.nameLabel,
.toolField {
    display: block;
    color: #6d4a1b;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.birdNameInput {
    display: block;
    width: 100%;
    height: 46px;
    margin-top: 6px;
    padding: 8px 12px;
    box-sizing: border-box;
    border: 3px solid #d6ba76;
    border-radius: 12px;
    background: #fff;
    color: #38230b;
    font: 800 18px "Trebuchet MS", "Gill Sans", sans-serif;
    user-select: text;
    -webkit-user-select: text;
}

.drawingFrame {
    width: 100%;
    max-width: 360px;
    margin: 14px auto 0;
    padding: 8px;
    box-sizing: border-box;
    border: 3px dashed #bf9441;
    border-radius: 16px;
    background: #dff4ff;
}

#drawingCanvas {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 10px;
    background: #fff;
    touch-action: none;
    cursor: crosshair;
}

.drawTools {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: center;
    margin: 12px -4px 0;
}

.toolField,
.toolButton {
    margin: 4px;
}

.toolField input {
    display: block;
    margin-top: 5px;
}

.toolField input[type="color"] {
    width: 52px;
    height: 38px;
    padding: 2px;
    border: 2px solid #a97b32;
    border-radius: 8px;
    background: #fff;
}

.thicknessField {
    width: 125px;
}

.thicknessField input {
    width: 120px;
    height: 34px;
}

.toolButton,
.secondaryButton,
.submitBirdButton {
    min-height: 42px;
    padding: 9px 13px;
    border: 2px solid #a8792c;
    border-radius: 11px;
    background: #fff4ce;
    color: #56350c;
    font: 900 13px "Trebuchet MS", "Gill Sans", sans-serif;
    cursor: pointer;
}

.toolButton.selected {
    border-color: #432808;
    background: #ffd95e;
}

.studioError {
    min-height: 20px;
    margin-top: 8px;
    color: #b02c20;
    font-size: 13px;
    font-weight: 800;
    text-align: center;
}

.studioActions {
    display: flex;
    justify-content: center;
    margin: 6px -5px 0;
}

.studioActions button {
    margin: 0 5px;
}

.submitBirdButton {
    min-width: 170px;
    border-color: #b45a19;
    background: #ff982e;
    color: #fff;
    font-size: 15px;
    text-transform: uppercase;
}

@media (max-height: 620px) and (orientation: landscape) {
    .birdStudio {
        padding: 8px;
    }

    .studioCard {
        max-width: 720px;
        padding: 12px;
    }

    .studioCard h1 {
        font-size: 22px;
    }

    .studioCard p {
        margin: 4px 0 8px;
    }

    .drawingFrame {
        max-width: 260px;
        margin-top: 8px;
    }

    .drawTools {
        margin-top: 6px;
    }
}
