:root {
    /* Variables */
    --font-main: 'Outfit', sans-serif;
    --font-display: 'Playfair Display', serif;
    --sidebar-width: 280px;
    --transition-speed: 0.3s;
    --color-primary: #32b8c6;
    --color-secondary: #2a8fa3;
    --color-accent: #0ffbf7;
    --color-bg-dark: #1a1e24;
    --color-bg-panel: #181b21;
    --color-text: #ffffff;
    --color-text-secondary: #a0a8b0;
    --color-success: #10b981;
    --color-error: #ef4444;
    --color-warning: #f59e0b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--color-bg-dark);
    color: var(--color-text);
    overflow: hidden;
    height: 100vh;
    /* Ensure full height */
    margin: 0;
}

/* --- CUSTOM SCROLLBAR (Black) --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #0f1115;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #444;
}

#app {
    display: flex;
    height: 100vh;
    transition: all 0.3s;
}

/* --- SIDEBAR --- */
#sidebar {
    width: var(--sidebar-width);
    background-color: var(--color-bg-panel);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    overflow-y: auto;
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#app.collapsed #sidebar {
    width: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
}

.logo-container {
    margin-bottom: 2.5rem;
    white-space: nowrap;
}

.logo {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: 2px;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-links {
    list-style: none;
    white-space: nowrap;
}

.nav-links li {
    margin-bottom: 0.5rem;
}

.nav-section {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--color-text-secondary);
    margin: 1.5rem 0 0.5rem 0;
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--color-text-secondary);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    transition: all 0.2s;
}

.nav-link i {
    margin-right: 10px;
    width: 18px;
    height: 18px;
}

.nav-link:hover {
    color: var(--color-text);
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    background-color: rgba(50, 184, 198, 0.1);
    color: var(--color-primary);
}

.nav-link.play-btn {
    background: linear-gradient(135deg, rgba(50, 184, 198, 0.2), rgba(15, 251, 247, 0.2));
    border: 1px solid rgba(50, 184, 198, 0.3);
    color: #fff;
    margin-top: 0.5rem;
}

/* --- MAIN CONTENT --- */
#main-content {
    position: relative;
    flex: 1;
    overflow: hidden;
    background: #000;
    display: flex;
    flex-direction: column;
}

/* PDF CONTAINER LAYOUT */
.pdf-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
    overflow: hidden;
}

.page-header {
    padding: 1rem 2rem;
    background: var(--color-bg-panel);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.pdf-embed-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.sidebar-toggle-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 500;
    background: transparent;
    /* Burger menu style */
    color: var(--color-text);
    /* White icon */
    border: none;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}

.sidebar-toggle-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-toggle-btn i {
    width: 32px;
    height: 32px;
    /* Large Icon */
}

/* --- GAME LAYOUT & DYNAMIC TRANSITION --- */
.game-layout-container {
    display: flex;
    height: 100%;
    width: 100%;
}

.poker-section {
    flex: 7;
    /* Default: Wide (70%) */
    background: radial-gradient(circle at center, #2d3139 0%, #111 100%);
    position: relative;
    transition: flex 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
}

.keno-panel {
    flex: 3;
    /* Default: Narrow (30%) - "Half Size" feel */
    background: linear-gradient(180deg, #1a1e24 0%, #121418 100%);
    border-left: 2px solid var(--color-primary);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow-y: auto;
    transition: flex 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    z-index: 20;

    /* ENABLE CONTAINER QUERIES */
    container-type: inline-size;
    container-name: keno;
}

/* EXPAND STATE: Hovering Keno makes it dominant */
.keno-panel:hover {
    flex: 7;
    /* Expands to 70% */
}

/* Note: Poker will shrink automatically due to flex-grow/shrink ratios if handled correctly by browser flex algo. 
   Total flex sum changes 10->10, so it works perfectly. */

/* --- POKER TABLE VISUALS --- */
.poker-table-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1000px;
    padding: 2rem;
}

/* PDF FRAME */
#pdf-frame {
    border: none;
    display: block;
    width: 100%;
    height: 100%;
}

.poker-table-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1000px;
    padding: 2rem;
}

.poker-table {
    width: 90%;
    max-width: 900px;
    aspect-ratio: 1.8;
    background: #1a5c38;
    border: 12px solid #3e2723;
    border-radius: 200px;
    box-shadow:
        inset 0 0 50px rgba(0, 0, 0, 0.8),
        0 20px 50px rgba(0, 0, 0, 0.5);
    position: relative;
    transform: rotateX(10deg);
}

/* Community Cards */
.community-cards {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    gap: 8px;
}

.card {
    width: 45px;
    height: 65px;
    background: #fff;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #000;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    font-size: 14px;
}

