:root {
    --ui-scale: 1rem; /* Base fallback scale for mobile layouts */
}

/* ========================================================
   CORE BOARD MOBILE SIZING ADJUSTMENTS
   ======================================================== */
.board-container-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 0; /* Remove padding to maximize edge-to-edge space */
    box-sizing: border-box;
}

.board {
    aspect-ratio: 1 / 1;
    width: 98vw;       /* Explicitly claims 98% of mobile screen width */
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

/* Ensure the outer wrapper doesn't bottle up the layout */
.app-layout-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    gap: calc(var(--ui-scale) * 1);
    box-sizing: border-box;
    padding: 0 calc(var(--ui-scale) * 0.2); /* Minimized safety margins on edges */
}

/* Tall screen / Portrait orientation rules */
.gameplay-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Landscape / Wide view adjustments */

/* Landscape / Wide view adjustments */
@media (width >= 768px) and (orientation: landscape), (width >= 992px) {
    .app-layout-container {
        display: grid !important;
        grid-template: "board controls" auto "board sidebar" 1fr / 94vh 1fr;
        gap: 20px;
        height: calc(100vh - 2rem);
        align-items: stretch;
    }

    .gameplay-area {
        display: contents;
    }

    .board-container-wrapper {
        grid-area: board;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100%;
    }

    .board {
        width: auto !important;
        height: 95vh !important;
        max-width: 100%;
        aspect-ratio: 1 / 1;
    }

    .controls-row {
        grid-area: controls;
        max-width: 100% !important;
        margin: 0;
    }

    /* ========================================================
       SIMPLIFIED CARD & TEXT SHRINKING
       ======================================================== */
    .metadata-sidebar {
        grid-area: sidebar;
        height: 100%;
        max-width: 100%;

        /* 1. Shrinks everything inside by 20% globally */
        zoom: 0.6;

        /* 2. Fallback scaling if your app overrides zoom logic */
        --ui-scale: 0.6rem;
    }
}

/* ========================================================
   4, 5, 6. UNIFIED TABBED SIDEBAR PANELS
   ======================================================== */
.metadata-sidebar {
    display: flex;
    flex-direction: column;
    background-color: #fff;
    border: 1px solid #e2e8f0;
    border-radius: calc(var(--ui-scale) * 0.5);
    overflow: hidden;
}

.sidebar-tabs {
    display: flex;
    background-color: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.tab-btn {
    flex: 1;
    padding: calc(var(--ui-scale) * 0.75) calc(var(--ui-scale) * 0.5);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: calc(var(--ui-scale) * 0.9);
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tab-btn:hover {
    color: #334155;
    background-color: #f1f5f9;
}

.tab-btn.active {
    color: #3273dc;
    border-bottom-color: #3273dc;
    background-color: #fff;
}

.sidebar-panel-content {
    flex: 1;
    padding: calc(var(--ui-scale) * 1);
    overflow-y: auto;
}

.tab-panel {
    display: none;
    height: 100%;
}

.tab-panel.active {
    display: block;
}

.sidebar-heading {
    font-size: calc(var(--ui-scale) * 1.2);
    font-weight: 700;
    color: #1e293b;
    margin-top: 0;
    margin-bottom: calc(var(--ui-scale) * 0.75);
}

