* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #8b5cf6;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #334155;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --shadow: rgba(0, 0, 0, 0.3);
}

html {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text-primary);
    padding: 0;
    line-height: 1.6;
    overflow-x: hidden;
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

@media (min-width: 1024px) {
    html {
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
        height: 100% !important;
    }
    
    body {
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box;
        height: 100vh !important;
    }
    
    .container {
        padding: 1.25rem !important;
    }
}

.container {
    max-width: 100%;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 1rem;
    gap: 0.75rem;
    overflow: hidden;
    min-height: 0; /* Critical for flex children to shrink properly */
}

@media (min-width: 1024px) {
    .container {
        margin-bottom: 0 !important;
        padding: 1.25rem !important;
    }
}


/* Header */
header {
    flex-shrink: 0;
    width: 100%;
}

@media (min-width: 1024px) {
    header {
        flex-shrink: 0;
        padding-bottom: 0 !important;
    }
}

.header-top {
    text-align: center;
    margin-bottom: 0;
}

.header-controls {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    width: 100%;
}

.up-button,
.help-button {
    flex-shrink: 0;
}

.up-button {
    margin-right: auto;
}

.help-button {
    margin-left: auto;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 4px;
}

header h1.clickable-title {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

header h1.clickable-title:hover {
    opacity: 0.8;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

/* Games View */
.games-view {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 0;
    min-height: 0;
}

.games-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 32px;
    margin: 0 auto;
    width: min(100%, 1040px);
    padding-top: 12px;
}

.game-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 26px;
    padding: 56px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    aspect-ratio: 1 / 1;
    flex: 0 0 320px;
    width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
}

.game-card:hover {
    background: var(--surface-light);
    border-color: var(--primary-color);
    transform: translateY(-6px);
    box-shadow: 0 16px 32px var(--shadow);
}

.game-icon {
    width: 140px;
    height: 140px;
    margin: 0 auto 36px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: transform 0.3s ease;
}

.game-card:hover .game-icon {
    transform: scale(1.1) rotate(5deg);
}

.game-card h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.game-card p {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
}

/* Sections View */
.sections-view {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

@media (min-width: 1024px) {
    .sections-view {
        padding: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        /* Do not disable scrolling here; forcing overflow hidden is a hack and strictly prohibited */
        overflow-y: auto;
        width: 100%;
        margin: 0 !important;
        margin-top: 1.5rem !important;
        margin-bottom: 0 !important;
        max-height: none !important;
        display: block;
    }
    
    .sections-view > * {
        margin-bottom: 0 !important;
    }
    
    .sections-view > *:last-child {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }
}

.sections-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin: 0 auto;
    width: 100%;
    max-width: 1100px;
    padding-top: 12px;
}

.section-card:last-child {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

.section-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 18px;
    padding: 28px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    aspect-ratio: 1 / 1;
    flex: 0 0 220px;
    width: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
}

.section-card:hover {
    background: var(--surface-light);
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: 0 12px 24px var(--shadow);
}

.section-icon {
    width: 88px;
    height: 88px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: transform 0.3s ease;
}

.section-card:hover .section-icon {
    transform: scale(1.1) rotate(5deg);
}

.section-card h2 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

@media (min-width: 1024px) {
    .section-card h2 {
        font-size: 1.25rem;
        margin-bottom: 6px;
    }
}

.section-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
}

@media (min-width: 1024px) {
    .section-card p {
        font-size: 0.9rem;
        line-height: 1.4;
    }
}

/* Back Button */
.up-button {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 48px;
    height: 48px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.up-button.hidden {
    display: none;
}

.up-button:hover {
    background: var(--surface-light);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

/* Search Section */
.search-section {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
}

/* Search section - inline with buttons (when in header) */
.header-controls .search-section {
    flex: 0 1 600px;
}

.search-section:not(.hidden) {
    display: flex;
}

.search-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.search-container {
    position: relative;
    flex: 1;
    max-width: 600px;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    border-radius: 4px;
}

.search-clear:hover {
    color: var(--text-primary);
    background: var(--surface-light);
}

.search-clear:active {
    transform: translateY(-50%) scale(0.95);
}

.search-clear.hidden {
    display: none;
}

#search-input {
    width: 100%;
    padding: 11px 48px 11px 48px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s;
    height: 48px;
    box-sizing: border-box;
    margin: 0;
    align-self: center;
}

#search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.search-info {
    color: var(--text-muted);
    font-size: 0.9rem;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: minmax(300px, 35%) 1fr;
    grid-template-rows: 1fr;
    gap: 1rem;
    align-items: stretch;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    height: 100%;
    /* Ensure it fills available space in flex container */
    align-self: stretch;
}

