* {
    box-sizing: border-box;
}

:root {
    /* Day Mode (Default) */
    --bg-gradient-start: #ffdde1;
    --bg-gradient-end: #ee9ca7;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);

    --primary-pink: #FF8BA7;
    --secondary-pink: #FFC6C7;
    --text-color: #4a3b3e;
    /* Darker brown for better contrast */
    --accent-blue: #A2D2FF;
    --accent-gold: #FFD93D;
    /* Used for selected icon */
    --positive-green: #6BCB77;
}

/* Night Mode (Jirai-kei Kawaii) */
body.dark-theme {
    --bg-gradient-start: #0f050f;
    --bg-gradient-end: #1f0a1f;
    --glass-bg: rgba(20, 10, 25, 0.85);
    /* Darker, more opaque */
    --glass-border: rgba(255, 110, 199, 0.5);
    /* Neon Pink Border */
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.8);

    --primary-pink: #ff2a6d;
    /* High saturation Neon Pink */
    --secondary-pink: #ff5c8d;
    --text-color: #f0f0f5;
    /* Off-white for better readability */
    --accent-blue: #d600ff;
    /* Neon Purple */
    --accent-gold: #ff0055;
    /* Reddish Pink for accents */
    --positive-green: #05ffa1;
    /* Cyber Green */

    --dark-card-bg: rgba(30, 20, 35, 0.6);
}

/* Selected Icon Pulse Animation */
@keyframes selectedPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(255, 215, 0, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0);
    }
}

body.dark-theme .grid-item.selected {
    animation: selectedPulseDark 1.5s infinite;
}

@keyframes selectedPulseDark {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 121, 198, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(255, 121, 198, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 121, 198, 0);
    }
}

body {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    background-attachment: fixed;
    color: var(--text-color);
    margin: 0;
    display: flex;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
    /* Default app-mode (no body scroll) */
}

/* Safety Scroll for Short Screens */
@media (max-height: 950px) {

    /* Increased from 800px */
    body {
        overflow-y: auto;
        /* Allow body scroll */
        height: auto;
    }

    .app-container {
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .dashboard-layout {
        height: auto;
        /* Let it grow */
        display: block;
        /* Stack panels */
    }

    .left-panel,
    .right-panel {
        height: auto;
        min-height: 400px;
        /* Ensure logical size */
        margin-bottom: 20px;
    }
}

.app-container {
    width: 100%;
    max-width: 1100px;
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    height: 100vh;
    box-sizing: border-box;
}

/* Dashboard Layout */
.main-content {
    flex: 1;
    min-height: 0;
    /* Crucial: allows flex child to shrink below content size */
    width: 100%;
    margin-bottom: 20px;
}

.dashboard-layout {
    display: flex;
    flex-direction: row;
    /* Horizontal split */
    gap: 20px;
    height: 100%;
    /* Fill meaningful space */
    min-height: 0;
}

/* Header */
.header h1 {
    font-size: 2rem;
    color: #fff;
    /* Keep title white as it usually has strong shadow/gradient behind */
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.5);
    /* White glow for legibility */
    margin-bottom: 0.2rem;
    font-weight: 800;
    letter-spacing: 0.05em;
}

.subtitle {
    font-size: 1rem;
    color: var(--text-color);
    /* Use dark text instead of white/transparent */
    font-weight: bold;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.8);
    margin: 0;
}

.lucky-display {
    margin-top: 5px;
    margin-bottom: 15px;
    /* Add space below */
    font-size: 0.9rem;
    color: var(--text-color);
    /* Dark text for light mode */
    background: rgba(255, 255, 255, 0.6);
    /* More opaque background */
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    animation: popIn 0.5s ease-out;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.lucky-display span {
    font-weight: bold;
    color: #e91e63;
    /* Stronger pink for emphasis in light mode */
    text-shadow: none;
}

/* Dashboard Layout */
.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    flex: 1;
    overflow: hidden;
    /* Contain scrolls usually */
}

/* If screen is short, allow layout to break out */
@media (max-height: 800px) {
    .dashboard-layout {
        overflow: visible;
        display: flex;
        /* Or grid */
        flex-direction: column;
        /* Stack panels vertically on short screens */
    }

    .left-panel,
    .right-panel {
        height: auto;
        /* Let them grow */
        min-height: 500px;
        /* Force size */
    }
}

.left-panel,
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow: hidden;
    height: 100%;
}

