body {
    font-family: "Pixelify Sans", sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #2c2c2c;
    color: #f0f0f0;
}

h1 {
    text-shadow: 2px 2px 0px #000000;
}

.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
    width: 90%;
}

.controls-top-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
}

#mute-button, #hint-button, #reset-button, #achievements-button {
    background-color: #3e3e3e;
    color: #f0f0f0;
    border: 2px outset #555;
    padding: 10px;
    font-family: "Pixelify Sans", sans-serif;
    cursor: pointer;
    margin-left: 10px;
    font-size: 20px;
}

#mute-button.muted::before {
    content: '🔇';
}

#mute-button:not(.muted)::before {
    content: '🔊';
}

#score-counter, #hint-counter {
    background-color: #3e3e3e;
    color: #f0f0f0;
    border: 2px outset #555;
    padding: 10px;
    font-family: "Pixelify Sans", sans-serif;
    margin-left: 10px;
    font-size: 20px;
}

#score-counter.clickable {
    cursor: pointer;
}

#score-counter.clickable:hover {
    border-style: inset;
    background-color: #4a4a4a;
}

#pokemon-input {
    padding: 10px;
    font-size: 16px;
    border: 2px outset #555;
    border-radius: 0;
    margin-bottom: 0;
    background-color: #3e3e3e;
    color: #f0f0f0;
    font-family: "Pixelify Sans", sans-serif;
}

#pokemon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 10px;
    width: 90%;
    max-width: 1200px;
}

.pokemon-tile {
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: #3e3e3e;
    border: 2px outset #555;
    border-radius: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.3s;
}

.pokemon-tile:hover {
    transform: scale(1.1);
    box-shadow: 0 0 10px #fff;
    border-color: #fff;
}

.pokemon-tile.revealed {
    border: 2px inset #555;
    visibility: visible;
}

.gen2-placeholder {
    visibility: hidden;
    cursor: default;
}


.pokemon-tile img {
    max-width: 90%;
    max-height: 90%;
    width: 90%;
    height: 90%;
    object-fit: contain;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: pixelated;
    -ms-interpolation-mode: nearest-neighbor;
}

#feedback-container {
    width: 100%;
    text-align: center;
    margin-top: 10px;
    font-size: 20px;
    font-weight: bold;
    min-height: 24px;
}

.correct {
    color: #4CAF50;
}

.incorrect {
    color: #F44336;
}

.hint {
    color: #2196F3;
}

@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.shake {
    animation: shake 0.5s;
}

@keyframes glitch-animation {
    0% {
        filter: hue-rotate(0deg) contrast(100%) brightness(100%);
        transform: translate(0, 0);
    }
    25% {
        filter: hue-rotate(90deg) contrast(120%) brightness(80%);
        transform: translate(-2px, 2px);
    }
    50% {
        filter: hue-rotate(180deg) contrast(80%) brightness(120%);
        transform: translate(2px, -2px);
    }
    75% {
        filter: hue-rotate(270deg) contrast(110%) brightness(90%);
        transform: translate(-1px, 1px);
    }
    100% {
        filter: hue-rotate(360deg) contrast(100%) brightness(100%);
        transform: translate(0, 0);
    }
}

.glitch {
    animation: glitch-animation 0.3s infinite;
}

@keyframes sparkle {
    0%, 100% {
        filter: brightness(1) hue-rotate(0deg);
    }
    50% {
        filter: brightness(1.5) hue-rotate(180deg) drop-shadow(0 0 5px #fff);
    }
}

.pokemon-tile.shiny img {
    animation: sparkle 2s infinite;
}

@keyframes holographic-border {
  0% { background-position: 0% 50% }
  50% { background-position: 100% 50% }
  100% { background-position: 0% 50% }
}

/* Modal Styles */
#pokemon-image.shiny {
    position: relative;
    border: 4px solid transparent;
}

#pokemon-image.shiny::before {
    content: '';
    position: absolute;
    top: -4px; left: -4px;
    width: calc(100% + 8px);
    height: calc(100% + 8px);
    background: linear-gradient(60deg, #f79533, #f37055, #ef4e7b, #a166ab, #5073b8, #1098ad, #07b39b, #6fba82);
    background-size: 300% 300%;
    animation: holographic-border 4s linear infinite;
    z-index: -1;
}

