/* ------------------------------------------------------------
 * Drey Cards
 * ------------------------------------------------------------
 * Compact practice-table presentation. The page deliberately has no
 * title block: live game state and controls own the top of the view.
 */

.drey-cards {
    box-sizing: border-box;
    max-width: 1220px;
    margin: 0 auto;
    padding: 0 0.7rem 0.7rem;
    font-family: Raleway, sans-serif;
}

/* ------------------------------------------------------------
 * Fixed game toolbar
 * ------------------------------------------------------------
 * Mirrors Drey's manager/table pattern: the toolbar remains at the top
 * while the game table scrolls underneath it.
 */

.drey-cards__topbar {
    position: sticky;
    z-index: 45;
    top: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.65rem;
    align-items: start;
    margin: 0 -0.7rem 0.55rem;
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid #c8d7c5;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(5px);
}

.drey-cards__status {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.35rem;
    margin: 0;
}

.drey-cards__status > div {
    min-width: 0;
    padding: 0.4rem 0.55rem;
    border: 1px solid #c8d7c5;
    border-radius: 6px;
    background: #f8fbf7;
}

.drey-cards__status-label {
    display: block;
    margin-bottom: 0.05rem;
    font-family: "Roboto Condensed", sans-serif;
    font-size: 0.65rem;
    line-height: 1;
    text-transform: uppercase;
}

.drey-cards__status strong {
    font-size: 0.9rem;
    line-height: 1.05;
}

.drey-cards__topbar-right {
    display: grid;
    gap: 0.22rem;
    justify-items: end;
    align-content: start;
}

.drey-cards__controls {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    margin: 0;
}

.drey-cards__controls .drey-module-button {
    min-height: 34px;
    padding: 4px 8px;
    white-space: nowrap;
}

.drey-cards__controls [data-game-last-card].is-called {
    background: #360f5a;
    color: #fff;
}

.drey-cards__intro {
    max-width: 610px;
    margin: 0;
    color: #485245;
    font-size: 0.7rem;
    line-height: 1.2;
    text-align: right;
}

/* ------------------------------------------------------------
 * Table shell
 * ------------------------------------------------------------
 */

.drey-cards__table {
    display: grid;
    gap: 0.4rem;
    padding: 0.55rem;
    border: 2px solid #214700;
    border-radius: 12px;
    background: #eef7eb;
}

/* ------------------------------------------------------------
 * Opponents
 * ------------------------------------------------------------
 */

.drey-cards__opponents {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
}

.drey-cards__opponent,
.drey-cards__human {
    position: relative;
    border-radius: 8px;
}

.drey-cards__opponent {
    min-height: 98px;
    padding: 0.45rem;
    background: rgba(255, 255, 255, 0.78);
    text-align: center;
}

.drey-cards__opponent.is-current,
.drey-cards__human.is-current {
    background: #f3e8ff;
    box-shadow: inset 0 0 0 3px #360f5a;
}

.drey-cards__opponent.is-current::after,
.drey-cards__human.is-current::after {
    content: "Current turn";
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 2px 5px;
    border-radius: 999px;
    background: #360f5a;
    color: #fff;
    font-size: 0.58rem;
    font-weight: 700;
    line-height: 1.2;
}

.drey-cards__player-head {
    display: flex;
    gap: 6px;
    align-items: center;
    text-align: left;
}

.drey-cards__avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border: 2px solid #214700;
    border-radius: 50%;
    object-fit: cover;
    background: #dcffdb;
}

.drey-cards__opponent strong {
    font-size: 0.84rem;
}

.drey-cards__opponent span {
    font-size: 0.76rem;
}

/* ------------------------------------------------------------
 * Opponent hands
 * ------------------------------------------------------------
 */

.drey-cards__mini-hand {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    min-height: 54px;
    padding: 4px 20px 0;
}

.drey-cards__mini-card {
    width: 40px;
    height: 56px;
    flex: 0 0 40px;
    margin-left: -31px;
    border: 1px solid #fff;
    border-radius: 4px;
    background: url("../img/cardBack.png") center / cover no-repeat;
    transform-origin: 50% 110%;
}

.drey-cards__mini-card:first-child {
    margin-left: 0;
}

.drey-cards__mini-card:nth-child(1)  { transform: rotate(-8deg) translateY(4px); }
.drey-cards__mini-card:nth-child(2)  { transform: rotate(-6deg) translateY(2px); }
.drey-cards__mini-card:nth-child(3)  { transform: rotate(-4deg) translateY(1px); }
.drey-cards__mini-card:nth-child(4)  { transform: rotate(-2deg); }
.drey-cards__mini-card:nth-child(5)  { transform: rotate(0deg); }
.drey-cards__mini-card:nth-child(6)  { transform: rotate(2deg); }
.drey-cards__mini-card:nth-child(7)  { transform: rotate(4deg) translateY(1px); }
.drey-cards__mini-card:nth-child(8)  { transform: rotate(6deg) translateY(2px); }
.drey-cards__mini-card:nth-child(9)  { transform: rotate(8deg) translateY(4px); }
.drey-cards__mini-card:nth-child(10) { transform: rotate(9deg) translateY(5px); }
.drey-cards__mini-card:nth-child(11) { transform: rotate(10deg) translateY(6px); }
.drey-cards__mini-card:nth-child(12) { transform: rotate(11deg) translateY(7px); }

