:root {
    --primary-color: #4facfe;
    --secondary-color: #00f2fe;
    --water-top: #00c6ff;
    --water-deep: #0072ff;
    --text-color: #ffffff;
    --ui-bg: rgba(0, 0, 0, 0.6);
    --btn-bg: #ff9800;
    --btn-hover: #f57c00;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Fredoka', sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: #222;
    color: var(--text-color);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

header {
    background: rgba(0, 0, 0, 0.4);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    height: 60px;
}

h1 {
    font-size: 24px;
    color: #fff;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.3);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

#stats-bar {
    font-size: 18px;
    font-weight: 500;
    display: flex;
    gap: 15px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: transform 0.1s, background 0.2s;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.95);
}

.secondary-btn {
    background: #444;
    color: #fff;
}

.primary-btn {
    background: var(--btn-bg);
    color: #fff;
}

#game-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    background: linear-gradient(to bottom, #87CEEB 0%, #B0E0E6 20%, #0072ff 100%); /* Fallback/Sky */
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through to canvas mostly */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 40px;
}

#top-controls {
    pointer-events: auto;
    margin-top: 10px;
    margin-right: 10px;
    align-self: flex-end;
    display: flex;
    gap: 10px;
}

#controls-container {
    pointer-events: auto;
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 40px;
    gap: 20px;
    margin-bottom: 20px;
}

#joystick-area {
    position: relative;
    width: 120px;
    height: 120px;
}

#joystick-base {
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    position: relative;
    touch-action: none; /* Prevent scroll */
}

#joystick-stick {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    position: absolute;
    top: 35px;
    left: 35px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    pointer-events: none;
}

#action-buttons {
    display: flex;
    gap: 20px;
}

.control-btn {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 4px solid #fff;
    color: white;
    font-size: 20px;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    transition: transform 0.1s, opacity 0.2s, background 0.2s;
}

.control-btn:active {
    transform: scale(0.95);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #555 !important;
    border-color: #888;
}

.control-btn-left {
    background: var(--btn-bg);
}

.control-btn-right {
    background: #4caf50;
}

/* Mobile Header Tweaks */
@media (max-width: 600px) {
    header {
        padding: 5px 10px;
        height: auto;
        flex-wrap: wrap;
    }

    h1 {
        font-size: 18px;
        width: 100%;
        text-align: center;
        margin-bottom: 5px;
    }

    .header-controls {
        width: 100%;
        justify-content: space-between;
    }

    #stats-bar {
        font-size: 14px;
        gap: 10px;
    }

    #best-catch-container {
        display: none !important; /* Hide best catch on small screens to save space */
    }

    #controls-container {
        padding: 0 10px;
    }

    .control-btn {
        width: 80px;
        height: 80px;
        font-size: 16px;
    }

    #joystick-area, #joystick-base {
        width: 100px;
        height: 100px;
    }

    #joystick-stick {
        width: 40px;
        height: 40px;
        top: 28px;
        left: 28px;
    }
}

/* Tension Meter */
#tension-container {
    pointer-events: auto;
    width: 300px;
    height: 40px;
    background: rgba(0,0,0,0.5);
    border-radius: 20px;
    padding: 5px;
    position: absolute;
    bottom: 180px; /* Above the button */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hidden {
    display: none !important;
}

#tension-bar-bg {
    width: 100%;
    height: 20px;
    background: #333;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

#tension-bar-fill {
    height: 100%;
    width: 0%; /* JS will control this */
    background: linear-gradient(to right, #4caf50, #ffeb3b, #f44336);
    transition: width 0.1s linear;
}

#tension-label {
    font-size: 12px;
    color: #fff;
    margin-top: 2px;
    letter-spacing: 1px;
}

#message-area {
    position: absolute;
    top: 20%;
    width: 100%;
    text-align: center;
    font-size: 32px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    pointer-events: none;
}

/* Modal */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    pointer-events: auto;
}

.modal-content {
    background: #333;
    padding: 20px;
    border-radius: 15px;
    width: 90%;
    max-width: 600px;
    color: white;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.large-modal {
    max-width: 800px;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    border-bottom: 1px solid #555;
    padding-bottom: 10px;
    overflow-x: auto;
}

.tab-btn {
    background: #444;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    color: #ccc;
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
    white-space: nowrap;
}

.tab-btn.active {
    background: var(--btn-bg);
    color: #fff;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 5px;
}

.item-card {
    background: #444;
    padding: 15px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    border: 2px solid transparent;
}

.item-card.equipped {
    border-color: #4caf50;
    background: #385038;
}

.item-card h4 {
    margin: 0;
    color: #fff;
}

.item-stats {
    font-size: 12px;
    color: #ccc;
}

.item-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
}

.btn-equip {
    background: #4caf50;
    color: white;
}

.btn-buy {
    background: var(--btn-bg);
    color: white;
}

.item-card.equipped .btn-equip {
    background: #666;
    cursor: default;
}

/* Journal */
.journal-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #555;
    border-radius: 5px;
}

.journal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    color: #fff;
}

.journal-table th, .journal-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #444;
}

.journal-table th {
    background: #444;
    position: sticky;
    top: 0;
}

.journal-table tr:nth-child(even) {
    background: rgba(255,255,255,0.05);
}

@media (max-width: 600px) {
    .journal-table {
        font-size: 11px;
    }
    .journal-table th, .journal-table td {
        padding: 5px;
    }
}
