.menu-start {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    z-index: 1000;
}

.menu-start.hidden {
    display: none;
}

.menu-start button {
    padding: 12px 20px;
    font-size: 16px;
}

.game-wrapper,
header {
    position: relative;
    z-index: 1;
}

.game-box {
    background: rgba(10, 0, 30, 0.85);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(123, 44, 255, 0.3);
    padding: 20px;
}

.game-wrapper {
    display: flex;
    justify-content: center;
    padding: 40px 20px;
}

.game-box {
    width: 100%;
    max-width: 1200px;
    background: rgba(10, 0, 30, 0.75);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(123, 44, 255, 0.3);
    border-radius: 20px;
    padding: 25px;
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 30px;
    box-shadow:
        0 0 40px rgba(123, 44, 255, 0.25),
        0 0 80px rgba(0, 212, 255, 0.15);
}

@media (max-width: 900px) {
    .game-box {
        grid-template-columns: 1fr;
    }
}

.game-main h2 {
    color: #ffffff;
    text-shadow: 0 0 10px #7b2cff;
    font-weight: 700;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.top-bar select {
    height: 36px;
}

#timer {
    color: #00d4ff;
    text-shadow: 0 0 8px #00d4ff;
}

button {
    background: linear-gradient(45deg, #990000, #cc0000);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
}

button:hover {
    transform: scale(1.05);
}

#grid {
    display: grid;
    justify-content: center;
    gap: 3px;
    padding: 10px;
    background: #ddd;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    touch-action: none;
}

.cell {
    width: 45px;
    height: 45px;
    font-size: 38px;
    background: #fafafa;
    border-radius: 6px;

    display: flex;
    align-items: center;
    justify-content: center;

    font-weight: bold;
    cursor: pointer;

    transition: 0.15s;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#grid,
.cell {
    user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
}

.cell:hover {
    background: rgba(123, 44, 255, 0.3);
}

.cell.active {
    background: #7b2cff;
    box-shadow: 0 0 12px #7b2cff;
    transform: scale(1.1);
}

.cell.found {
    background: #00d4ff;
    box-shadow: 0 0 12px #00d4ff;
}

.game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-box,
.ranking-box {
    background:
        linear-gradient(180deg,
            rgba(255, 255, 255, .05),
            rgba(255, 255, 255, .02));

    border:
        1px solid rgba(255, 255, 255, .08);

    border-radius: 24px;

    backdrop-filter:
        blur(18px) saturate(180%);

    -webkit-backdrop-filter:
        blur(18px) saturate(180%);

    box-shadow:
        0 10px 40px rgba(0, 0, 0, .35);

    position: relative;
    overflow: hidden;

    padding: 22px;
}

.ranking-box {
    position: relative;
}

.ranking-box::before {
    content: "";

    position: absolute;
    inset: 0;

    background:
        radial-gradient(circle at top left,
            rgba(123, 44, 255, .18),
            transparent 40%);

    pointer-events: none;
}

.ranking-box h3 {
    position: relative;

    font-size: 24px;
    font-weight: 800;

    margin-bottom: 20px;

    color: #fff;
}

#ranking {
    list-style: none;
    padding: 0;
    margin: 0;

    display: flex;
    flex-direction: column;
    gap: 12px;
}

#ranking li {
    display: grid;

    grid-template-columns:
        26px minmax(0, 1fr) auto auto;

    align-items: center;

    gap: 10px;

    padding: 14px;

    border-radius: 16px;

    background:
        rgba(255, 255, 255, .04);

    border:
        1px solid rgba(255, 255, 255, .05);

    transition:
        transform .2s ease,
        border-color .2s ease,
        background .2s ease;
}

#ranking li:hover {
    transform: translateY(-2px);

    background:
        rgba(123, 44, 255, .10);

    border-color:
        rgba(123, 44, 255, .35);
}

.rank-pos {
    font-size: 14px;
    font-weight: 700;

    color: #ffd54a;

    text-align: center;
}

.rank-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    color: rgba(255, 255, 255, .92);

    font-size: 14px;
    font-weight: 600;
}

.rank-time {
    color: #00d4ff;

    font-size: 14px;
    font-weight: 700;

    white-space: nowrap;
}

.rank-level {
    color: rgba(255, 255, 255, .65);

    font-size: 12px;

    white-space: nowrap;
}

.game-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.game-sidebar li {
    padding: 4px 0;
}

.game-sidebar li.found {
    text-decoration: line-through;
    color: #22c55e;
}

.game-sidebar h3 {
    color: #ffffff;
    font-size: 24px;
    font-weight: 800;
}

.game-sidebar li {
    color: #ddd;
}

.ranking-box {
    /* background: #f1f1f1;
    color: #7b2cff!important; */
    padding: 15px;
    border-radius: 12px;
}

.ranking-box h3 {
    margin-top: 0;
}

#progress {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
}

#progress-bar {
    height: 8px;
    width: 0%;
    background: linear-gradient(90deg, #7b2cff, #00d4ff);
    transition: 0.3s;
}

button {
    background: linear-gradient(45deg, #7b2cff, #00d4ff);
    box-shadow: 0 0 10px rgba(123, 44, 255, 0.6);
}

button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.8);
}

#level {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    background: linear-gradient(45deg, #7b2cff, #00d4ff);
    color: #fff;

    border: none;
    border-radius: 10px;

    padding: 8px 35px 8px 12px;

    font-weight: bold;
    cursor: pointer;

    box-shadow: 0 0 10px rgba(123, 44, 255, 0.6);

    transition: 0.2s;

    position: relative;
}

#level:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.8);
}