/* Flex container for the left panel content */
.selection-area {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* Glassmorphism Containers */
.champion-selection,
.result-area,
.assistant-bubble,
.role-btn,
.search-container input,
.counter-card,
.champion-grid {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--glass-shadow);
}

/* Assistant (Compact) */
.assistant-area {
    margin: 0;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 15px;
    min-height: 100px;
    flex-shrink: 0;
}

.assistant-bubble {
    color: var(--text-color);
    padding: 15px 25px;
    position: relative;
    max-width: 60%;
    line-height: 1.6;
    font-weight: bold;
    word-break: keep-all;
    /* Prevent breaking inside Japanese phrases */
    overflow-wrap: anywhere;
    /* Ensure long words still break if necessary */
}

/* Vertical specific bubble tail re-position */
.assistant-bubble::after {
    left: -10px;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
    border-width: 10px 10px 10px 0;
    border-color: transparent rgba(255, 255, 255, 0.75) transparent transparent;
}

.assistant-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, #fff 30%, transparent 70%);
    overflow: hidden;
    /* Clip zoomed image */
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.2));
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Light Mode (Vtuber) - Zoom on Face to show full head/face closeup */
body:not(.dark-theme) .assistant-avatar .avatar-img {
    width: 190%;
    height: 190%;
    object-fit: cover;
    object-position: center 5%;
    max-width: none;
}

/* Role Selector */
.role-selector {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.role-btn {
    background: rgba(255, 255, 255, 0.6);
    color: var(--text-color);
    padding: 8px 18px;
    border-radius: 50px;
    border: 2px solid transparent;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.role-btn:hover {
    transform: translateY(-3px);
    background: #fff;
    box-shadow: 0 5px 15px rgba(255, 183, 197, 0.4);
}

.role-btn.active {
    background: #fff;
    color: var(--primary-pink);
    border-color: var(--primary-pink);
    box-shadow: 0 5px 20px rgba(255, 139, 167, 0.4);
}

/* Input */
.search-container {
    margin-bottom: 15px;
    width: 100%;
    display: flex;
    justify-content: center;
}

input#champion-search {
    width: 90%;
    padding: 12px 20px;
    border-radius: 50px;
    border: 2px solid transparent;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    color: var(--text-color);
    transition: all 0.3s;
    background: rgba(255, 255, 255, 0.8);
}

input#champion-search:focus {
    width: 100%;
    background: #fff;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px rgba(162, 210, 255, 0.3);
}

/* Champion Grid */
.champion-selection {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 300px;
    /* Safety Min Height */
    padding: 15px;
    background: rgba(255, 255, 255, 0.4);
    border: none;
}

.instruction-text {
    margin-bottom: 10px;
    color: #fff;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.champion-grid {
    flex: 1;
    min-height: 0;
    /* Crucial for flex nested scrolling */
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    /* Dynamic columns */
    gap: 10px;
    padding: 10px;
    padding-right: 8px;
    /* Space for scrollbar */
    background: rgba(255, 255, 255, 0.6);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.05);
    align-content: start;
    /* Prevent stretching */
    /* Ensure scrollbar works */
    max-height: 100%;
}

.grid-item {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.grid-item:hover {
    transform: translateY(-5px) scale(1.05);
    border-color: var(--accent-blue);
    z-index: 2;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.grid-item:hover img {
    transform: scale(1.1);
}


.grid-item.selected {
    border-color: var(--accent-gold);
    border-width: 4px;
    /* Thicker border */
    transform: scale(1.15) !important;
    /* Make it pop more */
    box-shadow: 0 0 20px rgba(255, 217, 61, 0.8);
    animation: selectedPulse 1.5s infinite;
    z-index: 10;
}

/* Theme Toggle Button */
.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    position: relative;
    margin-bottom: 0.5rem;
}

.theme-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
}

.theme-btn:hover {
    transform: rotate(15deg) scale(1.1);
    background: var(--primary-pink);
    color: #fff;
}

/* Results */
.result-area {
    margin-top: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 15px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    min-height: 400px;
    /* Safety Min Height */
}

.result-area h2 {
    font-size: 1.2rem;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    margin-top: 5px;
}

.counter-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    /* Vertical stack for side panel */
    gap: 15px;
    padding-right: 5px;
}

/* Memo Section */
.memo-section {
    background: rgba(255, 255, 255, 0.5);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
}

.memo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.memo-section h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-color);
}

.copy-btn {
    background: var(--text-color);
    color: #fff;
    border: none;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'M PLUS Rounded 1c', sans-serif;
}

