:root {
    --primary: #2c3e50;
    --accent: #3498db;
    --success: #2ecc71;
    --gold: #f1c40f;
    --island-sand: #f3e5ab;
    --ocean-blue: #0077be;
    --glass: rgba(255, 255, 255, 0.2);
    --glass-heavy: rgba(255, 255, 255, 0.8);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
}

#app {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 20px;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 10;
}


.stats {
    background: rgba(255, 255, 255, 0.92);
    padding: 12px 25px;
    border-radius: 20px;
    display: flex;
    gap: 25px;
    pointer-events: auto;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.stats:hover {
    background: #ffffff;
    border-color: var(--primary);
}

.top-rights {
    display: flex;
    gap: 15px;
    align-items: center;
    pointer-events: auto;
}

.stat-item {
    font-weight: bold;
    font-size: 1.2rem;
    color: var(--primary);
}

.stat-item.clock {
    color: var(--accent);
    min-width: 100px;
    text-align: right;
}

.btn-circular {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    cursor: pointer;
    pointer-events: auto;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-circular:hover {
    transform: scale(1.15) rotate(5deg);
    background: #f0f7ff;
    border-color: var(--primary);
    box-shadow: 0 0 30px rgba(52, 152, 219, 0.3);
}

#message-container {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
}

.message {
    background: #ffffff;
    color: var(--primary);
    padding: 8px 16px;
    border-radius: 20px;
    margin-top: 5px;
    animation: fadeInOut 2s forwards;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.message.boss {
    background: linear-gradient(45deg, #ff0000, #990000);
    color: white;
    font-size: 1.5rem;
    font-weight: 900;
    padding: 15px 30px;
    border: 3px solid #ffcc00;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    animation: fadeInOut 4s forwards, pulse 0.5s infinite alternate;
}

@keyframes pulse {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.05);
    }
}

@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;
}

#sound-toggle {
    font-size: 1.5rem;
    margin-bottom: 0;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 32px;
    min-width: 320px;
    max-width: 550px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    transform: translateY(20px) scale(0.95);
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.modal:not(.hidden) .modal-content {
    transform: translateY(0) scale(1);
}

.hidden:not(.modal) {
    display: none !important;
}


.modal-content h3 {
    margin-bottom: 20px;
    color: var(--primary);
}

.close-btn,
#sell-all-btn {
    margin-top: 20px;
    padding: 10px 25px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.close-btn {
    background: #eee;
}

.close-btn:hover {
    background: #ddd;
}

#sell-all-btn {
    background: var(--success);
    color: white;
}

#sell-all-btn:hover {
    background: #27ae60;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    margin: 20px 0;
    max-height: 250px;
    overflow-y: auto;
    padding: 10px;
}

.inv-item {
    background: #f1f5f9;
    padding: 12px;
    border-radius: 12px;
    font-size: 13px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.fish-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.fish-details {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
}

.fish-name {
    font-weight: 700;
    color: #1a202c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fish-rarity {
    font-size: 11px;
    color: #718096;
}

.sell-btn-small {
    background: var(--success);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.sell-btn-small:hover {
    background: #27ae60;
}

.inv-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}



#interact-prompt {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    font-weight: bold;
    border: 2px solid white;
    pointer-events: none;
    z-index: 20;
    transition: opacity 0.2s;
}

#npc-dialogue {
    position: absolute;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    color: var(--primary);
    padding: 15px 25px;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    min-width: 250px;
    text-align: center;
    border-bottom: 5px solid var(--accent);
    pointer-events: none;
    z-index: 15;
}

#npc-name {
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
    color: var(--accent);
}

#leaderboard {
    position: absolute;
    top: 90px;
    right: 25px;
    background: rgba(255, 255, 255, 0.92);
    padding: 18px;
    border-radius: 20px;
    width: 280px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
    transition: all 0.3s ease;
}

#leaderboard h4 {
    margin-bottom: 10px;
    text-align: center;
    color: var(--primary);
}

