:root {
    --pokedex-red: #d9453f;
    --pokedex-red-dark: #b82a25;
    --pokedex-screen-bg: #e0e0e0;
    --pokedex-screen-border: #4a4a4a;
    --font-color: #333;
    --disabled-color: #555;
    --disabled-bg: #222;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Press Start 2P', cursive;
    background-color: #3a3a3a;
    color: var(--font-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    overflow: hidden;
}

@media (max-width: 950px) {
    body {
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 20px 0;
        align-items: flex-start;
    }

    #pokedex {
        flex-direction: column;
        width: 95vw;
        max-width: 500px;
        padding: 0;
        transform: none;
        opacity: 1; /* Override pre-start opacity for mobile */
    }

    #pokedex.pre-start {
        opacity: 0;
        transform: scale(0.7);
        pointer-events: none;
    }

    .pokedex-left {
        width: 100%;
        border-radius: 20px 20px 0 0;
        border-right: 3px solid #000;
        border-bottom: 2px solid #6d1512;
    }

    .pokedex-right {
        width: 100%;
        border-radius: 0 0 20px 20px;
        padding-top: 20px;
        padding-bottom: 20px;
    }

    #pokedex-screen {
        height: auto;
        min-height: 380px;
        aspect-ratio: 1 / 1.05;
    }
}

#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    font-family: 'Press Start 2P', cursive;
    text-align: center;
    transition: opacity 1s ease-out;
}

#start-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

#start-screen h1 {
    font-size: 2.5em;
    text-shadow: 3px 3px 0px var(--pokedex-red);
    margin-bottom: 20px;
}

#start-screen p {
    font-size: 1.2em;
    margin-bottom: 40px;
}

#start-button {
    font-family: 'Press Start 2P', cursive;
    font-size: 1.5em;
    padding: 15px 30px;
    background-color: var(--pokedex-red);
    color: #fff;
    border: 3px solid #000;
    border-radius: 10px;
    cursor: pointer;
    text-shadow: 1px 1px 2px #000;
    animation: blink-animation 1.5s infinite;
}

#start-button:hover {
    background-color: var(--pokedex-red-dark);
}

@keyframes blink-animation {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.hidden {
    display: none !important;
}

#pokedex {
    display: flex;
    perspective: 1000px;
    justify-content: space-between;
    padding: 10px;
    position: relative;
    overflow: hidden;
    transition: opacity 1s ease-in 0.5s, transform 1s ease-in 0.5s;
    transform: scale(0.9);
    transform-origin: center;
}

.pokedex-left, .pokedex-right {
    background-color: var(--pokedex-red);
    padding: 20px;
    border: 3px solid #000;
    box-shadow: 5px 5px 10px rgba(0,0,0,0.5);
}

.pokedex-left {
    border-radius: 20px 0 0 20px;
    border-right: 2px solid #6d1512;
    z-index: 2;
    width: 480px;
}

.pokedex-right {
    border-radius: 0 20px 20px 0;
    background-color: #d13c37;
    width: 380px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    padding-top: 50px;
    padding-bottom: 50px;
}

.top-bar {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.camera-lens {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #1f68b3, #4ea5f5);
    border: 5px solid #fff;
    border-radius: 50%;
    margin-right: 15px;
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.4);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.camera-reflection {
    width: 30px;
    height: 30px;
    background-color: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    position: absolute;
    top: 15px;
    left: 15px;
    transform: rotate(-45deg);
}

.led {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    border: 2px solid #000;
    margin: 0 5px;
}
.led.red { background-color: #ff1a1a; }
.led.yellow { background-color: #ffcc00; }
.led.green { background-color: #4dff4d; }


.pokedex-screen-container {
    background-color: #b0b0b0;
    border-radius: 15px;
    padding: 15px;
    border: 2px solid #000;
    box-shadow: inset 3px 3px 5px rgba(0,0,0,0.3);
}

#pokedex-screen {
    background-color: var(--pokedex-screen-bg);
    border: 2px solid var(--pokedex-screen-border);
    border-radius: 10px;
    height: 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    position: relative;
    font-size: 1.2em;
}

.screen-header {
    width: 100%;
    text-align: center;
    padding-top: 5px;
}

.screen-header .dot {
    height: 10px;
    width: 10px;
    background-color: var(--pokedex-red);
    border-radius: 50%;
    display: inline-block;
    margin: 0 10px;
}

#menu-container {
    width: 100%;
    height: 250px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#main-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 80%;
}

#main-menu li {
    padding: 10px;
    color: #333;
    text-shadow: 1px 1px #ccc;
    cursor: pointer;
    position: relative;
    padding-left: 30px; 
}

#main-menu li.selected {
    color: #000;
    font-weight: bold;
}

