﻿*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    background: radial-gradient(circle at top, #1d2d5a 0%, #0f1633 45%, #070b1a 100%);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: #f4e8c8;
    overflow: hidden;
}

body {
    min-height: 100vh;
}

/* Container query root */
.poker-container {
    container-type: inline-size;
    container-name: poker;
    width: 100%;
    height: 100%;
}

/* ── Recovery ───────────────────────────────────────────── */
.recovery-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    padding: 2rem;
}

.recovery-content {
    text-align: center;
    padding: 2rem 2.5rem;
    border-radius: 18px;
    background: rgba(10, 18, 45, 0.88);
    border: 1px solid rgba(233, 69, 96, 0.4);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.recovery-spinner {
    font-size: 3rem;
    display: inline-block;
    animation: rspin 1.2s linear infinite;
    margin-bottom: 1rem;
    color: #ffd54d;
}

@keyframes rspin {
    to {
        transform: rotate(360deg);
    }
}

.recovery-content h2 {
    color: #ffd54d;
    margin-bottom: 0.5rem;
    font-size: clamp(1.2rem, 3cqi, 2rem);
}

.recovery-content p {
    color: #d4ddff;
    font-size: clamp(0.95rem, 1.8cqi, 1.1rem);
}

/* ── Main game wrapper ──────────────────────────────────── */
.poker-game {
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 0.8cqi;
    padding: 1cqi;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(16, 31, 72, 0.98), rgba(10, 20, 48, 0.98));
    border: 1px solid rgba(212, 175, 55, 0.28);
}

    /* ── Header ─────────────────────────────────────────────── */
    /* Only hand-area shrinks when space is tight — everything else holds its size */
    .poker-game > *:not(.hand-area) {
        flex-shrink: 0;
    }

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.2cqi;
    background: linear-gradient(135deg, #123b7a, #16213e);
    border: 2px solid #e94560;
    border-radius: 1cqi;
    padding: 0.75cqi 1.3cqi;
    flex-shrink: 0;
}

    .game-header h1 {
        font-size: clamp(0.85rem, 2.1cqi, 1.5rem);
        color: #ffd54d;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        text-shadow: 0 0 10px rgba(255, 213, 77, 0.25);
    }

.balance {
    font-size: clamp(0.8rem, 2cqi, 1.35rem);
    color: #ffe56a;
    font-weight: 800;
    white-space: nowrap;
}

/* ── Paytable ───────────────────────────────────────────── */
.paytable {
    display: flex;
    gap: 1cqi;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(233, 69, 96, 0.35);
    border-radius: 0.9cqi;
    padding: 0.7cqi 1cqi;
    flex-shrink: 0;
}

.paytable-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.18cqi;
}

.paytable-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.7cqi;
    padding: 0.18cqi 0.35cqi;
    border-radius: 0.35cqi;
    font-size: clamp(0.6rem, 1.35cqi, 1rem);
    line-height: 1.45;
}

.pt-hand {
    color: #b8d6ff;
}

.pt-pays {
    color: #ffd54d;
    font-weight: 800;
    white-space: nowrap;
}

.paytable-highlight {
    background: rgba(212, 175, 55, 0.18);
}

    .paytable-highlight .pt-hand {
        color: #fff;
        font-weight: 700;
    }

    .paytable-highlight .pt-pays {
        color: #ffe56a;
    }

/* ── Hand area ──────────────────────────────────────────── */
.hand-area {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 0.7cqi;
    flex-shrink: 1;
    padding: 1.2cqi 0.25cqi 0;
}

/* Card slot controls width of each card column */
.card-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.42cqi;
    flex-shrink: 0;
    width: clamp(72px, 18.5cqi, 220px);
}

.hold-badge-row {
    height: clamp(18px, 2.6cqi, 30px);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex-shrink: 0;
}

.hold-badge {
    font-size: clamp(0.5rem, 1.25cqi, 0.9rem);
    font-weight: 900;
    letter-spacing: 0.12em;
    color: #1a1400;
    background: linear-gradient(180deg, #ffd54d, #d4af37);
    border: 1px solid #ffea8a;
    border-radius: 4px;
    padding: 2px 9px;
    white-space: nowrap;
    text-transform: uppercase;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.25);
}

.hold-badge-spacer {
    height: clamp(18px, 2.6cqi, 30px);
    flex-shrink: 0;
}