/* ------------------------------------------------------------
 * Centre table
 * ------------------------------------------------------------
 * Explicit columns keep the pickup pile fixed instead of allowing it to
 * drift according to the width of the discard or move-history content.
 */

.drey-cards__centre {
    display: grid;
    grid-template-columns: 76px 220px minmax(0, 1fr);
    grid-template-areas: "draw discard moves";
    gap: 0.55rem;
    align-items: center;
    min-height: 108px;
    padding: 0.15rem 0;
}

.drey-cards__draw-area {
    grid-area: draw;
    display: grid;
    justify-items: center;
    align-content: center;
    min-width: 0;
}

.drey-cards__pile-label,
.drey-cards__discard-label {
    margin-top: 2px;
    font-size: 0.66rem;
    font-weight: 700;
    line-height: 1;
}

.drey-cards__discard-area {
    grid-area: discard;
    min-width: 0;
    text-align: center;
}

.drey-cards__discard-stack {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 82px;
    padding-left: 46px;
}

.drey-cards__discard-stack .drey-card {
    flex: 0 0 auto;
    margin-left: -46px;
}

.drey-cards__discard-stack .drey-card:first-child {
    margin-left: 0;
}

.drey-cards__last-moves {
    grid-area: moves;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
    min-width: 0;
    margin: 0;
}

.drey-cards__last-move {
    min-width: 0;
    min-height: 48px;
    padding: 5px 7px;
    border: 1px solid rgba(33, 71, 0, 0.25);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.55);
    text-align: left;
}

.drey-cards__last-move strong {
    display: block;
    margin-bottom: 1px;
    font-size: 0.72rem;
}

.drey-cards__last-move span {
    display: block;
    overflow: hidden;
    font-family: "Roboto Condensed", sans-serif;
    font-size: 0.68rem;
    line-height: 1.15;
    text-overflow: ellipsis;
}

/* ------------------------------------------------------------
 * Cards
 * ------------------------------------------------------------
 */

.drey-card {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    width: 62px;
    height: 90px;
    padding: 5px;
    border: 2px solid #262626;
    border-radius: 7px;
    background: #fff;
    color: #111;
    font-family: Georgia, serif;
    cursor: pointer;
    user-select: none;
}

.drey-card__rank {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
}

.drey-card__suit {
    position: absolute;
    top: 25px;
    left: 6px;
    font-size: 0.95rem;
}

.drey-card__centre-mark {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 2rem;
}

.drey-card--spades,
.drey-card--clubs {
    color: #3f8f22;
}

.drey-card--hearts,
.drey-card--diamonds {
    color: #7a2b9a;
}

.drey-card--back {
    display: block;
    padding: 0;
    border: 2px solid #214700;
    background: url("../img/cardBack.png") center / cover no-repeat;
    color: transparent;
    overflow: hidden;
}

.drey-card--back .drey-card__back-mark,
.drey-card--back .drey-card__back-text {
    display: none;
}

.drey-card:disabled {
    cursor: default;
    opacity: 0.7;
}

/* ------------------------------------------------------------
 * Human hand
 * ------------------------------------------------------------
 */

.drey-cards__message {
    min-height: 1rem;
    margin: 0;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.15;
}

.drey-cards__human {
    padding: 0.45rem;
}

.drey-cards__hand-heading {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.drey-cards__hand-heading > span {
    padding-right: 4px;
    font-size: 0.78rem;
}

.drey-cards__hand {
    display: flex;
    align-items: flex-end;
    min-height: 98px;
    overflow-x: auto;
    padding: 4px 4px 6px;
}

.drey-cards__hand .drey-card {
    margin-left: -19px;
    transition:
        transform 120ms ease,
        box-shadow 120ms ease,
        background-color 120ms ease;
}

.drey-cards__hand .drey-card:first-child {
    margin-left: 0;
}

@media (hover: hover) {
    .drey-cards__hand .drey-card:hover:not(.is-selected) {
        z-index: 3;
        transform: translateY(-5px);
    }
}

.drey-cards__hand .drey-card.is-selected {
    z-index: auto;
    transform: none;
    margin-right: 0;
    border-color: #360f5a;
    box-shadow: inset 0 0 0 3px #360f5a;
    background: #f3e8ff;
}

/* ------------------------------------------------------------
 * Dialogs
 * ------------------------------------------------------------
 */

.drey-cards__suit-picker,
.drey-cards__rules-modal {
    position: fixed;
    z-index: 9999;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.48);
}

