/* ------------------------------------------------------------
   Paskahousu v0.5 styling
------------------------------------------------------------ */

:root {
    --table-image: url("/assets/table/hex_table_green.png");

    --card-width: 96px;
    --card-height: 132px;

    --pile-width: 150px;
    --pile-height: 210px;
}


/* ------------------------------------------------------------
   Base
------------------------------------------------------------ */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: Arial, Helvetica, sans-serif;
    background: #181818;
    color: #f0f0f0;
}

body {
    overflow-x: hidden;
}

#app {
    width: 100%;
    min-height: 100vh;
}


/* ------------------------------------------------------------
   Header
------------------------------------------------------------ */

.game-header {
    padding: 12px 18px;
    background: #181818;
    border-bottom: 1px solid #333333;
}

.game-header h1 {
    margin: 0 0 12px 0;
    font-size: 28px;
    font-weight: 700;
}

.status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.status-box {
    padding: 8px 14px;
    background: #2b2b2b;
    border: 1px solid #444444;
    border-radius: 9px;
    font-size: 17px;
}


/* ------------------------------------------------------------
   Player Status
------------------------------------------------------------ */

.players-status {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 8px 0 14px 0;
}

.player-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #252525;
    border: 1px solid #444444;
    border-radius: 10px;
    font-size: 17px;
}

.player-status.current-player {
    border-color: #00b839;
    background: #17351f;
}

.player-status.human-player {
    font-weight: 700;
}

.player-name {
    color: #ffffff;
}

.player-card-count {
    color: #cccccc;
}


/* ------------------------------------------------------------
   Message Box
------------------------------------------------------------ */

.message-box {
    min-height: 36px;
    padding: 8px 12px;
    background: #303030;
    border: 1px solid #505050;
    border-radius: 8px;
    color: #ffffff;
    font-size: 17px;
}

.error_message {
    border-color: #ff3030;
    color: #ffdddd;
    background: #4a2020;
}


/* ------------------------------------------------------------
   Main Layout
------------------------------------------------------------ */

.game-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 14px 18px 24px 18px;
}

/* ------------------------------------------------------------
   Table Section and Table Canvas
------------------------------------------------------------ */

.table-section {
    width: 100%;
    margin: 0;
    padding: 0;
}

.table-section h2 {
    margin: 0 0 12px 0;
    font-size: 22px;
    font-weight: 700;
}

.table-area {
    position: relative;
}

.table-area.hex-table {
    position: relative;
    width: 100%;
    max-width: 1050px;
    height: 1050px;
    margin: 0 auto;
    padding: 0;

    background-image: var(--table-image);
    background-size: contain;
    background-position: center center;
    background-repeat: no-repeat;
    background-color: transparent;

    filter:
        drop-shadow(0 24px 34px rgba(0, 0, 0, 0.55)) drop-shadow(0 8px 14px rgba(0, 0, 0, 0.35));

    border: none;
    border-radius: 0;
    overflow: visible;
}

/* ------------------------------------------------------------
   Shared Card Rendering
------------------------------------------------------------ */

.table-card,
.burn-card,
.hand-card,
.opponent-card-back {
    width: var(--card-width);
    height: var(--card-height);
    border-radius: 8px;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform-origin: center center;
    filter:
        drop-shadow(-2px 0 2px rgba(0, 0, 0, 0.18)) drop-shadow(0 3px 4px rgba(0, 0, 0, 0.45));
}

.table-card {
    position: absolute;
}

.burn-card {
    position: absolute;
}

.opponent-card-back {
    position: absolute;
}

.hand-card {
    position: absolute;
    top: 8px;
    cursor: pointer;
    transition:
        top 0.12s ease,
        transform 0.12s ease,
        filter 0.12s ease;
}

.hand-card:hover {
    filter:
        brightness(1.06) drop-shadow(-2px 0 2px rgba(0, 0, 0, 0.18)) drop-shadow(0 3px 4px rgba(0, 0, 0, 0.45));
}

.hand-card.selected {
    top: -8px;
    outline: 3px solid #00b839;
    outline-offset: -5px;
    border-radius: 8px;
}

.hand-card.invalid {
    outline: 3px solid #ff2020;
    outline-offset: -5px;
    border-radius: 8px;
    filter:
        brightness(1.12) drop-shadow(0 0 8px rgba(255, 0, 0, 0.85)) drop-shadow(-2px 0 2px rgba(0, 0, 0, 0.18)) drop-shadow(0 3px 4px rgba(0, 0, 0, 0.45));
}


/* ------------------------------------------------------------
   Table and Burn Piles
------------------------------------------------------------ */

