:root{
    --bg:#07130f;
    --felt:#0b5b3b;
    --gold:#e7c66b;
    --panel:#10221b;
    --text:#f4f1e6;
    --muted:#aebdb5;
    --red:#d95757;
}

*{
    box-sizing:border-box;
}

body{
    margin:0;
    background:radial-gradient(circle at 50% 35%,#123f2d 0,#06100d 70%);
    font-family:system-ui,-apple-system,sans-serif;
    color:var(--text);
    min-height:100vh;
    overflow-x:hidden;
    /* Keeps clicks snappy and keeps the linter perfectly happy */
    touch-action:manipulation;
}

button{
    font:inherit;
}

#app{
    max-width:1250px;
    margin:auto;
    padding:16px;
}

header{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px;
    margin-bottom:12px;
    flex-wrap:wrap;
}

h1{
    margin:0;
    color:var(--gold);
    font-size:28px;
}

.badge{
    background:var(--panel);
    padding:8px 12px;
    border-radius:10px;
    border:1px solid #234137;
    font-size:13px;
}

.header-right{
    display:flex;
    gap:10px;
    align-items:center;
    flex-wrap:wrap;
}

#table{
    position:relative;
    min-height:720px;
    border-radius:28px;
    background:radial-gradient(
        ellipse at center,
        #0e7650 0,
        #0b5d40 46%,
        #073c2a 100%
    );
    border:12px solid #241d15;
    box-shadow:
        inset 0 0 70px #032317,
        0 15px 45px #0008;
    overflow:hidden;
}

#table:after{
    content:"";
    position:absolute;
    inset:12px;
    border:2px solid #d7b75d33;
    border-radius:20px;
    pointer-events:none;
}

.team-score{
    position:absolute;
    z-index:5;
    background:#06140fdd;
    border:1px solid #45695a;
    padding:8px 14px;
    border-radius:10px;
    font-size:13px;
    color:var(--muted);
    box-shadow:0 6px 15px #0009;
    transition:all 0.3s;
}

.team-score .val{
    color:var(--gold);
    font-size:18px;
    font-weight:800;
    margin-left:6px;
    vertical-align:middle;
}

.team-score.top{
    top:16px;
    left:16px;
}

.team-score.bottom{
    bottom:16px;
    left:16px;
    border-color:var(--gold);
}

.player{
    position:absolute;
    z-index:3;
    background:#071811d9;
    border:1px solid #315346;
    padding:8px 12px;
    border-radius:12px;
    text-align:center;
    min-width:110px;
    transition:all 0.3s ease;
}

.player.active{
    border-color:var(--gold);
    box-shadow:0 0 20px #e7c66b66;
    transform:scale(1.05);
}

.player.empty{
    opacity:.5;
}

#p0{
    bottom:12px;
    left:50%;
    transform:translateX(-50%);
}

#p1{
    left:12px;
    top:50%;
    transform:translateY(-50%);
}

#p2{
    top:12px;
    left:50%;
    transform:translateX(-50%);
}

#p3{
    right:12px;
    top:50%;
    transform:translateY(-50%);
}

.name{
    font-weight:700;
}

.score{
    font-size:12px;
    color:var(--muted);
}

#trump{
    position:absolute;
    top:83px;
    left:50%;
    transform:translateX(-50%);
    z-index:4;
    background:#06140fdd;
    border:1px solid #45695a;
    border-radius:14px;
    padding:8px 15px;
    text-align:center;
}

#trump .suit{
    font-size:26px;
}

.hearts,
.diamonds{
    color:#ff7777;
}

.clubs,
.spades{
    color:#fff;
}

#message{
    position:absolute;
    top:128px;
    left:50%;
    transform:translateX(-50%);
    z-index:5;
    width:min(500px,90%);
    background:#06140feb;
    border:1px solid #527466;
    border-radius:12px;
    padding:10px;
    text-align:center;
    display:none;
}

#trick{
    position:absolute;
    left:50%;
    top:50%;
    transform:translate(-50%,-50%);
    width:360px;
    height:260px;
    z-index:4;
}

.played{
    position:absolute;
    width:76px;
    height:106px;
}

.played.n{
    top:0;
    left:50%;
    transform:translateX(-50%);
}

.played.s{
    bottom:0;
    left:50%;
    transform:translateX(-50%);
}

.played.w{
    left:0;
    top:50%;
    transform:translateY(-50%);
}

.played.e{
    right:0;
    top:50%;
    transform:translateY(-50%);
}

.played .card.winner{
    box-shadow:
        0 0 40px #e7c66b,
        0 0 15px #fff !important;
    transform:scale(1.15) !important;
    border-color:var(--gold) !important;
    z-index:10;
}

#trick-piles{
    position:absolute;
    inset:0;
    pointer-events:none;
    z-index:2;
}

