:root {
    /* Neutral Color Palette */
    --bg-color: #f6f7f9;
    --bg-gradient: linear-gradient(180deg, #ffffff 0%, #f3f4f6 100%);
    --card-bg: #ffffff;
    --card-bg-gradient: linear-gradient(135deg, #ffffff 0%, #f7f8fa 100%);
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --accent: #2563eb; /* blue-600 */
    --accent-glow: rgba(37, 99, 235, 0.3);
    --danger: #dc2626; /* red-600 */
    --success: #16a34a; /* green-600 */
    --border: #e5e7eb;
    --btn-text: #ffffff;
    --ps1-gray: #9ca3af; /* legacy variable retained */
    --ps1-blue: #2563eb; /* use accent */
}

[data-theme="light"] {
    /* Light theme same as default to keep neutral */
    --bg-color: #f6f7f9;
    --bg-gradient: linear-gradient(180deg, #ffffff 0%, #f3f4f6 100%);
    --card-bg: #ffffff;
    --card-bg-gradient: linear-gradient(135deg, #ffffff 0%, #f7f8fa 100%);
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --accent: #2563eb;
    --accent-glow: rgba(37, 99, 235, 0.3);
    --danger: #dc2626;
    --success: #16a34a;
    --border: #e5e7eb;
    --btn-text: #ffffff;
    --ps1-gray: #9ca3af;
    --ps1-blue: #2563eb;
}

/* Remove CRT overlay for a clean template */
body::before {
    content: none;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

/* Headings: use Inter for a clean, neutral style */
h1 {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    color: var(--text-main);
    font-weight: 600;
    letter-spacing: 0;
    font-size: 1.25em;
    text-shadow: none;
}

.subtitle {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 0.9em;
    opacity: 0.7;
    margin: 6px 0 0 0;
    letter-spacing: 0;
}

/* Clean header styles (neutral) */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1400px;
    margin-bottom: 25px;
    padding: 20px 25px;
    background: var(--card-bg-gradient);
    border-radius: 4px;
    border: 3px solid var(--border);
    box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.1),
    inset -2px -2px 0 rgba(0, 0, 0, 0.3),
    0 4px 20px rgba(0, 0, 0, 0.4);
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Retro 3D Bevel Button Style */
.theme-btn {
    padding: 10px 14px;
    border-radius: 6px;
    background: #111827;
    border: 1px solid #111827;
    color: #ffffff;
    cursor: pointer;
    font-size: 1.1em;
    transition: background 0.15s ease, transform 0.05s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.theme-btn:hover {
    background: #1f2937;
}

.theme-btn:active {
    transform: translateY(1px);
}

/* PS1 Style Buttons */
button,
.file-btn {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85rem;
    background: #ffffff;
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

button:hover,
.file-btn:hover {
    background: #f9fafb;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

button:active {
    transform: translateY(1px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
}

.btn-outline:hover {
    background: var(--accent);
    color: var(--btn-text);
}

.btn-danger {
    color: #ffffff;
    border-color: #dc2626;
    background: #dc2626;
}

.btn-danger:hover {
    background: #ef4444;
}

/* Header control buttons with uniform styling */
.sm-btn {
    font-family: inherit;
    font-size: 0.8rem;
    padding: 8px 12px;
    border-radius: 4px;
    border: 3px solid;
    border-color: #5a6a8a #1a2a4a #1a2a4a #5a6a8a;
    background: linear-gradient(180deg, var(--ps1-blue) 0%, #0f2540 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4);
    transition: all 0.1s;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sm-btn:hover {
    background: linear-gradient(180deg, #2a4a70 0%, #1a3a5a 100%);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4), 0 0 10px var(--accent-glow);
}

.sm-btn:active {
    border-color: #1a2a4a #5a6a8a #5a6a8a #1a2a4a;
    box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.5);
    transform: translate(1px, 1px);
}

/* Red danger button for Format */
.sm-btn.btn-danger {
    background: linear-gradient(180deg, #8a2020 0%, #5a1515 100%);
    border-color: #aa4040 #4a1010 #4a1010 #aa4040;
    color: #fff;
}

.sm-btn.btn-danger:hover {
    background: linear-gradient(180deg, #aa3030 0%, #7a2020 100%);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4), 0 0 15px rgba(255, 80, 80, 0.6);
}

/* Light theme button overrides */
[data-theme="light"] .sm-btn {
    background: linear-gradient(180deg, #4a6a9a 0%, #2a4a6a 100%);
    border-color: #6a8aba #3a5a8a #3a5a8a #6a8aba;
}

[data-theme="light"] .sm-btn:hover {
    background: linear-gradient(180deg, #5a7aba 0%, #3a5a8a 100%);
}

[data-theme="light"] .btn-danger {
    background: linear-gradient(180deg, #aa4444 0%, #883333 100%);
    border-color: #cc6666 #662222 #662222 #cc6666;
    color: #fff;
}

[data-theme="light"] .btn-outline {
    background: rgba(0, 85, 170, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

input[type="file"] {
    display: none;
}

/* Dual-Pane Layout */
.workspace {
    display: flex;
    gap: 24px;
    width: 100%;
    max-width: 1200px;
    flex-wrap: wrap;
    justify-content: center;
}

.card-pane {
    flex: 1;
    min-width: 420px;
    background: var(--card-bg-gradient);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

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

.pane-title {
    font-size: 0.9em;
    font-weight: 600;
    color: var(--accent);
}

.pane-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.file-status {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8em;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding: 8px 12px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid var(--border);
}

/* Block Counter */
.block-counter {
    font-size: 0.75em;
    color: var(--success);
    text-align: right;
    margin-bottom: 8px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    width: 100%;
}

/* Slot Cards with PS1 Style */
.slot-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.slot-card:hover {
    transform: translateY(-1px);
    border-color: var(--accent);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.slot-card.empty {
    opacity: 0.6;
    border-style: dashed;
    background: #f3f4f6;
}

/* Pulsing Selection Effect */
.slot-card.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

/* Icon Wobble Animation */
.icon-canvas {
    width: 48px;
    height: 48px;
    image-rendering: pixelated;
}

/* Action Buttons */
.psx-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: transform 0.1s, filter 0.1s;
    filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.5));
}

.psx-btn img {
    width: 100%;
    height: 100%;
    display: block;
}

.psx-btn:hover {
    transform: scale(1.2);
    filter: brightness(1.3) drop-shadow(0 0 8px var(--accent-glow));
}

.psx-btn:active {
    transform: scale(0.9);
}

.slot-info {
    flex: 1;
    min-width: 0;
}

.slot-id {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 0.75em;
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 4px;
    text-shadow: none;
}

.game-title {
    font-size: 0.9em;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65em;
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 2px;
    display: inline-block;
}

/* Drop Overlay */
.drop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 22, 40, 0.9);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px dashed var(--accent);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.drop-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.drop-msg {
    font-family: 'Press Start 2P', cursive;
    font-size: 1em;
    color: var(--accent);
    background: var(--card-bg);
    padding: 30px 50px;
    border-radius: 4px;
    border: 3px solid var(--accent);
    box-shadow: 0 0 30px var(--accent-glow);
    text-shadow: 0 0 10px var(--accent-glow);
    animation: pulse-glow 1.5s ease-in-out infinite;
}

/* Small action buttons for slots */
.slot-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.action-btn {
    width: 28px;
    height: 28px;
    padding: 4px;
    border: 2px solid var(--border);
    background: linear-gradient(180deg, #3a4a6a 0%, #2a3a5a 100%);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    color: var(--text-main);
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: linear-gradient(180deg, var(--accent) 0%, #2a5acc 100%);
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
    transform: scale(1.1);
}

/* Recover button for empty slots */
.recover-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.4em;
    padding: 6px 10px;
    background: transparent;
    border: 2px dashed var(--success);
    color: var(--success);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.recover-btn:hover {
    background: var(--success);
    color: #000;
    border-style: solid;
    box-shadow: 0 0 10px rgba(46, 213, 115, 0.5);
}

/* Import input */
.import-input {
    display: none;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--card-bg-gradient);
    width: 600px;
    max-width: 90%;
    border: 3px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    animation: modal-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modal-pop {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 3px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}

.modal-header h2 {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 1em;
    margin: 0;
    color: var(--accent);
    text-shadow: none;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5em;
    cursor: pointer;
    line-height: 1;
    transition: color 0.1s;
}

.close-btn:hover {
    color: var(--danger);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.help-section h3 {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 0.95em;
    color: var(--text-main);
    margin: 0 0 10px 0;
    border-bottom: 2px solid var(--border);
    padding-bottom: 5px;
    display: inline-block;
}

.help-section p, .help-section ul {
    font-size: 0.9em;
    line-height: 1.5;
    color: var(--text-main);
    margin: 0;
}

.help-section ul {
    padding-left: 20px;
    margin-top: 5px;
}

.help-section li {
    margin-bottom: 5px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 2px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7em;
    color: var(--text-muted);
}