.table-pile {
    position: absolute;
    left: 43%;
    top: calc(50% + 15px);
    width: var(--pile-width);
    height: var(--pile-height);
    transform: translate(-50%, -50%);
    z-index: 35;
    overflow: visible;
}

.burn-pile-wrapper {
    position: absolute;
    left: 57.5%;
    top: calc(50% + 28px);

    width: var(--pile-width);
    height: var(--pile-height);

    transform: translate(-50%, -50%);

    z-index: 35;
    overflow: visible;
    pointer-events: none;
}

.burn-pile {
    position: relative;

    width: var(--pile-width);
    height: var(--pile-height);

    margin: 0;
    padding: 0;
    overflow: visible;
}

.empty-burn-pile {
    position: absolute;
    left: 27px;
    top: 8px;
    width: var(--card-width);
    height: var(--card-height);
    border: 2px dashed rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    background: transparent;
}

/* ------------------------------------------------------------
   Player Hand Area
------------------------------------------------------------ */

.player-hand-wrapper {
    position: absolute;
    left: 49%;
    top: calc(78% - 60px);

    width: 280px;
    height: 170px;

    transform: translate(-50%, -50%);
    z-index: 40;

    overflow: hidden;
    border-radius: 14px;

    background: transparent;
    border: none;
    box-shadow: none;
}

.hand-scroll {
    position: relative;

    width: 100%;
    height: 170px;
    box-sizing: border-box;

    overflow-x: auto;
    overflow-y: hidden;

    padding: 16px 8px 10px 8px;

    background: transparent;
    border: none;
    border-radius: 14px;
}

.hand-area {
    position: relative;

    height: 136px;
    min-width: 0;

    background: transparent;
    border: none;
    overflow: visible;
}


/* ------------------------------------------------------------
   Player Hand Scrollbar
------------------------------------------------------------ */

.hand-scroll::-webkit-scrollbar {
    height: 8px;
}

.hand-scroll::-webkit-scrollbar-track {
    margin-left: 18px;
    margin-right: 18px;

    background: rgba(0, 0, 0, 0.24);
    border-radius: 999px;
}

.hand-scroll::-webkit-scrollbar-thumb {
    background: rgb(140, 140, 140);
    border-radius: 999px;
}

.hand-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.82);
}

/* ------------------------------------------------------------
   Opponent Hand Area
------------------------------------------------------------ */

.opponent-slots {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 25;
}

.opponent-slot {
    position: absolute;
    width: var(--card-width);
    height: var(--card-height);
    border: 2px dashed rgba(255, 255, 255, 0.30);
    border-radius: 10px;
    box-sizing: border-box;
    pointer-events: none;
    z-index: 4;
    opacity: 1;
}

.opponent-card-stack {
    position: absolute;
    width: var(--pile-width);
    height: var(--pile-height);
    transform-origin: center center;
    overflow: visible;
    pointer-events: none;
    z-index: 30;
}


/* Opponent 1 - top / 12 o'clock */

.opponent-slot-1 {
    left: 50%;
    top: calc(25% - 30px);
    transform: translate(-50%, -50%) rotate(3deg);
}

.opponent-card-stack-1 {
    left: 50%;
    top: calc(25% - 30px);
    transform: translate(-50%, -50%) rotate(3deg);
}


/* Opponent 2 - upper left */

.opponent-slot-2 {
    left: calc(30% + 20px);
    top: calc(38% - 45px);
    transform: translate(-50%, -50%) rotate(-63deg);
}

.opponent-card-stack-2 {
    left: calc(30% + 20px);
    top: calc(38% - 45px);
    transform: translate(-50%, -50%) rotate(-63deg);
}


/* Opponent 3 - upper right */

.opponent-slot-3 {
    left: calc(70% - 20px);
    top: calc(38% - 45px);
    transform: translate(-50%, -50%) rotate(53.5deg);
}

.opponent-card-stack-3 {
    left: calc(70% - 20px);
    top: calc(38% - 45px);
    transform: translate(-50%, -50%) rotate(53.5deg);
}


/* Opponent 4 - lower left */

.opponent-slot-4 {
    left: calc(30% - 4px);
    top: calc(62% - 60px);
    transform: translate(-50%, -50%) rotate(58deg);
}

.opponent-card-stack-4 {
    left: calc(30% - 4px);
    top: calc(62% - 60px);
    transform: translate(-50%, -50%) rotate(58deg);
}


/* Opponent 5 - lower right */

.opponent-slot-5 {
    left: calc(70% + 1px);
    top: calc(62% - 8px);
    transform: translate(-50%, -50%) rotate(-57deg);
}