.copy-btn:hover {
    background: var(--primary-pink);
    transform: translateY(-1px);
}

.copy-btn:active {
    transform: scale(0.95);
}

textarea#my-memo {
    width: 100%;
    height: 60px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    padding: 10px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    background: rgba(255, 255, 255, 0.9);
    /* Higher opacity for readability */
    color: #333;
    /* Explicit dark color ensuring contrast */
    font-weight: 500;
    box-sizing: border-box;
    /* Fix width overflow */
    transition: all 0.3s;
}

textarea#my-memo::placeholder {
    color: rgba(0, 0, 0, 0.5);
}

/* Dark Mode Textarea Override */
body.dark-theme textarea#my-memo {
    background: rgba(40, 20, 40, 0.8);
    color: #ffdde1;
    border-color: var(--secondary-pink);
}

body.dark-theme textarea#my-memo::placeholder {
    color: rgba(255, 221, 225, 0.5);
}

textarea#my-memo:focus {
    background: #fff;
    border-color: var(--accent-blue);
    box-shadow: 0 0 10px rgba(162, 210, 255, 0.5);
}

body.dark-theme textarea#my-memo:focus {
    background: rgba(50, 20, 50, 0.95);
    border-color: var(--accent-gold);
    box-shadow: 0 0 10px rgba(255, 217, 61, 0.3);
}

.memo-status {
    font-size: 0.8rem;
    color: var(--positive-green);
    height: 1.2rem;
    /* Reserve space */
    margin-top: 5px;
    text-align: right;
    font-weight: bold;
}

.counter-card {
    background: rgba(255, 255, 255, 0.85);
    padding: 15px;
    display: flex;
    flex-direction: row;
    align-items: center;
    text-align: left;
    transition: transform 0.3s, box-shadow 0.3s;
    border-left: 5px solid var(--primary-pink);
}

.counter-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

.champ-icon {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border: 2px solid #fff;
}

.card-content h3 {
    margin: 0 0 5px 0;
    color: var(--primary-pink);
    font-size: 1.2rem;
}

.card-content p {
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0;
    color: #666;
}

/* Match Recorder */
/* Match Recorder (Compact) */
.match-recorder {
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.recorder-title {
    margin: 0;
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--text-color);
    white-space: nowrap;
}

.record-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    /* Safety wrap */
    justify-content: center;
}

.record-btn {
    padding: 5px 14px;
    border-radius: 30px;
    border: none;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.win-btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.win-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(79, 172, 254, 0.4);
}

.lose-btn {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
    background: linear-gradient(135deg, #ff5f6d 0%, #ffc371 100%);
    color: white;
}

.lose-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(255, 95, 109, 0.4);
}

/* Modal Styling */
.modal {
    display: flex;
    /* Hidden toggled via class */
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);

    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: relative;
    color: var(--text-color);
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover {
    color: #000;
}

body.dark-theme .close-modal:hover {
    color: #fff;
}

.stats-overview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.5);
    padding: 20px;
    border-radius: 15px;
    text-align: center;
}

.stat-card h3 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    opacity: 0.8;
}

.stat-card p {
    margin: 0;
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary-pink);
}

.lane-stats-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.lane-stats-item:last-child {
    border-bottom: none;
}

/* Pro Tips Styling Overhaul */
.pro-tips {
    margin-top: 12px;
    padding: 10px 15px;
    background: rgba(162, 210, 255, 0.15);
    /* Light blue tint */
    border-radius: 10px;
    border: 1px solid rgba(162, 210, 255, 0.3);
    font-size: 0.85rem;
    color: #4a6fa5;
    font-weight: 700;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
}

.tip-icon {
    margin-right: 5px;
}

/* Animations matching JS */
.avatar-face {
    transition: all 0.3s ease-out;
}

.expression-happy {
    transform: scale(1.1) translateY(-5px);
}

.expression-thinking {
    transform: rotate(5deg) scale(1.05);
}

.expression-excited {
    animation: happyBounce 0.6s infinite alternate;
}

