/* --- 1. THEME VARIABLES --- */
:root {
    /* Main Backgrounds */
    --bg-dark: #121214;      /* Navbar/Header */
    --bg-card: #1c1c1f;      /* Sidebar/Containers */
    --bg-deep: #08080a;      /* Page Background */
    
    /* Text Colors */
    --text-main: #e0e0e0;
    --text-dim: #a0a0a5;
    --text-bright: #f8fafc;
    
    /* Borders & Interaction */
    --border: #33333b;
    --input-bg: #121214;

    /* Navigation and Footer height */
    --nav-height: 60px;
    --footer-height: 80px;

    /* THEME: DEFAULT (Neutral Slate) */
    --accent: #64748b;       
    --accent-hover: #94a3b8;
    --accent-contrast: #e03131;
    --accent-glow: rgba(100, 116, 139, 0.1);
}
/* THEME: DEFAULT (Deep Blue) */
body.theme-default {
    --accent: #64748b;       
    --accent-hover: #94a3b8;
    --accent-contrast: #e03131;
    --accent-glow: rgba(100, 116, 139, 0.1);
}
/* THEME: YU-GI-OH! (Deep Blue) */
body.theme-yugioh {
    --accent: #3b5bdb;       
    --accent-hover: #4c6ef5;
    --accent-contrast: #e03131;
    --accent-glow: rgba(59, 91, 219, 0.1);
}

/* THEME: POKEMON (Red) */
body.theme-pokemon {
    --accent: #ffcb05;       
    --accent-hover: #ff4d4d;
    --accent-contrast: #ff1f1f;
    --accent-glow: rgba(255, 203, 5, 0.1);
}

/* THEME: MTG (Bronze) */
body.theme-magic {
    --accent: #bc6c25;       
    --accent-hover: #dda15e;
    --accent-contrast: #fde047;
    --accent-glow: rgba(188, 108, 37, 0.1);
}

/* --- 2. BASE RESET & LAYOUT --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-deep);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, sans-serif;
    line-height: 1.6;
    overflow: hidden;
    min-width: 375px;
    position: relative; /* Necessary for the pseudo-element anchor */
}

/* The Parchment Noise Layer */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    /* Subtle overlay settings */
    opacity: 0.03;
    contrast: 150%; 
    brightness: 100%;
    pointer-events: none;
    z-index: -1;
}

/* Ensure the body and main wrapper fill the screen */
body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    background-color: var(--bg-deep); /* Your parchment/dark base */
}

[data-load="main-app.html"] {
    display: flex;
    flex-direction: column;
    align-items: center; /* Centers horizontally */
    justify-content: flex-start;
    width: 100%;
    max-width: 1400px; /* Adjust based on your design */
    margin: 0 auto;    /* Centers the whole container */
    padding: 20px;
    box-sizing: border-box;
}

/* --- 3. NAVBAR & NAVIGATION --- */
.navbar {
    background-color: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    height: var(--nav-height);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 20px;
}

.nav-links {
    display: flex;
    gap: 5px;
    height: 100%;
}

.tablink {
    background: none;
    border: none;
    padding: 0 20px;
    color: var(--text-dim);
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    height: 100%;
}

.tablink:hover {
    color: var(--text-bright);
    background-color: rgba(255,255,255,0.05);
}

.tablink.active {
    color: var(--accent);
    border-bottom: 3px solid var(--accent);
}

.logo { height: 40px; }
/* Container for the main logo and the beta tag */
.main-logo-container {
    position: relative;
    display: inline-block;
}

/* The BETA Tag */
.badge-beta {
    position: absolute;
    top: 30px; 
    right: -15px; 
    background-color: #ff4757;
    color: white;
    font-size: 0.55rem; /* Slightly smaller looks a bit cleaner on icons */
    font-weight: bold;
    padding: 1px 5px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    pointer-events: none;
    z-index: 10; /* Ensures it stays on top of the logo */
}

/* Layout for the logo section */
.nav-logo-section {
    display: flex;
    align-items: center;
    gap: 20px; /* Space between Grub logo and Game logo */
}

/* The Game Logo styling */
.game-logo {
    height: 35px; /* Adjust based on your logo heights */
    width: auto;
    display: block;
    /* Optional: subtle shadow to make it pop */
    filter: drop-shadow(0px 2px 4px rgba(0,0,0,0.2));
}

/* Optional: Vertical divider between logos */
.game-logo-container {
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    padding-left: 15px;
}

/* --- 4. PAGE STRUCTURE --- */
.page-layout {
    display: grid;
    /* 260px columns to fit 250px ads with 5px margins on each side */
    grid-template-columns: 260px 1fr 260px;
    gap: 20px;
    height: calc(100vh - var(--nav-height) - var(--footer-height)); 
    padding: 20px;
    width: 100%;
    max-width: 100%; 
    margin: 0 auto;
    align-items: start;
}

