﻿/* --- 3D BOARD STYLES (Design Concepts 10 - VOLUMETRIC LAYERS) --- */

.perspective-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 2500px;
    contain: layout style;
}

.perspective-container .scene {
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 2500px;
}

.perspective-container .floating {
    position: relative;
    transform-style: preserve-3d;
    transform-origin: 50% 50%;
    width: var(--board-width, 800px);
    height: var(--board-height, 480px);
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.02);
    box-shadow: 0 50px 100px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s;
}

/* BASE LAYERS (1-8) */
.perspective-container .thickness {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.01);
    border: 2px solid rgba(255, 255, 255, 0.1);
    pointer-events: none;
}

.perspective-container .thickness:nth-child(1) {
    transform: translateZ(-10px);
}

.perspective-container .thickness:nth-child(2) {
    transform: translateZ(-20px);
}

.perspective-container .thickness:nth-child(3) {
    transform: translateZ(-30px);
}

.perspective-container .thickness:nth-child(4) {
    transform: translateZ(-40px);
}

.perspective-container .thickness:nth-child(5) {
    transform: translateZ(-50px);
}

.perspective-container .thickness:nth-child(6) {
    transform: translateZ(-60px);
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.2);
}

.perspective-container .card_body {
    position: relative;
    width: 100%;
    height: 100%;
    transform: translateZ(0px);
    backdrop-filter: none;
    /* Blur removed for clarity */
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.03);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    /* Grid padding reduced from 25px to give cells more space */
    transform-style: preserve-3d;
}


.perspective-container .grid {
    width: 100%;
    height: 100%;
    display: grid;
    /* Columns ve Rows JS tarafÄ±ndan set edilecek */
    transform-style: preserve-3d;
}

/* VOLUMETRIC CELL - 6-FACE CUBE STRUCTURE */
.perspective-container .cell {
    position: relative;
    transform-style: preserve-3d;
    width: 100%;
    height: 100%;
    cursor: pointer;
    transition: transform 0.2s ease-out;
    --depth: 30px;
    /* Increased from 25px for even more pronounced 3D */
}

/* HIDE faces on header cells (A-M, 1-7) - they don't need 3D boxes */
.perspective-container .cell.head .face {
    display: none !important;
}

/* Common Face Properties */
.perspective-container .face {
    position: absolute;
    border: none;
    backface-visibility: visible;
}

/* 1. FRONT FACE (Cap) - Rounded and Visible */
.perspective-container .face.front {
    width: 100%;
    height: 100%;
    transform: translateZ(var(--depth));

    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inconsolata', monospace;
    /* Dynamic font: fills 90% of cell */
    font-size: clamp(0.5rem, calc(var(--cell-size, 30px) * 0.45), 2rem);
    font-weight: bold;
    color: #fff;

    /* Glass Fill */
    background: rgba(255, 255, 255, 0.15);
    box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.01);

    /* Only cap has border */
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
}

/* 2. BACK FACE (Base) */
.perspective-container .face.back {
    width: 100%;
    height: 100%;
    transform: translateZ(0px);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
}

/* 3. RIGHT FACE (Side Wall) - SHORTENED */
.perspective-container .face.right {
    width: var(--depth);
    height: calc(100% - 12px);
    top: 6px;
    right: 0;
    transform-origin: right;
    transform: rotateY(-90deg);
    background: rgba(255, 255, 255, 0.05);
    /* Nearly invisible */
}

/* 4. LEFT FACE (Side Wall) - SHORTENED */
.perspective-container .face.left {
    width: var(--depth);
    height: calc(100% - 12px);
    top: 6px;
    left: 0;
    transform-origin: left;
    transform: rotateY(90deg);
    background: rgba(255, 255, 255, 0.05);
    /* Nearly invisible */
}

/* 5. TOP FACE (Ceiling) - SHORTENED */
.perspective-container .face.top {
    width: calc(100% - 12px);
    height: var(--depth);
    left: 6px;
    top: 0;
    transform-origin: top;
    transform: rotateX(-90deg);
    background: rgba(255, 255, 255, 0.05);
    /* Nearly invisible */
}

/* 6. BOTTOM FACE (Floor) - SHORTENED */
.perspective-container .face.bottom {
    width: calc(100% - 12px);
    height: var(--depth);
    left: 6px;
    bottom: 0;
    transform-origin: bottom;
    transform: rotateX(90deg);
    background: rgba(255, 255, 255, 0.05);
    /* Nearly invisible */
    box-shadow: none;
}

/* --- Interactions --- */
.perspective-container .cell:hover {
    transform: translateZ(10px);
}

.perspective-container .cell:hover .face.front {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

/* --- Special Colors --- */
.perspective-container .face.front.mine {
    color: #ff5555;
    text-shadow: 0 0 10px #ff0000;
}

.perspective-container .face.front.strip {
    color: #55aaff;
    text-shadow: 0 0 10px #0055ff;
}

/* CONTENT OVERLAY (for placed items) */
.perspective-container .cell-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inconsolata', monospace;
    font-size: 1.2rem;
    color: #fff;
    /* BLUE TINT for placed items */
    background: rgba(0, 150, 255, 0.25);
    border: 1px solid rgba(100, 200, 255, 0.6);
    border-top: 2px solid rgba(150, 220, 255, 0.9);
    border-radius: 8px;
    transform: translateZ(calc(var(--depth) + 1px));
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2), inset 0 0 10px rgba(0, 100, 255, 0.3);
    backdrop-filter: blur(4px);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Hover Effect */
.perspective-container .cell:hover .cell-content {
    border-color: rgba(255, 255, 255, 1);
    background: rgba(0, 150, 255, 0.4);
    transform: translateZ(calc(var(--depth) + 5px));
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
}

/* PLACEMENT STATES (Ghost) */
.perspective-container .cell-content.ghost-ok {
    background: rgba(50, 255, 50, 0.4) !important;
    border-color: #55ff55 !important;
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.6) !important;
}

.perspective-container .cell-content.ghost-bad {
    background: rgba(255, 50, 50, 0.4) !important;
    border-color: #ff5555 !important;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.6) !important;
}

/* GAME STATES - Updated Colors */
.perspective-container .cell-content.mine,
.perspective-container .cell-content.hit-mine {
    background: rgba(255, 50, 50, 0.5) !important;
    /* MINE = RED */
    border-color: #ff5555 !important;
    box-shadow: 0 0 15px #ff0000 !important;
    color: #fff !important;
}

.perspective-container .cell-content.hit-prime {
    background: rgba(50, 150, 255, 0.5) !important;
    /* HIT = BLUE */
    border-color: #55aaff !important;
    box-shadow: 0 0 15px #0088ff !important;
    color: #fff !important;
}

/* MISS = YELLOW */
.perspective-container .cell-content.miss {
    background: rgba(255, 200, 50, 0.5) !important;
    color: #fff !important;
    border-color: #ffcc00 !important;
    box-shadow: 0 0 15px rgba(255, 200, 0, 0.6) !important;
}

/* ====== MOBILE RESPONSIVE FIXES ====== */

