/* Viemärikaaos - Tyylitiedosto */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #fff;
}

.game-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 10px;
}

/* Header */
.game-header {
    text-align: center;
    margin-bottom: 8px;
}

.game-header h1 {
    font-size: 1.8rem;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
    margin-bottom: 8px;
    background: linear-gradient(45deg, #00d4ff, #7b2cbf);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.timer-container,
.score-container {
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 15px;
    border-radius: 25px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.timer-label,
.score-label {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-right: 8px;
}

.timer,
.score {
    font-size: 1.2rem;
    font-weight: bold;
}

.timer {
    color: #00ff88;
}

.timer.warning {
    color: #ffaa00;
    animation: pulse 0.5s infinite;
}

.timer.danger {
    color: #ff4444;
    animation: pulse 0.3s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.score {
    color: #00d4ff;
}

/* Game Area */
.game-area {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 10px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Grandpa Track */
.grandpa-track {
    position: relative;
    height: 50px;
    background: linear-gradient(90deg, #2d5016 0%, #4a7c23 50%, #2d5016 100%);
    border-radius: 10px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    padding: 0 15px;
    overflow: hidden;
    border: 3px solid #1a3009;
}

.grandpa-track::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 10px;
    background: linear-gradient(90deg, #8B4513, #A0522D, #8B4513);
    border-radius: 0 0 7px 7px;
}

.grandpa {
    font-size: 2rem;
    position: absolute;
    left: 15px;
    transition: left 0.1s linear;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));
    z-index: 2;
}

.grandpa.walking {
    animation: walk 0.3s infinite;
}

@keyframes walk {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-5px) rotate(2deg); }
}

.toilet {
    font-size: 2rem;
    position: absolute;
    right: 15px;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));
}

/* Board Container */
.board-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.start-point,
.end-point {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 1.8rem;
    padding: 6px;
    background: rgba(0, 212, 255, 0.2);
    border-radius: 10px;
    border: 2px solid rgba(0, 212, 255, 0.5);
}

.start-point .label,
.end-point .label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Game Board */
.game-board {
    display: grid;
    grid-template-columns: repeat(7, 50px);
    grid-template-rows: repeat(5, 50px);
    gap: 2px;
    background: #1a1a2e;
    padding: 6px;
    border-radius: 10px;
    border: 3px solid #3a3a5e;
}