.lb-entry {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    padding: 5px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.lb-entry:last-child {
    border-bottom: none;
}

/* Ultra Smooth Shop UI */
#shop-modal .modal-content {
    background: #ffffff;
    border-radius: 40px;
    padding: 45px;
    max-width: 600px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 50px 100px rgba(0, 0, 0, 0.15);
}

.shop-tabs {
    display: flex;
    background: #f1f5f9;
    padding: 6px;
    border-radius: 20px;
    margin-bottom: 30px;
}

.tab-btn {
    flex: 1;
    padding: 14px;
    border-radius: 14px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    color: #64748b;
    border: none;
    cursor: pointer;
    background: transparent;
}

.tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 8px 16px rgba(52, 152, 219, 0.15);
}

.shop-view {
    animation: fadeSlideIn 0.5s ease;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.upgrade-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.upgrade-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    padding: 24px;
    border-radius: 24px;
    border: 1px solid #f1f5f9;
    transition: all 0.3s ease;
}

.upgrade-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    border-color: rgba(52, 152, 219, 0.2);
}

.upgrade-info h4 {
    color: #1a202c;
    font-size: 1.15rem;
    margin-bottom: 4px;
    margin-top: 0;
    text-align: left;
}

.upgrade-info p {
    color: #718096;
    font-size: 0.9rem;
    margin: 0;
}

.upgrade-info b {
    color: var(--primary);
    font-weight: 800;
}

.buy-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
}

.buy-btn:hover:not(:disabled) {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.buy-btn:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    box-shadow: none;
    cursor: not-allowed;
}

/* Start Screen Overlay */
#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.start-content {
    text-align: center;
    color: white;
    background: rgba(255, 255, 255, 0.95);
    padding: 50px 70px;
    border-radius: 30px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.1);
    animation: fadeInUp 0.8s ease-out;
    max-width: 90%;
    pointer-events: auto;
}

.start-content h1 {
    font-size: 4rem;
    margin-bottom: 10px;
    color: var(--primary);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.start-content p {
    font-size: 1.4rem;
    margin-bottom: 30px;
    color: #4a5568;
}

.controls-hint {
    background: rgba(0, 0, 0, 0.05);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 40px;
    font-size: 1rem;
    color: var(--primary);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.controls-hint p {
    margin: 5px 0;
}

#start-btn,
#restart-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 18px 50px;
    font-size: 1.6rem;
    border-radius: 60px;
    cursor: pointer;
    font-weight: 800;
    box-shadow: 0 10px 25px rgba(52, 152, 219, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#start-btn:hover,
#restart-btn:hover {
    transform: scale(1.08) translateY(-3px);
    box-shadow: 0 15px 35px rgba(52, 152, 219, 0.5);
    background: #2980b9;
}

/* Game Over Modal Styling */
#game-over-modal {
    z-index: 10000;
}

#game-over-modal .modal-content {
    background: #ffffff;
    padding: 50px;
    border-radius: 30px;
    text-align: center;
    color: var(--primary);
    min-width: 450px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

#game-stats {
    margin: 30px 0;
    text-align: left;
    background: rgba(255, 255, 255, 0.5);
    padding: 25px;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 1.1rem;
}

.stat-row:last-child {
    border-bottom: none;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Leaderboard & Index Badges */
.badge {
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.6rem;
    font-weight: bold;
    text-transform: uppercase;
}

.lb-pts {
    background: var(--primary);
    color: white;
}

.lb-rarity-row {
    display: flex;
    gap: 8px;
    margin: 2px 0;
    font-size: 0.75rem;
}

.lb-rarity-row span {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* Fish Index Styles */
.index-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px 5px;
}

.index-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.index-item.locked {
    opacity: 0.6;
    filter: grayscale(1);
    background: rgba(0, 0, 0, 0.05);
}

.index-item.caught {
    background: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--primary);
}

.index-icon {
    font-size: 1.5rem;
}

.index-info {
    display: flex;
    flex-direction: column;
}