/* PORTRAIT MODE - Taller board, strips pushed down */
@media (max-width: 768px) and (orientation: portrait) {

    /* Board sizing - DISABLED: Let JS control via base rule CSS variables
    .perspective-container .floating {
        width: var(--board-width, 88vw);
        height: var(--board-height, 55vw);
        max-width: none;
        max-height: none;
    }
    */

    /* Position board at top */
    .perspective-container {
        align-items: flex-start !important;
        padding-top: 10px !important;
    }

    .perspective-container .cell-content {
        font-size: 0.65rem !important;
    }

    .perspective-container .cell {
        --depth: 15px !important;
    }

    .perspective-container .face.front {
        font-size: 0.7rem !important;
    }

    /* REVERTED: Default padding for Stage 1 (25px) */
    /* TARGETED FIX: Stage 2 Only */
    #stage2 .perspective-container .card_body {
        padding: 4px 4px !important;
        /* Reduced only for Battle Screen */
    }

    /* Sidebar compact styling for shorter text */

    /* FORCE PARENT LAYOUT TO BE AUTO */
    #stage1.layout {
        grid-template-columns: auto 1fr !important;
    }

    /* Sidebar compact styling for shorter text - ULTRA SPECIFIC */
    html body #stage1 aside.sidebar {
        overflow: visible !important;
        font-size: 0.7rem !important;
        width: fit-content !important;
        min-width: 0px !important;
        max-width: 90px !important;
        padding: 4px !important;
        flex-shrink: 0 !important;
        flex-basis: auto !important;
    }

    /* HOST CONTENT FIX: Hide desktop elements in mobile sidebar */
    #stage1 .sidebar>h3,
    #stage1 .sidebar>.strips-list,
    #stage1 .sidebar>#mpInfoPanel {
        display: none !important;
    }

    /* Compact instruction text styling */
    #stage1 .footer-hint,
    #stage1 .footer-legend {
        font-size: 9px !important;
        text-align: center !important;
        line-height: 1.3 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 2px !important;
    }

    /* Stack legend items vertically */
    #stage1 .footer-legend span {
        display: block !important;
        margin-top: 2px !important;
    }
}

/* LANDSCAPE MODE - All Mobile/Tablet Landscape Fixes */
@media (max-width: 850px) and (orientation: landscape) {

    /* 1. BOARD - DISABLED: Let JS control via base rule CSS variables
    .perspective-container .floating {
        width: var(--board-width, 80%);
        height: var(--board-height, 90vh);
        max-width: none;
        max-height: none;
        margin: 1vh auto;
        padding: 5px;
        border-radius: 30px;
    }
    */

    /* Thickness layers - match floating border-radius */
    .perspective-container .thickness {
        border-radius: 30px !important;
    }

    /* Card body - match floating border-radius */
    .perspective-container .card_body {
        border-radius: 30px !important;
    }

    .perspective-container {
        align-items: flex-start !important;
        justify-content: center !important;
        padding: 0 !important;
    }

    #stage1 .main-area {
        padding: 0 !important;
        flex: 1 !important;
    }

    /* Scene - NO padding for headers to be at top */
    .perspective-container .scene {
        padding: 0 !important;
    }

    /* === GRID - STANDARD GAP === */
    .perspective-container .grid {
        gap: 6px !important;
    }

    /* === HEADER FIX === */
    .perspective-container .cell.head {
        transform: translateZ(0) !important;
        transform-style: flat !important;
        position: relative !important;
        z-index: 100 !important;
    }

    /* Header text */
    .perspective-container .cell.head .cell-content {
        font-size: 10px !important;
        line-height: 1 !important;
    }

    /* === CELLS - STANDARD VALUES === */
    .perspective-container .cell {
        --depth: 15px !important;
        border-radius: 8px !important;
    }

    .perspective-container .face {
        border-radius: 8px !important;
    }

    .perspective-container .face.front {
        border-radius: 8px !important;
    }

    /* CELL NUMBERS */
    .perspective-container .cell-content {
        font-size: 11px !important;
    }

    .perspective-container .face.front {
        font-size: 11px !important;
    }

    /* 2. SIDEBAR - DYNAMIC (fit-content based on strips) */
    #stage1 .sidebar {
        overflow-y: auto !important;
        max-height: 95vh !important;
        width: fit-content !important;
        min-width: 160px !important;
        max-width: 300px !important;
        padding: 5px 10px !important;
        padding-bottom: 30px !important;
    }

    /* 3. STRIPS - Scale based on sidebar fit */
    #stage1 .sidebar .strip,
    #stage1 .strips-area .strip,
    .strips-container .strip,
    .strip {
        transform: scale(0.55) !important;
        transform-origin: left top !important;
        margin-bottom: -12px !important;
        white-space: nowrap !important;
    }

    /* Sidebar text */
    #stage1 .sidebar .legend,
    #stage1 .sidebar .instructions,
    #stage1 .sidebar p,
    #stage1 .sidebar small,
    #stage1 .footer-legend,
    #stage1 .footer-hint {
        font-size: 0.55rem !important;
        line-height: 1.2 !important;
        white-space: normal !important;
        text-overflow: clip !important;
        width: 100% !important;
    }
}

/* General small screens */
@media (max-width: 850px) {
    .perspective-container .cell-content {
        font-size: 0.8rem;
    }
}

/* Force transparency on original sharp-edged containers */
.main-area,
.board-card,
#boardStage1,
#boardStage2,
.grid,
#gridDesign,
#gridBattle {
    background: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    border: none !important;
    backdrop-filter: none !important;
    outline: none !important;
}

/* ===== STAGE 2 SYNC: Identical styling to Stage 1 ===== */
#stage2 .perspective-container .cell,
#gridBattle .cell {
    --depth: 30px;
}

/* HIDE faces on Stage 2 header cells too */
#stage2 .cell.head .face,
#gridBattle .cell.head .face {
    display: none !important;
}

#stage2 .face.front,
#gridBattle .face.front {
    background: rgba(255, 255, 255, 0.15) !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    border-radius: 8px !important;
}

#stage2 .face.back,
#gridBattle .face.back {
    background: rgba(255, 255, 255, 0.02) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

#stage2 .face.left,
#stage2 .face.right,
#stage2 .face.top,
#stage2 .face.bottom,
#gridBattle .face.left,
#gridBattle .face.right,
#gridBattle .face.top,
#gridBattle .face.bottom {
    background: rgba(255, 255, 255, 0.05) !important;
    /* Match Stage 1 */
}

/* Remove any old cell background colors from Stage 2 */
#stage2 .cell,
#gridBattle .cell {
    background: transparent !important;
}

/* ===== DESKTOP STAGE 2 ONLY (min-width: 1024px) ===== */
@media (min-width: 1024px) {

    /* ===== MINI GRID FIX ===== */
    /* Override style.css line 2496: div#stage2.layout { overflow-y: auto !important; } */
    div#stage2.layout {
        overflow: visible !important;
        overflow-y: visible !important;
    }

    /* Remove scroll from sidebar and mini-grid containers */
    #stage2 .sidebar,
    div#stage2 .sidebar,
    div#stage2.layout>.sidebar {
        overflow: visible !important;
        overflow-y: visible !important;
        max-height: none !important;
    }

    #stage2 .stage2-box,
    #stage2 .mini-grid-wrap,
    div#stage2 .mini-grid-wrap {
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important;
        overflow-y: visible !important;
        max-height: none !important;
    }

    #stage2 #miniGrid {
        width: 100% !important;
        overflow: visible !important;
    }

    /* Info panel - start lower */
    #stage2 h3 {
        margin-top: 20px !important;
    }

}