.trick-pile{
    position:absolute;
    width:54px;
    height:76px;
    transition:all 0.3s;
    z-index:2;
}

.trick-pile::after{
    content:attr(data-label);
    position:absolute;
    bottom:-28px;
    left:50%;
    transform:translateX(-50%);
    font-size:11px;
    color:var(--gold);
    white-space:nowrap;
    font-weight:800;
    background:rgba(0,0,0,0.6);
    padding:4px 8px;
    border-radius:6px;
    text-shadow:0 2px 4px #000;
}

.trick-pile.my-team{
    bottom:120px;
    right:60px;
}

.trick-pile.opp-team{
    top:60px;
    right:60px;
}

.card-back{
    position:absolute;
    width:100%;
    height:100%;
    border-radius:6px;
    border:2px solid #ddd;
    background:#0c3866;
    background-image:repeating-linear-gradient(
        45deg,
        transparent,
        transparent 5px,
        #072240 5px,
        #072240 10px
    );
    box-shadow:-2px 2px 6px #0007;
}

#hand{
    position:absolute;
    bottom:82px;
    left:50%;
    transform:translateX(-50%);
    z-index:6;
    display:flex;
    justify-content:center;
    align-items:flex-end;
    width:min(92%,760px);
}

.card{
    width:68px;
    height:96px;
    border-radius:9px;
    background:#fff;
    color:#111;
    border:2px solid #ddd;
    box-shadow:0 6px 16px rgba(0,0,0,0.5);
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    font-weight:800;
    cursor:pointer;
    transition:
        transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.25s,
        margin-top 0.4s;
    position:relative;
    /* UPDATED: Prefix order fixed for the linter, touch-action remains for snappy clicks */
    -webkit-user-select:none;
    user-select:none;
    touch-action:manipulation;
}

.card+.card{
    margin-left:-18px;
}

.card:hover{
    transform:translateY(-24px) scale(1.12) rotate(0deg) !important;
    z-index:30;
    box-shadow:0 20px 40px rgba(0,0,0,0.8);
}

.card.unplayable{
    opacity:1 !important;
    filter:brightness(0.65);
    cursor:not-allowed;
    transform:translateY(10px) !important;
}

.card.unplayable:hover{
    transform:translateY(10px) scale(1) rotate(0deg) !important;
    box-shadow:0 6px 16px rgba(0,0,0,0.5);
}

.card .rank{
    font-size:22px;
}

.card .suit{
    font-size:25px;
}

.card.hearts,
.card.diamonds{
    color:#ff7777;
}

.played .card.hearts,
.played .card.diamonds{
    color:#ff7777;
}

.card.selected{
    transform:translateY(-30px) scale(1.15) rotate(0deg) !important;
    z-index:40 !important;
    box-shadow:0 15px 35px rgba(231,198,107,0.7) !important;
    border:2px solid var(--gold) !important;
}

@keyframes swipeIn{
    0%{
        opacity:0;
        top:-250px;
        transform:scale(0.2);
        box-shadow:0 40px 80px rgba(0,0,0,0.8);
    }

    100%{
        opacity:1;
        top:0px;
        box-shadow:0 6px 16px rgba(0,0,0,0.5);
    }
}

@keyframes playCardAnim{
    0%{
        opacity:0;
        transform:scale(1.6) translateY(20px);
        box-shadow:0 30px 60px rgba(0,0,0,0.7);
    }

    100%{
        opacity:1;
        transform:scale(1) translateY(0);
        box-shadow:0 6px 16px rgba(0,0,0,0.5);
    }
}

#controls{
    position:absolute;
    bottom:12px;
    left:50%;
    transform:translateX(-50%);
    z-index:10;
    display:flex;
    gap:8px;
    align-items:center;
    flex-wrap:wrap;
    justify-content:center;
    width:90%;
}

.btn{
    border:0;
    border-radius:10px;
    padding:10px 16px;
    background:var(--gold);
    color:#17140b;
    font-weight:800;
    cursor:pointer;
    transition:all 0.2s;
}

.btn:hover:not(:disabled){
    filter:brightness(1.1);
    transform:translateY(-2px);
}

.btn:active:not(:disabled){
    transform:translateY(0);
}

.btn.secondary{
    background:#173127;
    color:#eee;
    border:1px solid #426454;
}

.btn:disabled{
    opacity:.45;
    cursor:not-allowed;
}

#leaveBtn{
    display:none;
    padding:6px 12px;
    font-size:12px;
}

#startBtn,
#playAgainBtn,
#packBtn{
    display:none;
}

#sortBtn,
#lastTrickBtn{
    display:flex;
}

#createBtn{
    width:100%;
    margin-bottom:10px;
}

#startFromLobbyBtn{
    width:100%;
    margin-top:8px;
}