.opponent-card-stack-5 {
    left: calc(70% - 15px);
    top: calc(62% - 35px);
    transform: translate(-50%, -50%) rotate(-57deg);
}


/* ------------------------------------------------------------
   Bottom Game Controls
------------------------------------------------------------ */

.setup-section {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
    margin: 0 0 12px 0;
    padding: 0;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
}

.setup-section label {
    margin-left: 4px;
}

.setup-section label:first-child {
    margin-left: 0;
}

.setup-section select {
    height: 40px;
    padding: 0 14px;
    border: 1px solid #555555;
    border-radius: 10px;
    background: #eeeeee;
    color: #111111;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

/* ------------------------------------------------------------
   Action Buttons
------------------------------------------------------------ */

.action-section {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 18px;

    width: 100%;
    max-width: 1050px;

    margin: -105px auto 0 auto;
    padding: 10px 0;

    position: relative;
    z-index: 60;
}

.action-section .game-button {
    width: 140px;
    min-width: 140px;
    max-width: 140px;
    height: 45px;
}

.game-button {
    min-width: 150px;
    height: 56px;
    padding: 0 22px;
    border-radius: 14px;
    border: 1px solid #777777;
    background: linear-gradient(#f4f4f4, #d8d8d8);
    color: #111111;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.85),
        0 2px 4px rgba(0, 0, 0, 0.35);
}

.game-button:hover {
    background: linear-gradient(#ffffff, #e2e2e2);
}

.game-button:active {
    transform: translateY(1px);
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.25),
        0 1px 2px rgba(0, 0, 0, 0.35);
}

.game-button.secondary {
    min-width: 150px;
}

/* ------------------------------------------------------------
   Smaller Screens
------------------------------------------------------------ */

@media (max-width: 1100px) {
    .table-area.hex-table {
        max-width: 900px;
        height: 900px;
    }

    .setup-section,
    .action-section {
        max-width: 900px;
    }

    .action-section {
        margin-top: -90px;
    }
}


@media (max-width: 900px) {
    .game-header h1 {
        font-size: 24px;
    }

    .status-box,
    .player-status,
    .message-box {
        font-size: 14px;
    }

    .table-area.hex-table {
        max-width: 760px;
        height: 760px;
    }

    .setup-section,
    .action-section {
        max-width: 760px;
    }

    .setup-section {
        gap: 8px;
    }

    .setup-section select {
        height: 36px;
        padding: 0 10px;
        font-size: 13px;
    }

    .action-section {
        gap: 14px;
        margin-top: -76px;
        padding: 8px 0;
    }

    .action-section .game-button {
        width: 135px;
        min-width: 135px;
        max-width: 135px;
        height: 48px;
        padding: 0 14px;
        font-size: 15px;
    }
}


@media (max-width: 700px) {
    .game-layout {
        padding-left: 8px;
        padding-right: 8px;
    }

    .game-header {
        padding-left: 10px;
        padding-right: 10px;
    }

    .game-header h1 {
        font-size: 21px;
    }

    .status-row,
    .players-status {
        gap: 6px;
    }

    .status-box,
    .player-status {
        padding: 6px 9px;
        font-size: 12px;
    }

    .message-box {
        min-height: 32px;
        padding: 6px 9px;
        font-size: 12px;
    }

    .table-area.hex-table {
        max-width: 620px;
        height: 620px;
    }

    .setup-section,
    .action-section {
        max-width: 620px;
    }

    .setup-section {
        justify-content: center;
        gap: 6px 8px;
        font-size: 12px;
    }

    .setup-section select {
        height: 34px;
        padding: 0 8px;
        border-radius: 8px;
        font-size: 12px;
    }

    .setup-section .game-button {
        min-width: 105px;
        height: 38px;
        padding: 0 10px;
        font-size: 12px;
    }

    .action-section {
        gap: 10px;
        margin-top: -62px;
        padding: 8px 0;
    }

    .action-section .game-button {
        width: 110px;
        min-width: 110px;
        max-width: 110px;
        height: 40px;
        padding: 0 10px;
        font-size: 13px;
    }
}


@media (max-width: 520px) {
    .table-area.hex-table {
        max-width: 460px;
        height: 460px;
    }

    .setup-section,
    .action-section {
        max-width: 460px;
    }

    .setup-section {
        justify-content: center;
    }

    .setup-section label {
        margin-left: 0;
    }

    .action-section {
        gap: 8px;
        margin-top: -46px;
    }

    .action-section .game-button {
        width: 96px;
        min-width: 96px;
        max-width: 96px;
        height: 38px;
        padding: 0 8px;
        font-size: 12px;
    }
}