/* ===== UNIVERSAL SIZING FIX ===== */
/* Make .floating wrap tightly around the grid like Stage 1 does */
body:not(.enable-stage2-frame) #stage1 .perspective-container .floating,
body:not(.enable-stage2-frame) #stage2 .perspective-container .floating,
body:not(.enable-stage2-frame) #stage2 #cardBattle.floating {
    width: fit-content !important;
    height: fit-content !important;
    min-width: auto !important;
    max-width: none !important;
}

/* Ensure card_body doesn't force extra width */
body:not(.enable-stage2-frame) #stage1 .card_body,
body:not(.enable-stage2-frame) #stage2 .card_body {
    width: auto !important;
    height: auto !important;
}

/* ====== STAGE 2 - LAYOUT AND COLORS ====== */

/* 1. REMOVE BLUR */
#stage2,
#battleCard,
#gridBattle,
.battle-grid {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* === STAGE 2 PORTRAIT: Pano geniÃ…Å¸, hÃƒÂ¼creler daha kÃƒÂ¼ÃƒÂ§ÃƒÂ¼k === */
@media (orientation: portrait) {
    #stage2 .perspective-container .floating {
        width: fit-content !important;
        max-width: 98vw !important;
        margin: 2px auto !important;
        padding: 3px !important;
    }

    #stage2 .perspective-container .scene {
        padding: 0 !important;
        /* Removed transform: scale(0.92) - was blocking JS tilt effect */
        transform-origin: center top !important;
    }

    #stage2 .perspective-container .grid {
        gap: 6px !important;
    }

    /* Cells - Standard mobile depth */
    #stage2 .perspective-container .cell {
        --depth: 15px !important;
    }

    /* Font boyutu - REMOVED: was blocking dynamic 75% fill rule */
    /* See UNIVERSAL DYNAMIC FONT SIZE section at end of file */
}

/* === STAGE 2 LANDSCAPE: Daha geniÃ…Å¸ pano === */
@media (orientation: landscape) {
    #stage2 .perspective-container {
        align-items: flex-start !important;
        padding-top: 0 !important;
    }

    #stage2 .perspective-container .floating {
        width: 81% !important;
        height: auto !important;
        max-height: 80vh !important;
        margin: 0 auto !important;
        padding: 5px !important;
    }

    #stage2 .perspective-container .scene {
        padding: 0 !important;
    }

    #stage2 .perspective-container .grid {
        gap: 6px !important;
    }

    /* Sidebar - more space for mini grid */
    #stage2 .sidebar,
    #stage2 .stage2-box,
    div#stage2.layout .sidebar {
        display: block !important;
        text-align: center !important;
        /* Center content */
        width: 100% !important;
        max-height: none !important;
        overflow: visible !important;
    }

    #stage2 .mini-grid-wrap {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        width: 100% !important;
        padding-top: 0 !important;
        margin-top: 0 !important;
    }

    /* MINI GRID WRAPPER - The element with the background */
    #stage2 .stage2-box {
        width: fit-content !important;
        /* Shrink to fit grid */
        margin: 0 auto 5px auto !important;
        /* Center horizontally */
        padding: 5px !important;
        /* Slight padding (+~2%) */
        display: inline-block !important;
        /* Allow centering */
    }

    /* MINI GRID - Force hairline gap AND COMPACT WIDTH */
    #miniGrid,
    #stage2 #miniGrid,
    .grid.mini {
        align-self: center !important;
        display: grid !important;
        gap: 1px !important;
        grid-gap: 1px !important;
        width: 100% !important;
        /* CRITICAL: Prevent stretching */
        max-width: 100% !important;
        justify-content: center !important;
        margin: 0 auto !important;
    }

    /* Move Main Board Up Closer to Header - Using margin instead of transform */
        #stage2 #cardBattle {
        margin-top: -60px !important;
        padding-top: 0 !important;
        top: 0 !important;
    }

    body:not(.enable-stage2-frame) #stage1 .perspective-container .floating,
    body:not(.enable-stage2-frame) #stage2 .perspective-container .floating {
        margin-top: 0 !important;
        padding-top: 0 !important;
        top: 0 !important;
    }

    /* Remove padding from parent containers */
    #stage2.layout,
    div#stage2.layout,
    #stage2 .perspective-container {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
    }
}

/* 2. HEADER CELLS - NO 3D BOXES (safe rule) */
#stage2 .cell.head .face,
#gridBattle .cell.head .face,
.battle-grid .cell.head .face {
    display: none !important;
}

/* 3. BATTLE GRID HIT COLORS - SIMPLE (NO ::after override!) */

/* HIT = BLUE */
#gridBattle .cell.hit-prime .face.front,
#stage2 .cell.hit-prime .face.front,
.battle-grid .cell.hit-prime .face.front {
    background: rgba(50, 150, 255, 0.7) !important;
    border: 2px solid #55aaff !important;
    box-shadow: 0 0 15px #0088ff !important;
}

/* MISS = YELLOW */
#gridBattle .cell.miss .face.front,
#stage2 .cell.miss .face.front,
.battle-grid .cell.miss .face.front {
    background: rgba(255, 200, 50, 0.7) !important;
    border: 2px solid #ffcc00 !important;
    box-shadow: 0 0 15px rgba(255, 200, 0, 0.6) !important;
}

/* MINE = RED */
#gridBattle .cell.hit-mine .face.front,
#stage2 .cell.hit-mine .face.front,
.battle-grid .cell.hit-mine .face.front {
    background: rgba(255, 50, 50, 0.7) !important;
    border: 2px solid #ff5555 !important;
    box-shadow: 0 0 15px #ff0000 !important;
}

/* 4. MINIMAP COLORS */

/* DYNAMIC FONT SIZE for Mini Grid - Fill cells proportionally */
#miniGrid .cell,
.grid.mini .cell {
    font-size: clamp(8px, calc(100% * 0.8), 24px) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: bold !important;
    line-height: 1 !important;
}

/* PRE-HIT: SayÃ�zÂ±lar mavi, mayÃ�zÂ±nlar kÃ�zÂ±rmÃ�zÂ±zÃ�zÂ± (vurulmadan ÃƒÂ¶nce) */
#miniGrid .cell.prime,
.grid.mini .cell.prime {
    background: rgba(50, 150, 255, 0.7) !important;
}

#miniGrid .cell.mine,
.grid.mini .cell.mine {
    background: rgba(220, 50, 50, 0.7) !important;
}

/* POST-HIT: Vurulunca yeÃ…Å¸il (sayÃ�zÂ±lar), koyu kÃ�zÂ±rmÃ�zÂ±zÃ�zÂ± (mayÃ�zÂ±n) */
#miniGrid .cell.hit-prime,
.grid.mini .cell.hit-prime {
    background: rgba(50, 200, 100, 0.9) !important;
}

#miniGrid .cell.hit-mine,
.grid.mini .cell.hit-mine {
    background: rgba(180, 30, 30, 0.9) !important;
}

/* MISS: Karavana sarÄ± + O */
#miniGrid .cell.miss,
.grid.mini .cell.miss {
    background: rgba(255, 200, 50, 0.8) !important;
    /* font-size inherited from dynamic rule above */
    overflow: hidden !important;
    box-sizing: border-box !important;
}