.index-name {
    font-weight: bold;
    font-size: 0.85rem;
    color: var(--primary);
}

.index-rarity {
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: bold;
    margin-top: 2px;
}

.index-rarity.common {
    color: #7f8c8d;
}

.index-rarity.rare {
    color: #3498db;
}

.index-rarity.legend {
    color: #f1c40f;
}

.index-rarity.boss {
    color: #e74c3c;
}

.sell-btn-large {
    width: 100%;
    padding: 15px;
    margin-top: 15px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sell-btn-large:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.4);
}

.fish-icon-inline {
    font-size: 2.2rem;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 20px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
    flex-shrink: 0;
}

.upgrade-item.locked {
    background: #f1f5f9;
    border-color: #e2e8f0;
    cursor: not-allowed;
    pointer-events: none;
}

.upgrade-item.locked .buy-btn {
    background: #cbd5e0;
    color: #718096;
    cursor: not-allowed;
}

.upgrade-item.locked:hover {
    transform: none;
    box-shadow: none;
}

/* Mobile Controls */
#mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

#joystick-container {
    position: absolute;
    bottom: 40px;
    left: 40px;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.85);
    /* More solid */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.5);
    pointer-events: auto;
    touch-action: none;
}

#joystick-base {
    width: 120px;
    height: 120px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    position: relative;
}

#joystick-knob {
    width: 60px;
    height: 60px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

#mobile-actions {
    position: absolute;
    bottom: 50px;
    right: 50px;
    pointer-events: auto;
}

.mobile-btn {
    width: 90px;
    height: 90px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    user-select: none;
    touch-action: none;
}

.mobile-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.3);
}

/* Detect Touch Support & Mobile Responsiveness */
@media (hover: none) and (pointer: coarse) {
    #mobile-controls:not(.hidden) {
        display: block !important;
    }

    .stats {
        gap: 12px;
        padding: 8px 15px;
        font-size: 0.9rem;
    }

    .stat-item {
        font-size: 1rem;
    }

    .top-rights {
        gap: 8px;
    }

    .btn-circular {
        width: 50px;
        height: 50px;
        font-size: 1.4rem;
    }

    #joystick-container {
        width: 120px;
        height: 120px;
        bottom: 30px;
        left: 30px;
    }

    #joystick-base {
        width: 100px;
        height: 100px;
    }

    #mobile-actions {
        bottom: 30px;
        right: 30px;
    }

    .mobile-btn {
        width: 80px;
        height: 80px;
        font-size: 2.2rem;
    }

    /* Responsive Modals */
    .modal-content,
    #shop-modal .modal-content {
        padding: 25px 20px;
        border-radius: 24px;
        width: 92%;
        max-width: 95%;
        margin: 0 10px;
    }

    .modal-content h2,
    .modal-content h3 {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }

    .shop-tabs {
        padding: 4px;
        margin-bottom: 15px;
    }

    .tab-btn {
        padding: 10px;
        font-size: 0.85rem;
    }

    .inventory-grid,
    .index-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 8px;
        max-height: 50vh;
    }

    .inv-item,
    .index-item {
        padding: 10px;
        font-size: 0.8rem;
    }

    .upgrade-item {
        padding: 15px;
        border-radius: 18px;
    }

    .upgrade-info h4 {
        font-size: 1rem;
    }

    .upgrade-info p {
        font-size: 0.8rem;
    }

    .buy-btn {
        padding: 10px 15px;
        font-size: 0.8rem;
    }
}

/* Leaderboard Toggle styling */
#lb-toggle-btn {
    transition: transform 0.3s ease;
}

#leaderboard.collapsed {
    width: auto;
    min-width: 180px;
}

#leaderboard.collapsed #leaderboard-entries {
    display: none;
}

#leaderboard.collapsed #lb-toggle-btn {
    transform: rotate(-90deg);
}

.lb-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 8px;
    margin-bottom: 5px;
}

#leaderboard.collapsed .lb-header {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}