.content-wrapper {
    min-width: 0;
    grid-column: 2;
    height: 100%; /* Take up full grid height */
    overflow-y: auto; /* This is your vertical scrollbar */
    overflow-x: hidden;
    display: block; /* Ensure it's not a flex container that squashes children */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    padding-top: 10px;
    width: 100%;
    max-width: 100%;
}
.content-wrapper .container {
    background-color: transparent; /* Let the content-wrapper handle the background if needed */
    box-shadow: none;
    padding: 0;
}

.container {
    background-color: var(--bg-card);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    max-width: 100% !important;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

#main-content-area {
    width: 100%;
    display: block;
}

/*--- ADS ---*/
.ad-sidebar {
    display: flex;
    flex-direction: column; /* Stacks the blocks vertically */
    gap: 20px;              /* Space between the two 300px blocks */
    width: 100%;
    align-items: center;    /* Keeps ads centered in the 260px column */
}
.ad-placeholder {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-dim);
    
    /* Strict Ad Dimensions */
    width: 250px;
    height: 300px;
    
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 4px;
    flex-shrink: 0; /* Prevents the boxes from squashing */
}
.ad-placeholder::before {
    content: "Ad placeholder";
    opacity: 0.5;
}

.mobile-anchor-ad {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background-color: var(--bg-dark);
    border-top: 2px solid var(--accent);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.5);
}

#main-content-area {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
    min-width: 0;
}

#main-content-area > div {
    width: 100% !important;
    max-width: 1200px;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* --- 5. CALCULATOR & INPUTS --- */
.calculator-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 30px;
    align-items: start;
}

.input-sidebar h3 {
    color: var(--accent);
    font-size: 1.2rem;
    letter-spacing: 1px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
    position: relative;
}
.input-sidebar h3::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 50px;
    height: 2px;
    background-color: var(--accent);
}
.input-sidebar {
    background-color: var(--bg-card);
    padding: 25px;
    border-radius: 8px;
    border: 1px solid var(--border);
}


.visual-display {
    background-color: var(--bg-card);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border);
    height: 550px; 
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

#plot {
    height: 400px; 
    width: 100%;
}

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

input[type="number"], select {
    width: 100%;
    background-color: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-bright);
    padding: 10px;
    border-radius: 4px;
    outline: none;
}

input:focus {
    border-color: var(--accent);
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type=number] {
    -moz-appearance: textfield;
}

.btn-primary {
    width: 100%;
    background-color: var(--accent);
    color: var(--text-bright);
    border: none;
    padding: 12px;
    border-radius: 4px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 10px var(--accent-glow);
    transition: 0.2s;
}

.btn-primary:hover {
    filter: brightness(1.2);
}

.visual-display {
    /* Ensure the graph container takes up every pixel of available width */
    width: 100%;
    display: flex;
    flex-direction: column;
}

#K_value_label {
    width: 100%;
}

.results-panel {
    border: 1px solid var(--accent) !important;
    background-color: color-mix(in srgb, var(--accent) 5%, var(--bg-dark)) !important;
    backdrop-filter: blur(8px); 
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center; 
    text-align: center;
    width: 100%; 
    box-sizing: border-box; 
}

#SuccessCalculator .results-panel {
    height: 450px;
    padding: 0 60px; 
}

#DistributionCalculator .results-panel {
    height: 100px;
    margin-top: auto;
}

.results-panel > .animate-pop {
    width: 100% !important; 
    display: block !important; 
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-pop {
    animation: fadeIn 0.5s forwards;
}

/* --- 6. HIDING LOGIC --- */
.yugioh-only, .pokemon-only, .magic-only { display: none !important; }

body.theme-yugioh .yugioh-only { display: inline-block !important; }
body.theme-pokemon .pokemon-only { display: inline-block !important; }
body.theme-mtg .magic-only { display: inline-block !important; }

/* --- 7. FOOTER --- */
.footer {
    background: var(--bg-card);
    height: var(--footer-height);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-top: 1px solid var(--border);
    box-sizing: border-box;
    overflow: hidden;
}

.footer-container {
    display: flex;
    flex-direction: column;
    gap: 6px; /* Very tight spacing */
}

.footer-socials {
    display: flex;
    justify-content: center;
    gap: 30px;
}

.f-icon {
    font-size: 1.1rem;
    color: var(--text-bright);
    opacity: 0.8;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

/* Hover Logic - Targeted by specific brand class */
.f-icon:hover {
    opacity: 1;
}
.f-icon.youtube:hover { 
    background: #ff0000; 
}

.f-icon.discord:hover { 
    background: #5865F2; 
}

.f-icon.email:hover { 
    background: var(--accent); 
}

.footer-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.75rem; /* Compact text */
    color: var(--text-main);
}

.footer-info a {
    color: var(--text-dim);
    text-decoration: none;
    margin: 0 10px;
    text-decoration: none;
}

.footer-info a:hover {
    opacity: 1;
    text-decoration: underline;
    color: var(--accent);
}

.sep {
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.7rem;
}

.copyright {
    font-weight: bold;
    color: var(--accent); /* Adds a little pop of your brand color */
}

/* --- TOGGLE SWITCH STYLING --- */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--border);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px; width: 16px;
    left: 3px; bottom: 3px;
    background-color: var(--text-bright);
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* --- DECK BUILDER & ARCHITECT LAYOUT --- */