.menu-selector {
    position: absolute;
    left: 0;
    top: 10px;
    width: 0;
    height: 0;
    display: inline-block;
}

#main-menu li.selected .menu-selector {
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 15px solid var(--pokedex-red);
}

#image-container {
    width: 250px;
    height: 250px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

#pokemon-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.5));
    transition: transform 0.5s ease, opacity 0.5s ease;
}

#pokemon-image.loading {
    animation: bounce 0.5s ease-in-out;
}

#pokemon-image.player-turn {
    transform: none; 
}

#pokemon-image.battle-position-player {
    position: absolute;
    bottom: -15px;
    left: -40px;
    width: 180px;
    height: 180px;
}

#opponent-pokemon-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.5));
    position: absolute;
    top: -30px;
    left: 0;
}

#opponent-pokemon-image.battle-position-opponent {
    top: 0;
    right: -40px;
    left: auto;
    width: 150px;
    height: 150px;
}

#pokemon-image.wiggling {
    animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    perspective: 1000px;
}

#pokemon-image.captured {
    transform: scale(0);
    opacity: 0;
}

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

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

#game-message-container {
    position: absolute;
    bottom: 35px;
    left: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    color: white;
    text-shadow: 1px 1px #000;
    border-radius: 5px;
    padding: 8px;
    text-align: center;
    font-size: 0.8em;
    z-index: 10;
}

#game-message.hidden {
    display: none;
}

.screen-footer {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.screen-footer .red-button {
    width: 30px;
    height: 30px;
    background-color: var(--pokedex-red);
    border: 2px solid #000;
    border-radius: 50%;
}

.screen-footer .lines {
    display: flex;
    flex-direction: column;
    grid-gap: 4px;
    align-items: flex-end;
}

.screen-footer .line {
    width: 50px;
    height: 4px;
    background-color: #333;
    border-radius: 2px;
}

.pokedex-controls-left {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 0 10px;
}

.big-button {
    width: 90px;
    height: 90px;
    background-color: var(--pokedex-red-dark);
    border-radius: 50%;
    border: 3px solid #000;
    box-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1.2;
    text-align: center;
    color: white;
    font-size: 16px;
    padding: 5px;
}
.big-button:active {
    background-color: #c93e39;
    box-shadow: inset 2px 2px 4px rgba(0,0,0,0.5);
}

.control-buttons {
    display: flex;
}

.green-button-sm, .orange-button-sm {
    width: 50px;
    height: 20px;
    border: 2px solid #000;
    border-radius: 10px;
    margin: 0 8px;
    cursor: pointer;
}
.green-button-sm { background-color: #4dff4d; }
.orange-button-sm { background-color: #ffcc00; }

.d-pad {
    position: relative;
    width: 120px;
    height: 120px;
}
.d-pad-btn {
    position: absolute;
    background-color: #333;
    box-shadow: 2px 2px 3px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: background-color 0.2s;
}
.d-pad-btn:active {
    background-color: #555;
    box-shadow: inset 1px 1px 3px rgba(0,0,0,0.6);
}
.d-pad-up, .d-pad-down { width: 40px; height: 40px; left: 40px; }
.d-pad-left, .d-pad-right { width: 40px; height: 40px; top: 40px; }
.d-pad-up { top: 0; border-radius: 5px 5px 0 0; }
.d-pad-down { bottom: 0; border-radius: 0 0 5px 5px; }
.d-pad-left { left: 0; border-radius: 5px 0 0 5px; }
.d-pad-right { right: 0; border-radius: 0 5px 5px 0; }
.d-pad-center {
    width: 40px;
    height: 40px;
    top: 40px;
    left: 40px;
    background-color: #333;
    border-radius: 2px;
}

.d-pad-btn.disabled, .big-button.disabled {
    background-color: var(--disabled-bg) !important;
    cursor: not-allowed;
    box-shadow: inset 1px 1px 3px rgba(0,0,0,0.6) !important;
}

#pokemon-info {
    background-color: #2ca59f;
    border: 2px solid #000;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    color: #fff;
    text-shadow: 1px 1px 2px #000;
    position: relative;
}

#caught-icon {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 35px;
    height: 35px;
    image-rendering: pixelated;
}

#caught-icon img {
    width: 100%;
    height: 100%;
}

