* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    min-height: 100vh;
    overflow: hidden;
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none !important;
    padding: 20px;
    overflow-y: auto;
    z-index: 1;
}

.screen.active {
    display: block !important;
    z-index: 10;
}

#title-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: radial-gradient(circle, #2a5298 0%, #1e3c72 100%);
}

.title-fish {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 50px;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.title-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

#title-fish-left {
    width: 120px;
    height: 120px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    filter: hue-rotate(0deg) saturate(1.2);
    animation: float 3s ease-in-out infinite;
}

#title-fish-right {
    width: 120px;
    height: 120px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    filter: hue-rotate(180deg) saturate(1.3);
    transform: scaleX(-1);
    animation: float 3s ease-in-out infinite 1.5s;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

#title-fish-right {
    animation: float-flipped 3s ease-in-out infinite 1.5s;
}

@keyframes float-flipped {
    0%, 100% { transform: scaleX(-1) translateY(0px); }
    50% { transform: scaleX(-1) translateY(-10px); }
}

#title-screen h1 {
    font-size: 4rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

#title-screen p {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

button {
    background: linear-gradient(45deg, #ff6b6b, #ff8e8e);
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

button:disabled {
    background: #666;
    cursor: wait;
    transform: none;
    opacity: 0.6;
}

#character-creation {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

#character-creation h2 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    text-align: center;
}

.character-form {
    background: rgba(255,255,255,0.1);
    padding: 30px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    max-width: 500px;
    width: 100%;
    margin: 0 auto;
    text-align: center;
}

.character-form label {
    display: block;
    margin: 20px 0 10px;
    font-size: 1.2rem;
    font-weight: bold;
}

#betta-name {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 10px;
}

.random-name-button {
    background: linear-gradient(45deg, #4CAF50, #66BB6A);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
    width: 100%;
}

.random-name-button:hover {
    background: linear-gradient(45deg, #45a049, #5cb85c);
    transform: translateY(-1px);
}

.color-selection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 10px;
    margin: 15px 0;
}

.color-option {
    padding: 15px 10px;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.color-option:hover {
    transform: scale(1.05);
    border-color: white;
}

.color-option.selected {
    border-color: #ffff00;
    box-shadow: 0 0 15px rgba(255,255,0,0.5);
}

#character-preview {
    text-align: center;
    margin: 20px 0;
    padding: 20px;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
}

#betta-preview {
    width: 96px;
    height: 96px;
    margin: 0 auto 10px;
    transition: all 0.3s ease;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#village h2, #world-map h2, #combat h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 20px;
}

.location-description {
    background: rgba(255,255,255,0.1);
    padding: 20px;
    border-radius: 10px;
    margin: 0 auto 20px;
    text-align: center;
    max-width: 600px;
}

.village-locations {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px auto;
    max-width: 600px;
}

.village-center {
    grid-column: 1 / -1;
    max-width: 280px;
    margin: 0 auto;
}

.village-exit {
    display: flex;
    justify-content: center;
    margin: 20px auto;
    max-width: 600px;
}

.village-exit .location {
    max-width: 280px;
}

.location {
    background: rgba(255,255,255,0.1);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.location:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.3);
    transform: translateY(-2px);
}

#player-stats {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0,0,0,0.7);
    padding: 15px;
    border-radius: 10px;
    z-index: 1000;
    display: none;
    align-items: center;
    gap: 15px;
    min-width: 200px;
}

#player-stats.show {
    display: flex;
}

.stats-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.stat {
    margin: 0;
    font-weight: bold;
    text-align: left;
    font-size: 0.9rem;
}

.player-name-stat {
    font-size: 1.1rem;
    color: #4488ff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 3px;
    margin-bottom: 3px;
}

#stats-player-sprite {
    width: 64px;
    height: 64px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.6));
    flex-shrink: 0;
}

#version-info {
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    z-index: 500;
    font-family: monospace;
}

#dialogue-box {
    max-width: 600px;
    margin: 100px auto;
    background: rgba(0,0,0,0.9);
    padding: 30px;
    border-radius: 15px;
    border: 3px solid #4488ff;
}

#npc-name {
    font-size: 1.5rem;
    font-weight: bold;
    color: #4488ff;
    margin-bottom: 15px;
    display: block;
}

#dialogue-text {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 20px;
    min-height: 100px;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#dialogue-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dialogue-option {
    background: rgba(68, 136, 255, 0.2);
    border: 2px solid #4488ff;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.dialogue-option:hover {
    background: rgba(68, 136, 255, 0.4);
}

.map-navigation {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 30px 0;
    gap: 10px;
}

.nav-row {
    display: flex;
    gap: 10px;
    align-items: center;
    position: relative;
    z-index: 100;
}

.nav-row button {
    min-width: 140px;
    position: relative;
    z-index: 100;
}