.main-builder {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.deck-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.section-header {
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
}

.section-header h3 {
    margin: 0;
    font-size: 0.9rem;
    letter-spacing: 1px;
    color: var(--accent);
}

.btn-add-row {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-weight: bold;
    font-size: 0.75rem;
}

.btn-add-row:hover {
    color: var(--accent);
    background: rgba(255,255,255,0.02);
}

.row-anim {
    transition: all 0.3s ease-out;
    opacity: 1;
    transform: translateX(0);
}

.row-enter {
    opacity: 0;
    transform: translateX(-20px);
}

.row-exit {
    opacity: 0;
    transform: translateX(20px);
    background-color: rgba(255, 0, 0, 0.1) !important;
}

/* --- ANALYTICS FOOTER --- */

.analytics-footer {
    position: sticky;
    bottom: 20px;
    z-index: 100;
}

.stat-card {
    background: color-mix(in srgb, var(--bg-card), #000 20%);
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 -10px 25px rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
}

.footer-layout {
    display: flex;
    gap: 40px;
    align-items: flex-start;
}

.footer-section { flex: 1; }

.prob-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

/* Simulation Section */
.sim-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px dashed var(--border);
}

.btn-sim-main {
    padding: 15px 30px;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
    text-transform: uppercase;
    transition: all 0.3s;
}

.btn-sim-main:hover {
    background: var(--accent);
    color: var(--text-bright);
    box-shadow: 0 0 20px var(--accent-glow);
}

.has-tooltip {
    position: relative;
    cursor: help;
}

.tooltiptext {
    visibility: hidden;
    width: 180px;
    background-color: #1a1a1a;
    color: var(--text-bright);
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -90px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.7rem;
    border: 1px solid var(--accent);
}

.has-tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Container for the controls */
.deck-controls {
    display: flex;
    gap: 10px;
    align-items: stretch;
    margin-bottom: 0px;
}

.deck-controls .input-group {
    display: flex; /* Helps inner input fill height */
    flex-grow: 1;
}

/* Unified styling for Name and Buttons */
#deck-name, .btn-control {
    height: 40px; /* Fixed height for both */
    box-sizing: border-box; /* Ensures padding doesn't add to height */
    margin: 0; /* Remove browser defaults */
    display: flex;
    align-items: center;
}

#deck-name {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    /* This tells the browser to use dark-mode default colors for autofill */
    color-scheme: dark; 
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-bright);
    border: 1px solid var(--accent);
    border-radius: 4px;
    font-size: 0.9rem;
    outline: none;
    box-sizing: border-box;
}

/* Specifically targeting the "internal" browser state */
#deck-name:focus, #deck-name:active {
    background-color: rgba(0, 0, 0, 0.4) !important;
}

/* This targets the specific white background bug in Chrome/Edge */
#deck-name:-webkit-autofill {
    -webkit-box-shadow: 0 0 0px 1000px #111 inset !important;
    -webkit-text-fill-color: var(--text-bright) !important;
}

.btn-control {
    padding: 0 20px;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
    transition: all 0.2s ease;
    justify-content: center;
}

.btn-control:hover {
    background: rgba(var(--accent), 0.1); /* Subtle glow effect */
    border-color: var(--game-accent-glow);
    color: var(--text-bright);
}

