:root {
    --bg-color: #202020;
    --panel-bg: #18181b;
    /* Zinc-900 */
    --panel-border: #27272a;
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --accent-color: #ffcb05;
    /* Pokemon Yellow */

    /* Card Variables */
    --card-width: 350px;
    --card-height: 490px;
    --card-radius: 16px;

    /* Dynamic Card Colors */
    --card-bg: #f0f0f0;
    --card-border: #ffd700;
    --type-color: #a8a878;
    --header-text: #000;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100%;
}

/* --- Editor Panel (Left) --- */
.editor-panel {
    width: 420px;
    background: var(--panel-bg);
    border-right: 1px solid var(--panel-border);
    padding: 2rem;
    overflow-y: auto;
    flex-shrink: 0;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    z-index: 20;
}

.panel-header h1 {
    color: var(--accent-color);
    font-family: 'Outfit', sans-serif;
    margin-bottom: 0.5rem;
}

.form-group {
    background: #27272a;
    /* Zinc-800 */
    border: 1px solid #3f3f46;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.form-group h3 {
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #a1a1aa;
    /* Zinc-400 */
    font-weight: 600;
    border-bottom: 1px solid #3f3f46;
    padding-bottom: 0.75rem;
}

.input-wrapper {
    margin-bottom: 1rem;
}

.input-wrapper label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    background: #18181b;
    border: 1px solid #3f3f46;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: #f4f4f5;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(255, 203, 5, 0.15);
    background: #09090b;
}

/* Custom File Upload */
.file-upload-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.custom-file-upload {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    background: #3f3f46;
    color: white;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s;
}

.custom-file-upload:hover {
    background: #52525b;
}

input[type="file"] {
    display: none;
}

.file-name {
    font-size: 0.85rem;
    color: #a1a1aa;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.color-pickers {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.color-pickers .input-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 0 0 2px #3f3f46;
    transition: transform 0.2s;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

input[type="color"]:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 2px var(--accent-color);
}

.row {
    display: flex;
    gap: 1rem;
}

.row .input-wrapper {
    flex: 1;
}

.hidden {
    display: none;
}

.mt-2 {
    margin-top: 0.5rem;
}

/* Tag Input Styles */
.tag-input-container {
    background: #18181b;
    border: 1px solid #3f3f46;
    border-radius: 8px;
    padding: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 48px;
    transition: border-color 0.2s;
}

.tag-input-container:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(255, 203, 5, 0.15);
    background: #09090b;
}

.tag-input-container input {
    flex: 1;
    border: none;
    padding: 0.25rem;
    min-width: 100px;
    background: transparent;
    box-shadow: none;
}

.tag-input-container input:focus {
    border: none;
    box-shadow: none;
}

.editor-tag {
    background: #3f3f46;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    border: 1px solid #52525b;
}

.editor-tag .remove-tag {
    cursor: pointer;
    color: #ef4444;
    font-weight: bold;
    font-size: 1.1rem;
    line-height: 1;
}

.actions {
    margin-top: 2rem;
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    background: var(--accent-color);
    color: #000;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 4px 6px -1px rgba(255, 203, 5, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(255, 203, 5, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

/* --- Preview Panel (Right) --- */
.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #121212;
    perspective: 1500px;
    overflow: hidden;
    position: relative;
}

.top-bar {
    position: absolute;
    top: 1rem;
    right: 2rem;
    z-index: 100;
}

.search-input {
    width: 250px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

.card-scene {
    width: var(--card-width);
    height: var(--card-height);
    position: relative;
}

.card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.1s ease-out;
}

.card-face {
    width: 100%;
    height: 100%;
    background: var(--card-bg);
    border: 12px solid var(--card-border);
    border-radius: var(--card-radius);
    position: relative;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    /* Subtle base texture */
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0IiBoZWlnaHQ9IjQiPgo8cmVjdCB3aWR0aD0iNCIgaGVpZ2h0PSI0IiBmaWxsPSIjZmZmIiBmaWxsLW9wYWNpdHk9IjAuMDUiLz4KPC9zdmc+');
}

