:root {
    --bg-dark: #0A1A14;
    --primary: #00B894;
    --primary-dark: #009879;
    --secondary: #00CEC9;
    --accent: #FDCB6E;
    --danger: #FF7675;
    --text: #FFFFFF;
    --text-muted: rgba(255, 255, 255, 0.6);
    --glass: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --border-radius: 12px;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-wrapper {
    width: 100%;
    max-width: 900px;
    height: 100vh;
    max-height: 850px;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
    position: relative;
}

header {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

h1 {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--primary);
    text-shadow: 0 0 15px rgba(0, 184, 148, 0.4);
    margin: 0;
}

header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 15px 25px;
    backdrop-filter: blur(10px);
    gap: 20px;
}

.hud-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.hud-item:not(.meter-container) {
    align-items: center;
    min-width: 100px;
}

.hud-item .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    font-weight: 600;
}

.hud-item .value {
    font-size: 1.5rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--secondary);
}

.meter-container {
    flex: 1;
}

.meter-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.meter-bar {
    width: 100%;
    height: 16px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--glass-border);
}

.meter-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary), var(--primary));
    width: 0%;
    border-radius: 8px;
    transition: width 0.1s linear, background-color 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 184, 148, 0.5);
}

.meter-details {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
    margin-top: 5px;
    font-variant-numeric: tabular-nums;
}

main {
    flex: 1;
    display: flex;
    gap: 20px;
    overflow: hidden;
}

.tools-panel, .website-panel {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    backdrop-filter: blur(10px);
}

.tools-panel {
    flex: 0 0 250px;
}

.website-panel {
    flex: 1;
}

h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 10px;
    letter-spacing: 1px;
}

.tool-hint {
    font-size: 0.8rem;
    color: var(--accent);
    text-align: center;
}

.tools-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.tool-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: grab;
    user-select: none;
    transition: all 0.2s ease;
}

.tool-card:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    border-color: var(--secondary);
}

.tool-card:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.tool-card .icon {
    font-size: 1.8rem;
}

.tool-card .name {
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
}

.components-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding-right: 5px;
}

.component-card {
    background: rgba(0, 0, 0, 0.3);
    border: 2px dashed var(--glass-border);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.component-card.drag-over {
    border-color: var(--primary);
    background: rgba(0, 184, 148, 0.1);
    transform: scale(1.02);
}

.component-card.optimized {
    border-style: solid;
    border-color: var(--primary);
    background: rgba(0, 184, 148, 0.05);
}

.component-card.error {
    border-color: var(--danger);
    background: rgba(255, 118, 117, 0.1);
    animation: shake 0.4s ease-in-out;
}

.comp-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.comp-name {
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.comp-type {
    font-size: 0.7rem;
    color: var(--secondary);
    background: rgba(0, 206, 201, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.comp-status {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.comp-size {
    font-size: 1.2rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    transition: color 0.3s ease;
}

.comp-size.shrunk {
    color: var(--primary);
}

.comp-size.bloated {
    color: var(--danger);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

/* OVERLAYS */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 26, 20, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 100;
}

.overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.overlay-content {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    padding: 40px;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.overlay h2 {
    font-size: 2rem;
    color: var(--secondary);
    font-weight: 800;
}

.instructions p {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1.5;
}

.instructions strong {
    color: var(--primary);
}

.btn {
    appearance: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    font-size: 1.1rem;
    padding: 16px 36px;
    border-radius: 8px;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn.primary {
    background: var(--primary);
    color: var(--bg-dark);
    box-shadow: 0 4px 15px rgba(0, 184, 148, 0.3);
}

.btn.primary:hover {
    background: var(--secondary);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 206, 201, 0.4);
}

.btn.primary:active {
    transform: translateY(0);
}

/* Lighthouse Ring */
.lighthouse-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
}

.lh-ring {
    width: 120px;
    height: 120px;
    position: relative;
}

.lh-ring svg {
    width: 100%;
    height: 100%;
}

.lh-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 3;
}

.lh-progress {
    fill: none;
    stroke: var(--primary);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dasharray 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.lh-score {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text);
}

.lh-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.stats-grid {
    display: flex;
    gap: 20px;
    width: 100%;
    justify-content: center;
}

.stat-box {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px 25px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
}

.stat-lbl {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
}

.stat-val {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--accent);
}

@media (max-width: 768px) {
    main {
        flex-direction: column;
    }
    .tools-panel {
        flex: none;
    }
    .hud {
        flex-wrap: wrap;
    }
    .meter-container {
        flex: 1 1 100%;
        order: 3;
    }
}