/* --- ARCHITECT TABLE SYSTEM --- */
.architect-table {
    table-layout: fixed;
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.architect-table th {
    text-align: left;
    padding: 10px;
    background: rgba(0, 0, 0, 0.4);
    color: var(--text-dim);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.05rem;
}

.architect-table td {
    padding: 6px 3px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.architect-table th:nth-child(1), 
.architect-table td:nth-child(1) { width: auto; }   /* Name: Huge share of space */

.architect-table th:nth-child(2), 
.architect-table td:nth-child(2) { width: 100px; } /* Type: Locked */

.architect-table th:nth-child(3), 
.architect-table td:nth-child(3) { width: 40px; }

.architect-table th:nth-child(4), 
.architect-table td:nth-child(4) { width: 170px; }

.architect-table th:nth-child(5), 
.architect-table td:nth-child(5) { width: 50px; }  /* Delete: Locked */
.architect-table td:last-child {
    padding-right: 100 !important;
    text-align: right; /* Keeps it snug against the right edge */
}

.qty-input {
    text-align: center;
    padding-left: 0 !important;
    padding-right: 0 !important;
    color: var(--text-main) !important;
    -moz-appearance: textfield;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}


/* Input Styling */
.architect-table input, 
.architect-table select {
    width: 100%;
    background: rgba(255,255,255,0.02);
    border: 1px solid transparent;
    color: var(--text-main);
    padding: 3px;
    border-radius: 4px;
    box-sizing: border-box;
}
.architect-table select {
    padding-left: 4px !important;
    padding-right: 8px !important; /* Room for the dropdown arrow */
    text-overflow: ellipsis;
}

.architect-table input:focus, 
.architect-table select:focus {
    border-color: var(--accent);
    background: rgba(0,0,0,0.3);
    outline: none;
}

/* Styled Delete Button */
.btn-delete {
    width: 22px;
    height: 22px;
    background-color: var(--accent) !important;
    color: #000 !important; 
    border: none;
    border-radius: 4px;
    font-size: 1.2rem;
    font-weight: 900;
    cursor: pointer;
    display: flex; /* Flex ensures the 'X' is dead center */
    align-items: center;
    justify-content: center;
    margin: 0 auto; 
    padding: 0;
    line-height: 0;
}

.btn-delete:active {
    transform: scale(0.9);
}

/* Main Deck takes the full top row */
.main-deck-section {
    grid-column: 1 / span 2;
}

/* Side and Extra will sit side-by-side naturally in the next row */
.side-deck-section, .extra-deck-section {
    grid-column: span 1;
}

/* If Extra Deck is hidden, make Side Deck full width */
.extra-deck-hidden .side-deck-section {
    grid-column: 1 / span 2;
}

.type-input:hover, 
.role-input:hover, 
#global-game-selector:hover {
    border-color: var(--accent);
}
.type-input:focus, 
#global-game-selector:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}
select option {
    background-color: var(--bg-card); /* Matches your card background */
    color: var(--text-bright);
    padding: 10px;
}

.clickable-header {
    cursor: pointer;
    transition: color 0.2s;
    position: relative;
}

.clickable-header:hover {
    color: var(--accent);
    text-decoration: underline;
}

.clickable-header i {
    opacity: 0.6;
    margin-left: 4px;
}

.clickable-header:hover i {
    opacity: 1;
}

/* Container cell for the name and indicator */
.card-row td:first-child {
    position: relative;
    padding-left: 12px !important; /* Make room for the 4px strip + some breathing space */
}

/* The actual color strip */
.type-indicator {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px; /* Slightly wider for better visibility */
    transition: background-color 0.3s ease;
    border-radius: 2px 0 0 2px; /* Slight rounding on the outer edge */
}

/* Optional: Subtle hover effect for the row */
.card-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* Probability Grid */
#dynamic-probs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px; /* Your 4px connection rule */
}

.prob-box {
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 10px;
    border-radius: 4px;
    /* Use the game's accent color for the mini-banner */
    border-left: 3px solid var(--accent); 
    min-width: 90px;
    transition: transform 0.1s ease;
    border-left-width: 3px;
    border-left-style: solid;
}

.prob-box:hover {
    background: rgba(255, 255, 255, 0.08);
}

.prob-box label { 
    font-size: 0.6rem; 
    color: var(--text-dim); 
    display: block; 
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.prob-box .big-num { 
    font-size: 1rem; 
    font-weight: 800; 
    color: var(--text-bright); 
}

/* Donut chart */
#type-donut-wrapper {
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Fix for Plotly's internal SVG centering */
.js-plotly-plot .plotly .main-svg {
    background: transparent !important;
}

.btn-reset {
    height: 38px;
    background: #333; /* Darker, neutral color */
    color: #999;
    border: 1px solid #444;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.7rem;
    transition: all 0.2s;
}

.btn-reset:hover {
    background: #442222; /* Very subtle red hint */
    color: #ff8888;
    border-color: #aa4444;
}

/* UNIVERSAL MODAL */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.modal-content.parchment-theme {
    background: #08080a;
    border: 1px solid var(--accent);
    box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.2);
    width: 90%;
    max-width: 500px;
    border-radius: 8px;
    padding: 20px;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    padding: 5px;
    transition: color 0.2s;
}

.modal-close:hover { color: var(--accent); }

.hidden { display: none !important; }

.modal-footer {
    display: flex;
    justify-content: flex-end; /* Pushes buttons to the right */
    gap: 10px;                 /* Spacing between buttons */
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Ensure buttons don't stretch to full width on mobile */
.modal-footer button {
    flex: 0 1 auto; 
    min-width: 100px;
}

/* Vision Modal */
.vision-container {
    line-height: 1.6;
    color: var(--text-main);
    max-height: 60vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.vision-feature {
    margin-top: 20px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
}

.vision-feature h4 {
    margin: 0 0 5px 0;
    color: var(--accent);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.vision-feature p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* Legal Modal */
.legal-doc {
    text-align: left;
    max-height: 60vh; /* Adds scroll for long text */
    overflow-y: auto;
    padding-right: 10px;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-dim);
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.legal-section {
    margin-bottom: 20px;
}

.legal-section h4 {
    color: var(--accent);
    margin-bottom: 8px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.legal-section p {
    margin: 0;
}

/* Contact Form Styling */
.architect-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    text-align: left;
    margin-top: 10px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--accent-color);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-control, 
#feedbackMessage {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 10px;
    color: var(--text-bright);
    font-family: inherit;
    transition: all 0.2s ease;
}

#feedbackMessage {
    min-height: 120px;
    resize: vertical;
}

.form-control:focus, 
#feedbackMessage:focus {
    outline: none;
    border-color: var(--accent-color, #4a6ee0);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 8px rgba(74, 110, 224, 0.2);
}

.status-msg {
    font-size: 0.9rem;
    min-height: 20px;
    color: #aaa;
    font-style: italic;
    margin-top: 5px;
}

/* Specific styling for the select dropdown icon */
select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 12px) center;
    padding-right: 30px;
}