/* 5. CELL CONTENT - TRANSPARENT (don't override text!) */
#gridBattle .cell-content,
#stage2 .cell-content,
.battle-grid .cell-content {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* 6. HIT CELLS - NO WHITE BACKGROUND */
#stage2 .cell.hit-prime .cell-content,
#stage2 .cell.hit-mine .cell-content,
#stage2 .cell.miss .cell-content,
#gridBattle .cell.hit-prime .cell-content,
#gridBattle .cell.hit-mine .cell-content,
#gridBattle .cell.miss .cell-content {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

/* ====== STAGE 2 MENU CHANGES ====== */

/* 1. HIDE original card-header completely (scoreboard now in topbar) */
body.stage2-active #battleCard>.card-header {
    display: none !important;
}

/* 2. HIDE selDiff and selBoard in Stage 2 */
body.stage2-active #selDiff,
body.stage2-active #selBoard {
    display: none !important;
}

/* 3. TOPBAR - Split layout: left side and right side */
body.stage2-active .topbar {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    min-height: 45px !important;
    padding: 5px 15px !important;
}

/* 4. Style topbarStage2Right - ONLY in Stage 2 */
body.stage2-active #topbarStage2Right {
    display: flex !important;
    align-items: center !important;
    gap: 20px !important;
}

#topbarStage2Right .score-table-topbar {
    border-collapse: collapse !important;
}

#topbarStage2Right .score-table-topbar td {
    padding: 0 4px !important;
    line-height: 1.2 !important;
}

/* ========================================= */
/* FINAL OVERRIDES FOR WHITE SQUARE & ALIGNMENT */
/* ========================================= */

/* 1. Prevent white square artifact behind 3D cells */
.perspective-container .cell {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* 2. Force Left Alignment in Landscape Mode */
@media (orientation: landscape) {
    #stage2 .sidebar {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        text-align: left !important;
        width: 100% !important;
        padding-left: 0 !important;
        /* Force flush left */
        margin-left: 0 !important;
    }

    #stage2 .stage2-box {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        text-align: left !important;
        width: 100% !important;
        padding: 0 !important;
        /* Remove box padding */
    }

    #stage2 .mini-grid-wrap {
        display: flex !important;
        width: 100% !important;
        justify-content: flex-start !important;
        padding-left: 0 !important;
        /* REMOVED 20px padding */
        margin-left: 0 !important;
    }

    /* FIX: Info Panel width in landscape */
    #stage2 .stage2-box:last-child,
    #stage2 .info-area {
        width: 100% !important;
        flex-grow: 1 !important;
    }

    #infoPanel {
        width: 100% !important;
    }

    #miniGrid {
        margin-left: 0 !important;
        margin-right: auto !important;
    }
}

/* 7. GAME RESULT STYLES */
.game-result-win {
    font-size: 1.5rem !important;
    color: #4caf50 !important;
    /* Green */
    font-weight: bold !important;
    text-align: center !important;
    display: block !important;
    margin-top: 10px !important;
    text-shadow: 0 0 10px rgba(76, 175, 80, 0.5) !important;
}

.game-result-lose {
    font-size: 1.5rem !important;
    color: #f44336 !important;
    /* Red */
    font-weight: bold !important;
    text-align: center !important;
    margin-top: 10px !important;
    text-shadow: 0 0 10px rgba(244, 67, 54, 0.5) !important;
}

/* ========================================= */
/* ========================================= */
/* STAGE 1 LANDSCAPE FIX (RELAXED)           */
/* ========================================= */
@media (orientation: landscape) {
    #stage1 .perspective-container .floating {
        /* Dikeyde ekrana sÃ�zÂ±Ã�zÅ¸sÃ�zÂ±n ama geniÃ…Å¸liÃ�zÅ¸i kÃ�zÂ±sÃ�zÂ±tlamayalÃ�zÂ±m */
        height: auto !important;

        /* 90vh yeterli, address bar vs. iÃƒÂ§in yer kalsÃ�zÂ±n */
        max-height: 90vh !important;

        /* GeniÃ…Å¸lik serbest kalsÃ�zÂ±n, ÃƒÂ§ok kÃƒÂ¼ÃƒÂ§ÃƒÂ¼lmesin */
        width: 100% !important;
        max-width: none !important;
        /* Ãƒâ€“nceki 65vw kÃ�zÂ±sÃ�zÂ±tÃ�zÂ±nÃ�zÂ± kaldÃ�zÂ±r */

        margin: 0 auto !important;
    }

    /* Aspect-ratio zorlamasÃ�zÂ±nÃ�zÂ± kaldÃ�zÂ±r, doÃ�zÅ¸al oranÃ�zÂ±nÃ�zÂ± kullansÃ�zÂ±n */


    /* Sidebar ve Content dÃƒÂ¼zeni */
    #stage1.layout {
        display: flex !important;
        flex-direction: row !important;
        align-items: stretch !important;
        /* Ã�zÂ°ÃƒÂ§eriÃ�zÅ¸i dikeyde yay */
        overflow: hidden !important;
    }

    #stage1 .sidebar {
        width: 300px !important;
        /* Biraz geniÃ…Å¸lettim */
        flex-shrink: 0 !important;
        overflow-y: auto !important;
        height: 100% !important;
    }

    #stage1 .main-area {
        flex-grow: 1 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        /* FIX: Stack from top */
        overflow: hidden !important;
        height: 100% !important;
        padding: 10px !important;
        /* Biraz padding ekle */
    }
}

/* ========================================= */
/* CRITICAL TRANSITION FIX                   */
/* ========================================= */
/* Landscape modundaki !important kuralÃ�zÂ± ezmek iÃƒÂ§in */
body.stage2-active #stage1,
body.stage2-active #stage1.layout {
    display: none !important;
}

body.stage2-active #stage2,
body.stage2-active #stage2.layout {
    display: flex !important;
}

/* ========================================= */
/* ========================================= */
/* STAGE 1 PORTRAIT FIX (UPDATED)            */
/* ========================================= */
@media (orientation: portrait) {
    #stage1 .perspective-container .floating {
        width: 100% !important;
        max-width: 95vw !important;
        /* EkranÃ�zÂ± doldur */
        height: auto !important;
        /* Ã�zÂ°ÃƒÂ§eriÃ�zÅ¸e gÃƒÂ¶re uza (sÃƒÂ¼ndÃƒÂ¼rme) */
        margin: 0 auto !important;
        padding-top: 10px !important;
    }

    /* HÃƒÂ¼creler kare olsun */
    #stage1 .perspective-container .cell {
        aspect-ratio: 1 / 1 !important;
        height: auto !important;
    }

    #stage1 .perspective-container {
        padding-left: 5px !important;
        padding-right: 5px !important;
        align-items: flex-start !important;
    }

    /* Font boyutu */
    #stage1 .perspective-container .face.front {
        font-size: 0.8rem !important;
    }
}

/* ========================================= */
/* UNIFIED LAYOUT RULES (STANDARDIZED)       */
/* ========================================= */

