:root {
    --bg-color: #121212;
    --bezel-color: #4a4a50;
    --bezel-highlight: #6e6e75;
    --bezel-shadow: #2a2a30;
    --screen-bg: #0a0a0c;
    
    /* --- NEW COLOR PALETTE --- */
    --seafoam: #4ff0aa; 
    --seafoam-dim: #205c43;
    
    --yellow: #e8b923;     /* Mustard Yellow */
    --purple: #c084fc;     /* Soft Purple */
    --pink: #ff4081;       /* Neon Pink */
    --blue: #40c4ff;       /* Light Blue */
    --coral: #E07B6B;      /* Coral */
    
    --font-pixel: 'Press Start 2P', cursive, monospace;
}

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

body {
    background-color: var(--bg-color);
    font-family: var(--font-pixel);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh; 
    padding: 10px; 
    overflow: hidden; 
    -webkit-tap-highlight-color: transparent;
}

/* --- THE HARDWARE BEZEL --- */
.terminal-bezel {
    background-color: var(--bezel-color);
    border-top: 6px solid var(--bezel-highlight);
    border-left: 6px solid var(--bezel-highlight);
    border-right: 8px solid var(--bezel-shadow);
    border-bottom: 8px solid var(--bezel-shadow);
    border-radius: 20px;
    padding: 15px; 
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
    max-width: 1100px; 
    width: 100%;
    display: flex;
    flex-direction: column;
    max-height: 95vh;
}

/* --- HARDWARE DETAILS --- */
.bezel-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 0 5px;
    flex-shrink: 0; 
}

.lights-container { display: flex; gap: 8px; }
.led {
    width: 12px; height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.5);
}
.led.red { background: #ff5f56; box-shadow: 0 0 5px #ff5f56; }
.led.yellow { background: #ffbd2e; box-shadow: 0 0 5px #ffbd2e; }
.led.green { background: #27c93f; box-shadow: 0 0 5px #27c93f; }

.vent-grill {
    display: flex; gap: 4px;
    background: #333;
    padding: 4px;
    border-radius: 4px;
    box-shadow: inset 1px 1px 3px black;
}
.vent-grill span {
    width: 4px; height: 12px;
    background-color: #555;
    border-right: 1px solid #222;
}

.power-indicator {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.5rem; color: #888;
}
.led.small { width: 6px; height: 6px; }

/* --- THE SCREEN --- */
.terminal-screen {
    background-color: var(--screen-bg);
    border: 8px solid #222;
    border-radius: 8px;
    padding: 30px;
    position: relative;
    overflow-y: auto; 
    overflow-x: hidden;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.8);
    flex-grow: 1; 
    display: flex;
    flex-direction: column;
}

.scanline-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        rgba(0, 0, 0, 0.2) 2px,
        rgba(0, 0, 0, 0.2) 4px
    );
    z-index: 20;
    opacity: 0.6;
}

/* --- TYPOGRAPHY --- */
.screen-header {
    text-align: left;
    margin-bottom: 40px;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

.title-3d {
    color: var(--seafoam);
    font-size: 5rem;
    line-height: 1.1;
    margin-bottom: 25px;
    text-shadow: 
        5px 5px 0px var(--seafoam-dim),
        10px 10px 0px #0e2a1e,
        0 0 20px rgba(79, 240, 170, 0.4);
    transform: perspective(500px) rotateX(5deg);
}

.subtitle {
    color: var(--seafoam);
    font-size: 0.9rem;
    line-height: 1.6;
    max-width: 650px;
    text-shadow: 2px 2px 0px var(--seafoam-dim);
}

/* --- TOOLS GRID --- */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    position: relative;
    z-index: 2;
    padding-bottom: 20px; 
}

/* --- CARD STYLES & THEMING --- */

.tool-card {
    --theme-color: #fff; /* Fallback */
    
    display: flex; /* Changed to flex column for easier mobile stacking */
    flex-direction: column;
    text-decoration: none;
    background: #1a1a1a;
    border: 4px solid #444;
    padding: 8px;
    box-shadow: 5px 5px 0px #000;
    position: relative;
    overflow: hidden; 
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    height: 100%; /* Ensures uniform height */
}

/* --- THEME DEFINITIONS --- */
.tool-card.theme-yellow { --theme-color: var(--yellow); }
.tool-card.theme-purple { --theme-color: var(--purple); }
.tool-card.theme-pink   { --theme-color: var(--pink); }
.tool-card.theme-blue   { --theme-color: var(--blue); }
.tool-card.theme-coral  { --theme-color: var(--coral); }