/* Scrollbar styling for the modal doc */
.legal-doc::-webkit-scrollbar {
    width: 4px;
}
.legal-doc::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}

/* YuGiOh Role Modal */
.role-guide {
    line-height: 1.6;
    color: var(--text-dim);
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.role-guide::-webkit-scrollbar {
    width: 6px;
}

.role-guide::-webkit-scrollbar-track {
    background: transparent;
}

.role-guide::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}

.role-intro {
    font-style: italic;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 10px;
}

.role-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 800;
    margin-bottom: 5px;
    color: var(--bg-deep);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-item {
    margin-bottom: 15px;
}

.role-item p {
    margin: 4px 0 0 0;
    line-height: 1.4;
}

.role-footer {
    margin-top: 10px;
    padding: 10px;
    background: rgba(var(--accent-rgb), 0.1);
    border-radius: 4px;
    font-size: 0.8rem;
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Toast message*/
.toast-notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--game-accent);
    color: var(--text-bright);
    padding: 8px 20px;
    border-radius: 4px;
    font-weight: 800;
    font-size: 0.8rem;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
}
.toast-notification.show { opacity: 1; bottom: 40px; }

/* SIM FIELD STYLING */
.sim-content {
    margin-top: 15px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px dashed #333;
    border-radius: 4px;
    padding: 15px;
    transition: all 0.3s ease;
}

.sim-content.hidden {
    display: none;
}

/* MANUAL SIMMING */
.sim-button-row {
    display: flex;       /* Switch from grid to flex */
    gap: 15px;
    margin-top: 20px;
    width: 100%;
}

.sim-button-row button {
    flex: 1;            /* Each button takes equal available space */
    padding: 20px;
    font-weight: bold;
    font-size: 1rem;
    letter-spacing: 1.5px;
    cursor: pointer;
    border-radius: 4px;
    text-transform: uppercase;
    transition: all 0.2s ease;
    
    /* Ensure hidden buttons don't take up space */
    display: none;      
}

/* Ensure buttons are visible if their display isn't explicitly set to 'none' by JS */
.sim-button-row button:not([style*="display: none"]) {
    display: block; 
}

.btn-auto-sim-toggle, .btn-manual-sim-toggle{
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #333;
    color: var(--text-dim);
    padding: 20px;
    font-weight: bold;
    font-size: 1rem;
    letter-spacing: 1.5px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.btn-auto-sim-toggle:hover, .btn-manual-sim-toggle:hover{
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--accent);
    color: var(--text-bright);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

.analysis-container {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.analysis-main {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
}

/* Container for the configuration panel */
#sim-config-panel {
    display: none;
    border-left: 2px solid var(--accent);
    background: rgba(0,0,0,0.4);
    margin: 15px 0;
    transition: all 0.2s ease-in-out;
}
.manual-sim-container {
    padding: 15px;
    background: rgba(0,0,0,0.15);
    border: 1px solid #222;
    margin-top: 10px;
}
.config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.config-title {
    font-size: 0.7rem;
    color: var(--accent);
    text-transform: uppercase;
    font-weight: bold;
}

/* Hand cards */
.manual-card-row {
    display: flex;
    flex: 1;
    min-width: 120px;
    justify-content: space-between; /* Pushes name to left, role to right */
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 1px 10px;
    border-radius: 2px 0 0 2px;
    margin-bottom: 4px;
    min-height: 30px;
}

.card-left-group {
    display: flex;
    flex-direction: column;
    flex: 1; /* Takes up available space */
    min-width: 0; /* Allows text truncation if needed */
}

.card-title {
    font-weight: bold;
    font-size: 1rem;
    color: var(--text-bright)
}

.card-subtitle {
    font-size: 0.7rem; 
    color: var(--text-dim); 
    opacity: 0.9;
    margin-top: 2px;
}

.card-right-role {
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--accent);
    text-transform: uppercase;
    margin-left: 10px;
    white-space: nowrap; /* Prevents role from wrapping */
}

/* Row for each button's settings */
.config-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    align-items: center;
}

.config-row input {
    background: #111;
    border: 1px solid #444;
    color: var(--text-bright);
    padding: 8px;
    border-radius: 3px;
    font-size: 0.8rem;
    flex-grow: 1;
}

.config-row input:focus {
    border-color: var(--accent);
    outline: none;
}

/* Dynamic Grid for up to 8 buttons */
.sim-action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(20%, 1fr));
    gap: 10px;
    margin: 15px 0;
    width: 100%;
}