#confirmCutBtn{
    width:100%;
}

#modalPackBtn{
    width:100%;
    margin-top:15px;
    display:none;
}

#actionBtns{
    position:absolute;
    bottom:16px;
    right:16px;
    display:none;
    gap:10px;
    z-index:50;
    pointer-events:auto;
}

.icon-btn{
    width:44px;
    height:44px;
    border-radius:50%;
    background:#173127;
    border:1px solid #426454;
    color:var(--gold);
    display:flex;
    justify-content:center;
    align-items:center;
    cursor:pointer;
    box-shadow:0 4px 10px rgba(0,0,0,0.5);
    transition:all 0.2s;
    padding:0;
}

.icon-btn:hover{
    background:#20493a;
    transform:scale(1.1);
}

#emotes{
    position:absolute;
    top:16px;
    right:16px;
    gap:8px;
    z-index:20;
    display:none;
    flex-wrap:wrap;
    justify-content:flex-end;
}

.emote-btn{
    padding:6px;
    font-size:18px;
    line-height:1;
}

.emote-bubble{
    position:absolute;
    font-size:44px;
    pointer-events:none;
    z-index:100;
    filter:drop-shadow(0 4px 8px rgba(0,0,0,0.5));
    animation-duration:3.5s;
    animation-fill-mode:forwards;
    animation-timing-function:cubic-bezier(0.34,1.56,0.64,1);
}

.emote-bubble.vp-0{
    bottom:80px;
    left:50%;
    transform:translateX(-50%);
    animation-name:floatSouth;
}

.emote-bubble.vp-1{
    left:140px;
    top:50%;
    transform:translateY(-50%);
    animation-name:floatWest;
}

.emote-bubble.vp-2{
    top:80px;
    left:50%;
    transform:translateX(-50%);
    animation-name:floatNorth;
}

.emote-bubble.vp-3{
    right:140px;
    top:50%;
    transform:translateY(-50%);
    animation-name:floatEast;
}

@keyframes floatSouth{
    0%{
        opacity:0;
        transform:translate(-50%,20px) scale(0.5);
    }

    15%{
        opacity:1;
        transform:translate(-50%,0) scale(1.2);
    }

    30%{
        transform:translate(-50%,-10px) scale(1);
    }

    80%{
        opacity:1;
        transform:translate(-50%,-40px) scale(1);
    }

    100%{
        opacity:0;
        transform:translate(-50%,-60px) scale(0.8);
    }
}

@keyframes floatNorth{
    0%{
        opacity:0;
        transform:translate(-50%,-20px) scale(0.5);
    }

    15%{
        opacity:1;
        transform:translate(-50%,0) scale(1.2);
    }

    30%{
        transform:translate(-50%,10px) scale(1);
    }

    80%{
        opacity:1;
        transform:translate(-50%,40px) scale(1);
    }

    100%{
        opacity:0;
        transform:translate(-50%,60px) scale(0.8);
    }
}

@keyframes floatWest{
    0%{
        opacity:0;
        transform:translate(-20px,-50%) scale(0.5);
    }

    15%{
        opacity:1;
        transform:translate(0,-50%) scale(1.2);
    }

    30%{
        transform:translate(10px,-50%) scale(1);
    }

    80%{
        opacity:1;
        transform:translate(40px,-50%) scale(1);
    }

    100%{
        opacity:0;
        transform:translate(60px,-50%) scale(0.8);
    }
}

@keyframes floatEast{
    0%{
        opacity:0;
        transform:translate(20px,-50%) scale(0.5);
    }

    15%{
        opacity:1;
        transform:translate(0,-50%) scale(1.2);
    }

    30%{
        transform:translate(-10px,-50%) scale(1);
    }

    80%{
        opacity:1;
        transform:translate(-40px,-50%) scale(1);
    }

    100%{
        opacity:0;
        transform:translate(-60px,-50%) scale(0.8);
    }
}

#side{
    display:flex;
    gap:10px;
    margin-top:12px;
    flex-wrap:wrap;
}

.panel{
    background:#0c1d16;
    border:1px solid #29463b;
    border-radius:12px;
    padding:10px 14px;
}

.flex-grow-1{
    flex:1;
}

#cutModal,
#lastTrickModal{
    position:fixed;
    inset:0;
    background:#0009;
    z-index:100;
    display:none;
    align-items:center;
    justify-content:center;
    padding:20px;
    -webkit-backdrop-filter:blur(5px);
    backdrop-filter:blur(5px);
}

#modal{
    position:fixed;
    inset:0;
    background:transparent;
    z-index:100;
    display:none;
    align-items:center;
    justify-content:center;
    padding:20px;
    pointer-events:none;
}

#modal .modalbox{
    pointer-events:auto;
    box-shadow:0 10px 40px rgba(0,0,0,0.9);
    border:1px solid var(--gold);
}