/* Larger cards and larger text */
.card {
    width: clamp(72px, 18.5cqi, 220px);
    height: clamp(101px, 25.9cqi, 308px); /* 5:7 ratio */
    border-radius: clamp(6px, 1cqi, 14px);
    border: 2px solid #d7d2c6;
    cursor: pointer;
    user-select: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: clamp(5px, 0.9cqi, 12px);
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
    font-weight: 800;
    flex-shrink: 0;
    overflow: hidden;
    background: #fffef7;
    font-size: clamp(0.7rem, 2cqi, 1.35rem);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}

    .card:hover {
        transform: translateY(-4px);
    }

.card-empty {
    background: linear-gradient(135deg, #1a3a5a, #0a2040);
    border-color: #2a4a7a;
    cursor: default;
}

.card-back-face {
    font-size: 3.4em;
    opacity: 0.35;
    line-height: 1;
    margin: auto;
}

.card-face,
.card-red,
.card-black {
    background: #fffef7;
}

    .card-red .card-corner,
    .card-red .card-suit-center {
        color: #c71f1f;
    }

    .card-black .card-corner,
    .card-black .card-suit-center {
        color: #171717;
    }

.card-held {
    border-color: #ffd54d !important;
    box-shadow: 0 0 16px rgba(255, 213, 77, 0.78), 0 5px 18px rgba(0, 0, 0, 0.38);
}

.card-joker {
    background: linear-gradient(160deg, #3f1808, #7a2e0c, #47200a) !important;
    border-color: #ffd54d;
    color: #ffd54d;
}

/* Corner ranks much bigger */
.card-corner {
    font-size: 1.2em;
    font-weight: 900;
    line-height: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
}

    .card-corner.top {
        align-items: flex-start;
        text-align: left;
    }

    .card-corner.bottom {
        align-items: flex-end;
        text-align: right;
        transform: rotate(180deg);
    }

.card-rank {
    font-size: 1em;
    line-height: 0.95;
}

.card-suit-small {
    font-size: 0.95em;
    line-height: 0.95;
}

/* Center suit bigger */
.card-suit-center {
    font-size: 3.8em;
    line-height: 1;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Joker layout */
.joker-top,
.joker-bottom {
    width: 100%;
    font-size: 1.7em;
    line-height: 1;
    font-weight: 900;
}

.joker-top {
    text-align: left;
}

.joker-bottom {
    text-align: right;
    transform: rotate(180deg);
}

.joker-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72em;
    font-weight: 900;
    letter-spacing: 0.08em;
    color: #ffe182;
    text-align: center;
    padding: 0 0.2em;
}

/* ── Message area ───────────────────────────────────────── */
.message-area {
    min-height: clamp(74px, 10cqi, 120px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5cqi;
    flex: 1 1 auto;
    text-align: center;
    padding: 0.5cqi;
}

.result-message {
    text-align: center;
    font-size: clamp(1rem, 2.3cqi, 1.9rem);
    font-weight: 800;
    padding: 0.2em 0.6em;
    border-radius: 10px;
    animation: fadeIn 0.35s ease;
}

    .result-message.win {
        color: #86f7a8;
        text-shadow: 0 0 12px rgba(134, 247, 168, 0.28);
    }

    .result-message.lose {
        color: #d6d2cb;
    }

    .result-message.game-over {
        color: #ff7b7b;
        font-size: clamp(1rem, 2.1cqi, 1.6rem);
        font-weight: 800;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        animation: none;
    }

.hand-name {
    font-size: clamp(0.95rem, 1.8cqi, 1.35rem);
    font-weight: 800;
    color: #ffd54d;
}

.attract-message,
.draw-hint {
    font-size: clamp(0.85rem, 1.65cqi, 1.15rem);
    color: #41d7ff;
    text-align: center;
}

.attract-message {
    animation: attractPulse 2s ease-in-out infinite;
}

@keyframes attractPulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.45;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.92);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ── Controls ───────────────────────────────────────────── */
.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5cqi;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(233, 69, 96, 0.28);
    border-radius: 1cqi;
    padding: 0.8cqi 1cqi;
    flex-shrink: 0;
    flex-wrap: nowrap;
}

.bet-panel {
    display: flex;
    align-items: center;
    gap: 0.4cqi;
    flex-wrap: nowrap;
    flex-shrink: 1;
    min-width: 0;
}

.bet-label {
    font-size: clamp(0.65rem, 1.5cqi, 1.2rem);
    font-weight: 800;
    color: #ffd54d;
    white-space: nowrap;
    flex-shrink: 0;
}

.bet-buttons,
.action-buttons {
    display: flex;
    align-items: center;
    gap: 0.4cqi;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.18s ease;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

    .btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        transform: none !important;
    }

.btn-sm {
    min-width: clamp(28px, 3.8cqi, 50px);
    height: clamp(30px, 4cqi, 46px);
    padding: 0 0.6em;
    font-size: clamp(0.8rem, 1.4cqi, 1.15rem);
    background: linear-gradient(180deg, #f15a75, #e94560);
    color: #fff;
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.35);
}

    .btn-sm:hover:not(:disabled) {
        transform: translateY(-1px);
        box-shadow: 0 6px 15px rgba(233, 69, 96, 0.45);
    }

.btn-primary {
    min-width: clamp(56px, 9cqi, 150px);
    height: clamp(34px, 4.8cqi, 58px);
    padding: 0 0.7em;
    font-size: clamp(0.72rem, 1.5cqi, 1.25rem);
    background: linear-gradient(180deg, #23cfff, #0aa4e8);
    color: #fff;
    box-shadow: 0 6px 18px rgba(35, 207, 255, 0.35);
}

    .btn-primary:hover:not(:disabled) {
        transform: translateY(-2px);
        box-shadow: 0 8px 22px rgba(35, 207, 255, 0.45);
    }

.btn-secondary {
    min-width: clamp(78px, 12cqi, 210px);
    height: clamp(34px, 4.8cqi, 58px);
    padding: 0 0.7em;
    font-size: clamp(0.7rem, 1.4cqi, 1.2rem);
    background: linear-gradient(180deg, #ff5d7c, #e94560);
    color: #fff;
    box-shadow: 0 6px 18px rgba(233, 69, 96, 0.36);
}

    .btn-secondary:hover:not(:disabled) {
        transform: translateY(-2px);
        box-shadow: 0 8px 22px rgba(233, 69, 96, 0.5);
    }

/* ── Errors ─────────────────────────────────────────────── */
.error-message {
    margin-top: 0.4cqi;
    padding: 0.75em 1em;
    background: rgba(255, 0, 0, 0.12);
    border: 1px solid rgba(255, 90, 90, 0.5);
    border-radius: 10px;
    text-align: center;
    color: #ff9c9c;
    font-size: clamp(0.85rem, 1.45cqi, 1rem);
    flex-shrink: 0;
}

/* ── Responsive fallback ────────────────────────────────── */
@media (max-width: 700px) {
    .poker-game {
        padding: 10px;
        gap: 10px;
    }

    .game-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .paytable {
        flex-direction: row;
    }

    .controls-bar {
        flex-direction: row;
        align-items: center;
    }

    .bet-panel,
    .action-buttons {
        justify-content: center;
    }

    .hand-area {
        gap: 6px;
    }
}

/* 2-panel only (560-660px wide): tighten spacing so controls stay visible */
@container poker (min-width: 560px) and (max-width: 660px) {
    .poker-game {
        gap: 0.2cqi !important;
        padding: 0.4cqi !important;
    }

    .game-header {
        padding: 0.3cqi 1cqi !important;
    }

    .paytable {
        padding: 0.2cqi 0.8cqi !important;
    }

    .paytable-row {
        font-size: clamp(0.5rem, 1.05cqi, 0.78rem) !important;
        padding: 0.08cqi 0.3cqi !important;
        line-height: 1.35 !important;
    }

    .message-area {
        min-height: 0 !important;
        padding: 0.15cqi !important;
        gap: 0.2cqi !important;
    }

    .result-message,
    .attract-message,
    .draw-hint,
    .hand-name {
        font-size: clamp(0.75rem, 1.5cqi, 1rem) !important;
    }

    .hand-area {
        padding-top: 0.2cqi !important;
    }

    .controls-bar {
        padding: 0.4cqi 0.8cqi !important;
    }

    .hold-badge-row {
        height: 14px !important;
    }

    .hold-badge-spacer {
        height: 14px !important;
    }

    .card {
        height: clamp(77px, 20cqi, 200px) !important;
    }

    .card-slot {
        width: clamp(55px, 16.5cqi, 190px) !important;
    }
}

/* Short viewport (2-panel non-maximized): reduce card height to fit controls */
@media (max-height: 420px) {
    .card {
        height: clamp(60px, 18cqi, 180px) !important;
    }

    .hold-badge-row,
    .hold-badge-spacer {
        height: 14px !important;
    }

    .poker-game {
        gap: 2px !important;
        padding: 4px !important;
    }

    .paytable-row {
        font-size: 0.6rem !important;
        line-height: 1.3 !important;
        padding: 1px 3px !important;
    }

    .message-area {
        min-height: 0 !important;
        padding: 2px !important;
    }

    .hand-area {
        padding-top: 2px !important;
    }

    .controls-bar {
        padding: 4px 8px !important;
    }

    .game-header {
        padding: 3px 10px !important;
    }
}