/* --- Effects --- */
.card-grain {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 8;
    pointer-events: none;
    opacity: 0.4;
    mix-blend-mode: overlay;
    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.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

.holo-gradient {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    pointer-events: none;
    mix-blend-mode: color-dodge;
    opacity: 0.7;
    /* Bumped up */
    background: linear-gradient(115deg,
            transparent 20%,
            rgba(255, 0, 150, 0.6) 30%,
            rgba(0, 255, 255, 0.6) 45%,
            transparent 60%);
    background-size: 300% 300%;
    background-position: 50% 50%;
    transition: opacity 0.3s;
}

.holo-sparkle {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 11;
    pointer-events: none;
    mix-blend-mode: overlay;
    background-image:
        radial-gradient(white 1px, transparent 1px),
        radial-gradient(white 1px, transparent 1px);
    background-size: 30px 30px;
    background-position: 0 0, 15px 15px;
    opacity: 0.4;
}

/* --- Card Content Layout --- */
.card-content {
    position: relative;
    z-index: 5;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.75rem;
    color: #000;
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, sans-serif;
}

/* Header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
    height: 30px;
}

.pokemon-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--header-text);
}

.hp-group {
    display: flex;
    align-items: center;
    gap: 2px;
    color: #d00;
    font-weight: 800;
}

.hp-label {
    font-size: 0.6rem;
    margin-top: 4px;
}

.hp-value {
    font-size: 1.4rem;
}

.type-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-left: 4px;
    background-size: cover;
    background-position: center;
    /* Default fallback */
    background-color: #333;
}

/* Image Frame */
.image-frame {
    width: 100%;
    height: 180px;
    background: #fff;
    border: 3px solid #a0a080;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 0.4rem;
    position: relative;
    overflow: hidden;
}

.image-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Info Strip */
.info-strip {
    background: linear-gradient(90deg, #e0c068, #c0a048);
    font-size: 0.6rem;
    font-weight: bold;
    font-style: italic;
    text-align: center;
    padding: 2px 0;
    margin: 0 -0.5rem 0.5rem -0.5rem;
    width: calc(100% + 1rem);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Attacks Section */
.attacks-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: center;
}

.attack-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cost-icons {
    display: flex;
    gap: 2px;
    width: 45px;
    min-width: 45px;
    justify-content: center;
}

.energy {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: #333;
    /* Default, will be overridden by JS */
    box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.3), 1px 1px 2px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.attack-desc {
    font-size: 1.1rem;
    line-height: 1.1;
    color: #000;
    flex: 1;
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-left: 4px;
}

.attack-desc strong {
    white-space: nowrap;
}

.damage {
    font-size: 1.1rem;
    font-weight: 700;
    margin-left: auto;
}

/* Footer Stats */
.footer-stats {
    display: flex;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 0.25rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    min-height: 40px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 33%;
}

.stat-box .label {
    font-size: 0.5rem;
    text-transform: uppercase;
    margin-bottom: 2px;
    color: #555;
}

.language-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.55rem;
    font-weight: bold;
    line-height: 1.1;
}

.stat-box .icon {
    font-size: 1rem;
}

/* Flavor Text */
.flavor-text-box {
    border: 2px solid #a0a080;
    background: rgba(255, 255, 255, 0.5);
    padding: 0.25rem;
    font-size: 0.65rem;
    font-style: italic;
    margin-top: 0.25rem;
    min-height: 30px;
    display: flex;
    align-items: center;
}

/* Bottom Info */
.bottom-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.55rem;
    font-weight: bold;
    margin-top: 2px;
}

/* --- DM Status --- */
.dm-status {
    position: absolute;
    bottom: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 8px;
    border-top-left-radius: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.1);
}

.dm-status .icon {
    font-size: 1rem;
}

.dm-status.hidden {
    display: none;
}

/* --- Checkbox --- */
.checkbox-wrapper label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: #f4f4f5;
}

.checkbox-wrapper input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-color);
}

/* --- Buttons --- */
.actions {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
}

.btn-secondary {
    flex: 1;
    padding: 1rem;
    background: #3f3f46;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-secondary:hover {
    background: #52525b;
}

/* Mobile */
@media (max-width: 800px) {
    .app-container {
        flex-direction: column;
        overflow-y: auto;
    }

    .editor-panel {
        width: 100%;
        height: auto;
    }

    .preview-panel {
        padding: 2rem;
        min-height: 600px;
    }
}