.cell {
    width: 50px;
    height: 50px;
    background: linear-gradient(145deg, #2a2a4e, #1e1e3a);
    border: 2px solid #3a3a5e;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    transition: all 0.2s ease;
    position: relative;
}

.cell:hover {
    background: linear-gradient(145deg, #3a3a6e, #2e2e5a);
    border-color: #00d4ff;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

.cell.has-pipe {
    background: linear-gradient(145deg, #1e3a1e, #0f2a0f);
    border-color: #00ff88;
}

.cell.water-flowing {
    animation: waterGlow 0.5s infinite alternate;
}

@keyframes waterGlow {
    0% {
        box-shadow: inset 0 0 10px rgba(0, 150, 255, 0.5);
        background: linear-gradient(145deg, #1e3a4e, #0f2a3a);
    }
    100% {
        box-shadow: inset 0 0 20px rgba(0, 200, 255, 0.8);
        background: linear-gradient(145deg, #2e4a5e, #1f3a4a);
    }
}

.cell.start-cell {
    border-color: #00ff88;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

.cell.end-cell {
    border-color: #ff8800;
    box-shadow: 0 0 10px rgba(255, 136, 0, 0.5);
}

/* Pipe Styles */
.pipe {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.pipe svg {
    width: 50px;
    height: 50px;
}

/* Next Pipe Container */
.next-pipe-container {
    text-align: center;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 2px dashed rgba(255, 255, 255, 0.2);
}

.next-pipe-container h3 {
    margin-bottom: 5px;
    font-size: 0.85rem;
    opacity: 0.8;
}

.next-pipe {
    width: 55px;
    height: 55px;
    margin: 0 auto;
    background: linear-gradient(145deg, #2a2a4e, #1e1e3a);
    border: 3px solid #00d4ff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

/* Bottom Controls */
.bottom-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.btn-water {
    background: linear-gradient(45deg, #00aaff, #0066cc);
    color: #fff;
    padding: 12px 20px;
    font-size: 1rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: none;
    letter-spacing: 0;
    animation: waterPulse 2s infinite;
}

.btn-water:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 170, 255, 0.5);
}

@keyframes waterPulse {
    0%, 100% { box-shadow: 0 0 10px rgba(0, 170, 255, 0.3); }
    50% { box-shadow: 0 0 20px rgba(0, 170, 255, 0.6); }
}

/* Instructions */
.instructions {
    margin-top: 8px;
    text-align: center;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.instructions p {
    margin: 2px 0;
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Highscore Container */
.highscore-container {
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.highscore-container h3 {
    text-align: center;
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: #ffd700;
}

.highscore-list {
    max-height: 150px;
    overflow-y: auto;
}

.month-label {
    text-align: center;
    font-size: 0.7rem;
    opacity: 0.7;
    margin-bottom: 5px;
    text-transform: capitalize;
}

.scores-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.score-entry {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 5px;
    margin-bottom: 2px;
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.03);
}

.score-entry.top-three {
    background: rgba(255, 215, 0, 0.1);
}

.score-entry .rank {
    width: 25px;
    font-weight: bold;
}

.score-entry .name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.score-entry .points {
    font-weight: bold;
    color: #00d4ff;
}

.no-scores {
    text-align: center;
    font-size: 0.8rem;
    opacity: 0.6;
    padding: 10px;
}

/* Game Over Highscores */
.game-over-highscores {
    margin-top: 15px;
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
}

.game-over-content {
    max-height: 90vh;
    overflow-y: auto;
}

/* Score Submit */
.score-submit {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.score-submit.hidden {
    display: none;
}

.score-submit input {
    padding: 10px 15px;
    font-size: 1rem;
    border: 2px solid rgba(0, 212, 255, 0.5);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    text-align: center;
    width: 200px;
}

.score-submit input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.score-submit input:focus {
    outline: none;
    border-color: #00d4ff;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.btn-submit {
    background: linear-gradient(45deg, #ffd700, #ffaa00);
    color: #1a1a2e;
    padding: 10px 25px;
    font-size: 0.9rem;
}

/* Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: linear-gradient(145deg, #2a2a4e, #1e1e3a);
    padding: 40px 50px;
    border-radius: 20px;
    text-align: center;
    border: 3px solid rgba(0, 212, 255, 0.5);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 90%;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.overlay-content h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    background: linear-gradient(45deg, #00d4ff, #7b2cbf);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.overlay-content p {
    margin: 10px 0;
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Buttons */
.btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: bold;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.btn-start {
    background: linear-gradient(45deg, #00ff88, #00d4ff);
    color: #1a1a2e;
}

.btn-restart {
    background: linear-gradient(45deg, #ff8800, #ff4444);
    color: #fff;
}

.btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: scale(0.98);
}

/* Water Animation */
.water-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: radial-gradient(circle, #00d4ff, #0088ff);
    border-radius: 50%;
    animation: waterFlow 0.5s linear;
    pointer-events: none;
}

@keyframes waterFlow {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.5);
    }
}

/* Win/Lose States */
.game-over-title.win {
    color: #00ff88 !important;
    -webkit-text-fill-color: #00ff88 !important;
}

.game-over-title.lose {
    color: #ff4444 !important;
    -webkit-text-fill-color: #ff4444 !important;
}

/* Responsive */
@media (max-width: 768px) {
    .game-header h1 {
        font-size: 1.8rem;
    }

    .game-board {
        grid-template-columns: repeat(7, 45px);
        grid-template-rows: repeat(5, 45px);
    }

    .cell {
        width: 45px;
        height: 45px;
        font-size: 1.8rem;
    }

    .stats {
        gap: 15px;
    }

    .timer-container,
    .score-container {
        padding: 8px 15px;
    }

    .overlay-content {
        padding: 25px 30px;
    }

    .btn {
        padding: 12px 30px;
        font-size: 1rem;
    }
}

@media (max-width: 500px) {
    .game-board {
        grid-template-columns: repeat(7, 38px);
        grid-template-rows: repeat(5, 38px);
        gap: 2px;
        padding: 5px;
    }

    .cell {
        width: 38px;
        height: 38px;
        font-size: 1.5rem;
    }

    .board-container {
        flex-direction: column;
    }

    .start-point,
    .end-point {
        font-size: 1.5rem;
    }
}