@keyframes happyBounce {
    0% {
        transform: translateY(0) scale(1.05);
    }

    100% {
        transform: translateY(-10px) scale(1.05);
    }
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes heartbeat {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* Mobile Polish */
@media (max-width: 600px) {
    .header h1 {
        font-size: 1.8rem;
    }

    .assistant-area {
        flex-direction: row;
        justify-content: center;
    }

    .assistant-bubble::after {
        /* Side arrow for mobile */
        bottom: auto;
        top: 50%;
        left: -10px;
        transform: translateY(-50%);
        border-width: 10px 10px 10px 0;
        border-color: transparent rgba(255, 255, 255, 0.75) transparent transparent;
    }

    /* Revert bubble tail for vertical stack (default) logic if mixed, but focusing horizontal layout */
    .assistant-bubble {
        margin-top: 0;
        margin-left: 15px;
    }
}

/* Result Tabs */
.result-header-group {
    background: rgba(255, 255, 255, 0.3);
    border-bottom: 1px solid var(--glass-border);
    margin: -15px -15px 15px -15px;
    /* Negative margin to fill top */
    padding: 15px 15px 0 15px;
    border-radius: 20px 20px 0 0;
}

.result-tabs {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px;
    font-family: inherit;
    font-weight: bold;
    color: #888;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: var(--primary-pink);
    background: rgba(255, 255, 255, 0.2);
}

.tab-btn.active {
    color: var(--primary-pink);
    border-bottom-color: var(--primary-pink);
}

body.dark-theme .tab-btn.active {
    color: var(--secondary-pink);
    border-bottom-color: var(--secondary-pink);
}

.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
    /* For scrolling inside */
    flex-direction: column;
    height: 100%;
    /* Critical: Ensure full height passed down */
}

.tab-content.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

/* Make counter list scrollable within tab */
/* Make counter list scrollable within tab */
#tab-counters {
    height: 100%;
    overflow: hidden;
    padding: 15px;
}

#counter-list {
    overflow-y: auto;
    padding-right: 5px;
    height: 100%;
    /* Fill container */
}

/* --- Two-Column Layouts (Shared Logic) --- */
.counters-layout,
.analysis-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 15px;
    height: 100%;
    align-items: stretch;
    overflow: hidden;
}

/* Specific columns */
.counters-main,
.counters-sub,
.analysis-main,
.analysis-sub {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.counters-sub,
.analysis-sub {
    gap: 10px;
}

.analysis-main {
    /* Analysis specific gap */
    gap: 10px;
}

/* Responsive: Stack nested columns on laptops/tablets */
@media (max-width: 1400px) {

    .counters-layout,
    .analysis-layout {
        grid-template-columns: 1fr;
        /* Stack vertically */
    }
}


/* ... */

/* Update Container Styles to fit inside columns */


/* ... */

/* Skill Description Box */
.skill-description-box {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    padding: 20px;
    /* More breathing room */
    font-size: 0.9rem;
    line-height: 1.5;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: opacity 0.2s ease;

    /* Dynamic Filling */
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    /* Crucial for flex scrolling */

    margin-top: 10px;
}

/* Memo Section Adjustment for Grid */
.memo-section {
    flex: 1;
    /* Fill remaining height in right col */
    min-height: 0;
    /* Allow shrinking */
    display: flex;
    flex-direction: column;
    margin-top: 0;
    /* Remove old margin */
    /* Visuals re-applied from base class if needed, but base class handles padding/bg */
    overflow: hidden;
    /* Contain textarea */
}

#my-memo {
    flex: 1;
    /* Textarea fills space */
    height: 100%;
    /* Ensure fill */
    min-height: 0;
    /* Allow shrinking */
    resize: none;
    /* Let flex handle size */
}




/* Adjust wrapper */
.result-area {
    padding-top: 0;
    /* Header takes space */
}

/* Hide the old toggle icon if we are fully expanded in tab, 
   but user might still want to toggle. Let's keep it but make it expanded by default in tab? */
.champ-detail-area {
    margin-bottom: 20px;
    animation: fadeIn 0.4s ease;
}

.champ-detail-container {
    display: flex;
    flex-direction: column;
    /* Force vertical stack */
    gap: 10px;
    /* Gap between children */
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 2px solid var(--primary-pink);
    position: relative;
    flex: 1;
    /* Critical: Fill available height in analysis-main */
    min-height: 0;
    /* Allow shrinking */
    overflow: hidden;
    /* Contain internal scrolls */
}

body.dark-theme .champ-detail-container {
    background: var(--dark-card-bg);
    border-color: var(--dark-primary);
}

.champ-detail-header-row {
    flex-shrink: 0;
    display: flex;
    gap: 15px;
    align-items: center;
}

/* Remove old body styles, keep it clean */

