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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    padding: 20px;
}

header {
    background: #2c3e50;
    color: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

header h1 {
    margin-bottom: 10px;
}

#file-input-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#file-input {
    margin-bottom: 10px;
    padding: 10px;
    border: 2px dashed #3498db;
    border-radius: 4px;
    width: 100%;
    cursor: pointer;
}

#file-info {
    padding: 10px;
    background: #ecf0f1;
    border-radius: 4px;
    margin-top: 10px;
}

#flag-config-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#batch-analysis-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#batch-analysis-section h2 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.run-all-btn {
    width: 100%;
    padding: 15px 30px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
}

.run-all-btn:hover:not(:disabled) {
    background: #c0392b;
}

.run-all-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.analysis-progress {
    margin-top: 20px;
    padding: 15px;
    background: #ecf0f1;
    border-radius: 4px;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #bdc3c7;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2980b9);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 15px;
}

#progress-text {
    font-size: 14px;
    color: #2c3e50;
    text-align: center;
}

.all-results-section {
    margin-top: 20px;
    padding: 20px;
    background: #ecf0f1;
    border-radius: 4px;
}

.all-results-section h3 {
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 18px;
}

.all-results-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.result-category {
    background: white;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.category-header {
    padding: 15px 20px;
    background: #34495e;
    color: white;
    margin: 0;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    transition: background 0.3s;
}

.category-header:hover {
    background: #2c3e50;
}

.toggle-icon {
    display: inline-block;
    width: 20px;
    margin-right: 10px;
    font-size: 12px;
}

.result-count {
    margin-left: auto;
    font-size: 14px;
    opacity: 0.8;
}

.category-results {
    padding: 15px;
    max-height: 600px;
    overflow-y: auto;
}

.result-item {
    margin-bottom: 15px;
}

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

.result-content {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    border-left: 3px solid #3498db;
}

.result-separator {
    border: none;
    border-top: 1px solid #bdc3c7;
    margin: 15px 0;
}

.result-content h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #2c3e50;
}

.result-content pre {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 15px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 12px;
    line-height: 1.4;
    margin: 10px 0;
}

.result-content img,
.result-content canvas {
    max-width: 100%;
    border: 1px solid #bdc3c7;
    margin: 10px 0;
    border-radius: 4px;
}

.result-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
}

.result-content table th,
.result-content table td {
    padding: 8px;
    text-align: left;
    border: 1px solid #bdc3c7;
}

.result-content table th {
    background: #34495e;
    color: white;
}

.flag-config {
    margin-bottom: 20px;
}

.flag-input-group {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #ecf0f1;
}

.flag-input-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.flag-config label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #2c3e50;
}

.flag-config input[type="text"] {
    width: 100%;
    padding: 10px;
    border: 2px solid #bdc3c7;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    margin-bottom: 8px;
}

.flag-config input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
}

.flag-config button {
    padding: 10px 20px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.flag-config button:hover {
    background: #229954;
}

.flag-info {
    margin-top: 8px;
    color: #7f8c8d;
}

.detected-flags {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #ecf0f1;
}

.detected-flags h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.flags-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.flag-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #ecf0f1;
    border-radius: 4px;
    border-left: 4px solid #27ae60;
}

.flag-text {
    flex: 1;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: #2c3e50;
    word-break: break-all;
    margin-right: 10px;
}

.copy-btn {
    padding: 6px 12px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.3s;
    white-space: nowrap;
}

.copy-btn:hover {
    background: #2980b9;
}

.no-flags {
    color: #7f8c8d;
    font-style: italic;
    padding: 20px;
    text-align: center;
}

.flag-highlight {
    background: #f39c12;
    color: #2c3e50;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

#tabs {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}

.tab-buttons {
    display: flex;
    flex-wrap: wrap;
    background: #34495e;
    border-bottom: 2px solid #2c3e50;
}

.tab-btn {
    flex: 1;
    min-width: 120px;
    padding: 15px 20px;
    background: #34495e;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.tab-btn:hover {
    background: #2c3e50;
}

.tab-btn.active {
    background: #3498db;
}

.tab-content {
    display: none;
    padding: 20px;
}

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

.tab-content h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.tool-section {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.tool-section button {
    padding: 12px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.tool-section button:hover {
    background: #2980b9;
}

.tool-section button:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.results {
    background: #ecf0f1;
    padding: 15px;
    border-radius: 4px;
    margin-top: 20px;
    max-height: 600px;
    overflow-y: auto;
}

.results h4 {
    margin-top: 15px;
    margin-bottom: 10px;
    color: #2c3e50;
}

.results pre {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 15px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 12px;
    line-height: 1.4;
}

.results img {
    max-width: 100%;
    border: 1px solid #bdc3c7;
    margin: 10px 0;
    border-radius: 4px;
}

.results canvas {
    max-width: 100%;
    border: 1px solid #bdc3c7;
    margin: 10px 0;
    border-radius: 4px;
}

.results table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
}

.results table th,
.results table td {
    padding: 8px;
    text-align: left;
    border: 1px solid #bdc3c7;
}

.results table th {
    background: #34495e;
    color: white;
}

.results .error {
    color: #e74c3c;
    padding: 10px;
    background: #ffe6e6;
    border-radius: 4px;
    margin: 10px 0;
}

.results .success {
    color: #27ae60;
    padding: 10px;
    background: #e6ffe6;
    border-radius: 4px;
    margin: 10px 0;
}

.results .warning {
    color: #f39c12;
    padding: 10px;
    background: #fff3cd;
    border-radius: 4px;
    margin: 10px 0;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin: 10px 0;
}

.image-grid img {
    width: 100%;
    height: auto;
}

.rectangle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin: 10px 0;
}

.rectangle-item {
    text-align: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
}

.rectangle-item h5 {
    margin-bottom: 10px;
    font-size: 12px;
    color: #2c3e50;
}

.rectangle-item img {
    max-width: 100%;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
}

.base91-item {
    padding: 10px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #3498db;
}

.palette-display {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 5px;
    margin: 10px 0;
}

.palette-item {
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #bdc3c7;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.palette-info {
    background: rgba(255, 255, 255, 0.8);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-family: 'Courier New', monospace;
}

.diff-image-item {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 15px;
}

.diff-image-item h5 {
    margin-bottom: 10px;
    color: #2c3e50;
    font-size: 14px;
}

.diff-image-item img {
    max-width: 100%;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
}

.gif-frame-display {
    margin: 15px 0;
}

.gif-frame-display img {
    max-width: 100%;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
}

.hex-view {
    font-family: 'Courier New', monospace;
    font-size: 11px;
}

.highlight {
    background: yellow;
    color: black;
}

@media (max-width: 768px) {
    .tool-section {
        grid-template-columns: 1fr;
    }
    
    .tab-buttons {
        flex-direction: column;
    }
    
    .tab-btn {
        width: 100%;
    }
}