/* 1. PORTRAIT MODE (DÃ�zÂ°KEY) */
@media (orientation: portrait) {

    /* Pano boyutlandÃ�zÂ±rma - Her iki stage iÃƒÂ§in ortak */
    #stage1 .perspective-container .floating,
    #stage2 .perspective-container .floating {
        width: 100% !important;
        max-width: 95vw !important;
        /* EkranÃ�zÂ± tam doldur */
        height: auto !important;
        /* Ã�zÂ°ÃƒÂ§eriÃ�zÅ¸e gÃƒÂ¶re uza (SÃƒÂ¼ndÃƒÂ¼rme yok) */
        margin: 0 auto !important;
        padding-top: 10px !important;
    }

    /* HÃƒÂ¼creler KARE olsun */
    #stage1 .perspective-container .cell,
    #stage2 .perspective-container .cell {
        aspect-ratio: 1 / 1 !important;
        height: auto !important;
    }

    /* Container hizalama */
    #stage1 .perspective-container,
    #stage2 .perspective-container {
        padding-left: 5px !important;
        padding-right: 5px !important;
        align-items: flex-start !important;
        /* ÃƒÅ“ste yasla */
    }

    /* Font boyutu */
    #stage1 .perspective-container .face.front,
    #stage2 .perspective-container .face.front {
        font-size: 0.8rem !important;
    }
}

/* 2. LANDSCAPE MODE (YATAY) */
@media (orientation: landscape) {

    /* Pano boyutlandÃ�zÂ±rma */
    #stage1 .perspective-container .floating,
    #stage2 .perspective-container .floating {
        height: auto !important;
        max-height: 85vh !important;
        /* Dikeyde taÃ…Å¸ma */
        width: auto !important;
        /* GeniÃ…Å¸lik serbest */
        max-width: none !important;
        margin: 0 auto !important;
    }

    /* Stage 1 Sidebar DÃƒÂ¼zeni - Fix */
    #stage1.layout {
        display: flex !important;
        flex-direction: row !important;
        align-items: stretch !important;
        overflow: hidden !important;
    }

    #stage1 .sidebar {
        width: 300px !important;
        flex-shrink: 0 !important;
        overflow-y: auto !important;
        height: 100% !important;
    }

    #stage1 .main-area {
        flex-grow: 1 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        /* FIX: Stack from top */
        height: 100% !important;
        padding: 10px !important;
    }
}

/* 3. CRITICAL TRANSITION OVERRIDES (Reinforce) */
body.stage2-active #stage1 {
    display: none !important;
}

body.stage2-active #stage2 {
    display: flex !important;
}

/* ========================================= */
/* CORRECTED: GLOBAL LAYOUT & VISUALS        */
/* ========================================= */

/* 1. RESET FOR ALL STAGES */
#stage1 .perspective-container .floating,
#stage2 .perspective-container .floating {
    height: auto !important;
    transform-origin: center center !important;
}

#stage1 .perspective-container .cell,
#stage2 .perspective-container .cell {
    aspect-ratio: 1 / 1 !important;
    height: auto !important;
}

/* 2. PORTRAIT MODE (MOBILE/TABLET) */
@media (orientation: portrait) {

    /* Genel Container: VarsayÃ�zÂ±lan ROW olsun (Sidebar solda kalsÃ�zÂ±n) */
    /* Ancak ÃƒÂ§ok darsa (telefonsa) mecburen COLUMN olur, ama kullanÃ�zÂ±cÃ�zÂ± 'Solda' dediÃ�zÅ¸i iÃƒÂ§in ROW deneyelim */
    #stage1.layout:not(.force-hide),
    #stage1:not(.force-hide),
    #stage2.layout:not(.force-hide),
    #stage2:not(.force-hide) {
        display: flex !important;
        flex-direction: row !important;
        /* YAN YANA */
        align-items: stretch !important;
        height: 100vh !important;
        overflow: hidden !important;
    }

    /* SIDEBAR: YUKARI YASLA (FIX) */
    #stage1 .sidebar {
        order: 0 !important;
        /* Sol BaÃ…Å¸a */
        /* GeniÃ…Å¸lik: Ã�zÂ°ÃƒÂ§eriÃ�zÅ¸e gÃƒÂ¶re veya sabit */
        width: auto !important;
        min-width: 70px !important;
        /* Ãƒâ€¡ok daralmasÃ�zÂ±n */
        max-width: 300px !important;

        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        /* YUKARI YASLA! */
        padding-top: 20px !important;

        background: rgba(0, 0, 0, 0.2) !important;
        overflow-y: auto !important;
        height: 100% !important;
    }

    /* PANO: BÃƒÅ“YÃƒÅ“T VE ORTALA */
    #stage1 .perspective-container,
    #stage2 .perspective-container {
        order: 1 !important;
        flex-grow: 1 !important;
        /* Kalan alanÃ�zÂ± al */
        width: auto !important;
        height: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 5px !important;
    }

    #stage1 .perspective-container .floating,
    #stage2 .perspective-container .floating {
        /* Pano ÃƒÂ§ok bÃƒÂ¼yÃƒÂ¼k olup sidebarÃ�zÂ± ezmesin */
        width: 100% !important;
        height: auto !important;
        max-width: 90vw !important;
        /* Biraz pay bÃ�zÂ±rak */
    }

    /* HÃƒÅ“CRE AYARLARI (Refinements) */
    #stage1 .perspective-container .grid,
    #stage2 .perspective-container .grid {
        gap: 2px !important;
    }

    #stage1 .perspective-container .face.front,
    #stage2 .perspective-container .face.front {
        border-radius: 4px !important;
        font-size: 0.8rem !important;
    }

    /* ONLINE STAGE 2 FIX */
    #stage2 .stage2-box,
    #stage2 .mini-grid-wrap {
        /* Online'da saÃ�zÅ¸a/alta at */
        /* Row modunda saÃ�zÅ¸da kalÃ�zÂ±rlar */
        order: 2 !important;
        width: 120px !important;
        /* SaÃ�zÅ¸da ince bir sÃƒÂ¼tun */
        flex-shrink: 0 !important;
    }
}

/* 3. LANDSCAPE MODE (DESKTOP) */
@media (orientation: landscape) {

    #stage1.layout:not(.force-hide),
    #stage1:not(.force-hide),
    #stage2.layout:not(.force-hide),
    #stage2:not(.force-hide) {
        flex-direction: row !important;
    }

    /* Sidebar: Sola Yasla, Yukari Yasla */
    #stage1 .sidebar,
    #stage2 .stage2-box,
    #stage2 .mini-grid-wrap {
        width: 300px !important;
        min-width: 240px !important;
        max-width: 300px !important;
        flex-shrink: 0 !important;
        height: 100% !important;

        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        /* Desktopta da yukarÃ�zÂ± */
    }

    #stage1 .perspective-container,
    #stage2 .perspective-container {
        flex-grow: 1 !important;
    }

    #stage1 .perspective-container .floating,
    #stage2 .perspective-container .floating {
        height: auto !important;
        max-height: 92vh !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
    }

    #stage1 .perspective-container .grid,
    #stage2 .perspective-container .grid {
        gap: 3px !important;
    }
}

/* ========================================= */
/* FINAL: GLOBAL VISUAL REFINEMENTS (OFFLINE & ONLINE) */
/* ========================================= */

/* 1. RESET DIMENSIONS & ASPECT RATIO */
#stage1 .perspective-container .floating,
#stage2 .perspective-container .floating {
    height: auto !important;
    transform-origin: center center !important;
}