.modal {
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #2c2c2c;
    margin: 5% auto;
    padding: 20px;
    border: 2px outset #555;
    width: 80%;
    max-width: 500px;
    color: #f0f0f0;
    font-family: "Pixelify Sans", sans-serif;
    position: relative;
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-button:hover,
.close-button:focus {
    color: white;
    text-decoration: none;
    cursor: pointer;
}

#pokemon-number {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 24px;
    color: #aaa;
}

.modal-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
}

.modal-navigation button {
    background-color: #3e3e3e;
    color: #f0f0f0;
    border: 2px outset #555;
    padding: 10px 20px;
    font-family: "Pixelify Sans", sans-serif;
    cursor: pointer;
    font-size: 18px;
}

#pokemon-image {
    image-rendering: pixelated;
    display: block;
    width: 100%;
    clip-path: inset(0 32px 0 0);
    max-height: 400px;
}

#gym-leader-image {
    image-rendering: pixelated;
    display: block;
    width: 50%;
}

#pokemon-image.fallback-image {
    width: 50%;
}

#gym-leader-pokemon-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 20px;
}

#gym-leader-pokemon-grid img {
    width: 100px;
    height: 100px;
    image-rendering: pixelated;
    border: 2px solid #555;
    padding: 5px;
}

@media (max-width: 600px) {
    .controls-top-row {
        flex-direction: column;
        width: 100%;
    }

    #pokemon-input {
        width: 100%;
        margin-bottom: 10px;
    }

    #mute-button, #hint-button, #reset-button, #score-counter {
        width: 100%;
        margin-left: 0;
        margin-bottom: 10px;
        box-sizing: border-box;
    }

    .modal-content {
        margin: 10% auto;
        padding: 15px;
    }

    h1 {
        font-size: 2em;
    }

    #feedback-container {
        font-size: 18px;
    }

    #pokemon-input, #mute-button, #hint-button, #reset-button, #score-counter, #achievements-button {
        font-size: 16px;
    }
}

/* Achievement Notification Banner */
#achievement-banner {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #4CAF50;
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 1000;
    font-size: 20px;
    display: flex;
    align-items: center;
    transition: top 0.5s ease-in-out;
}

#achievement-banner.show {
    top: 20px;
}

#achievement-banner svg {
    width: 30px;
    height: 30px;
    margin-right: 15px;
    stroke: white;
}

/* Achievements Modal */
#achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.achievement-badge {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: #3e3e3e;
    border: 2px outset #555;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: help;
}

.achievement-badge svg {
    width: 70%;
    height: 70%;
    stroke: #f0f0f0;
    fill: #f0f0f0;
}

.achievement-badge.locked {
    filter: grayscale(1);
    opacity: 0.4;
    background: #2a2a2a;
}

.achievement-badge .tooltip {
    visibility: hidden;
    width: 200px;
    background-color: #1c1c1c;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 10px;
    position: absolute;
    z-index: 1;
    bottom: 110%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
}

.achievement-badge:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

.achievement-badge .tooltip h4 {
    margin: 0 0 5px 0;
}

.achievement-badge .tooltip p {
    margin: 0;
    font-size: 14px;
}

#top-scores-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

#top-scores-table th, #top-scores-table td {
    border: 2px solid #555;
    padding: 8px;
    text-align: center;
}

#top-scores-table th {
    background-color: #3e3e3e;
    color: #f0f0f0;
}

#top-scores-table tbody tr:nth-child(odd) {
    background-color: #333;
}

#top-scores-table tbody tr:nth-child(even) {
    background-color: #2c2c2c;
}

#oak-modal .modal-content {
    overflow: auto; /* To contain the floated image */
}

#oak-modal img {
    image-rendering: pixelated;
}

#oak-modal-close-button, #champion-modal-close-button {
    background-color: #3e3e3e;
    color: #f0f0f0;
    border: 2px outset #555;
    padding: 10px 20px;
    font-family: "Pixelify Sans", sans-serif;
    cursor: pointer;
    font-size: 18px;
    display: block;
    margin: 20px auto 0;
}