#encounter-log, #village-encounter-log, #combat-log {
    width: 700px;
    margin: 0 auto 30px;
    background: rgba(0,0,0,0.5);
    padding: 15px;
    border-radius: 10px;
    max-height: 150px;
    overflow-y: auto;
    position: relative;
    z-index: 10;
}

#combat-log {
    background: rgba(0,0,0,0.7);
    max-height: 160px;
    font-size: 0.9rem;
    order: 3;
    margin: 0 auto 20px;
}

/* Position logs at bottom on world map and village screens */
#world-map #encounter-log,
#village #village-encounter-log {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
}

.log-entry {
    margin: 5px 0;
    padding: 5px;
    border-left: 3px solid #4488ff;
    padding-left: 10px;
}

.log-entry:first-child {
    font-weight: bold;
    color: #ffffff;
}

.log-entry:not(:first-child) {
    color: #aaaaaa;
    opacity: 0.8;
}


.combatants {
    display: flex;
    justify-content: space-around;
    margin: 30px 0;
    order: 1;
}

.player-combat, .enemy-combat {
    text-align: center;
    background: rgba(255,255,255,0.1);
    padding: 20px;
    border-radius: 10px;
    min-width: 200px;
}

#player-fish-combat {
    width: 72px;
    height: 72px;
    margin: 0 auto 10px;
    transition: transform 0.1s ease;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#player-fish-combat.submarine {
    width: 96px;
    height: 96px;
}

#enemy-fish-combat {
    width: 72px;
    height: 72px;
    margin: 0 auto 10px;
    transform: scaleX(-1);
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#player-fish-combat.shake {
    animation: shake 0.5s ease-in-out;
}

#enemy-fish-combat.shake {
    animation: shake-enemy 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px) rotate(-2deg); }
    75% { transform: translateX(5px) rotate(2deg); }
}

@keyframes shake-enemy {
    0%, 100% { transform: scaleX(-1) translateX(0); }
    25% { transform: scaleX(-1) translateX(-5px) rotate(-2deg); }
    75% { transform: scaleX(-1) translateX(5px) rotate(2deg); }
}

.hp-bar {
    width: 100%;
    height: 20px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    margin: 10px 0;
    overflow: hidden;
}

.hp-fill {
    height: 100%;
    background: linear-gradient(45deg, #4CAF50, #8BC34A);
    transition: width 0.3s ease;
    width: 100%;
}

#combat {
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#combat-area {
    display: flex;
    flex-direction: column;
}

#combat.combat-over {
    cursor: wait !important;
}

#combat.combat-over * {
    cursor: wait !important;
}

.combat-actions {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    margin: 20px 0;
    order: 2;
}

.spell-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.enemy-level-display {
    font-size: 0.9rem;
    color: #ffaa00;
    font-weight: bold;
    margin: 5px 0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
}

.combat-actions button {
    margin: 0 5px;
    background: linear-gradient(45deg, #4488ff, #6699ff);
}

.swim-away-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.swim-away-message {
    text-align: center;
    font-size: 0.9rem;
    color: #ffaa00;
    font-weight: bold;
    margin-top: 10px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
}

.log-entry {
    margin: 5px 0;
    padding: 5px;
    border-left: 3px solid #4488ff;
    padding-left: 10px;
}

/* Congratulations Popup */
.congratulations-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.congratulations-popup.show {
    display: flex;
    animation: fadeIn 0.5s ease-in-out;
}

.popup-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    max-width: 500px;
    border: 3px solid #fff;
    animation: popIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.popup-text h1 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: bounce 1s infinite alternate;
}

.popup-text p {
    font-size: 1.3rem;
    margin-bottom: 15px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.popup-text .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-style: italic;
}

.popup-text .dev-note {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-bottom: 30px;
}

.celebration-button {
    background: linear-gradient(45deg, #4a90e2, #007acc);
    border: none;
    padding: 15px 30px;
    border-radius: 30px;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(74, 144, 226, 0.3);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.celebration-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(74, 144, 226, 0.4);
}

/* Confetti Animation */
.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #ffdf00;
    animation: confetti-fall 3s linear infinite;
}

.confetti:nth-child(1) {
    left: 10%;
    animation-delay: 0s;
    background: #ff6b6b;
}

.confetti:nth-child(2) {
    left: 20%;
    animation-delay: 0.5s;
    background: #4ecdc4;
}

.confetti:nth-child(3) {
    left: 30%;
    animation-delay: 1s;
    background: #45b7d1;
}

.confetti:nth-child(4) {
    left: 40%;
    animation-delay: 1.5s;
    background: #96ceb4;
}

.confetti:nth-child(5) {
    left: 60%;
    animation-delay: 2s;
    background: #ffeaa7;
}