#stage1 .perspective-container .cell,
#stage2 .perspective-container .cell {
    aspect-ratio: 1 / 1 !important;
    height: auto !important;
}

/* 2. PORTRAIT MODE (MOBILE) - GLOBAL FIX */
@media (orientation: portrait) {

    /* Container DÃƒÂ¼zeni: Dikey */
    #stage1.layout:not(.force-hide),
    #stage1:not(.force-hide),
    #stage2.layout:not(.force-hide),
    #stage2:not(.force-hide) {
        flex-direction: column !important;
        justify-content: flex-start !important;
        padding-top: 10px !important;
    }

    /* Ana Pano: En ÃƒÅ“stte ve Tam GeniÃ…Å¸lik */
    #stage1 .perspective-container,
    #stage2 .perspective-container {
        order: 1 !important;
        width: 100% !important;
        flex-grow: 0 !important;
        margin-bottom: 20px !important;
        padding: 0 !important;
    }

    #stage1 .perspective-container .floating,
    #stage2 .perspective-container .floating {
        width: 96% !important;
        /* EkranÃ�zÂ± tam doldur */
        max-width: 96vw !important;
        margin: 0 auto !important;
    }

    /* HÃƒÅ“CRE AYARLARI (TÃƒÂ¶rpÃƒÂ¼lenmiÃ…Å¸ kare, az boÃ…Å¸luk) */
    #stage1 .perspective-container .grid,
    #stage2 .perspective-container .grid {
        gap: 2px !important;
    }

    #stage1 .perspective-container .face.front,
    #stage2 .perspective-container .face.front {
        border-radius: 4px !important;
        font-size: 0.8rem !important;
    }

    /* Sidebars / Mini Grids: Panonun AltÃ�zÂ±na */
    #stage1 .sidebar,
    #stage2 .stage2-box,
    #stage2 .mini-grid-wrap {
        order: 2 !important;
        width: 100% !important;
        max-width: 95% !important;
        margin: 0 auto 5px auto !important;
        display: flex !important;
        justify-content: center !important;
    }
}

/* 3. LANDSCAPE MODE (DESKTOP) - GLOBAL FIX */
@media (orientation: landscape) {

    /* Container DÃƒÂ¼zeni: Yatay */
    #stage1.layout:not(.force-hide),
    #stage1:not(.force-hide),
    #stage2.layout:not(.force-hide),
    #stage2:not(.force-hide) {
        flex-direction: row !important;
        align-items: stretch !important;
    }

    /* Sidebars: Sola Yasla, Sabit GeniÃ…Å¸lik */
    /* Sidebars: Sola Yasla, Sabit GeniÃ…Å¸lik -> REVÄ°ZE: Ä°Ã§eriÄŸe gÃ¶re ve Ortala */
    #stage1 .sidebar,
    #stage2 .stage2-box,
    #stage2 .mini-grid-wrap {
        width: fit-content !important;
        /* FIX: Shrink to content */
        min-width: 0 !important;
        max-width: 300px !important;
        flex-shrink: 0 !important;
        overflow-y: visible !important;
        height: auto !important;
        max-height: 100% !important;
        margin: 0 auto !important;
        /* Center it */
        padding: 5px !important;
        /* 2% margin effect */
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }

    /* Ana Pano: BÃƒÅ“YÃƒÅ“TÃƒÅ“LDÃƒÅ“ */
    #stage1 .perspective-container,
    #stage2 .perspective-container {
        flex-grow: 1 !important;
        width: auto !important;
        justify-content: center !important;
        align-items: center !important;
    }

    #stage1 .perspective-container .floating,
    #stage2 .perspective-container .floating {
        height: auto !important;
        max-height: 92vh !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
    }

    /* Landscape Grid Gap */
    #stage1 .perspective-container .grid,
    #stage2 .perspective-container .grid {
        gap: 3px !important;
    }
}

/* ========================================= */
/* FINAL USER REQUEST: SIDEBAR ALWAYS LEFT   */
/* ========================================= */

@media (orientation: portrait) {

    /* Container: YAN YANA (ROW) */
    #stage1.layout:not(.force-hide),
    #stage1:not(.force-hide),
    #stage2.layout:not(.force-hide),
    #stage2:not(.force-hide) {
        display: flex !important;
        flex-direction: row !important;
        /* ASLA column olmasÃ�zÂ±n */
        align-items: stretch !important;
        height: 100vh !important;
        overflow: hidden !important;
    }

    /* MENÃƒÅ“ (SIDEBAR): SOLDA SABÃ�zÂ°T */
    #stage1 .sidebar {
        order: 0 !important;
        width: 75px !important;
        /* Dar sÃƒÂ¼tun */
        min-width: 75px !important;
        max-width: 80px !important;

        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        /* Ã�zÂ°konlar ortalÃ�zÂ± */
        justify-content: flex-start !important;
        /* ÃƒÅ“stten baÃ…Å¸la */
        padding-top: 10px !important;

        background: rgba(0, 0, 0, 0.3) !important;
        overflow: visible !important;
        /* TaÃ…Å¸ma serbest (InfoPanel iÃƒÂ§in) */
        border-right: 1px solid rgba(255, 255, 255, 0.1) !important;
        z-index: 100 !important;

        /* FIX: Content kadar uzasÃ�zÂ±n */
        height: auto !important;
        align-self: flex-start !important;
        padding-bottom: 2px !important;
        /* Minimized space as requested */
        border-bottom-right-radius: 15px !important;
    }

    /* Mobil MenÃƒÂ¼ ButonlarÃ�zÂ± (Ã�zÂ°kon + Etiket) */
    #mobileMenuBtns .mobile-menu-btn {
        width: 60px !important;
        height: 60px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 5px !important;
        margin-bottom: 15px !important;
        font-size: 10px !important;
    }

    #mobileMenuBtns .icon {
        font-size: 24px !important;
        margin-bottom: 2px !important;
    }

    #mobileMenuBtns .label {
        font-size: 9px !important;
        display: block !important;
    }

    /* PANO ALANI (MAIN AREA): SAÃ�zÅ¾DA */
    #stage1 .perspective-container,
    #stage2 .perspective-container {
        order: 1 !important;
        flex-grow: 1 !important;
        width: auto !important;
        height: 100% !important;
        position: relative !important;
        z-index: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        /* ÃƒÅ“stten baÃ…Å¸la */
        padding-top: 20px !important;
    }

    #stage1 .perspective-container .floating,
    #stage2 .perspective-container .floating {
        /* Sidebar payÃ�zÂ±nÃ�zÂ± dÃƒÂ¼Ã…Å¸ */
        width: 95% !important;
        max-width: none !important;
        height: auto !important;
        max-height: 55vh !important;
        /* Ã…Âžeritlere/Panellere yer kalsÃ�zÂ±n */
    }

    /* INFO PANEL (ONLINE): SIDEBAR'DAN TAÃ…ÂžSIN */
    #mpInfoPanel {
        width: 180px !important;
        /* GeniÃ…Å¸let */
        position: relative !important;
        left: 5px !important;
        /* Biraz saÃ�zÅ¸a */
        background: #2a2a40 !important;
        z-index: 200 !important;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.5) !important;
        border: 1px solid #444 !important;
    }
}