/* Results Panel */
.results-panel {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

.results-list {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem;
    min-height: 0;
    max-height: 100%;
}

.results-list::-webkit-scrollbar {
    width: 8px;
}

.results-list::-webkit-scrollbar-track {
    background: var(--surface);
}

.results-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.results-list::-webkit-scrollbar-thumb:hover {
    background: var(--surface-light);
}

/* Result Item (for sections view search) */
.result-item {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.result-item:hover {
    background: var(--surface-light);
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.result-item-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.result-type {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.95rem;
}

.result-name {
    flex: 1;
    color: var(--text-primary);
    font-size: 1rem;
}

.result-id {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.result-type-label {
    font-weight: 600;
    color: var(--primary-color);
    margin-right: 4px;
}

/* Skill Card */
.skill-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.skill-card:hover {
    background: var(--surface-light);
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.skill-card.active {
    background: var(--surface-light);
    border-color: var(--primary-color);
}

.skill-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.skill-icon {
    width: 32px;
    height: 32px;
    background-image: url('IconSet.png');
    background-size: 512px auto; /* 16 columns × 32px = 512px */
    background-repeat: no-repeat;
    image-rendering: -moz-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    flex-shrink: 0;
    border-radius: 4px;
}

.skill-card-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    flex: 1;
    line-height: 1.4;
}

.skill-card-costs {
    display: flex;
    gap: 8px;
    font-size: 0.75rem;
}

.cost-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.cost-mp {
    background: rgba(59, 130, 246, 0.2);
    color: var(--info);
}

.skill-card-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Detail Panel */
.detail-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-width: 100%;
}

.detail-content {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.detail-panel::-webkit-scrollbar {
    width: 8px;
}

.detail-panel::-webkit-scrollbar-track {
    background: var(--surface);
}

.detail-panel::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.detail-panel::-webkit-scrollbar-thumb:hover {
    background: var(--surface-light);
}

.detail-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 0;
    color: var(--text-muted);
}

.detail-placeholder svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.detail-placeholder p {
    font-size: 1rem;
}

/* Detail Content */
.detail-header {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.detail-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.detail-icon {
    width: 48px;
    height: 48px;
    background-image: url('IconSet.png');
    background-size: 768px auto; /* 16 columns × 48px = 768px */
    background-repeat: no-repeat;
    image-rendering: -moz-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border-radius: 8px;
    border: 2px solid var(--border);
}

/* Enemy Battler Sprites */
.enemy-battler {
    object-fit: contain;
    image-rendering: -moz-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border-radius: 4px;
    background: var(--surface-light);
    border: 1px solid var(--border);
}

.enemy-battler-list {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.enemy-battler-detail {
    width: 280px;
    height: 280px;
    border-radius: 8px;
    border: 2px solid var(--border);
}

.detail-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
}

.detail-id {
    font-size: 0.65em;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 6px;
    opacity: 0.7;
    vertical-align: 0.25em;
    display: inline-block;
    line-height: 1;
}

.detail-description {
    font-size: 1.1rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.tag-primary {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
}

.tag-success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.tag-warning {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.tag-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.tag-info {
    background: rgba(59, 130, 246, 0.2);
    color: var(--info);
}

/* Detail Sections */
.detail-section {
    margin-bottom: 20px;
}

.section-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: '';
    width: 4px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 2px;
}

.subsection {
    margin-bottom: 16px;
}

.subsection:last-child {
    margin-bottom: 0;
}

.subsection-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    margin-top: 12px;
}

.subsection:first-child .subsection-title {
    margin-top: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.stat-item {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

.stat-item:last-child {
    margin-bottom: 0;
}

.stat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.stat-id {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface);
    padding: 4px 8px;
    border-radius: 4px;
    min-width: 40px;
    text-align: center;
}

.stat-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.stat-abbrev {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.stat-explanation {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
}

.stat-interactions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.8;
}

.stat-interactions strong {
    color: var(--primary-light);
    font-weight: 600;
    display: inline-block;
    margin-top: 8px;
}

.stat-interactions strong:first-child {
    margin-top: 0;
}

.stat-interactions code {
    background: var(--background);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    color: var(--text-primary);
    border: 1px solid var(--border);
    word-break: break-all;
    overflow-wrap: break-word;
    max-width: 100%;
    display: inline-block;
}

.stats-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Calculation examples in stats section */
.calculation-example {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
}

.calculation-example > div {
    margin: 4px 0;
}

.calculation-example > div:last-child {
    margin-top: 8px;
    font-weight: 600;
    color: var(--primary-light);
}

/* Effect Items */
.effect-item {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
}

.effect-type {
    font-weight: 600;
    color: var(--primary-light);
    margin-bottom: 4px;
}

.effect-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Note Section */
.note-container {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

/* Cross-reference links */
.cross-reference {
    color: var(--primary-light);
    text-decoration: underline;
    text-decoration-color: var(--primary-light);
    text-underline-offset: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.cross-reference:hover {
    color: var(--primary-color);
    text-decoration-color: var(--primary-color);
    background-color: rgba(99, 102, 241, 0.1);
    padding: 2px 4px;
    margin: -2px -4px;
    border-radius: 3px;
}

.cross-reference:active {
    color: var(--primary-dark);
}

.note-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.note-toggle {
    margin-top: 12px;
    padding: 8px 16px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.note-toggle:hover {
    background: var(--border);
}

.note-toggle:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Damage Formula */
.formula-box {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 1rem;
    color: var(--text-primary);
    overflow-x: auto;
    line-height: 1.6;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* Utility Classes */
.text-muted {
    color: var(--text-muted);
}

.text-small {
    font-size: 0.85rem;
}

.mt-2 {
    margin-top: 8px;
}

.mb-2 {
    margin-bottom: 8px;
}

.hidden {
    display: none !important;
}

/* Help Button */
.help-button {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 48px;
    height: 48px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.help-button:hover {
    background: var(--surface-light);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--surface);
    border-radius: 16px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px var(--shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--surface-light);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.help-section {
    margin-bottom: 32px;
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-light);
    margin-bottom: 12px;
}

.help-section h4 {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-top: 16px;
    margin-bottom: 8px;
}

.help-section p {
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.7;
}

.help-section ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 12px;
}

.help-section li {
    color: var(--text-secondary);
    padding: 6px 0;
    padding-left: 24px;
    position: relative;
}

.help-section li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
}

.help-note {
    background: var(--background);
    border-left: 3px solid var(--info);
    padding: 12px;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Section Toggle */
.section-toggle {
    background: var(--background);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    margin-bottom: 12px;
}

.section-toggle:hover {
    background: var(--surface-light);
    border-color: var(--primary-color);
    color: var(--text-primary);
}

.section-toggle span {
    font-size: 0.8rem;
    transition: transform 0.2s ease;
}

.section-toggle:hover span {
    transform: translateX(2px);
}

/* Show Original Toggle */
.show-original-toggle {
    margin-top: 12px;
    padding: 8px 16px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.show-original-toggle:hover {
    background: var(--border);
    border-color: var(--primary-color);
}

.show-original-toggle:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.original-data-box {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}


/* ============================================
   RESPONSIVE DESIGN - MOBILE & TABLET
   ============================================ */

/* Tablet Landscape and Below (1024px) */
@media (max-width: 1024px) {
    body {
        padding: 0;
    }
    
    .container {
        max-width: 100%;
        padding: 0.75rem;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
    
    /* Single column layout for main content */
    .main-content {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    /* Mobile navigation: show only one panel at a time */
    .detail-panel {
        display: none;
        position: static;
    }
    
    .detail-panel.mobile-active {
        display: flex;
        flex: 1;
        min-height: 0;
    }
    
    /* Hide search bar, title, and description when viewing item detail on mobile */
    .container:has(.detail-panel.mobile-active) .search-section,
    body:has(.detail-panel.mobile-active) .search-section {
        display: none !important;
    }
    
    .container:has(.detail-panel.mobile-active) header h1#header-title,
    body:has(.detail-panel.mobile-active) header h1#header-title {
        display: none !important;
    }
    
    .container:has(.detail-panel.mobile-active) header .subtitle#header-subtitle,
    body:has(.detail-panel.mobile-active) header .subtitle#header-subtitle {
        display: none !important;
    }
    
    .games-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 20px;
    }
    
    .sections-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 16px;
    }
}

/* Tablet Portrait and Below (768px) */
@media (max-width: 768px) {
    body {
        padding: 12px;
        font-size: 15px;
    }
    
    /* Header Adjustments */
    .header-content {
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto auto;
        gap: 12px 16px;
        align-items: center;
    }
    
    .header-left {
        grid-column: 1;
        grid-row: 1;
        justify-self: start;
    }
    
    .header-content > div:nth-child(2) {
        grid-column: 1 / -1;
        grid-row: 2;
        text-align: center;
    }
    
    .header-actions {
        grid-column: 3;
        grid-row: 1;
        justify-self: end;
    }
    
    header h1 {
        font-size: 1.5rem;
        line-height: 1.3;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .up-button,
    .help-button {
        min-width: 44px;
        min-height: 44px;
        padding: 12px;
    }
    
    /* Games & Sections View */
    .games-grid,
    .sections-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 0;
    }
    
    .game-card,
    .section-card {
        padding: 24px;
    }
    
    .game-icon,
    .section-icon {
        width: 64px;
        height: 64px;
        margin-bottom: 16px;
    }
    
    .game-icon svg,
    .section-icon svg {
        width: 40px;
        height: 40px;
    }
    
    .game-card h2,
    .section-card h2 {
        font-size: 1.25rem;
    }
    
    /* Search Section */
    .search-section {
        padding: 0;
        margin-bottom: 16px;
    }
    
    .search-section:not(.hidden) {
        margin-top: 0;
    }
    
    .search-wrapper {
        flex-direction: row;
        gap: 12px;
        flex-wrap: wrap;
    }
    
    .search-info {
        order: 2;
    }
    
    .search-input,
    #search-input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 14px 44px 14px 44px;
        min-height: 48px;
    }
    
    .search-icon {
        width: 44px;
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .search-icon img {
        width: 20px;
        height: 20px;
    }
    
    /* Results List */
    .results-list {
        padding: 0.5rem;
    }
    
    .skill-card {
        padding: 14px;
        margin-bottom: 10px;
    }
    
    .skill-card-header {
        gap: 10px;
    }
    
    /* Keep icons same size on tablet for consistency */
    .skill-card-title {
        font-size: 0.95rem;
    }
    
    .skill-card-description {
        font-size: 0.8rem;
        line-height: 1.4;
    }
    
    .cost-badge {
        font-size: 0.75rem;
        padding: 2px 6px;
    }
    
    /* Detail Panel */
    .detail-panel {
        padding: 1rem;
    }
    
    /* Make detail panel larger when active on mobile */
    .detail-panel.mobile-active {
        flex: 1;
        min-height: 0;
    }
    
    .detail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        padding-bottom: 16px;
    }
    
    /* Keep icons same size on tablet for consistency */
    .detail-name {
        font-size: 1.5rem;
    }
    
    .detail-description {
        font-size: 0.9rem;
    }
    
    .section-title {
        font-size: 1rem;
        padding: 10px 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    .stat-value {
        font-size: 0.95rem;
    }
    
    /* Help Modal */
    .help-modal {
        padding: 16px;
    }
    
    .help-content {
        max-width: 100%;
        max-height: calc(100vh - 40px);
        margin: 0;
        border-radius: 12px;
    }
    
    .help-header {
        padding: 20px;
    }
    
    .help-header h2 {
        font-size: 1.5rem;
    }
    
    .close-help {
        width: 36px;
        height: 36px;
        font-size: 1.5rem;
    }
    
    .help-body {
        padding: 20px;
    }
    
    .help-section h3 {
        font-size: 1.1rem;
    }
    
    .help-section {
        font-size: 0.9rem;
    }
}

/* Mobile Landscape and Below (640px) */
@media (max-width: 640px) {
    body {
        padding: 8px;
    }
    
    header {
        margin-bottom: 12px;
    }
    
    header h1 {
        font-size: 1.3rem;
    }
    
    .subtitle {
        font-size: 0.85rem;
    }
    
    .game-card,
    .section-card {
        padding: 20px;
    }
    
    .game-card h2,
    .section-card h2 {
        font-size: 1.1rem;
    }
    
    .game-card p,
    .section-card p {
        font-size: 0.85rem;
    }
    
    /* Single column stats grid for very small screens */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .detail-section {
        padding: 14px;
    }
    
    /* Enemy battler sprites - medium size on small mobile */
    .enemy-battler-list {
        width: 28px;
        height: 28px;
    }
    
    .enemy-battler-detail {
        width: 200px;
        height: 200px;
    }
    
    /* Make scrollbars thinner on mobile */
    .results-list::-webkit-scrollbar,
    .detail-panel::-webkit-scrollbar {
        width: 4px;
    }
}

/* Small Mobile Phones (480px and below) */
@media (max-width: 480px) {
    body {
        padding: 6px;
        font-size: 14px;
    }
    
    header h1 {
        font-size: 1.2rem;
    }
    
    .subtitle {
        font-size: 0.8rem;
    }
    
    .header-actions {
        gap: 8px;
    }
    
    .up-button,
    .help-button {
        min-width: 40px;
        min-height: 40px;
        padding: 10px;
    }
    
    .up-button img,
    .help-button img {
        width: 18px;
        height: 18px;
    }
    
    .game-card,
    .section-card {
        padding: 16px;
        border-radius: 12px;
    }
    
    .game-icon,
    .section-icon {
        width: 56px;
        height: 56px;
        margin-bottom: 12px;
    }
    
    .game-icon svg,
    .section-icon svg {
        width: 32px;
        height: 32px;
    }
    
    .game-card h2,
    .section-card h2 {
        font-size: 1rem;
        margin-bottom: 6px;
    }
    
    .game-card p,
    .section-card p {
        font-size: 0.8rem;
    }
    
    .search-section {
        padding: 0;
        margin-bottom: 12px;
    }
    
    .search-section:not(.hidden) {
        margin-top: 0;
    }
    
    .search-input,
    #search-input {
        padding: 12px 40px 12px 40px;
        font-size: 16px;
    }
    
    .results-count {
        font-size: 0.85rem;
        padding: 8px 12px;
    }
    
    .results-list {
        padding: 0.375rem;
    }
    
    .skill-card {
        padding: 12px;
        margin-bottom: 8px;
        border-radius: 8px;
    }
    
    /* Keep icons same size on mobile for consistency */
    .skill-card-title {
        font-size: 0.9rem;
    }
    
    .skill-card-description {
        font-size: 0.75rem;
    }
    
    .detail-panel {
        padding: 0.75rem;
    }
    
    /* Make detail panel larger when active on small mobile */
    .detail-panel.mobile-active {
        flex: 1;
        min-height: 0;
    }
    
    .detail-header {
        padding-bottom: 12px;
    }
    
    /* Keep icons same size on mobile for consistency */
    .detail-name {
        font-size: 1.3rem;
    }
    
    .detail-description {
        font-size: 0.85rem;
    }
    
    /* Enemy battler sprites - smaller on mobile */
    .enemy-battler-list {
        width: 24px;
        height: 24px;
    }
    
    .enemy-battler-detail {
        width: 160px;
        height: 160px;
    }
    
    .detail-section {
        padding: 12px;
        margin-bottom: 12px;
        border-radius: 8px;
    }
    
    .section-title {
        font-size: 0.95rem;
        padding: 8px 0;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    .stat-value {
        font-size: 0.9rem;
    }
    
    .show-original-toggle {
        padding: 8px 12px;
        font-size: 0.8rem;
        width: 100%;
        justify-content: center;
    }
    
    .help-content {
        border-radius: 8px;
    }
    
    .help-header {
        padding: 16px;
    }
    
    .help-header h2 {
        font-size: 1.3rem;
    }
    
    .close-help {
        width: 32px;
        height: 32px;
        font-size: 1.3rem;
    }
    
    .help-body {
        padding: 16px;
    }
    
    .help-section {
        margin-bottom: 20px;
    }
    
    .help-section h3 {
        font-size: 1rem;
        margin-bottom: 8px;
    }
    
    .help-section p,
    .help-section li {
        font-size: 0.85rem;
    }
    
    .help-note {
        font-size: 0.8rem;
        padding: 8px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .skill-card {
        min-height: 80px;
        cursor: default;
    }
    
    .game-card,
    .section-card {
        cursor: default;
    }
    
    /* Remove hover effects on touch devices */
    .skill-card:hover {
        transform: none;
    }
    
    .game-card:hover,
    .section-card:hover {
        transform: none;
    }
    
    /* Active states for touch feedback */
    .skill-card:active {
        transform: scale(0.98);
    }
    
    .game-card:active,
    .section-card:active {
        transform: scale(0.98);
    }
    
    .up-button:active,
    .help-button:active {
        transform: scale(0.95);
    }
}

/* Landscape Mode Adjustments for Phones */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        padding: 8px;
    }
    
    header {
        margin-bottom: 8px;
    }
    
    header h1 {
        font-size: 1.1rem;
    }
    
    .subtitle {
        display: none; /* Hide subtitle in landscape to save space */
    }
    
    .results-list,
    .detail-panel {
        /* Heights are handled by flexbox */
    }
    
    .game-card,
    .section-card {
        padding: 16px 20px;
    }
    
    .game-icon,
    .section-icon {
        width: 48px;
        height: 48px;
    }
}