.modalbox{
    background:#10221b;
    border:1px solid #4b705f;
    border-radius:18px;
    padding:24px;
    max-width:500px;
    width:100%;
    box-shadow:0 20px 60px #000;
    animation:playCardAnim 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

.modalbox h2{
    margin-top:0;
    color:var(--gold);
}

.suits{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:10px;
}

.suitbtn{
    padding:18px;
    border-radius:12px;
    border:1px solid #45695a;
    background:#17352a;
    color:#fff;
    cursor:pointer;
    font-size:25px;
    transition:all 0.2s;
}

.suitbtn:hover{
    background:#20493a;
    transform:scale(1.05);
}

#cutSlider{
    width:100%;
    margin:20px 0;
}

#log{
    max-height:100px;
    overflow:auto;
    font-size:12px;
    color:#b9c9c1;
    padding-right:8px;
}

#lastTrickModal .modalbox{
    text-align:center;
}

#lastTrickModal h2{
    margin-top:0;
    color:var(--gold);
}

#closeLastTrickBtn{
    margin-top:20px;
    width:100%;
}

#lastTrickContainer{
    position:relative;
    height:160px;
    width:100%;
    display:flex;
    justify-content:center;
    align-items:center;
    gap:-15px;
    margin-top:15px;
}

#lastTrickContainer .card{
    position:relative;
    transform:none;
    box-shadow:0 4px 10px #000;
    margin:0 -15px;
}

#lobby,
#roomPanel{
    position:fixed;
    inset:0;
    background:#0009;
    z-index:200;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:20px;
    -webkit-backdrop-filter:blur(8px);
    backdrop-filter:blur(8px);
}

.lobbybox{
    background:#10221b;
    border:1px solid #4b705f;
    border-radius:18px;
    padding:26px;
    max-width:440px;
    width:100%;
    box-shadow:0 20px 60px #000;
    animation:playCardAnim 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

.lobbybox h2{
    margin-top:0;
    color:var(--gold);
}

.lobbybox p{
    color:var(--muted);
    font-size:13px;
}

.lobbybox input{
    width:100%;
    padding:10px 12px;
    border-radius:8px;
    border:1px solid #45695a;
    background:#0c1d16;
    color:#fff;
    margin:6px 0 14px;
    font-size:15px;
}

.room-settings{
    margin-bottom:15px;
    padding:10px 15px;
    background:#0c1d16;
    border:1px solid #45695a;
    border-radius:8px;
}

.room-settings p{
    margin:0 0 10px 0;
    color:var(--gold);
    font-size:14px;
    font-weight:bold;
}

.settings-row{
    display:flex;
    gap:10px;
    justify-content:space-between;
}

.settings-row label{
    font-size:13px;
    color:var(--muted);
}

.settings-row select{
    background:#10221b;
    color:white;
    border:1px solid #45695a;
    border-radius:4px;
    padding:4px;
    font-family:inherit;
    margin-left:5px;
}

.row2{
    display:flex;
    gap:10px;
}

.seatrow{
    display:flex;
    justify-content:space-between;
    align-items:center;
    padding:8px 10px;
    border:1px solid #2a463b;
    border-radius:8px;
    margin-bottom:8px;
    background:#0c1d16;
}

.seatrow.me{
    border-color:var(--gold);
    box-shadow:inset 0 0 10px rgba(231,198,107,0.1);
}

.seatrow .stag{
    font-size:11px;
    color:var(--muted);
}

.roomcode{
    font-size:26px;
    letter-spacing:4px;
    font-weight:800;
    color:var(--gold);
    text-align:center;
    margin:6px 0 16px;
    -webkit-user-select:all;
    user-select:all;
}

.hidden{
    display:none !important;
}

.waitline{
    font-size:13px;
    color:var(--muted);
    text-align:center;
    margin-top:8px;
}

.err{
    color:var(--red);
    font-size:13px;
    min-height:16px;
}

#codeInput{
    text-transform:uppercase;
}

.lobby-subtitle{
    text-align:center;
    margin-top:-8px;
}

@media(max-width:700px){

    #table{
        min-height:680px;
    }

    .card{
        width:52px;
        height:78px;
    }

    .card .rank{
        font-size:17px;
    }

    .card .suit{
        font-size:20px;
    }

    #hand{
        bottom:88px;
    }

    .player{
        min-width:85px;
        padding:6px;
        font-size:12px;
    }

    .team-score{
        padding:6px 10px;
        font-size:11px;
    }

    .team-score .val{
        font-size:15px;
    }

    .trick-pile{
        width:40px;
        height:56px;
    }

    .trick-pile.my-team{
        bottom:150px;
        right:20px;
    }

    .trick-pile.opp-team{
        top:60px;
        right:20px;
    }
}