#pokemon-name {
    text-transform: capitalize;
    margin-top: 0;
    font-size: 1.8em;
}

#pokemon-id {
    font-size: 1.2em;
}

#pokemon-types {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 15px 0;
}

.type-badge {
    padding: 5px 10px;
    border-radius: 5px;
    border: 1px solid rgba(0,0,0,0.5);
    color: #fff;
    text-shadow: 1px 1px 1px #000;
    font-size: 0.9em;
    text-transform: uppercase;
}
#pokemon-stats {
    background-color: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 5px;
    font-size: 1em;
}
#pokemon-stats p {
    margin: 8px 0;
}

/* Gym View */
#gym-info {
    color: #fff;
    text-shadow: 1px 1px 2px #000;
    padding: 10px;
    height: 100%;
    display: flex;
    flex-direction: column;
}
#gym-info h2 {
    text-align: center;
    margin: 10px 0 5px 0;
    font-size: 1.4em;
}
.gym-item {
    background-color: rgba(0,0,0,0.2);
    padding: 8px;
    margin-bottom: 5px;
    border-radius: 5px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: background-color 0.2s, border-color 0.2s;
    text-align: center;
    font-size: 0.9em;
}
.gym-item:hover {
    background-color: rgba(0,0,0,0.4);
    border-color: #fff;
}
.gym-item.defeated {
    background-color: rgba(0,0,0,0.5);
    color: #aaa;
    cursor: not-allowed;
    text-decoration: line-through;
}
.gym-item.defeated-replay {
    background-color: #27ae60;
    color: #fff;
    cursor: pointer;
    text-decoration: none;
}
.gym-item.defeated-replay:hover {
    background-color: #2ecc71;
    border-color: #fff;
}
.gym-item.locked {
    background-color: rgba(0,0,0,0.2);
    color: #888;
    cursor: not-allowed;
}
#badge-collection {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.badge-icon {
    width: 50px;
    height: 50px;
    image-rendering: pixelated;
}

