/* Colour Crumble Game Styles */

/* Container and Layout */
.colour-crumble-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Mobile: prevent scrolling and fit to viewport */
@media (max-width: 767px) {
    .colour-crumble-container {
        height: 100vh;
        height: 100dvh;
        min-height: unset;
        padding: 8px;
        overflow: hidden;
        box-sizing: border-box;
    }

    .game-header {
        margin-bottom: 8px;
        padding: 8px;
    }
}

.game-header {
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.score-display {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
}

/* Game Board Wrapper */
.game-board-wrapper {
    width: 80%;
    max-width: 80vw;
    margin: 0 auto 30px;
}

@media (max-width: 767px) {
    .game-board-wrapper {
        margin: 0 auto 8px;
        width: 80%;
        max-width: 80vw;
        flex: 0 1 auto;
        max-height: 55vh;
        max-height: 55dvh;
    }

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

/* Game Board Grid - 8 columns x 10 rows */
.game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(10, 1fr);
    gap: 3px;
    background: rgba(0, 0, 0, 0.3);
    padding: 5px;
    border-radius: 10px;
    aspect-ratio: 8 / 10;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* Game Cell */
.game-cell {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    position: relative;
    transition: background 0.2s ease;
}

.game-cell.drop-target {
    background: rgba(0, 255, 0, 0.3);
    border-color: #00ff00;
}

.game-cell.invalid-drop {
    background: rgba(255, 0, 0, 0.3);
    border-color: #ff0000;
}

/* Square Styles */
.square {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    position: relative;
    box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.3),
                inset 0 2px 4px rgba(255, 255, 255, 0.3);
    transition: transform 0.1s ease;
}

.square::after {
    content: '';
    position: absolute;
    top: 10%;
    left: 10%;
    width: 30%;
    height: 30%;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    filter: blur(3px);
}

/* Five Color Variations */
.square.green {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
}

.square.blue {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
}

.square.yellow {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

.square.red {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
}

.square.pink {
    background: linear-gradient(135deg, #f472b6 0%, #ec4899 100%);
}

/* New Blocks Section */
.new-blocks-wrapper {
    width: 90%;
    max-width: 600px;
    margin: 0 auto;
}

@media (max-width: 767px) {
    .new-blocks-wrapper {
        margin: 0 auto;
        flex-shrink: 0;
        width: 95%;
    }

    .instructions {
        font-size: 13px;
        margin-bottom: 6px;
    }

    .new-blocks-container {
        padding: 10px 8px;
    }

    .block-preview-wrapper {
        min-width: 70px;
        min-height: 70px;
    }
}

.instructions {
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    color: white;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.new-blocks-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    gap: 20px;
}

/* Block Preview Wrapper - maintains fixed position */
.block-preview-wrapper {
    min-width: 150px;
    min-height: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Block Preview */
.block-preview {
    display: grid;
    gap: 2px;
    cursor: grab;
    padding: 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.block-preview:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.block-preview.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

/* Empty placeholder to maintain spacing */
.block-preview-empty {
    min-width: 100px;
    min-height: 100px;
    opacity: 0;
}

.block-preview.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.block-preview-cell {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.3),
                inset 0 2px 4px rgba(255, 255, 255, 0.3);
}

.block-preview-cell.empty {
    visibility: hidden;
}

/* Drag Ghost */
.drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.8;
    display: grid;
    gap: 2px;
}

.drag-ghost .square {
    width: 35px;
    height: 35px;
}

/* Animations */
@keyframes shatter {
    0% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.2) rotate(5deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.3) rotate(15deg);
    }
}

.square.shattering {
    animation: shatter 0.5s ease-out forwards;
}

@keyframes fall {
    from {
        transform: translateY(var(--fall-distance, 0));
    }
    to {
        transform: translateY(0);
    }
}

.square.falling {
    animation: fall 0.3s ease-in;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.square.matched {
    animation: pulse 0.3s ease-in-out;
}

/* Username Input */
.username-input {
    width: 100%;
    padding: 12px;
    font-size: 18px;
    border: 2px solid #667eea;
    border-radius: 8px;
    margin: 20px 0 10px 0;
    text-align: center;
    box-sizing: border-box;
}

.username-input:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(118, 75, 162, 0.1);
}

.username-error {
    color: #ef4444;
    font-size: 14px;
    margin: 5px 0 10px 0;
}

/* Game Over Modal */
.game-over-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content-custom {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    min-width: 320px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content-custom h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 36px;
}

.final-score-text {
    font-size: 24px;
    margin-bottom: 30px;
    color: #333;
}

.final-score-text span {
    font-weight: bold;
    color: #764ba2;
    font-size: 32px;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Responsive Design */
@media (min-width: 768px) {
    .game-board-wrapper {
        width: 60%;
    }

    .new-blocks-wrapper {
        width: 60%;
    }
}

@media (min-width: 992px) {
    .game-board-wrapper {
        max-height: 60vh;
        width: auto;
    }

    .game-board {
        height: 60vh;
        width: auto;
    }
}

@media (max-width: 576px) {
    .game-header {
        font-size: 13px;
    }

    .score-display {
        font-size: 16px;
    }

    .block-preview-cell {
        width: 28px;
        height: 28px;
    }

    .modal-content-custom {
        margin: 20px;
        padding: 30px 20px;
    }

    .modal-buttons {
        flex-direction: column;
    }

    .modal-buttons .btn {
        width: 100%;
    }
}

/* Score Popup Animation */
.score-popup {
    position: fixed;
    font-weight: bold;
    pointer-events: none;
    z-index: 1500;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    animation: scoreFloat 1.5s ease-out forwards;
}

@keyframes scoreFloat {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0.5);
    }
    20% {
        opacity: 1;
        transform: translateY(-20px) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) scale(1.2);
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.no-select {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Header Buttons */
.header-buttons {
    display: flex;
    gap: 8px;
}

/* Leaderboard Styles */
.leaderboard-modal-content {
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.leaderboard-content {
    margin: 20px 0;
    text-align: left;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
}

.leaderboard-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.leaderboard-table th {
    padding: 12px 8px;
    font-weight: bold;
    text-align: left;
}

.leaderboard-table td {
    padding: 12px 8px;
    border-bottom: 1px solid #e5e7eb;
}

.leaderboard-table tbody tr:hover {
    background-color: #f9fafb;
}

.leaderboard-rank {
    font-weight: bold;
    color: #667eea;
    text-align: center;
    width: 50px;
}

.leaderboard-rank.rank-1 {
    color: #fbbf24;
    font-size: 20px;
}

.leaderboard-rank.rank-2 {
    color: #9ca3af;
    font-size: 18px;
}

.leaderboard-rank.rank-3 {
    color: #cd7f32;
    font-size: 16px;
}

.leaderboard-username {
    font-weight: 600;
    color: #1f2937;
}

.leaderboard-score {
    font-weight: bold;
    color: #764ba2;
    text-align: right;
}

.leaderboard-empty {
    text-align: center;
    color: #6b7280;
    padding: 40px;
    font-style: italic;
}

@media (max-width: 576px) {
    .leaderboard-modal-content {
        max-width: 90%;
        margin: 10px;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 8px 4px;
        font-size: 14px;
    }

    .header-buttons {
        flex-direction: column;
        gap: 4px;
    }
}
