*{
    margin: 0;
    padding: 0;
}

/* Base styles */
body {
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Arial', sans-serif;
    background: linear-gradient(315deg, #16191d 0%, #252a2e 100%);
}

/* Global touch-feedback reset */
button, select, input, textarea, a,
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    outline: none;
}

/* Keyframes for notifications */
@keyframes slideDown {
    0% { opacity: 0; transform: translateY(-20px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-20px); }
}

/* Container grid for tall screens */
@media (min-height: 650px) {
    #container {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        grid-template-rows: repeat(5, 1fr);
        gap: 2%;
        width: 80vw;
        height: 80vw;
        max-width: 600px;
        max-height: 600px;
        background-color: #000;
        border-radius: 20px;
        padding: 3%;
        box-sizing: border-box;
        position: relative;
        overflow: hidden;
        margin: 0 auto 20px;
    }
}

/* Square and icon wrappers */
.square-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}
.square {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    aspect-ratio: 1;
    background: linear-gradient(320.64deg, #17191c -42.09%, #32383e 167.71%);
    border-radius: 10px;
    font-size: 50px;
    line-height: 1;
    box-shadow: 3px 3px 4px rgba(10, 9, 9, .4);
    z-index: 2;
}
.icon {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Trap selector and controls */
#trap-selector {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 80vw;
    max-width: 600px;
    margin: 20px auto;
    padding: 10px 20px;
    background-color: #0c0c0e;
    border-radius: 15px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
}
.trap-btn {
    width: 60px;
    height: 60px;
    background: rgba(209, 116, 72, .1);
    border: 1px solid #a35231;
    border-radius: 15px;
    font-size: 28px;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    user-select: none;
    box-shadow: -1px -1px 10px rgba(141, 68, 37, .15);
    transition: background 0.3s ease, transform 0.2s ease;
}
.trap-btn:hover {
    background: linear-gradient(145deg, #1b6c7f, #145965);
    transform: translateY(-3px);
}
#trap-count {
    font-size: 36px;
    color: #fff;
    font-weight: bold;
    padding: 0 20px;
    text-align: center;
}

/* Action buttons and notification */
#explodeButton,
#closeButton {
    width: 80vw;
    max-width: 600px;
    margin: 20px auto 0;
    padding: 12px 24px;
    font-size: 18px;
    font-family: 'Intro', sans-serif;
    color: #fff;
    background-color: #238fa9;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease, transform 0.2s ease;
}
#explodeButton:hover,
#closeButton:hover {
    background-color: #1b6c7f;
    transform: translateY(-3px);
}
#notification {
    display: none;
    position: absolute;
    top: 55px;
    left: 50%;
    transform: translateX(-50%);
    width: 80vw;
    max-width: 600px;
    padding: 10px;
    background-color: #1b6c7f;
    color: #fff;
    font-style: italic;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.5s ease forwards;
}
#notification.fade-out {
    animation: slideUp 0.5s ease forwards;
}
#progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 5px;
    background-color: #ff1744;
    width: 0;
}

/* Header and bottom tab navigation */
header {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 10px 20px;
    background-color: #333;
    color: #fff;
    display: flex;
    align-items: center;
    font-family: 'Intro', Arial, sans-serif;
    font-size: 24px;
    z-index: 10;
    box-sizing: border-box;
}
header img {
    width: 30px;
    height: 30px;
    margin-right: 10px;
    border-radius: 50%;
}
.tab {
    position: fixed;
    bottom: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    background-color: #333;
    padding: 10px 0;
    height: 70px;
    z-index: 10;
}
.tab button {
    flex: 1;
    margin: 0 10px;
    padding: 14px 20px;
    background: transparent;
    border: none;
    border-radius: 50px;
    color: #fff;
    font-family: 'Intro', Arial, sans-serif;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s ease;
}
.tab button img {
    width: 38px;
    height: 38px;
}
.tab button:hover {
    background-color: #555;
}
.tab button.active {
    background-color: #666;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .tab button { margin: 0 5px; padding: 10px 15px; font-size: 14px; }
    .tab button img { width: 32px; height: 32px; }
}
@media (max-width: 480px) {
    .tab button { margin: 0 3px; padding: 8px 12px; font-size: 12px; }
    .tab button img { width: 28px; height: 28px; }
}

/* Loading animation */
@keyframes loading {
    0% { width: 100%; }
    100% { width: 0; }
}
#loading-text span {
    display: inline-block;
    animation: bounce 0.3s ease infinite alternate;
    font-size: 42px;
    color: rgb(209, 178, 5);
    text-shadow: 0 0.25px 0 #ccc, 0 0.5px 0 #ccc, 0 0.75px 0 #ccc, 0 1px 0 #ccc;
    margin-top: 20px;
}
#loading-text span:nth-child(n) { animation-delay: calc((n - 1) * 0.1s); }
@keyframes bounce {
    0% {
        transform: translateY(0);
        text-shadow: 0 0.25px 0 #ccc;
    }
    100% {
        transform: translateY(-5px);
        text-shadow: 0 0.25px 0 #ccc;
    }
}

/* Back button styles */
.back-btn {
    position: relative;
    top: 10px;
    width: 310px;
    height: 50px;
    border: none;
    border-radius: 12px;
    background: red;
    color: #ddd;
    font-size: 22px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-shadow: 0 0 20px rgba(218, 8, 8, 1);
    box-shadow: none;
    z-index: 1;
}
.button2::before {
    content: "";
    position: absolute;
    inset: 0;
    background: blue;
    border-radius: 12px;
    z-index: -1;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.button2:hover::before {
    background: rgba(0, 0, 0, 0.3);
}