.drey-cards__suit-picker[hidden],
.drey-cards__rules-modal[hidden] {
    display: none;
}

.drey-cards__suit-dialog,
.drey-cards__rules-dialog {
    width: min(500px, 100%);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding: 1rem;
    border-radius: 10px;
    background: #fff;
}

.drey-cards__suit-dialog {
    width: min(420px, 100%);
    text-align: center;
}

.drey-cards__dialog-heading {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}

.drey-cards__rules-dialog p {
    margin: 0.55rem 0;
    line-height: 1.35;
}

.drey-cards__suit-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    margin-top: 0.8rem;
}

.drey-cards__suit-buttons button {
    min-height: 42px;
    border: 1px solid #214700;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-weight: 700;
}

/* ------------------------------------------------------------
 * Narrow desktop / tablet
 * ------------------------------------------------------------
 */

@media (max-width: 980px) {
    .drey-cards__topbar {
        grid-template-columns: 1fr;
    }

    .drey-cards__topbar-right {
        justify-items: stretch;
    }

    .drey-cards__controls {
        justify-content: flex-start;
    }

    .drey-cards__intro {
        max-width: none;
        text-align: left;
    }

    .drey-cards__centre {
        grid-template-columns: 70px 190px minmax(0, 1fr);
    }
}

/* ------------------------------------------------------------
 * Mobile
 * ------------------------------------------------------------
 */

@media (max-width: 700px) {
    .drey-cards {
        padding: 0 0.35rem 0.35rem;
    }

    .drey-cards__topbar {
        gap: 0.25rem;
        margin: 0 -0.35rem 0.3rem;
        padding: 0.3rem 0.35rem;
    }

    .drey-cards__status {
        gap: 0.18rem;
    }

    .drey-cards__status > div {
        padding: 0.22rem;
    }

    .drey-cards__status-label {
        font-size: 0.5rem;
    }

    .drey-cards__status strong {
        font-size: 0.68rem;
    }

    .drey-cards__controls {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 0.18rem;
    }

    .drey-cards__controls .drey-module-button {
        min-width: 0;
        min-height: 30px;
        padding: 2px 3px;
        font-size: 0.58rem;
        line-height: 1;
        white-space: normal;
    }

    .drey-cards__intro {
        display: none;
    }

    .drey-cards__table {
        gap: 0.25rem;
        padding: 0.32rem;
    }

    .drey-cards__opponents {
        gap: 0.25rem;
    }

    .drey-cards__opponent {
        min-height: 76px;
        padding: 0.3rem;
    }

    .drey-cards__avatar {
        width: 30px;
        height: 30px;
        flex-basis: 30px;
    }

    .drey-cards__opponent strong {
        font-size: 0.76rem;
    }

    .drey-cards__opponent span {
        font-size: 0.66rem;
    }

    .drey-cards__mini-hand {
        min-height: 42px;
        padding: 2px 16px 0;
    }

    .drey-cards__mini-card {
        width: 32px;
        height: 45px;
        flex-basis: 32px;
        margin-left: -25px;
    }

    .drey-cards__opponent.is-current::after,
    .drey-cards__human.is-current::after {
        top: 4px;
        right: 4px;
        font-size: 0.5rem;
    }

    .drey-cards__centre {
        grid-template-columns: 58px minmax(92px, 0.7fr) minmax(0, 1.5fr);
        gap: 0.25rem;
        min-height: 78px;
        padding: 0;
    }

    .drey-card {
        width: 50px;
        height: 72px;
        padding: 4px;
        border-radius: 6px;
    }

    .drey-card__rank {
        font-size: 0.86rem;
    }

    .drey-card__suit {
        top: 21px;
        left: 5px;
        font-size: 0.8rem;
    }

    .drey-card__centre-mark {
        font-size: 1.6rem;
    }

    .drey-cards__discard-stack {
        min-height: 70px;
        padding-left: 38px;
    }

    .drey-cards__discard-stack .drey-card {
        margin-left: -38px;
    }

    .drey-cards__last-moves {
        gap: 0.18rem;
    }

    .drey-cards__last-move {
        min-height: 38px;
        padding: 3px 4px;
    }

    .drey-cards__last-move strong,
    .drey-cards__last-move span {
        font-size: 0.58rem;
    }

    .drey-cards__message {
        font-size: 0.64rem;
    }

    .drey-cards__human {
        padding: 0.3rem;
    }

    .drey-cards__hand-heading {
        margin-bottom: 0.15rem;
    }

    .drey-cards__hand {
        min-height: 78px;
        padding: 2px 2px 3px;
    }

    .drey-cards__hand .drey-card {
        margin-left: -20px;
    }
}