.card.hidden {
    background: #b71c1c;
    background-image: repeating-linear-gradient(45deg, #a00 0, #a00 5px, #900 5px, #900 10px);
}

.card-small {
    width: 30px;
    height: 42px;
    font-size: 0;
}

.hero-cards .card {
    width: 55px;
    height: 80px;
    font-size: 18px;
    transform: translateY(-30px);
    border: 2px solid gold;
}

/* Pot */
.pot-display {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 12px;
    border-radius: 20px;
    color: #fff;
    font-size: 12px;
    display: flex;
    gap: 6px;
}

.pot-display .value {
    color: #ffd700;
    font-weight: bold;
}

/* Seats */
.seat {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 80px;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #555;
    background: #333;
    z-index: 2;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-info {
    background: #111;
    color: #fff;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 10px;
    margin-top: -10px;
    z-index: 3;
    text-align: center;
    border: 1px solid #333;
    min-width: 70px;
}

.player-info .name {
    color: #888;
    margin-bottom: 1px;
}

.player-info .chips {
    color: #4caf50;
    font-weight: bold;
}

/* Seat Positions */
.seat-1 {
    top: -30px;
    left: 30%;
}

.seat-2 {
    top: -30px;
    right: 30%;
}

.seat-3 {
    top: 40%;
    right: -50px;
}

.seat-4 {
    top: 40%;
    left: -50px;
}

.seat-hero {
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
}

/* Controls */
.poker-controls {
    height: 80px;
    background: linear-gradient(to top, #000, rgba(0, 0, 0, 0));
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding-bottom: 1rem;
}

.poker-btn {
    padding: 0.8rem 2rem;
    border-radius: 30px;
    border: none;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    font-size: 1rem;
    color: #fff;
    transition: transform 0.1s;
}

.poker-btn:hover {
    transform: translateY(-2px);
}

.btn-fold {
    background: #d32f2f;
}

.btn-check {
    background: #388e3c;
}

.btn-raise {
    background: #fbc02d;
    color: #000;
}

.raise-slider input {
    width: 150px;
    accent-color: #fbc02d;
}


/* --- KENO PANEL STYLES --- */
.keno-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.keno-title {
    font-weight: bold;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.countdown {
    font-family: monospace;
    font-size: 1.2rem;
    color: var(--color-accent);
}

/* GRID */
.number-grid-container {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex: 1;
    /* Take available space */
    overflow-y: auto;
    /* Scroll if needed */
}

.number-grid {
    display: grid;
    /* Default: Narrow layout (Vertical alignment focus) */
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

/* CONTAINER QUERY: When panel is wide, switch to 10 cols */
@container keno (min-width: 500px) {
    .number-grid {
        grid-template-columns: repeat(10, 1fr);
        gap: 6px;
    }

    /* Make buttons slightly bigger in wide mode? */
    .number-btn {
        height: 34px;
        font-size: 11px;
    }
}

.keno-panel:hover .number-grid {
    /* Fallback for browsers without container queries? Or just let it be. 
       Modern browsers supporting :has() usually support container queries. */
}

.number-btn {
    height: 30px;
    background: #222;
    border: 1px solid #444;
    color: #aaa;
    border-radius: 4px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}

.number-btn:hover {
    background: #333;
    border-color: #666;
}

.number-btn--selected {
    background: var(--color-primary);
    color: #000;
    border-color: var(--color-primary);
}

.number-btn--winning {
    background: var(--color-success);
    color: #fff;
}

.number-btn--drawn {
    background: var(--color-warning);
    color: #fff;
}

/* Balance & Controls */
.bet-controls-wrapper {
    background: rgba(255, 255, 255, 0.03);
    padding: 10px;
    border-radius: 8px;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.balance-display {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.balance-row {
    display: flex;
    justify-content: space-between;
    color: #888;
}

.balance-row .balance-value {
    color: #fff;
    font-weight: bold;
}

.balance-row--payout .balance-value {
    color: var(--color-success);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.input-label {
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
}

.bet-input {
    background: #111;
    border: 1px solid #333;
    color: #fff;
    padding: 8px;
    border-radius: 4px;
    width: 100%;
}

.bonus-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    padding: 5px;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 4px;
}

.bonus-badge {
    background: #fbc02d;
    color: #000;
    padding: 1px 4px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
}

.button-group {
    display: flex;
    gap: 8px;
}

.btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.btn-primary {
    background: var(--color-primary);
    color: #000;
}

.btn-secondary {
    background: #333;
    color: #fff;
    border: 1px solid #444;
}

.quick-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin-top: 5px;
}

.quick-btn {
    background: #222;
    border: 1px solid #333;
    color: #bbb;
    padding: 5px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
}

.quick-btn:hover {
    border-color: var(--color-primary);
    color: #fff;
}

/* TX Info */
.tx-info {
    margin-top: 1rem;
    padding: 8px;
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.7rem;
    color: var(--color-primary);
    position: relative;
    cursor: help;
}

/* Tooltip with 3s Delay */
.tx-tooltip {
    opacity: 0;
    visibility: hidden;
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    width: 250px;
    background: #0f1217;
    border: 1px solid var(--color-primary);
    padding: 10px;
    border-radius: 8px;
    text-align: left;
    z-index: 999;

    /* 3s delay on exit */
    transition: opacity 0.3s ease, visibility 0.3s ease;
    transition-delay: 3s;
}

.tx-info:hover .tx-tooltip,
.tx-tooltip:hover {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
    /* Instant enter */
}

.tooltip-header {
    font-weight: bold;
    color: var(--color-primary);
    border-bottom: 1px solid #333;
    padding-bottom: 5px;
    margin-bottom: 5px;
}

.tooltip-hash {
    word-break: break-all;
    color: #888;
    font-size: 0.7rem;
    margin-bottom: 10px;
    background: #000;
    padding: 5px;
}

.tooltip-link {
    display: block;
    text-align: center;
    background: var(--color-primary);
    color: #000;
    text-decoration: none;
    padding: 5px;
    border-radius: 4px;
    font-weight: bold;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}