.card-interior {
    background-color: #000;
    border: 2px solid #333;
    aspect-ratio: 1 / 1;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0; /* Margin handled by flex/grid now */
    box-shadow: inset 0 0 15px rgba(0,0,0,0.8);
    position: relative;
    z-index: 1;
}

.pixel-icon { 
    width: 70%; 
    height: 70%; 
    object-fit: contain;
    filter: grayscale(20%); 
    transition: 0.3s ease; 
}

.status-bar-container {
    height: 8px; background: #222; border: 1px solid #444;
    margin-top: auto; /* Pushes to bottom */
    position: relative;
    z-index: 5;
}
.status-bar { 
    height: 100%; width: 50%; 
    background-color: var(--theme-color);
    box-shadow: 0 0 5px var(--theme-color);
}


/* --- DESKTOP HOVER OVERLAY --- */
/* On desktop, this slides up over the icon */
.card-overlay {
    position: absolute;
    bottom: 20px; /* Sits above status bar */
    left: 0;
    width: 100%;
    height: calc(100% - 28px); /* Height minus status bar area */
    background: rgba(0, 0, 0, 0.95);
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    
    /* The Border that will Pulse */
    border-top: 2px solid var(--theme-color);
    border-bottom: 2px solid var(--theme-color); /* Added bottom border for symmetry */
    
    transform: translateY(105%); /* Hidden by default */
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1); 
    z-index: 10;
}

.tool-title {
    color: var(--theme-color);
    font-size: 0.8rem;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 2px 2px 0px #000;
}

.tool-desc {
    color: #ccc;
    font-size: 0.5rem;
    line-height: 1.5;
}

/* --- ANIMATIONS (Electro Pulse) --- */

@keyframes electro-pulse {
  0% { box-shadow: 0 0 5px var(--theme-color), inset 0 0 5px var(--theme-color); border-color: var(--theme-color); }
  50% { box-shadow: 0 0 20px var(--theme-color), inset 0 0 10px var(--theme-color); border-color: #fff; }
  100% { box-shadow: 0 0 5px var(--theme-color), inset 0 0 5px var(--theme-color); border-color: var(--theme-color); }
}

/* --- DESKTOP INTERACTIONS --- */

.tool-card:hover {
    transform: translate(-2px, -2px);
    box-shadow: 7px 7px 0px #000;
    border-color: #666;
}

.tool-card:hover .card-overlay {
    transform: translateY(0);
    /* Pulse applies to the overlay on desktop */
    animation: electro-pulse 0.8s infinite alternate;
}

.tool-card:hover .pixel-icon {
    filter: grayscale(0%); transform: scale(1.1);
}


/* --- MOBILE LAYOUT & INTERACTIONS --- */

@media (max-width: 768px) {
    /* ... Previous Mobile Resets ... */
    body { padding: 0; height: 100dvh; background-color: var(--bezel-color); }
    .terminal-bezel { max-width: none; height: 100%; border-radius: 0; border: none; box-shadow: none; padding: 10px; }
    .terminal-screen { padding: 20px; border-width: 4px; }
    .title-3d { font-size: 2.8rem; margin-bottom: 15px; }
    .subtitle { font-size: 0.75rem; }
    
    /* Mobile Grid */
    .tools-grid {
        grid-template-columns: repeat(2, 1fr); 
        gap: 15px;
        align-content: start;
    }

    /* --- MOBILE CARD RESTRUCTURE --- */
    
    .tool-card {
        padding: 5px;
        overflow: visible; /* Allow borders to shine */
    }

    .card-interior {
        margin-bottom: 0;
        border-bottom: none; /* Connects to text box */
    }

    /* Make Text Overlay STATIC and visible below icon */
    .card-overlay {
        position: relative;
        transform: none; /* No slide up */
        background: #000;
        height: auto;
        bottom: auto;
        left: auto;
        border: 2px solid #333;
        border-top: none; /* Merges with icon box */
        padding: 10px 5px;
        margin-bottom: 5px;
        
        /* Default state: No Pulse */
        animation: none;
    }

    .tool-title { font-size: 0.6rem; margin-bottom: 5px; }
    .tool-desc { 
        font-size: 0.45rem; 
        display: -webkit-box;
        -webkit-line-clamp: 3; /* Limit text lines */
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* --- MOBILE TOUCH INTERACTIONS --- */
    
    /* When user TAPS/CLICKS the card on mobile */
    .tool-card:active .card-overlay {
        /* Pulse applies to the text box border on mobile click */
        animation: electro-pulse 0.3s infinite alternate;
        border-color: var(--theme-color);
    }
    
    .tool-card:active .card-interior {
        border-color: var(--theme-color);
        box-shadow: 0 0 15px var(--theme-color);
    }
}