#level:focus {
    outline: none;
    box-shadow: 0 0 0 2px #00d4ff;
}

#level {
    background-image:
        linear-gradient(45deg, transparent 50%, white 50%),
        linear-gradient(135deg, white 50%, transparent 50%);
    background-position:
        calc(100% - 15px) center,
        calc(100% - 10px) center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.modal-overlay.hidden {
    display: none;
}

.modal-box {
    background: rgba(10, 0, 30, 0.95);
    border: 1px solid rgba(123, 44, 255, 0.4);
    border-radius: 15px;
    padding: 25px;
    max-width: 420px;
    text-align: center;
    box-shadow:
        0 0 30px rgba(123, 44, 255, 0.6),
        0 0 60px rgba(0, 212, 255, 0.3);
}

.modal-box h2 {
    color: #00d4ff;
    margin-bottom: 10px;
}

.modal-box p {
    color: #ddd;
    margin: 10px 0;
    line-height: 1.4;
}

.modal-box button {
    margin-top: 15px;
}

@keyframes pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}

@media (max-width: 768px) {

    .game-wrapper {
        padding: 10px;
    }

    .game-box {
        display: flex;
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .game-main h2 {
        font-size: 18px;
        text-align: center;
    }

    .game-sidebar ul {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .game-sidebar li {
        background: rgba(255, 255, 255, 0.08);
        padding: 4px 6px;
        border-radius: 6px;
        font-size: 12px;
    }

    #grid {
        width: 100%;
        padding: 5px;
        gap: 2px;
        overflow-x: auto;
        user-select: none;
    }

    .cell {
        width: calc((100vw - 60px) / var(--grid-size));
        height: calc((100vw - 40px) / var(--grid-size));
        font-size: clamp(10px, 2.5vw, 14px);
        aspect-ratio: 1 / 1;
    }

    .game-sidebar {
        gap: 10px;
    }

    .sidebar-box,
    .ranking-box {
        padding: 10px;
    }

    .ranking-box {
        order: 3;
    }

    .modal-overlay {
        margin: 10px;
        padding: 15px;
        align-items: flex-end;

    }

    .modal-box {
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;

        padding: 20px;
        max-height: 80vh;
        overflow-y: auto;

        animation: modalSlideUp 0.25s ease;
    }

    .modal-box h2 {
        font-size: 18px;
    }

    .modal-box p {
        font-size: 14px;
    }

    .modal-box button {
        width: 100%;
        padding: 12px;
        font-size: 16px;
        border-radius: 12px;
    }

    #level {
        width: 30%;
        font-size: 16px;
        padding: 10px;
    }
}

.custom-select {
    position: relative;
    width: 140px;
    cursor: pointer;
    user-select: none;
}

.select-selected {
    background: linear-gradient(45deg, #7b2cff, #00d4ff);
    color: #fff;
    padding: 8px 12px;
    border-radius: 10px;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(123, 44, 255, 0.6);
    transition: 0.2s;
}

.select-selected:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.8);
}

.select-items {
    position: absolute;
    top: 110%;
    left: 0;
    right: 0;
    background: rgba(10, 0, 30, 0.95);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(123, 44, 255, 0.4);
    box-shadow: 0 0 25px rgba(0, 212, 255, 0.3);
    z-index: 9999;
    animation: dropdownFade 0.2s ease;
}

.select-items div {
    padding: 10px;
    color: #fff;
    transition: 0.2s;
}

.select-items div:hover {
    background: rgba(123, 44, 255, 0.3);
}

.hidden {
    display: none;
}

#lista {
    display: flex;
    flex-wrap: wrap;

    gap: 10px;

    list-style: none;

    padding: 0;
    margin: 0;
}

#lista li {
    display: flex;
    align-items: center;
    justify-content: center;

    padding: 10px 14px;

    border-radius: 999px;

    background:
        linear-gradient(180deg,
            rgba(255, 255, 255, .06),
            rgba(255, 255, 255, .03));

    border:
        1px solid rgba(255, 255, 255, .08);

    color: rgba(255, 255, 255, .92);

    font-size: 13px;
    font-weight: 600;

    letter-spacing: .3px;

    transition:
        transform .2s ease,
        background .2s ease,
        border-color .2s ease,
        opacity .2s ease;

    backdrop-filter:
        blur(10px);

    -webkit-backdrop-filter:
        blur(10px);

    padding-inline: 14px;
}

#lista li:hover {
    transform: translateY(-2px);

    background:
        rgba(123, 44, 255, .15);

    border-color:
        rgba(123, 44, 255, .35);
}

#lista li.found {
    background:
        linear-gradient(90deg,
            rgba(34, 197, 94, .18),
            rgba(0, 212, 255, .12));

    border-color:
        rgba(34, 197, 94, .45);

    color:
        rgba(255, 255, 255, .55);

    text-decoration: line-through;

    opacity: .75;
}

.sidebar-box h3 {
    margin-bottom: 20px;
}

@keyframes dropdownFade {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .custom-select {
        width: 30vw;
    }

    .select-selected {
        text-align: center;
        padding: 10px;
        font-size: 16px;
    }
}

@keyframes modalSlideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.game-wrapper,
.game-box,
.game-main,
.game-sidebar,
#grid,
.cell {
    z-index: 1;
}

.select-items {
    z-index: 50;
}

.modal-overlay {
    z-index: 500;
}

@media (max-width: 768px) {

    .game-wrapper,
    .game-box,
    #grid {
        overflow: visible !important;
    }

    header,
    .navbar,
    .mobile-menu {
        position: relative;
        z-index: 999999 !important;
    }
}