/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    --neon-green: #39ff14;
    --neon-orange: #ff9933;
    --neon-blue: #00f3ff;
    --text-main: #eee;
    --text-muted: #888;
    --panel-bg: rgba(20, 20, 20, 0.9);
    --border-light: rgba(255, 255, 255, 0.2);
    
    /* Font Stack */
    --font-retro: 'VT323', monospace;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    
    --radius: 8px;
}

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

body {
    background-color: #050505;
    font-family: var(--font-body);
    color: var(--text-main);
    overflow-x: hidden;
    /* Prevent scroll bounce on mac */
    overscroll-behavior: none;
}

/* =========================================
   2. LAYERS & BACKGROUNDS
   ========================================= */
#bg-layer {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: -3;
    background-size: cover;
    background-position: center;
    transition: filter 0.5s;
}

#vignette-layer {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: -2;
    background: radial-gradient(circle at center, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.9) 100%);
    pointer-events: none;
}

.scanlines {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 100;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,0) 50%, rgba(0,0,0,0.1) 50%, rgba(0,0,0,0.1));
    background-size: 100% 4px;
}

.screen-transition {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #000;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease-in-out;
}
.screen-transition.active { opacity: 1; pointer-events: all; }

/* =========================================
   3. LAYOUT CONTAINER
   ========================================= */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.hidden { display: none !important; }

/* =========================================
   4. HERO SECTION
   ========================================= */
.hero {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2.5rem;
    text-align: center;
    animation: fadeIn 0.8s ease-out;
}

h1 {
    font-family: var(--font-retro);
    font-size: 4rem;
    line-height: 1;
    color: var(--neon-orange);
    text-shadow: 4px 4px 0 #000;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.blink {
    font-family: var(--font-retro);
    color: var(--neon-green);
    font-size: 1.5rem;
    letter-spacing: 2px;
    text-shadow: 2px 2px 0 #000;
    animation: blinker 1s step-end infinite;
}
@keyframes blinker { 50% { opacity: 0; } }

.pixel-box {
    background: var(--panel-bg);
    border: 1px solid var(--border-light);
    backdrop-filter: blur(8px);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--neon-blue);
    text-align: left;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(0,0,0,0.5);
    border: 1px solid #333;
    border-radius: 4px;
    padding: 0.5rem 0.8rem;
    transition: border-color 0.2s;
}
.input-wrapper:focus-within { border-color: var(--neon-orange); }

.currency {
    font-family: var(--font-retro);
    font-size: 2rem;
    color: #666;
    margin-right: 0.5rem;
    margin-top: 4px; /* Optical alignment */
}

input {
    background: transparent;
    border: none;
    color: #fff;
    font-family: var(--font-retro);
    font-size: 2.5rem;
    width: 100%;
    outline: none;
    line-height: 1;
}

/* THE BUTTON */
#calculate-btn {
    background: var(--neon-orange);
    color: #000;
    font-family: var(--font-retro);
    font-size: 1.8rem;
    border: none;
    border-radius: 4px;
    padding: 0.8rem;
    cursor: pointer;
    text-transform: uppercase;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 0 #b36b22;
    transition: transform 0.1s, box-shadow 0.1s;
    margin-top: 0.5rem;
}
#calculate-btn:hover { background: #ffaa55; }
#calculate-btn:active { transform: translateY(4px); box-shadow: none; }

.subtext-container {
    margin-top: 1rem;
}
.subtext {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.6);
    background: rgba(0,0,0,0.6);
    padding: 4px 8px;
    border-radius: 4px;
}

/* =========================================
   5. RESULTS SECTION
   ========================================= */
.results {
    width: 100%;
    margin-top: 2rem;
    padding-bottom: 2rem;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.pixel-btn-small {
    background: transparent;
    border: 1px solid var(--border-light);
    color: #aaa;
    font-family: var(--font-retro);
    font-size: 1.2rem;
    padding: 0.3rem 0.8rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}
.pixel-btn-small:hover { border-color: #fff; color: #fff; background: rgba(255,255,255,0.1); }

.character-sheet {
    background: var(--panel-bg);
    border: 1px solid var(--border-light);
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed rgba(255,255,255,0.2);
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.level-badge span {
    font-family: var(--font-retro);
    font-size: 3rem;
    color: var(--neon-green);
    line-height: 0.8;
    display: block;
}
.level-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    margin-bottom: 5px;
}

.total-tax-display { text-align: right; }
.total-val {
    font-family: var(--font-retro);
    font-size: 3rem;
    color: var(--neon-orange);
    line-height: 0.8;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.stat-row { margin-bottom: 0.5rem; }

.stat-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
    color: #ddd;
}
.stat-name { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.stat-num { font-family: var(--font-retro); font-size: 1.2rem; color: #aaa; }

.stat-bar-bg {
    height: 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 5px;
    overflow: hidden;
}
.stat-bar-fill {
    height: 100%;
    background: var(--neon-green);
    border-radius: 5px;
    width: 0%;
    transition: width 1s ease-out;
}

/* Achievements */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 10px;
}
.ach-card {
    background: rgba(255,255,255,0.05);
    padding: 12px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
    transition: transform 0.2s;
}
.ach-card:hover { transform: translateY(-2px); border-color: var(--neon-orange); }
.ach-header { color: var(--neon-orange); font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.quote-text { display: block; font-size: 0.85rem; color: #999; font-style: italic; line-height: 1.4; }

/* =========================================
   6. CUSTOM DROPDOWNS
   ========================================= */
.top-nav {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    gap: 1rem;
    z-index: 50;
}

.custom-dropdown {
    position: relative;
    font-size: 0.9rem;
    font-family: var(--font-body);
}

.dd-trigger {
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid #444;
    color: #eee;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    backdrop-filter: blur(4px);
    transition: border-color 0.2s;
}
.dd-trigger:hover { border-color: var(--neon-blue); }

.dd-menu {
    position: absolute;
    top: 110%;
    right: 0;
    width: max-content;
    min-width: 140px;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-5px);
    transition: all 0.2s;
    overflow: hidden;
    z-index: 60;
}
.custom-dropdown.active .dd-menu { opacity: 1; pointer-events: all; transform: translateY(0); }

.dd-item {
    padding: 0.8rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #2a2a2a;
    color: #aaa;
    transition: background 0.1s;
}
.dd-item:last-child { border-bottom: none; }
.dd-item:hover { background: #333; color: #fff; }
.dd-item.selected { color: var(--neon-green); font-weight: bold; }

/* =========================================
   7. RESPONSIVE
   ========================================= */
@media (max-width: 600px) {
    h1 { font-size: 3rem; }
    .hero { gap: 1.5rem; }
    .pixel-box { padding: 1.5rem; }
    input { font-size: 2rem; }
    
    .sheet-header { flex-direction: column; text-align: center; }
    .total-tax-display { text-align: center; margin-top: 1rem; }
    
    .stats-grid { grid-template-columns: 1fr; }
    
    .top-nav { top: 1rem; right: 1rem; }
    .dd-trigger { padding: 0.4rem 0.6rem; font-size: 0.8rem; }
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }