@media (pointer:fine) {
    .scroll-hint {
        width: 25px;
    }
}

@media (hover: hover) and (pointer: fine) {

    #hand .card:hover {
        transform: translateY(-10px);
    }
}

:root {
    --side-zone: 140px;
}

body {
    background:
        radial-gradient(circle at center, #0f6b2c 0%, #063812 70%),
        repeating-linear-gradient(
            45deg,
            rgba(255,255,255,0.015) 0px,
            rgba(255,255,255,0.015) 2px,
            rgba(0,0,0,0.015) 2px,
            rgba(0,0,0,0.015) 4px
        );

    background-blend-mode: overlay;
}

body {
    margin: 0;
}

/* ---------- MAIN TABLE LAYOUT ---------- */

main.container::before {

    content: "";
    position: absolute;
    inset: 0;

    background:
        radial-gradient(
            ellipse at top,
            rgba(255,255,255,0.08),
            rgba(255,255,255,0) 60%
        );

    pointer-events: none;
}

main.container {

    align-content: start;

    width: 95%;
    max-width: none;

    position: relative;

    background: #146b2b;

    box-shadow:
        inset 0 8px 40px rgba(0,0,0,0.35),
        0 8px 30px rgba(0,0,0,0.6);

    padding: 2rem;
    border-radius: 10px;

    display: grid;

    min-height: 100vh;

    grid-template-rows:
        80px      /* score */
        160px     /* opponent */
        auto      /* table */
        120px     /* moves */
        120px     /* hand */
        auto;     /* bottom */

    gap: 10px;
}

/* ---------- SCORE ---------- */

#match-score {
    font-size: 1.2rem;
    font-weight: bold;
    color: #f2d16b;
}

#hand.disabled {
    opacity: 0.6;
    pointer-events: none;
}

#opponent-area,
#hand-area {

    display: grid;

    grid-template-columns:
        var(--side-zone)
        1fr
        var(--side-zone);

    align-items: center;

    /* width: 100%; */
}

.side-left,
.side-right {

    display: flex;
    justify-content: center;
    align-items: center;
}

#sweeps-opponent,
#sweeps-player {
    display: flex;
    justify-content: center;
    width: 100%;
}

.sweep-counter {

    width: 50px;
    height: 80px;

    background-image: url("/static/cards/skin1_empty.png");
    background-size: 100% 100%;
    background-repeat: no-repeat;

    display: flex;
    justify-content: center;
    align-items: center;

    font-size: 30px;
    font-weight: bold;

    color: #111;

    border-radius: 6px;
}

/*
.sweep-counter:not(:empty) {

    text-shadow: 0 0 8px rgba(255,255,120,0.9);
}
*/    

.deck {

    width: 100px;
    height: 140px;

    position: relative;
    transform: translateY(4px);
}

.deck::before,
.deck::after {

    content: "";

    position: absolute;
    inset: 0;

    background-image: url("/static/cards/skin1_back_red.png");
    background-size: 100% 100%;
    background-repeat: no-repeat;

    border-radius: 6px;
}

.deck::before { transform: translate(4px,-4px); }
.deck::after  { transform: translate(8px,-8px); }

/* tom bunke */

.deck-empty {

    width: 100px;
    height: 140px;

    background-image: url("/static/cards/skin1_empty.png");
    background-size: 100% 100%;
    background-repeat: no-repeat;

    transform: translateY(4px);
}

/* ---------- OPPONENT ---------- */

#opponent-hand {
    display: flex;
    justify-content: center;
    align-items: center;
}


/* ---------- TABLE ---------- */

#table-area {

    position: relative;
    z-index: 1;

    width: 100%;

    min-height: 200px;   /* i stedet for height */

    overflow-x: auto;
    overflow-y: visible;

    -webkit-overflow-scrolling: touch;


    /* sikrer scrollbar stabilitet på desktop */
    scrollbar-gutter: stable;

    /* Firefox */
    scrollbar-width: auto;   
    
    display: block;
/*
    scroll-behavior: smooth;    
*/    
    overscroll-behavior-x: contain;    
}

/* scroll hint */

#table-frame {
    position: relative;
    width: 100%;
    overflow-x: hidden;
    overflow-y: visible;
}

.scroll-hint {
    position: absolute;
    top: 0;
    width: 50px;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    z-index: 10;
}

.scroll-hint.left {

    left: -2px;
    background: linear-gradient(
        to left,
        rgba(20,107,43,0),
        rgba(20,107,43,1)
    );
}

.scroll-hint.right {

    right: -2px;      /* i stedet for 0 */
    background: linear-gradient(
        to right,
        rgba(20,107,43,0),
        rgba(20,107,43,1)
    );
}

#table-frame.can-scroll-left .scroll-hint.left { opacity:1; }
#table-frame.can-scroll-right .scroll-hint.right { opacity:1; }


#table {

    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;

    align-items: flex-start;

    gap: 10px;

    padding-top: 30px;
    padding-bottom: 20px;

    width: fit-content;
    margin: 0 auto;    
}

#table .card {
    flex: 0 0 auto;
}

/* ---------- MOVES ---------- */

#moves-area {

    position: relative;
    z-index: 50;

    min-height: 0;

    display: flex;
    justify-content: center;
    align-items: flex-start;
}

#moves {

    display: flex;
    justify-content: center;
    align-items: center;

    gap: 12px;
}
/* ---------- PLAYER HAND ---------- */

#hand {

    display: flex;
    justify-content: center;
    align-items: flex-end;

    /* gap: 0 */
}

/* fan spread */

#hand {
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

#hand .card {
    position: relative;
}

#hand .card:not(:first-child) {
    margin-left: -40px;
}

/* sørg for valgt kort ligger øverst */

#hand .card.selected {
    z-index: 20;
}


/* ---------- CARD ---------- */

.card {
    margin-left: 6px;
    margin-right: 6px;
    cursor: pointer;
    position: relative;
    will-change: transform;
}

.card img {

    width: 100px;
    display: block;
    border-radius: 6px;

    transition: transform 0.15s;

    box-shadow: 0 4px 8px rgba(0,0,0,0.4); 
}


#hand .card.selected {
    transform: translateY(-12px);
}

/* selected overlay */

.card.selected::after {

    content: "";

    position: absolute;
    inset: 0;

    background-image: url("/static/cards/selected.png");

    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;

    pointer-events: none;
}


/* ---------- POPUP ---------- */

.popup {

    position: fixed;
    inset: 0;

    background: rgba(0,0,0,0.6);

    display: none;

    align-items: center;
    justify-content: center;

    z-index: 1000;
}

.popup-content {

    background: white;
    z-index: 1001;    

    padding: 2rem;

    border-radius: 10px;

    min-width: 350px;
}

/* ---------- BUILDS ---------- */

.card.build {
    position: relative;
}

.build-label {

    position: absolute;

    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);

    margin-bottom: 4px;

    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.5px;

    color: #eee;

    text-shadow: 0 1px 2px rgba(0,0,0,0.8);

    pointer-events: none;
}

/*
.build-label {
    left: 50%;
    transform: translateX(-50%);
}
*/

.card.build img {
    border: 2px solid rgba(255,255,255,0.25);
}

#next-match {
    margin-top: 30px;
}


#status-text {
    text-align: center;
    height: fit-content;
    margin-top: 20px;
    font-size: 0.9rem;
    color: #ddd;
    height: 1.2rem;
}

#bottom-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
}

.menu-buttons {
    margin-top: 30px;
    display: flex;
    gap: 10px;
}

#game-area {
    display:contents;
}