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

svg {
    touch-action: none;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 50px;
}

.game-container {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 1200px;
    width: 100%;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 10px;
    font-size: 2.5em;
}

.instructions {
    text-align: center;
    color: #666;
    margin-bottom: 10px;
    font-size: 2em;
    line-height: 1.6;
}

.game-area {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

#game-board {
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px solid #dee2e6;
    width: 100%;
    height: calc(100vh - 250px);
    max-width: 1200px;
}

/* Target hexagons (empty slots in the array) */
.target-hex {
    fill: #e9ecef;
    stroke: #adb5bd;
    stroke-width: 2;
    transition: fill 0.2s;
}

.target-hex:hover {
    fill: #dee2e6;
}

/* Moveable piece hexagons */
.piece-hex {
    fill: #667eea;
    stroke: #4c51bf;
    stroke-width: 2.5;
    transition: fill 0.1s, stroke 0.1s, stroke-width 0.1s;
}

.piece:hover .piece-hex:not(.highlighted) {
    fill: #764ba2;
    stroke: #5a3a7d;
}

.piece.placed .piece-hex:not(.highlighted) {
    fill: #667eea;
    stroke: #4c51bf;
}

/* Highlighted piece hexagons (when in a completed row) */
.piece-hex.highlighted {
    fill: #4CAF50;
    stroke: #2e7d32;
    stroke-width: 3;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.2);
    }
}

.piece-text {
    fill: white;
    font-size: 48px;
    font-weight: bold;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
    user-select: none;
}

.piece {
    transition: opacity 0.2s;
}

/* Row sum display above the array (SVG text) */
.row-sum-display-text {
    fill: #4CAF50;
    font-size: 40px;
    font-weight: bold;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
    user-select: none;
}

/* Completion message display (SVG text) */
.completion-message-text {
    fill: #4CAF50;
    font-size: 48px;
    font-weight: bold;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
    user-select: none;
}

.status {
    text-align: center;
    margin-bottom: 5px;
}

.button-container {
    text-align: center;
    margin-top: -40px;
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
    gap: 15px;
}

#hint-btn {
    background: #ff9800;
    color: white;
    border: none;
    padding: 8px 24px;
    font-size: 2em;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
}

#hint-btn:hover {
    background: #f57c00;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 152, 0, 0.4);
}

#hint-btn:active {
    transform: translateY(0);
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 30px;
    border-radius: 15px;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    position: relative;
}

.modal-content p {
    font-size: 1.3em;
    color: #333;
    margin: 0;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #333;
}

#message {
    font-size: 1.3em;
    font-weight: bold;
    margin-bottom: 15px;
    min-height: 30px;
}

#reset-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 24px;
    font-size: 2em;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
    /* margin-top: 3px; */
}

#reset-btn:hover {
    background: #764ba2;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

#reset-btn:active {
    transform: translateY(0);
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 10px 25px;
        padding-top: calc(env(safe-area-inset-top, 0px) + 50px);
    }

    .game-container {
        padding: 15px;
    }

    #game-board {
        height: auto;
        width: 100%;
    }

    h1 {
        font-size: 1.5em;
        margin-bottom: 10px;
    }

    .instructions {
        font-size: 1em;
        margin-bottom: 5px;
    }

    .row-sum-display-text {
        font-size: 56px;
    }

    #message {
        font-size: 1.1em;
    }

    #reset-btn,
    #hint-btn {
        padding: 5px 7px;
        font-size: 0.86em;
    }

    .button-container {
        gap: 10px;
    }

    .modal-content {
        margin: 30% auto;
        padding: 20px;
        max-width: 90%;
    }
}