.confetti:nth-child(6) {
    left: 70%;
    animation-delay: 2.5s;
    background: #fd79a8;
}

.confetti:nth-child(7) {
    left: 80%;
    animation-delay: 0.3s;
    background: #a29bfe;
}

.confetti:nth-child(8) {
    left: 90%;
    animation-delay: 1.8s;
    background: #fd79a8;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popIn {
    0% {
        transform: scale(0.3) rotate(-15deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.05) rotate(5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes bounce {
    0% { transform: translateY(0px); }
    100% { transform: translateY(-10px); }
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.rice-paddy-tuft {
    width: 48px;
    height: 48px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    opacity: 0.8;
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3));
    z-index: 1;
}

.betta-village {
    width: 100px;
    height: 100px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    filter: drop-shadow(3px 3px 6px rgba(0,0,0,0.4));
}

.map-player {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    filter: drop-shadow(1px 1px 3px rgba(0,0,0,0.5));
    transition: all 0.3s ease;
}

.map-player.submarine {
    width: 48px;
    height: 48px;
}

/* Shop UI Styling */
.shop-header {
    font-size: 1.3rem;
    font-weight: bold;
    color: #4CAF50;
    margin-bottom: 15px;
    text-align: center;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.shop-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 15px 0;
}

.shop-item {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 12px;
    transition: all 0.3s ease;
}

.shop-item-buyable {
    cursor: pointer;
    background: rgba(68, 136, 255, 0.1);
    border-color: rgba(68, 136, 255, 0.3);
}

.shop-item-buyable:hover {
    background: rgba(68, 136, 255, 0.2);
    border-color: rgba(68, 136, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(68, 136, 255, 0.2);
}

.shop-item-disabled {
    cursor: not-allowed;
}

.item-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: #fff;
    margin-bottom: 5px;
}

.item-description {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.8);
    margin-bottom: 8px;
    font-style: italic;
}

.item-price {
    font-size: 1rem;
    font-weight: bold;
    color: #ffaa00;
    text-align: right;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.shop-footer {
    font-size: 1rem;
    font-weight: bold;
    color: #4CAF50;
    text-align: center;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.2);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

/* Bubble Effect */
.bubble-effect {
    position: fixed;
    width: 12px;
    height: 12px;
    background: rgba(173, 216, 230, 0.8);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9998;
    animation: bubble-rise 2s ease-out forwards;
}

@keyframes bubble-rise {
    0% {
        opacity: 1;
        transform: translateY(0px) scale(0.5);
    }
    50% {
        opacity: 0.8;
        transform: translateY(-50vh) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-100vh) scale(1.5);
    }
}

/* Gravel Effect */
.gravel-particle {
    position: fixed;
    width: 4px;
    height: 4px;
    background: #8B4513;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9998;
}

.gravel-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9997;
}

@keyframes gravel-fall {
    0% {
        transform: translateY(-20px) translateX(0px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) translateX(var(--drift)) rotate(360deg);
        opacity: 0.3;
    }
}

/* Giant Gar Effect */
@keyframes giant-gar-swim {
    0% {
        transform: translateX(600px) scaleX(-1);
        opacity: 0.8;
    }
    20% {
        opacity: 1;
    }
    50% {
        transform: translateX(-50vw) scaleX(-1);
        opacity: 1;
    }
    80% {
        opacity: 1;
    }
    100% {
        transform: translateX(calc(-100vw - 600px)) scaleX(-1);
        opacity: 0.8;
    }
}

@media (max-width: 768px) {
    #title-screen h1 {
        font-size: 2.5rem;
    }
    
    .title-fish {
        flex-direction: column;
        gap: 20px;
    }
    
    #title-fish-left, #title-fish-right {
        width: 80px;
        height: 80px;
    }
    
    #title-fish-right {
        transform: scaleX(-1) scaleY(-1);
    }
    
    @keyframes float-flipped {
        0%, 100% { transform: scaleX(-1) scaleY(-1) translateY(0px); }
        50% { transform: scaleX(-1) scaleY(-1) translateY(-10px); }
    }
    
    .character-form {
        margin: 0 10px;
        padding: 20px;
    }
    
    .village-locations {
        max-width: 400px;
        gap: 10px;
    }
    
    .village-exit {
        max-width: 400px;
    }
    
    .village-center {
        max-width: 190px;
    }
    
    .village-exit .location {
        max-width: 190px;
    }
    
    .location {
        padding: 15px;
        font-size: 0.9rem;
    }
    
    #player-stats {
        position: static;
        margin: 20px auto;
        max-width: 300px;
        gap: 8px;
    }
    
    #stats-player-sprite {
        width: 48px;
        height: 48px;
    }
    
    #version-info {
        font-size: 0.8rem;
    }
    
    .combatants {
        flex-direction: column;
        gap: 20px;
    }
}