/* Edit Panel Elements */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 10px;
}
.success-dot { background: #4caf50; box-shadow: 0 0 5px #4caf50; }
.brick-dot { background: #f44336; box-shadow: 0 0 5px #f44336; }

.active-edit {
    background: var(--accent) !important;
    color: #000 !important;
    border-color: var(--text-bright) !important;
}

.config-row {
    display: flex;
    align-items: center;
    background: #000;
    margin-bottom: 5px;
    padding: 5px 10px;
    border: 1px solid #222;
}

/* Individual Action Buttons */
.btn-manual-action {
    border: none;
    border-radius: 4px;
    font-weight: 800;
    font-size: 0.75rem; /* Smaller text for 4-across fit */
    cursor: pointer;
    color: var(--text-bright);
    text-transform: uppercase;
    transition: filter 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4px;
}

.btn-manual-action.success { background: #2e7d32; border-bottom: 3px solid #1b4a1e; }
.btn-manual-action.success:hover {background: #1b4a1e;}
.btn-manual-action.brick { background: #c62828; border-bottom: 3px solid #8e1c1c; }
.btn-manual-action.brick:hover { background: #8e1c1c;}
.btn-manual-action:active {transform: translateY(2px) scale(0.98);}

.sim-utility-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 20px;
}

.btn-util {
    background: #222;
    border: 1px solid #444;
    color: var(--text-dim);
    padding: 8px;
    font-size: 0.65rem;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
}

.btn-util:hover {
    border-color: var(--accent);
    color: var(--text-bright);
    background: #2a2a2a;
}

/* Clean up Hand Viewer rows */
.manual-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: 4px;
    padding: 10px 15px;
    border-left: 4px solid var(--accent);
}

/* Styling for the small toggle button in the header */
.btn-config-tiny {
    background: none;
    border: 1px solid #444;
    color: #888;
    font-size: 0.6rem;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    text-transform: uppercase;
}

.btn-config-tiny:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* Add/Remove buttons inside config */
.btn-add-cat {
    padding: 5px 10px;
    font-size: 0.65rem;
    font-weight: bold;
    border-radius: 3px;
    border: none;
    cursor: pointer;
}

.btn-add-success { background: #2e7d32; color: #fff; }
.btn-add-brick { background: #c62828; color: #fff; }

.btn-remove-tiny {
    background: #444;
    color: #fff;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 3px;
    cursor: pointer;
}

.btn-remove-tiny:hover { background: #f44336; }

.category-results-row {
    display: flex;
    flex-wrap: nowrap; /* Force single row */
    overflow-x: auto; /* Allow scroll if screen is very narrow */
    justify-content: space-around;
    gap: 2px;
    margin: 15px 0;
    background: #0a0a0a;
    padding: 12px 5px;
    border: 1px solid #222;
}

.cat-stat-box {
    flex: 1;
    min-width: 60px;
    text-align: center;
    border-right: 1px solid #1a1a1a;
    transition: all 0.3s ease;
}

.cat-stat-box:last-child { border-right: none; }

.cat-stat-box.stat-success .cat-pct {color: #4caf50;}
.cat-stat-box.stat-success {border-top: 2px solid rgba(76, 175, 80, 0.3);}
.cat-stat-box.stat-brick .cat-pct {color: #f44336;}
.cat-stat-box.stat-brick {border-top: 2px solid rgba(244, 67, 54, 0.3);}

.cat-pct { font-size: 0.9rem; font-weight: 800; color: var(--accent); }
.cat-label { font-size: 0.55rem; color: var(--text-main); text-transform: uppercase; margin: 2px 0; }
.cat-count { font-size: 0.6rem; color: var(--text-dim); }

.status-dot.success-dot { background: #4caf50; box-shadow: 0 0 8px rgba(76, 175, 80, 0.5); }
.status-dot.brick-dot { background: #f44336; box-shadow: 0 0 8px rgba(244, 67, 54, 0.5); }


/* AUTO SIMMING */
.tracker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin: 15px 0;
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 4px;
}

.tracker-item {
    display: flex;
    justify-content: space-between; /* This pushes the value to the far right */
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tracker-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
}

.tracker-val {
    font-weight: bold;
    color: var(--accent); /* Your game's accent color */
    font-family: monospace;
}

.sim-loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
}

.sim-loader-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 10px var(--accent));
    animation: simPulse 1.5s infinite ease-in-out;
}

.sim-loader-text {
    font-size: 0.7rem;
    letter-spacing: 3px;
    color: var(--accent);
    font-weight: bold;
    text-transform: uppercase;
}

.streak-banner {
    display: flex;
    justify-content: space-around;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 15px;
}

.streak-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.s-label {
    font-size: 0.55rem;
    color: #666;
    letter-spacing: 1px;
    font-weight: bold;
}

.s-val {
    font-family: monospace;
    font-size: 1.1rem;
    font-weight: bold;
}

.tracker-section-title {
    grid-column: 1 / -1;
    font-size: 0.55rem;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.streak-highlight {
    grid-column: 1 / -1; /* Make the streak span the full width of the tracker grid */
    border-bottom: none !important;
}

@keyframes simPulse {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; filter: drop-shadow(0 0 20px var(--accent)); }
    100% { transform: scale(1); opacity: 0.8; }
}


/* --- Media Entry Styling --- */
.media-entry {
    background: var(--card-bg, #1a1a1a);
    border: 1px solid #333;
    border-radius: 8px;
    margin-bottom: 2rem;
    padding: 1.5rem;
}

.media-layout-wrapper {
    max-width: 900px;
    margin: 0 auto;
}

.media-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 5px;
}

.media-page-header h2 {
    font-family: 'Architects Daughter', cursive; /* Or your preferred brand font */
    color: var(--accent-color);
    font-size: 2rem;
    margin-bottom: 10px;
}

.media-grid {
    display: flex;
    flex-direction: column;
    gap: 5px; /* Space between different posts */
}

.media-text {
    line-height: 1.6;
    color: var(--text-bright);
    margin: 15px 0;
    white-space: pre-wrap; /* Preserves line breaks from your JSON */
}

.post-date {
    color:var(--text-dim);
    font-size: 0.8rem;
    font-style: italic;
}

.video-wrapper {
    width: 100%;
    max-width: 800px; /* Standard cap for Long videos */
    margin: 0 auto;
}

.video-standard {
    aspect-ratio: 16 / 9; /* Classic Widescreen for "Long" */
}

.video-short {
    max-width: 315px; /* Thinner for vertical content */
    aspect-ratio: 9 / 16;
}

.video-wrapper iframe {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.video-caption {
    margin-top: 10px;
    font-size: 0.85rem;
    font-style: italic;
    color: var(--text-dim);
    text-align: center;
    border-left: 2px solid var(--accent-color);
    padding-left: 10px;
}

/* The Import Buttons */
.deck-list-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 20px;
}

.btn-deck-import {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-deck-import:hover {
    background: var(--accent-color);
}

.deck-list-label {
    width: 100%;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    color: var(--accent-color);
    margin-bottom: 5px;
}

/* --- 7. MOBILE RESPONSIVENESS --- */
@media (max-width:1600px) {
    .main-builder {
        grid-template-columns: 1fr !important; /* Forces 1 column */
        gap: 15px;
    }

    .deck-section, 
    .deck-section-extra, 
    .deck-section-side {
        grid-column: 1 / span 1 !important; /* Everyone takes full width */
    }
}

@media (max-width: 1100px) {
    .page-layout {
        grid-template-columns: 1fr;
        padding: 5px 0px; /* Reduced side padding to 5px for more space */
        display: flex;
        flex-direction: column;
        align-items: center; /* Forces children to the center */
    }

    .ad-sidebar {
        display: none; /* Hide large desktop ads */
    }

    /* --- MOBILE NAVBAR --- */
    .navbar {
        position: relative; /* Overrides sticky */
        height: auto;
        padding: 15px 0;
    }

    .nav-container {
        display: flex;
        flex-wrap: wrap; /* Allows the nav-links to drop to a new line */
        align-items: center;
        justify-content: space-between; /* Logo left, Selector right */
        padding: 10px 15px;
        gap: 10px;
    }

    .nav-logo-section {
        flex: 1; /* Takes available space on the left */
        display: flex;
        align-items: center;
    }

    .logo {
        height: 30px; /* Smaller logo for SE */
    }

    /* HORIZONTAL SCROLLING TABS */
    .nav-links {
        order: 3; /* Ensures it stays below the logo/selector row */
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%; /* Force it to its own line */
        gap: 8px;
        margin-top: 5px;
    }

    .nav-links::-webkit-scrollbar {
        display: none; /* Hide scrollbar Chrome/Safari */
    }

    .tablink {
        background-color: var(--bg-card); /* Give them a slight "tile" look */
        border: 1px solid var(--border);
        border-radius: 6px;
        padding: 12px 5px !important;
        height: auto;
        text-align: center;
        font-size: 0.85rem;
        justify-content: center;
        border-bottom: 1px solid var(--border); /* Reset the desktop bottom line */
    }
    .tablink.active {
        background-color: rgba(255, 255, 255, 0.05);
        border-color: var(--accent);
        color: var(--accent);
        border-bottom: 1px solid var(--accent); /* Keep border consistent */
    }

    .nav-right {
        flex: 0 0 auto; /* Takes only as much space as the dropdown needs */
        width: auto; 
    }

    #global-game-selector {
        width: 130px; /* Constrain width so it doesn't crush the logo */
        font-size: 0.8rem;
        padding: 5px;
        height: 35px;
    }
    .game-switcher {
        width: 100%; /* Full width dropdown for easy thumb tapping */
    }

    .tablink[data-tab="TierList"] {
        grid-column: span 2;
    }
    /* --- CONTENT & FOOTER --- */
    .content-wrapper {
        overflow-y: none; /* Let the main page handle scrolling */
        height: calc(100vh - 300px);
    }

    .calculator-layout {
        grid-template-columns: 1fr; /* Stack sidebar and chart */
    }

    .footer {
        height: auto;
        padding: 40px 10px 100px 10px; /* Extra bottom padding so anchor ad doesn't cover text */
    }
    .mobile-anchor-ad {
        display: flex;
    }
}

@media (max-width: 800px) {
    .deck-architect-grid {
        grid-template-columns: 1fr;
    }
    .side-deck-section, .extra-deck-section {
        grid-column: span 1;
    }

}

/* Footer & Analytics stacking */
@media screen and (max-width: 768px) {
    .container, 
    .main-content, 
    body {
        padding-left: 0px !important;   /* Minimal safe distance from edge */
        padding-right: 0px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;        /* Ensure it takes full width */
    }

    /* If the "Architect Table" itself has forced margins */
    .architect-table-wrapper {
        margin: 0 -4px; /* Pulls the table slightly closer to the edge */
    }
    .footer-layout {
        flex-direction: column;
        gap: 20px;
    }

    .analytics-footer .footer-section {
        max-width: 100% !important;
        border-left: none !important;
        padding-left: 0 !important;
        border-top: 1px solid rgba(255,255,255,0.1);
        padding-top: 20px;
    }

    /* Adjust the donut chart size for mobile */
    #type-donut-wrapper {
        height: 100px;
        margin: 10px auto;
    }
}

@media (max-width: 500px) {
    .card-row td:first-child {
        padding-left: 8px !important; /* Slightly tighter indicator space */
    }
    .type-indicator {
        width: 4px; /* Slimmer strip on mobile */
    }
}

@media (max-width: 600px) {
    .architect-table th {
        font-size: 0.55rem;
        letter-spacing: 0.02rem;
        padding: 4px 2px;
    }

    /* 2. Target the actual data cells and inputs (The critical part) */
    .architect-table td,
    .architect-table input, 
    .architect-table select {
        font-size: 0.65rem !important; /* Adjust this; 0.3rem is likely too small to read! */
        padding: 2px !important;
        height: 28px; /* Standardize height for touch targets */
    }

    .architect-table th:nth-child(1), td:nth-child(1) { width: auto; }
    .architect-table th:nth-child(2), td:nth-child(2) { width: 60px; }  /* Type */
    .architect-table .qty-input {
        width: 100% !important;
        min-width: 0 !important; /* This is the key! */
        padding: 2px 0 !important;
        text-align: center;
    }
    .architect-table th:nth-child(3), 
    .architect-table td:nth-child(3) { 
        width: 25px !important; 
        padding-left: 2px !important;
        padding-right: 2px !important;
    }
    .architect-table th:nth-child(4), td:nth-child(4) { width: 105px; } /* Role */
    .architect-table th:nth-child(5), td:nth-child(5) { width: 35px; }  /* Delete */

    .btn-delete {
        width: 22px;
        height: 22px;
        font-size: 0.8rem;
    }

    /* Mobile Dashboard Optimization */
    .manual-sim-container {
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: -webkit-fill-available;
        padding: 8px;
        gap: 4px;
        box-sizing: border-box;
        overflow: hidden; 
    }

    .hand-list-wrapper {
        display: grid;
        grid-template-columns: 1fr 1fr; /* Two columns */
        grid-auto-rows: minmax(35px, 1fr); 
        gap: 4px;
        flex-grow: 1;
        overflow-x: hidden; /* No sideways scroll on mobile */
    }

    .manual-card-row {
        height: 50px; /* Slight bump for touch targets */
        padding: 4px 6px;
        display: block;
        justify-content: space-between;
        align-items: center;
    }

    .card-title {
        font-size: 0.6rem;
        -webkit-line-clamp: 2; /* Wraps long names perfectly */
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .card-subtitle { display: none; } /* Keeps it clean */

    .card-right-role {
        display: block;
        font-size: 0.5rem;
        opacity: 0.7;
        text-align: right;
        margin-left: auto;
        white-space: nowrap;
    }

    /* 3. Stats & Buttons - Ultra Dense */
    .category-results-row {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 1px;
    }

    .cat-stat-box {
        font-size: 0.5rem;
        padding: 1px;
    }

    .cat-pct { font-size: 0.65rem; font-weight: 800;}
    .cat-label { font-size: 0.45rem;}
    .cat-count { font-size: 0.5rem;}

    .sim-action-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }

    .btn-manual-action {
        height: 38px; /* Shorter tap targets to fit hand */
        font-size: 0.65rem;
        padding: 2px;
    }

    /* Hide utility row text to save space, just use icons or tiny text */
    .sim-utility-row {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 2px;
    }
    .btn-util { font-size: 0.5rem; padding: 4px 2px; }

    .tracker-grid {
        gap: 5px;
        margin: 5px 0;
        padding: 5px;
        border-radius: 4px;
    }

    .tracker-item {
        padding: 4px 0;
    }

    .tracker-label {
        font-size: 0.5rem;
        color: var(--text-dim);
        text-transform: uppercase;
    }

    .tracker-val {
        font-size: 0.5rem;
    }
}

/* Remove the reserved height/gap issue */
.manual-sim-container {
    display: flex;
    flex-direction: column;
    gap: 0; /* Let the margins of child elements handle spacing */
}

/* Utility Row - also flexible */
.sim-utility-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 10px; /* Reduced gap */
    padding-top: 15px;
    border-top: 1px solid #222;
}