/* ========================================= */
/* FIX v3.4.1: MAXIMIZE BOARD HEIGHT         */
/* ========================================= */
@media (orientation: portrait) {

    /* Pano YÃƒÂ¼ksekliÃ�zÅ¸ini ArtÃ�zÂ±r (Stats -> BaÃ…Å¸la hizasÃ�zÂ±na inmesi iÃƒÂ§in) */
    #stage1 .perspective-container .floating,
    #stage2 .perspective-container .floating {
        max-height: 72vh !important;
        /* Daha fazla yer kapla */
        transition: max-height 0.3s ease;
    }

    /* Ã…Âžeritler Kutusunu SÃ�zÂ±nÃ�zÂ±rla */
    #mobileStripsContainer,
    .mobile-strips-container {
        /* Ã�zÂ°ÃƒÂ§eriÃ�zÅ¸i sÃ�zÂ±Ã�zÅ¸dÃ�zÂ±rmaya ÃƒÂ§alÃ�zÂ±Ã…Å¸ ama ÃƒÂ§ok bÃƒÂ¼yÃƒÂ¼rse scroll olsun */
        flex-shrink: 1 !important;
        min-height: 0 !important;
        max-height: 60vh !important;
        overflow-y: visible !important;
        margin-top: 0 !important;
        /* JS controls this now */
    }

    /* Info Panel Overlay (EÃ�zÅ¸er gerekirse) */
    #mpInfoPanel {
        bottom: 5px !important;
        /* Biraz daha aÃ…Å¸aÃ�zÅ¸Ã�zÂ± */
    }
}

/* ========================================= */
/* FIX v3.4.2: FORCE BOARD WIDTH EXPANSION   */
/* ========================================= */
@media (orientation: portrait) {

    /* MAKSÃ�zÂ°MUM GENÃ�zÂ°Ã…ÂžLÃ�zÂ°K Ã�zÂ°Ãƒâ€¡Ã�zÂ°N PADDING SIFIRLA */
    #stage1 .perspective-container,
    #stage2 .perspective-container {
        padding: 0 !important;
        overflow: visible !important;
        /* Perspektif ayarÃ�zÂ±: Daha yakÃ�zÂ±ndan bakÃ�zÂ±nca (dÃƒÂ¼Ã…Å¸ÃƒÂ¼k deÃ�zÅ¸er) pano daha bÃƒÂ¼yÃƒÂ¼k gÃƒÂ¶rÃƒÂ¼nÃƒÂ¼r */
        perspective: 600px !important;
    }

    /* PANOYU ZORLA GENÃ�zÂ°Ã…ÂžLET */
    #stage1 .perspective-container .floating,
    #stage2 .perspective-container .floating {
        width: 100% !important;
        /* AlanÃ�zÂ±n tamamÃ�zÂ±nÃ�zÂ± kullan */
        margin: 0 !important;
        /* Kenar boÃ…Å¸luÃ�zÅ¸u yok */

        /* EÃ�zÅ¸er hala kÃƒÂ¼ÃƒÂ§ÃƒÂ¼kse Scale ile bÃƒÂ¼yÃƒÂ¼t */
        /* transform: scale(1.1); <-- Gerekirse eklenebilir */
    }

    /* Grid'in kendisi de geniÃ…Å¸lesin */
    #stage1 .perspective-container .grid,
    #stage2 .perspective-container .grid {
        width: 100% !important;
        gap: 1px !important;
        /* BoÃ…Å¸luklarÃ�zÂ± kÃ�zÂ±s, hÃƒÂ¼creleri bÃƒÂ¼yÃƒÂ¼t */
    }
}

/* ========================================= */
/* FIX v3.4.3: CALCULATED WIDTH & NO SHADOW  */
/* ========================================= */
@media (orientation: portrait) {

    /* 1. KapsayÃ�zÂ±cÃ�zÂ±larÃ�zÂ± GeniÃ…Å¸let ve Temizle */
    #boardStage1,
    .board-card {
        flex-grow: 0 !important;
        /* FIX: Do not expand to fill height */
        width: 100% !important;
        height: auto !important;
        background: transparent !important;
        /* GÃƒÂ¶lge/Arkaplan sil */
        box-shadow: none !important;
        border: none !important;
        overflow: visible !important;
    }

    #stage1 .perspective-container,
    #stage2 .perspective-container {
        width: 100% !important;
        padding: 0 !important;
        overflow: visible !important;
    }

    /* 2. Pano GeniÃ…Å¸liÃ�zÅ¸i: Ekran - Sidebar (100vw - 90px) */
    #stage1 .perspective-container .floating,
    #stage2 .perspective-container .floating {
        width: calc(100vw - 90px) !important;
        /* Tam sÃ�zÂ±Ã�zÅ¸dÃ�zÂ±r */
        margin-left: 0 !important;

        /* YÃƒÂ¼kseklik Serbest (75vh'a kadar) */
        height: auto !important;
        max-height: 75vh !important;

        /* Removed scale(1.05) - was blocking JS tilt */
        transform-origin: center top !important;
    }

    /* 3. Grid ve HÃƒÂ¼creler */
    #stage1 .perspective-container .grid,
    #stage2 .perspective-container .grid {
        width: 100% !important;
        gap: 1px !important;
    }
}

/* ========================================= */
/* FIX v3.5.0: UNBLOCK TOUCH INTERACTION     */
/* ========================================= */
@media (orientation: portrait) {

    /* Sidebar Container'Ã�zÂ± DokunuÃ…Å¸larÃ�zÂ± GeÃƒÂ§irsin */
    #stage1 .sidebar {
        pointer-events: none !important;
    }

    /* Ancak Ã�zÂ°ÃƒÂ§indeki Butonlar TÃ�zÂ±klanabilsin */
    #stage1 .sidebar>* {
        pointer-events: auto !important;
    }

    /* Info Panel de TÃ�zÂ±klanabilsin */
    #mpInfoPanel {
        pointer-events: auto !important;
    }

    /* Pano Kesinlikle TÃ�zÂ±klanabilir Olsun */
    #stage1 .perspective-container,
    #stage2 .perspective-container {
        pointer-events: auto !important;
        touch-action: none !important;
        /* TarayÃ�zÂ±cÃ�zÂ± kaydÃ�zÂ±rmasÃ�zÂ±nÃ�zÂ± engelle, JS yÃƒÂ¶netsin */
    }
}

/* ========================================= */
/* FIX v3.6.0: STAGE 2 LAYOUT & GRID FIT     */
/* ========================================= */
@media (orientation: portrait) {

    /* STAGE 2 Ãƒâ€“ZEL AYARLAR (Sidebar Yok) */
    #stage2 .perspective-container .floating {
        /* Sidebar payÃ�zÂ± bÃ�zÂ±rakma, ekranÃ�zÂ± ortala */
        width: 90vw !important;
        margin: 0 auto !important;
        transform-origin: center center !important;
        /* Grid taÃ…Å¸masÃ�zÂ±nÃ�zÂ± ÃƒÂ¶nlemek iÃƒÂ§in */
        height: auto !important;
        max-width: none !important;
    }

    #stage2 {
        align-items: center !important;
        /* Dikey ortala */
    }

    /* Grid TaÃ…Å¸Ã�zÂ±yorsa */
    #stage2 .battle-grid {
        width: 100% !important;
        box-sizing: border-box !important;
    }
}