/* Type Colors */
.type-normal { background-color: #A8A77A; }
.type-fire { background-color: #EE8130; }
.type-water { background-color: #6390F0; }
.type-electric { background-color: #F7D02C; }
.type-grass { background-color: #7AC74C; }
.type-ice { background-color: #96D9D6; }
.type-fighting { background-color: #C22E28; }
.type-poison { background-color: #A33EA1; }
.type-ground { background-color: #E2BF65; }
.type-flying { background-color: #A98FF3; }
.type-psychic { background-color: #F95587; }
.type-bug { background-color: #A6B91A; }
.type-rock { background-color: #B6A136; }
.type-ghost { background-color: #735797; }
.type-dragon { background-color: #6F35FC; }
.type-dark { background-color: #705746; }
.type-steel { background-color: #B7B7CE; }
.type-fairy { background-color: #D685AD; }

/* Inactive button styles */
#prev-btn.disabled, #next-btn.disabled {
    background-color: var(--disabled-bg);
    cursor: not-allowed;
    box-shadow: inset 1px 1px 3px rgba(0,0,0,0.6);
}

/* Pokeball animation */
#pokeball-sprite {
    position: absolute;
    width: 40px;
    height: 40px;
    z-index: 5;
    image-rendering: pixelated;
    transition: transform 0.5s ease-in-out, opacity 0.5s ease;
}

#pokeball-sprite.throw {
    animation: throw-anim 0.5s ease-out forwards;
}

#pokeball-sprite.wobble {
    animation: wobble-anim 1.5s ease-in-out forwards;
}

#pokeball-sprite.captured-ball {
    transform: scale(1.2);
    animation: none;
}

#pokeball-sprite.break-free {
    animation: break-free-anim 0.5s ease-out forwards;
}

@keyframes throw-anim {
    0% { transform: translate(-150px, -150px) scale(0.5) rotate(-180deg); opacity: 1; }
    100% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 1; }
}

@keyframes wobble-anim {
    0% { transform: rotate(0deg); }
    15% { transform: rotate(-15deg); }
    30% { transform: rotate(15deg); }
    45% { transform: rotate(-10deg); }
    60% { transform: rotate(10deg); }
    75% { transform: rotate(0deg); }
    100% { transform: rotate(0deg); }
}

@keyframes break-free-anim {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(2); opacity: 0.5; }
}

/* Battle UI */
.battle-stats {
    position: absolute;
    background: #f8f8f8;
    border: 3px solid #666;
    border-radius: 10px;
    padding: 5px;
    width: 180px;
    font-size: 0.8em;
    text-transform: uppercase;
    box-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    z-index: 1; 
}

#battle-stats-player {
    bottom: 5px;
    left: -50px;
}

#battle-stats-opponent {
    top: 5px;
    right: -50px;
}

.stat-name-hp {
    display: flex;
    flex-direction: column;
}

.hp-bar-container {
    background-color: #555;
    border: 1px solid #333;
    border-radius: 5px;
    height: 10px;
    margin-top: 5px;
    overflow: hidden;
}

.hp-bar {
    background-color: #32ff7e;
    height: 100%;
    width: 100%;
    transition: width 0.5s ease-in-out;
}

/* Victory Screen */
#victory-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #4a90e2, #88c1f9);
    color: white;
    text-shadow: 2px 2px 2px #333;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    z-index: 50;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity 1s ease-in;
}

#victory-screen.visible {
    opacity: 1;
}

#victory-image {
    width: 80%;
    max-width: 300px;
    margin-bottom: 10px;
    transform: scale(0);
    animation: victory-title-anim 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.5s forwards;
}

#victory-text {
    font-size: 1.2em;
    margin-bottom: 15px;
    opacity: 0;
    animation: fade-in 1s ease 1.5s forwards;
}

#victory-badge-container {
    opacity: 0;
    animation: fade-in 1s ease 2s forwards;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#victory-badge-container p {
    font-size: 0.9em;
    margin-bottom: 5px;
}

#victory-badge {
    width: 60px;
    height: 60px;
    image-rendering: pixelated;
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));
}

#victory-pokemon-team {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    opacity: 0;
    animation: fade-in 1s ease 2.5s forwards;
}

.victory-pokemon {
    width: 50px;
    height: 50px;
    image-rendering: pixelated;
    animation: team-bounce-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

#victory-final-message {
    margin-top: 20px;
    font-size: 0.8em;
    opacity: 0;
    animation: fade-in 1s ease 3.5s forwards;
}

@keyframes victory-title-anim {
    from { transform: scale(0) rotate(-180deg); }
    to { transform: scale(1) rotate(0deg); }
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes team-bounce-in {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

/* Proposal Styles */
#proposal-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 100%;
    opacity: 0;
    animation: fade-in 1s ease forwards;
}

#proposal-text {
    font-size: 1.2em;
    margin-bottom: 20px;
}

#proposal-question {
    font-size: 1.4em;
    margin-bottom: 30px;
    font-weight: bold;
}

#proposal-buttons {
    display: flex;
    gap: 20px;
}

#proposal-buttons button {
    font-family: 'Press Start 2P', cursive;
    font-size: 1.5em;
    padding: 15px 30px;
    color: #fff;
    border: 3px solid #000;
    border-radius: 10px;
    cursor: pointer;
    text-shadow: 1px 1px 2px #000;
    transition: transform 0.2s ease-in-out, background-color 0.2s;
}

#yes-btn {
    background-color: #2ecc71; /* Green */
}

#yes-btn:hover {
    background-color: #27ae60;
}

#no-btn {
    background-color: #e74c3c; /* Red */
}

#no-btn:hover {
    background-color: #c0392b;
}

#download-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 1.2em;
    padding: 10px 20px;
    color: #fff;
    border: 3px solid #000;
    border-radius: 10px;
    cursor: pointer;
    text-shadow: 1px 1px 2px #000;
    transition: transform 0.2s ease-in-out, background-color 0.2s;
    background-color: #3498db; /* Blue */
    margin-top: 15px;
    animation: fade-in 1s ease forwards;
}

#download-btn:hover {
    background-color: #2980b9;
}

#love-image {
    width: 80%;
    max-width: 300px;
    opacity: 0;
    animation: fade-in 1s ease forwards, team-bounce-in 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}