@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@500;700&family=Roboto:wght@400;700&display=swap');

:root {
    --grid-size: 7;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: #121822;
    background-image: radial-gradient(circle at center, #1b2333 0%, #0d121a 100%);
    font-family: 'Roboto', sans-serif;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;
}

.top-corner-btn {
    position: fixed;
    top: 15px;
    width: 44px;
    height: 44px;
    background: #212836;
    border: 2px solid #394254;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #8da4c7;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
.top-corner-btn * {
    pointer-events: none;
}
.top-corner-btn.left {
    left: 15px;
}
.top-corner-btn.right {
    right: 15px;
}
.top-corner-btn:hover {
    color: #00ffff;
    border-color: #00ffff;
    box-shadow: 0 0 10px rgba(0,255,255,0.4);
}
.top-corner-btn:active {
    transform: scale(0.85);
}



.game-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 20px 0;
}

#board-wrapper {
    display: flex;
    flex-direction: column;
    width: 90vw;
    max-width: min(500px, calc(100vh - 180px));
}

.bar {
    display: grid;
    grid-template-columns: repeat(var(--grid-size), 1fr);
    gap: 2%;
    padding: 0 2%;
    width: 100%;
    height: 70px;
    box-sizing: border-box;
    margin-bottom: -5px; 
    z-index: 2;
}

#bottom-bar {
    margin-bottom: 0;
    margin-top: -5px;
}

.bar-cell {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#board {
    display: grid;
    grid-template-columns: repeat(var(--grid-size), 1fr);
    grid-template-rows: repeat(var(--grid-size), 1fr);
    gap: 2%; 
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: #212836;
    padding: 2%;
    border-radius: 12px;
    box-sizing: border-box;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8), inset 0 0 10px rgba(0,0,0,0.5);
    z-index: 1;
}

.cell {
    background: #394254;
    border-radius: 8px;
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.1), 0 4px 6px rgba(0,0,0,0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s ease-out;
}
.cell:active {
    transform: scale(0.92);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.6);
}

.pipe-svg {
    width: 100%;
    height: 100%;
    pointer-events: none; 
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pipe-bg {
    fill: none;
    stroke-width: 30;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.pipe-fg {
    fill: none;
    stroke-width: 12;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 0.3s, filter 0.3s;
}

.unpowered .pipe-bg { stroke: #593500; }
.unpowered .pipe-fg { stroke: #ff9900; }

.powered .pipe-bg { stroke: #004d4d; }
.powered .pipe-fg { 
    stroke: #00ffff; 
    filter: drop-shadow(0 0 4px #00ffff) drop-shadow(0 0 8px #00ffff);
}

.side-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #8da4c7;
    font-size: clamp(8px, 2vw, 10px);
    font-weight: bold;
    text-align: center;
    font-family: 'Orbitron', sans-serif;
    gap: 3px;
    z-index: 3;
}
.side-item svg {
    width: 60%;
    max-width: 35px;
    height: auto;
}

.connector {
    position: absolute;
    width: 12px; 
    height: 25px;
    background-color: #ff9900;
    z-index: 0;
    border-radius: 6px;
    transition: background-color 0.3s, box-shadow 0.3s;
}

.connector.top-conn {
    bottom: -15px; 
}

.connector.bottom-conn {
    top: -15px; 
}

.connector.powered {
    background-color: #00ffff;
    box-shadow: 0 0 5px #00ffff, 0 0 10px #00ffff;
}

.overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(3px);
}

.modal {
    background: #212836;
    padding: clamp(20px, 5vw, 30px);
    border-radius: 15px;
    text-align: center;
    border: 2px solid #00ffff;
    box-shadow: 0 0 20px rgba(0,255,255,0.4);
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 90%;
    max-width: 350px;
    box-sizing: border-box;
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal h2 {
    font-family: 'Orbitron', sans-serif;
    color: #00ffff;
    margin-top: 0;
    margin-bottom: 20px;
}

.modal button {
    display: block;
    width: 100%;
    background: #ff9900;
    color: #121822;
    border: none;
    padding: 12px 24px;
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    transition: background 0.2s, transform 0.1s;
}

.modal button:active {
    transform: scale(0.95);
}

.modal button:hover {
    background: #ffb84d;
}

.modal button.secondary {
    background: #394254;
    color: white;
}
.modal button.secondary:hover {
    background: #4a566e;
}
