:root {
    --bg:        #0a0a12;
    --bg2:       #111120;
    --panel:     #14142a;
    --border:    #2a2a5a;
    --gold:      #f0c040;
    --gold2:     #c8922a;
    --cyan:      #30d8f0;
    --green:     #40e890;
    --red:       #f04060;
    --purple:    #9060f0;
    --text:      #dde0f8;
    --dim:       #7070a0;
    --shadow:    0 0 20px #0006;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'VT323', monospace;
    font-size: 24px;
    min-height: 100vh;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 2px, #ffffff04 2px, #ffffff04 4px),
        radial-gradient(ellipse at 20% 0%, #1a0a3a 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, #0a1a2a 0%, transparent 60%);
}

/* SCANLINE overlay */
body::after {
    content: '';
    position: fixed; inset: 0;
    background: repeating-linear-gradient(
        transparent 0px, transparent 3px, #00000018 3px, #00000018 4px
    );
    pointer-events: none; z-index: 9999;
}

header {
    text-align: center;
    padding: 28px 20px 20px;
    border-bottom: 2px solid var(--border);
    background: linear-gradient(180deg, #1a1035 0%, transparent 100%);
    position: relative;
}
header::before {
    content: '🐉';
    font-size: 52px;
    display: block;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 15px #9060f0);
    animation: dragon-float 4s ease-in-out infinite;
}

@keyframes dragon-float {
    0%, 100% {
        transform: translate(0, 0) rotate(5deg);
    }
    25% {
        transform: translate(10px, -8px) rotate(-2deg);
    }
    50% {
        transform: translate(0, -12px) rotate(-5deg);
    }
    75% {
        transform: translate(-10px, -8px) rotate(2deg);
    }
}

h1 {
    font-family: 'Press Start 2P', monospace;
    font-size: 20px;
    color: var(--gold);
    text-shadow: 0 0 20px var(--gold2), 3px 3px 0 #4a2800;
    letter-spacing: 2px;
    line-height: 1.6;
}
.subtitle {
    color: var(--cyan);
    font-size: 22px;
    margin-top: 8px;
    opacity: 0.8;
}

/* ==================== TABS ==================== */
.tabs {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 10px;
}
.tab-btn {
    background: var(--panel);
    border: 2px solid var(--border);
    color: var(--dim);
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    padding: 18px 26px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 8px 8px 0 0;
    border-bottom: none;
}
.tab-btn:hover { background: #302060; color: var(--gold); }
.tab-btn.active {
    background: linear-gradient(180deg, #5040c0, #2a2080);
    color: #fff;
    border-color: var(--cyan);
    box-shadow: 0 -4px 15px #5040c040, 0 0 10px #30d8f040;
}
.tab-content { display: none; }
.tab-content.active { display: grid; animation: slide-in-fade 0.4s ease forwards; }
/* ============================================== */

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.panel {
    background: var(--panel);
    border: 2px solid var(--border);
    border-radius: 4px;
    padding: 20px;
    box-shadow: var(--shadow), inset 0 1px 0 #ffffff08;
    position: relative;
}
.panel::before {
    content: attr(data-label);
    position: absolute;
    top: -15px; left: 16px;
    background: var(--panel);
    padding: 2px 10px;
    font-family: 'Press Start 2P', monospace;
    font-size: 11px;
    color: var(--gold);
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.panel:hover {
    border-color: var(--cyan);
    box-shadow: var(--shadow), 0 0 15px #30d8f020;
}

.full-width { grid-column: 1 / -1; }

label {
    display: block;
    color: var(--gold);
    font-size: 18px;
    margin-bottom: 6px;
    margin-top: 18px;
}
label:first-child { margin-top: 0; }

select, input[type=number], input[type=text] {
    width: 100%;
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: 'VT323', monospace;
    font-size: 24px;
    padding: 8px 14px;
    border-radius: 4px;
    outline: none;
    transition: border-color .2s;
}
select:focus, input:focus { border-color: var(--cyan); }

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-top: 12px;
}
.stat-box label { font-size: 16px; color: var(--cyan); margin-top: 0; }

.breed-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Adjusted stats display */
.adj-display {
    margin-top: 14px;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    display: none;
}
.adj-display.visible { display: block; }
.adj-display h4 { font-family:'Press Start 2P',monospace; font-size:11px; color:var(--purple); margin-bottom:10px; }
.adj-row {
    display: flex; justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid #ffffff08;
    font-size: 22px;
}
.adj-name { color: var(--dim); }
.adj-val  { color: var(--green); }
.adj-rank { color: var(--gold); font-size: 16px; }

/* Button */
.btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    padding: 18px 36px;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    letter-spacing: 2px;
    transition: all .2s;
    display: block;
    width: 100%;
    margin-top: 16px;
}
.btn-primary {
    background: linear-gradient(180deg, #5040c0, #2a2080);
    color: #fff;
    box-shadow: 0 4px 0 #1a1050, 0 0 20px #5040c040;
    text-shadow: 1px 1px 0 #1a1050;
}
.btn-primary:hover { 
    transform: translateY(-2px) scale(1.02); 
    box-shadow: 0 6px 0 #1a1050, 0 0 40px #9060f080; 
    text-shadow: 1px 1px 0 #1a1050, 0 0 10px #ffffff;
}
.btn-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #1a1050; }

/* Results area */
#results { display: none; }
#results.visible { display: block; }

.dadge-box {
    background: linear-gradient(135deg, #1a1540, #0a0a20);
    border: 2px solid var(--gold);
    border-radius: 6px;
    padding: 20px 24px;
    margin-bottom: 24px;
    display: flex;
    gap: 20px;
    align-items: center;
}
.dadge-face {
    font-size: 56px;
    flex-shrink: 0;
    animation: dragon-float 3.5s ease-in-out infinite reverse;
}
.dadge-text { font-size: 24px; color: var(--gold); line-height: 1.5; }
.dadge-name { font-family:'Press Start 2P',monospace; font-size:11px; color:var(--gold2); margin-bottom:8px; }

/* Comparison table */
.compare-table {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}
.parent-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: 4px;
}
.parent-card h4 { font-family:'Press Start 2P',monospace; font-size:11px; color:var(--cyan); margin-bottom:12px; }
.stat-line { display:flex; justify-content:space-between; padding:4px 0; font-size:22px; }
.stat-line .sname { color:var(--dim); }
.stat-line .sval  { color:var(--text); }
.stat-line .sadj  { color:var(--green); }
.order-display { margin-top:10px; padding:8px; background:var(--bg); border:1px solid var(--border); font-size:18px; }
.order-label { color:var(--dim); font-size:16px; }
.order-val { color:var(--purple); letter-spacing:4px; }

/* Children table */
.children-header {
    font-family:'Press Start 2P',monospace;
    font-size:13px;
    color:var(--gold);
    margin-bottom:16px;
    padding-bottom:12px;
    border-bottom:2px solid var(--border);
}

.child-row {
    display: grid;
    grid-template-columns: 2fr 1.2fr 1fr 1fr 60px;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    transition: background .15s;
    font-size: 22px;
}
.child-row:hover { background: #ffffff08; }
.child-row.best  { background: #f0c04010; border-left:4px solid var(--gold); }
.child-row.good  { background: #40e89008; border-left:4px solid var(--green); }
.child-row.bad   { border-left:4px solid var(--red); opacity:.7; }

.child-name { color: var(--text); }
.child-sub  { color: var(--dim); font-size:18px; }
.child-order { color: var(--purple); font-size:18px; letter-spacing:2px; }
.child-matches {
    text-align:center;
    font-family:'Press Start 2P',monospace;
    font-size:13px;
}
.match-stars { color:var(--gold); font-size:20px; }

.col-header {
    display: grid;
    grid-template-columns: 2fr 1.2fr 1fr 1fr 60px;
    gap: 12px;
    padding: 10px 16px;
    font-family:'Press Start 2P',monospace;
    font-size:10px;
    color: var(--dim);
    border-bottom: 2px solid var(--border);
    margin-bottom: 6px;
}

/* Save loader */
.save-section {
    background: var(--bg2);
    border: 1px solid var(--border);
    padding: 16px;
    margin-bottom: 20px;
    border-radius: 4px;
}
.save-section h4 { font-family:'Press Start 2P',monospace; font-size:11px; color:var(--cyan); margin-bottom:12px; }
.save-note { color:var(--dim); font-size:18px; line-height:1.5; }

/* Loading spinner */
.spinner {
    display: none;
    text-align: center;
    padding: 30px;
    color: var(--cyan);
    font-family:'Press Start 2P',monospace;
    font-size:12px;
    animation: blink 1s infinite;
}
.spinner.active { display: block; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* Responsive */
@media(max-width:720px) {
    main { grid-template-columns:1fr; }
    .full-width { grid-column:1; }
    .child-row { grid-template-columns:1fr 1fr; }
    .col-header { display:none; }
}

/* Animations */
@keyframes slide-in-fade {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
.stagger-anim {
    opacity: 0;
    animation: slide-in-fade 0.5s ease-out forwards;
}

main > .panel {
    opacity: 0;
    animation: slide-in-fade 0.5s ease-out forwards;
}
main > .panel:nth-child(2) { animation-delay: 0.15s; }
main > .full-width { opacity: 0; animation: slide-in-fade 0.5s ease-out forwards; animation-delay: 0.3s; }

@keyframes glow-in {
    from { opacity:0; transform:translateY(10px); }
    to   { opacity:1; transform:translateY(0); }
}
.anim { animation: glow-in .4s ease forwards; }