/* ========================================= */
/* FIX v3.10.0: MINI GAME VISUAL UPGRADE    */
/* Glassmorphism + 3D + Purple Neon          */
/* ========================================= */

#modalContent {
    /* Glassmorphism Background */
    background: linear-gradient(135deg, rgba(30, 20, 60, 0.95), rgba(15, 10, 35, 0.98)) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;

    /* 3D Effect - Border & Shadow */
    border: 2px solid rgba(139, 92, 246, 0.6) !important;
    /* Purple border */
    border-radius: 20px !important;
    box-shadow:
        0 0 20px rgba(139, 92, 246, 0.4),
        0 0 40px rgba(139, 92, 246, 0.2),
        0 8px 32px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;

    /* 3D Perspective */
    transform-style: preserve-3d !important;
    transform: perspective(1000px) rotateX(2deg) !important;

    /* Spacing */
    padding: 30px 40px !important;
    min-width: 300px !important;
}

/* Neon Glow Animation */
@keyframes neonPulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(139, 92, 246, 0.4), 0 0 40px rgba(139, 92, 246, 0.2), 0 8px 32px rgba(0, 0, 0, 0.5);
    }

    50% {
        box-shadow: 0 0 30px rgba(139, 92, 246, 0.6), 0 0 60px rgba(139, 92, 246, 0.3), 0 8px 32px rgba(0, 0, 0, 0.5);
    }
}

#modalContent {
    animation: neonPulse 2s ease-in-out infinite !important;
}

/* Mini Game Title */
#modalContent h2 {
    color: #fff !important;
    text-shadow: 0 0 10px rgba(139, 92, 246, 0.8), 0 0 20px rgba(139, 92, 246, 0.4) !important;
    font-size: 1.8rem !important;
    margin-bottom: 15px !important;
}

/* Mini Game Input Field */
#modalContent input#pg {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 2px solid rgba(139, 92, 246, 0.5) !important;
    border-radius: 10px !important;
    color: #fff !important;
    font-size: 1.5rem !important;
    padding: 12px 20px !important;
    text-align: center !important;
    width: 120px !important;
    outline: none !important;
    transition: border-color 0.3s, box-shadow 0.3s !important;
}

#modalContent input#pg:focus {
    border-color: rgba(139, 92, 246, 0.9) !important;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.5) !important;
}

/* Target Display */
#modalContent #aiTargetRoll {
    color: #a78bfa !important;
    text-shadow: 0 0 15px rgba(139, 92, 246, 0.8) !important;
}

/* Timer Display */
#modalContent #miniTimerDisplay {
    color: #f59e0b !important;
    text-shadow: 0 0 10px rgba(245, 158, 11, 0.5) !important;
}

/* ========================================= */
/* FIX v3.10.1: CUSTOM NUMPAD STYLING        */
/* ========================================= */

.custom-numpad {
    margin-top: 15px;
}

/* Portrait: 3x4 Grid */
.numpad-grid.portrait {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 200px;
    margin: 0 auto;
}

/* Landscape: Horizontal Row */
.numpad-row.horizontal {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 5px;
}

/* Numpad Buttons Base */
.numpad-btn {
    background: rgba(139, 92, 246, 0.2) !important;
    border: 2px solid rgba(139, 92, 246, 0.5) !important;
    border-radius: 10px !important;
    color: #fff !important;
    font-size: 1.3rem !important;
    font-weight: bold !important;
    padding: 12px 18px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    min-width: 50px;
}

.numpad-btn:hover,
.numpad-btn:active {
    background: rgba(139, 92, 246, 0.4) !important;
    border-color: rgba(139, 92, 246, 0.8) !important;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.5) !important;
    transform: scale(1.05) !important;
}

/* Enter Button - Green */
.numpad-btn.numpad-enter {
    background: rgba(34, 197, 94, 0.3) !important;
    border-color: rgba(34, 197, 94, 0.6) !important;
}

.numpad-btn.numpad-enter:hover,
.numpad-btn.numpad-enter:active {
    background: rgba(34, 197, 94, 0.5) !important;
    border-color: rgba(34, 197, 94, 0.9) !important;
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.5) !important;
}

/* Clear Button - Red */
.numpad-btn.numpad-clear {
    background: rgba(239, 68, 68, 0.3) !important;
    border-color: rgba(239, 68, 68, 0.6) !important;
}

.numpad-btn.numpad-clear:hover,
.numpad-btn.numpad-clear:active {
    background: rgba(239, 68, 68, 0.5) !important;
    border-color: rgba(239, 68, 68, 0.9) !important;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.5) !important;
}

/* Landscape spacing adjustments */
.numpad-row.horizontal .numpad-btn {
    padding: 10px 14px !important;
    font-size: 1.1rem !important;
    min-width: 40px;
}

/* ========================================= */
/* FIX v3.10.3: FORCE MODAL DARK THEME       */
/* Override theme-hand and theme-light       */
/* ========================================= */

/* Force dark modal regardless of theme */
body #modalContent,
body.theme-hand #modalContent,
body.theme-light #modalContent,
#modalContent {
    background: linear-gradient(135deg, rgba(30, 20, 60, 0.98), rgba(15, 10, 35, 0.99)) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 2px solid rgba(139, 92, 246, 0.6) !important;
    border-radius: 20px !important;
    box-shadow:
        0 0 20px rgba(139, 92, 246, 0.4),
        0 0 40px rgba(139, 92, 246, 0.2),
        0 8px 32px rgba(0, 0, 0, 0.5) !important;
    color: #fff !important;
}

body #modalContent *,
body.theme-hand #modalContent *,
body.theme-light #modalContent * {
    color: #fff !important;
}

body #modalContent h2,
body.theme-hand #modalContent h2,
body.theme-light #modalContent h2 {
    color: #fff !important;
    text-shadow: 0 0 10px rgba(139, 92, 246, 0.8) !important;
}

body #modalContent input#pg,
body.theme-hand #modalContent input#pg,
body.theme-light #modalContent input#pg {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 2px solid rgba(139, 92, 246, 0.5) !important;
    color: #fff !important;
}

/* Force numpad styling regardless of theme */
body .custom-numpad,
body.theme-hand .custom-numpad,
body.theme-light .custom-numpad,
body .numpad-btn,
body.theme-hand .numpad-btn,
body.theme-light .numpad-btn {
    color: #fff !important;
}

body .numpad-grid.portrait,
body .numpad-row.horizontal {
    display: grid !important;
}

body .numpad-grid.portrait {
    grid-template-columns: repeat(3, 1fr) !important;
}

body .numpad-row.horizontal {
    display: flex !important;
    flex-wrap: nowrap !important;
}

/* ========================================= */
/* ========================================= */

/* TEMPORARY: Remove frame from Stage 2 as requested by user */
body:not(.enable-stage2-frame) #stage1 .perspective-container .thickness,
body:not(.enable-stage2-frame) #stage2 .perspective-container .thickness {
    display: none !important;
}
body:not(.enable-stage2-frame) #stage1 .perspective-container .floating,
body:not(.enable-stage2-frame) #stage2 .perspective-container .floating,
body:not(.enable-stage2-frame) #stage2 #cardBattle.floating {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}
body:not(.enable-stage2-frame) #stage1 .card_body,
body:not(.enable-stage2-frame) #stage2 .card_body {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}



