/* Neon Pipes - Design System */
:root {
    --bg-color: #0a0a0f;
    --neon-cyan: #00ffff;
    --neon-pink: #ff2d78;
    --neon-green: #39ff14;
    --neon-yellow: #ffe600;
    --grid-subtle: #1a1a2e;
    --glass-bg: rgba(20, 20, 30, 0.8);
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-main: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: white;
    font-family: var(--font-main);
    overflow: hidden;
    position: fixed;
    inset: 0;
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* HUD Styling */
.hud {
    height: 60px;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    align-items: center;
    background: var(--glass-bg);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    z-index: 100;
}

.hud-left { display: flex; gap: 15px; }
.hud-center { 
    display: flex; 
    justify-content: center; 
    gap: 20px;
    font-weight: 700;
    letter-spacing: 1px;
}
.hud-right { display: flex; justify-content: flex-end; gap: 15px; }

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label { font-size: 10px; opacity: 0.6; text-transform: uppercase; }
.stat-value { font-size: 18px; color: var(--neon-cyan); text-shadow: 0 0 10px var(--neon-cyan); }

.hud-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-size: 18px;
}

.hud-btn:hover { background: rgba(255, 255, 255, 0.15); border-color: var(--neon-cyan); }

/* Game Container */
.game-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

/* Grid Styling */
.pipe-grid {
    display: grid;
    gap: 4px;
    background: var(--grid-subtle);
    padding: 4px;
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    position: relative;
}

.pipe-cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background: var(--bg-color);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
    position: relative;
}

.pipe-cell:active { transform: scale(0.95); }

/* Source & Destination Nodes */
.node {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    z-index: 10;
}

.source-node {
    background: var(--neon-green);
    box-shadow: 0 0 15px var(--neon-green);
    top: -10px;
    left: -10px;
}

.dest-node {
    background: var(--neon-yellow);
    box-shadow: 0 0 15px var(--neon-yellow);
    bottom: -10px;
    right: -10px;
}

/* Pipe Visuals (SVG inside cells) */
.pipe-svg {
    width: 100%;
    height: 100%;
}

.pipe-path {
    fill: none;
    stroke: #1a6b6b; /* Dim unconnected color */
    stroke-width: 24; /* Approx 30% of 80px cell */
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: all 0.3s;
}

.pipe-cell.connected .pipe-path {
    stroke: var(--neon-cyan);
    filter: drop-shadow(0 0 8px var(--neon-cyan));
}

/* Flow Animation */
.flow-pulse {
    fill: none;
    stroke: var(--neon-pink);
    stroke-width: 18; /* Slightly thinner than pipe */
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 20, 1000;
    stroke-dashoffset: 0;
    display: none;
}

.flowing .flow-pulse {
    display: block;
    animation: flowAnim 1.5s linear infinite;
}

@keyframes flowAnim {
    from { stroke-dashoffset: 100; }
    to { stroke-dashoffset: -100; }
}

/* Screen Overlays */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 20px 20px 20px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 40px;
    border-radius: 24px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
    margin: auto;
}

.modal h2 { 
    font-size: 32px; 
    margin-bottom: 10px; 
    color: var(--neon-cyan);
    text-shadow: 0 0 15px var(--neon-cyan);
}

.modal p { opacity: 0.8; margin-bottom: 30px; }

.btn-main {
    background: var(--neon-cyan);
    color: black;
    border: none;
    padding: 14px 28px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    margin-bottom: 10px;
}

.btn-main:hover { transform: translateY(-2px); box-shadow: 0 5px 20px rgba(0, 255, 255, 0.4); }

.btn-outline {
    background: transparent;
    color: white;
    border: 1px solid var(--glass-border);
    padding: 12px 24px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-outline:hover { background: rgba(255, 255, 255, 0.05); border-color: var(--neon-pink); color: var(--neon-pink); }

/* Hint Button */
#hint-btn {
    color: var(--neon-yellow);
    border-color: rgba(255, 230, 0, 0.2);
    box-shadow: 0 0 10px rgba(255, 230, 0, 0.1);
}

#hint-btn:not(:disabled):hover { 
    background: rgba(255, 230, 0, 0.15); 
    border-color: var(--neon-yellow);
    color: var(--neon-yellow);
    box-shadow: 0 0 15px rgba(255, 230, 0, 0.4);
}

#hint-btn:disabled {
    opacity: 0.3;
    border-color: var(--glass-border);
    cursor: default;
    box-shadow: none;
}

/* Hint Countdown Overlay */
.hint-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 40px;
    font-weight: 800;
    color: var(--neon-yellow);
    text-shadow: 0 0 20px var(--neon-yellow);
    pointer-events: none;
    z-index: 300;
    opacity: 0;
    transition: opacity 0.3s;
}

.hint-overlay.active { opacity: 1; }

/* Social Sharing */
.social-sharing {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.share-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(255,255,255,0.05);
    color: white;
    text-decoration: none;
    padding: 0;
}

.share-btn svg {
    width: 20px;
    height: 20px;
}

.share-btn.wa:hover { 
    background: #25D366; 
    border-color: #25D366; 
    color: white; 
    box-shadow: 0 0 15px rgba(37, 211, 102, 0.4);
}

.share-btn.x:hover { 
    background: #000; 
    border-color: #fff; 
    color: white; 
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
}

/* How to Play Overlay */
#htp-overlay .modal {
    max-width: 500px;
    text-align: left;
}

.htp-content {
    margin: 20px 0;
    font-size: 14px;
    line-height: 1.6;
}

.htp-content li { margin-bottom: 10px; }

/* Mode Selection Styles */
.mode-modal {
    padding: 30px;
}

.mode-cards {
    display: flex;
    gap: 20px;
    margin-top: 30px;
}

.mode-card {
    flex: 1;
    background: #0d1b2a;
    border: 2px solid var(--glass-border);
    border-radius: 20px;
    padding: 25px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

.mode-card.classic { border-color: var(--neon-cyan); }
.mode-card.perfect { border-color: var(--neon-pink); }

.mode-card:hover {
    transform: translateY(-5px);
    background: #152a3f;
}

.mode-card.classic:hover { box-shadow: 0 0 20px rgba(0, 255, 255, 0.3); }
.mode-card.perfect:hover { box-shadow: 0 0 20px rgba(255, 45, 120, 0.3); }

.mode-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.mode-card h3 {
    font-size: 20px;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.mode-card p {
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 15px;
    opacity: 0.8;
}

.mode-difficulty {
    font-size: 12px;
    color: var(--neon-yellow);
    margin-bottom: 20px;
    font-weight: 700;
}

@media (max-width: 600px) {
    .mode-cards { flex-direction: column; gap: 12px; margin-top: 20px; }
    .mode-card { padding: 15px; }
    .mode-modal { padding: 20px; }
    .mode-icon { font-size: 36px; margin-bottom: 10px; }
    .mode-card h3 { font-size: 18px; margin-bottom: 8px; }
    .mode-card p { font-size: 12px; margin-bottom: 12px; line-height: 1.4; }
    .mode-difficulty { margin-bottom: 12px; }
}
@media (max-width: 600px) {
    .hud { height: 50px; padding: 0 10px; }
    .stat-value { font-size: 16px; }
    .hud-btn { width: 32px; height: 32px; font-size: 16px; }
}