.champ-spells-row {
    flex-shrink: 0;
    display: flex;
    gap: 12px;
    /* Increased gap */
    margin-top: 15px;
    /* More space from header */
    margin-bottom: 15px;
    flex-wrap: wrap;
    /* Prevent overflow on small screens */
    padding-left: 6px;
    /* Safety buffer for first item outline/shadow */
}



.detail-icon-lg {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    border: 2px solid var(--primary-pink);
}

.detail-info {
    flex: 1;
}

.detail-name {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
    color: var(--text-dark);
}

body.dark-theme .detail-name {
    color: var(--dark-text);
}

.detail-title-text {
    font-size: 0.9rem;
    color: #888;
    font-weight: normal;
    margin-left: 5px;
}

/* Spells & Tooltips */
.champ-spells-row {
    display: flex;
    gap: 10px;
}

.spell-slot {
    position: relative;
    width: 40px;
    height: 40px;
    cursor: pointer;
}

.spell-slot img {
    width: 100%;
    height: 100%;
    border-radius: 6px;
    border: 1px solid #ddd;
    transition: transform 0.2s;
}

.spell-slot:hover img {
    transform: scale(1.1);
    border-color: var(--primary-pink);
}

.spell-key {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: var(--text-dark);
    color: white;
    font-size: 0.6rem;
    padding: 1px 4px;
    border-radius: 4px;
    font-weight: bold;
}

body.dark-theme .spell-key {
    background: var(--dark-primary);
}

/* Skill Description Box */
.skill-description-box {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    padding: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: opacity 0.2s ease;
    min-height: 60px;
    /* Prevent layout jump */
    max-height: 120px;
    overflow-y: auto;
    flex-shrink: 0;
    /* Critical: Prevent shrinking */
    margin-top: 5px;
    /* Explicit spacing */
}

body.dark-theme .skill-description-box {
    background: rgba(0, 0, 0, 0.3);
    border-color: var(--glass-border);
    color: #eee;
}

.skill-description-box strong {
    display: block;
    color: var(--primary-pink);
    margin-bottom: 5px;
    font-size: 1rem;
}

.skill-description-box p {
    margin: 0;
}

/* Update Spell Slot Active State */
.spell-slot.active img {
    border-color: var(--primary-pink);
    box-shadow: 0 0 0 2px var(--primary-pink);
    transform: scale(1.1);
}


/* Tooltip */
.tooltip-container .tooltip {
    visibility: hidden;
    width: 250px;
    background-color: rgba(0, 0, 0, 0.9);
    color: #fff;
    text-align: left;
    border-radius: 6px;
    padding: 10px;
    position: absolute;
    z-index: 100;
    bottom: 125%;
    /* Position above */
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.85rem;
    line-height: 1.4;
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.tooltip-container .tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.9) transparent transparent transparent;
}

.tooltip-container:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

/* CC Warning Box */
.cc-warning-box {
    background: #fff0f0;
    border: 2px solid #ffcccc;
    border-radius: 8px;
    padding: 15px;
    /* Increased padding */
}

body.dark-theme .cc-warning-box {
    background: rgba(255, 0, 0, 0.15);
    border-color: #ff6b6b;
}

.cc-warning-box.safe {
    background: #f0fff4;
    border-color: #c3e6cb;
}

body.dark-theme .cc-warning-box.safe {
    background: rgba(0, 255, 0, 0.1);
    border-color: #28a745;
}

.cc-title {
    font-weight: bold;
    color: #e74c3c;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

body.dark-theme .cc-title {
    color: #ff6b6b;
    /* Lighter red for dark bg */
}

.cc-warning-box.safe .cc-title {
    color: #2ecc71;
}

.cc-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cc-item {
    display: grid;
    grid-template-columns: 25px 30px 1fr;
    /* Key | Icon | Tags */
    gap: 8px;
    align-items: center;
    font-size: 0.9rem;
    padding: 6px 0;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.1);
}

.cc-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid rgba(0, 0, 0, 0.1);
    display: block;
    /* Remove inline spacing */
}

body.dark-theme .cc-item {
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.cc-item:last-child {
    border-bottom: none;
}

.cc-key {
    background: #e74c3c;
    color: white;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    min-width: 24px;
    text-align: center;
}

.cc-name {
    font-weight: bold;
}

.cc-tags {
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: bold;
    white-space: normal;
    line-height: 1.4;
}

.skill-cd {
    font-size: 0.85rem;
    color: #888;
    margin-left: 10px;
    font-weight: normal;
}

body.dark-theme .skill-cd {
    color: #bbb;
}