:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden; /* Prevent scrolling */
    width: 100vw;
    height: 100vh;
    touch-action: none; /* Prevent pull-to-refresh and browser gestures */
    overscroll-behavior: none;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

canvas#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated; /* Good for 2D retro feel */
}

/* UI Layer covering the canvas */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through to canvas when exploring */
}

/* Glassmorphism utility */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 12px;
}

/* Top Displays */
#coin-display, #inventory-display, #score-display {
    position: absolute;
    right: 20px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.2rem;
    font-weight: 600;
}

#score-display {
    top: 160px;
    cursor: pointer;
    pointer-events: auto;
    transition: background-color 0.2s;
}

#score-display:hover {
    background: rgba(15, 23, 42, 0.8);
}

#coin-display {
    top: 110px;
}

#inventory-display {
    top: 60px;
}

#music-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    pointer-events: auto;
    transition: background-color 0.2s;
}

#music-toggle:hover {
    background: rgba(15, 23, 42, 0.8);
}

#music-toggle.playing {
    border-color: var(--success);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

/* Action Prompt */
#action-prompt {
    position: absolute;
    top: 65%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 10px 20px;
    background-color: rgba(0,0,0,0.7);
    border-radius: 30px;
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: opacity 0.2s;
    animation: float 2s infinite ease-in-out;
}

kbd {
    background-color: #f8fafc;
    color: #0f172a;
    padding: 4px 10px;
    border-radius: 6px;
    border-bottom: 3px solid #cbd5e1;
    font-family: monospace;
    font-size: 1.1rem;
}

/* Modals */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto; /* Catch clicks */
    z-index: 10;
}

.modal-content {
    padding: 30px;
    width: 400px;
    max-width: 90%;
    text-align: center;
    animation: scaleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-content h2 {
    font-size: 2rem;
    margin-bottom: 10px;
    color: var(--warning);
}

.merchant-stats {
    margin: 20px 0;
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 8px;
}

.stat {
    margin: 5px 0;
    font-size: 1.1rem;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

button {
    font-family: inherit;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, filter 0.2s;
}

button:active {
    transform: scale(0.95);
}

button:hover {
    filter: brightness(1.1);
}

.primary-btn {
    background-color: var(--primary);
    color: white;
}
.primary-btn:disabled {
    background-color: #475569;
    color: #94a3b8;
    cursor: not-allowed;
    transform: none;
}

.secondary-btn {
    background-color: transparent;
    border: 1px solid var(--text-color);
    color: var(--text-color);
}

/* Fishing Mini-Game */
#fishing-minigame {
    position: absolute;
    bottom: 120px; /* Above the hotbar */
    left: 50%;
    transform: translateX(-50%);
    pointer-events: auto;
    z-index: 5;
    width: 600px; /* Match typical bottom bar sizes */
}

.minigame-container {
    padding: 15px 30px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.minigame-bite {
    font-size: 3rem;
    font-weight: 900;
    margin-top: -20px;
    margin-bottom: -10px;
    text-shadow: 0 0 10px rgba(0,0,0,0.5);
    animation: bounce 0.5s infinite alternate;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}

.minigame-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--success);
}

.progress-container {
    width: 100%;
    height: 15px;
    background-color: rgba(0,0,0,0.5);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255,255,255,0.2);
}

.progress-bar {
    width: 0%;
    height: 100%;
    background-color: var(--success);
    transition: width 0.1s linear, background-color 0.2s;
}

.tension-area {
    width: 100%;
    height: 40px;
    background-color: rgba(0,0,0,0.4);
    border-radius: 20px;
    position: relative;
    border: 2px solid var(--glass-border);
    overflow: hidden;
}

.tension-track {
    position: relative;
    width: 100%;
    height: 100%;
}

.tension-zone {
    position: absolute;
    height: 100%;
    background-color: rgba(59, 130, 246, 0.5); /* Primary color w/ alpha */
    border: 2px solid var(--primary);
    border-radius: 8px;
    top: 0;
    left: 0;
    transition: left 0.1s linear; /* Changed from bottom to left */
}

.fish-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 0;
    transition: left 0.1s linear;
    line-height: 0;
}

.controls-hint {
    font-size: 0.9rem;
    color: #94a3b8;
}

/* Notifications */
#notification-area {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.notification {
    background-color: var(--glass-bg);
    backdrop-filter: blur(10px);
    padding: 12px 24px;
    border-radius: 30px;
    border: 1px solid var(--success);
    color: var(--success);
    font-weight: 600;
    animation: slideDown 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), fadeOut 0.5s 2.5s forwards;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
}

.notification.warning {
    border-color: var(--warning);
    color: var(--warning);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.2);
}

/* Hotbar */
#hotbar-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: auto;
}

.hotbar {
    display: flex;
    background-color: rgba(15, 23, 42, 0.9);
    border: 2px solid #1e293b;
    border-radius: 4px;
    overflow: hidden;
}

.hotbar-slot {
    width: 70px;
    height: 70px;
    position: relative;
    border-right: 1px solid #334155;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #94a3b8;
    cursor: pointer;
    transition: background-color 0.2s;
}

.hotbar-slot:last-child {
    border-right: none;
}

.hotbar-slot:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.hotbar-slot.active {
    background-color: rgba(56, 189, 248, 0.15);
}

/* Four corners overlay for highlighted slot like the image */
.hotbar-slot.active::before, .hotbar-slot.active::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    border: 2px solid #38bdf8;
    box-sizing: border-box;
}

.slot-number {
    position: absolute;
    top: 4px;
    left: 6px;
    font-size: 0.8rem;
    font-weight: bold;
    color: #cbd5e1;
}

.slot-icon {
    font-size: 1.8rem;
    margin-bottom: 2px;
}
.slot-name {
    font-size: 0.7rem;
    text-align: center;
    line-height: 1.1;
    color: #f8fafc;
    padding: 0 4px;
}

.slot-weight {
    position: absolute;
    bottom: 4px;
    right: 4px;
    font-size: 0.65rem;
    color: #94a3b8;
}

/* Hotbar & Inventory Additions */
#hotbar-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: auto;
    display: flex; /* Allow expand button to sit next to it */
    align-items: flex-end;
    gap: 10px;
}

.hotbar-btn {
    width: 60px;
    height: 60px;
    background-color: rgba(15, 23, 42, 0.9);
    border: 2px solid #1e293b;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #94a3b8;
    cursor: pointer;
    transition: background-color 0.2s;
}
.hotbar-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}
.hotbar-btn span {
    font-size: 1.2rem;
}

.inventory-panel {
    width: 600px; /* Base size */
    max-width: 90vw;
    height: 70vh;
    display: flex;
    flex-direction: column;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr); /* 6 width */
    grid-auto-rows: 70px; /* Fixed height for slots */
    gap: 5px;
    overflow-y: auto; /* Infinite scroll */
    margin: 20px 0;
    padding-right: 10px;
    flex-grow: 1; /* Take up remaining height */
}

/* Custom scrollbar for inventory */
.inventory-grid::-webkit-scrollbar {
    width: 8px;
}
.inventory-grid::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
}
.inventory-grid::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

/* Base styles for individual grid slots (inheriting some hotbar slot styles conceptually, but defined here for grid) */
.grid-slot {
    background-color: rgba(15, 23, 42, 0.9);
    border: 1px solid #334155;
    border-radius: 4px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #94a3b8;
    cursor: pointer;
    transition: background-color 0.2s;
}

.grid-slot:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.grid-slot.active {
    background-color: rgba(56, 189, 248, 0.15);
    border-color: #38bdf8;
}

.rarity-uncommon {
    background-color: rgba(34, 197, 94, 0.2) !important;
    border-color: #4ade80 !important;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.4);
}

.rarity-unusual {
    background-color: rgba(216, 172, 196, 0.4) !important; /* Grayish Pink */
    border-color: #d8acc4 !important;
    box-shadow: 0 0 10px rgba(216, 172, 196, 0.6);
}

.rarity-rare {
    background-color: rgba(138, 43, 226, 0.5) !important; /* Darker Blue-Violet */
    border-color: #8a2be2 !important; 
    box-shadow: 0 0 10px rgba(138, 43, 226, 0.6);
}

.rarity-legendary {
    background-color: rgba(250, 204, 21, 0.2) !important;
    border-color: #fef08a !important;
    box-shadow: 0 0 8px rgba(254, 240, 138, 0.4);
}

.rarity-secret {
    background: linear-gradient(135deg, rgba(0,0,0,0.6), rgba(255,255,255,0.15), rgba(0,0,0,0.6)) !important;
    border-color: #888 !important;
    box-shadow: 0 0 12px rgba(255,255,255,0.3);
    animation: secret-shimmer 2s ease-in-out infinite;
}

@keyframes secret-shimmer {
    0%, 100% { box-shadow: 0 0 8px rgba(255,255,255,0.2); }
    50% { box-shadow: 0 0 16px rgba(255,255,255,0.5); }
}

.favorited {
    border-color: #facc15 !important;
    background-color: rgba(250, 204, 21, 0.15) !important;
}

.favorite-star {
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 1.2rem;
    color: #facc15;
    text-shadow: 0 0 5px rgba(0,0,0,0.8);
    z-index: 2;
}

/* Rod Chest */
.chest-section {
    margin: 15px 0;
    text-align: left;
}

.chest-section h3 {
    font-size: 0.9rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.chest-rod-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(0,0,0,0.3);
    border: 1px solid #334155;
    border-radius: 8px;
    margin-bottom: 6px;
    transition: background-color 0.2s;
}

.chest-rod-item.empty {
    color: #64748b;
    justify-content: center;
    font-style: italic;
}

.chest-rod-item.equipped {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.1);
}

.chest-rod-icon {
    font-size: 1.5rem;
}

.chest-rod-info {
    flex: 1;
}

.chest-rod-name {
    font-weight: 600;
    font-size: 1rem;
}

.chest-rod-stats {
    font-size: 0.8rem;
    color: #94a3b8;
}

.chest-rod-item button {
    padding: 6px 14px;
    font-size: 0.85rem;
}

/* Utilities */
.hidden {
    display: none !important;
}

@keyframes float {
    0%, 100% { transform: translate(-50%, -50%); }
    50% { transform: translate(-50%, -60%); }
}

@keyframes scaleIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; }
}

/* --- Auth Modal --- */
#auth-modal {
    z-index: 25;
}

.auth-panel {
    width: 360px !important;
    max-width: 90vw !important;
    text-align: center;
}

.auth-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 4px;
}

.auth-tab {
    flex: 1;
    padding: 8px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.5);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.auth-tab:hover {
    color: rgba(255,255,255,0.8);
}

.auth-tab.active {
    background: var(--primary);
    color: white;
}

.auth-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    margin-bottom: 12px;
}

.auth-error.hidden {
    display: none;
}

#auth-username, #auth-password {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

#auth-username:focus, #auth-password:focus {
    border-color: var(--primary);
}

#auth-username::placeholder, #auth-password::placeholder {
    color: rgba(255,255,255,0.3);
}

/* Player display / Logout */
#player-display {
    position: absolute;
    top: 20px;
    left: 20px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    pointer-events: auto;
}

#player-display.hidden {
    display: none;
}

#player-name-label {
    color: rgba(255,255,255,0.7);
}

.logout-btn {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.35);
}

/* --- Leaderboard --- */
.leaderboard-panel {
    width: 480px !important;
    max-width: 90vw !important;
}

.leaderboard-score-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 0;
    font-size: 2rem;
    font-weight: 800;
    color: #facc15;
}

.leaderboard-score-header .icon {
    font-size: 1.8rem;
}

.leaderboard-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.leaderboard-section {
    margin-top: 12px;
}

.leaderboard-section h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.4);
    margin-bottom: 8px;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 280px;
    overflow-y: auto;
}

.lb-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
}

.lb-row:nth-child(1) { background: rgba(250, 204, 21, 0.1); }
.lb-row:nth-child(2) { background: rgba(148, 163, 184, 0.1); }
.lb-row:nth-child(3) { background: rgba(180, 83, 9, 0.1); }

.lb-rank {
    font-weight: 800;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.4);
    min-width: 28px;
}

.lb-row:nth-child(1) .lb-rank { color: #facc15; }
.lb-row:nth-child(2) .lb-rank { color: #94a3b8; }
.lb-row:nth-child(3) .lb-rank { color: #b45309; }

.lb-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lb-name {
    font-weight: 700;
    font-size: 0.85rem;
}

.rarity-text-common { color: #94a3b8; }
.rarity-text-uncommon { color: #4ade80; }
.rarity-text-unusual { color: #38bdf8; }
.rarity-text-rare { color: #a78bfa; }
.rarity-text-legendary { color: #facc15; }
.rarity-text-secret { color: #ccc; }

.lb-detail {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.4);
}

.lb-pts {
    font-weight: 800;
    font-size: 0.9rem;
    color: #4ade80;
}

.lb-empty {
    text-align: center;
    color: rgba(255,255,255,0.3);
    padding: 20px;
    font-size: 0.85rem;
}

.leaderboard-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lb-stat {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(255,255,255,0.04);
    font-size: 0.8rem;
}

.lb-stat-label {
    color: rgba(255,255,255,0.4);
}

/* Leaderboard Tabs */
.leaderboard-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 4px;
}

.lb-tab {
    flex: 1;
    padding: 8px 4px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.5);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.lb-tab:hover {
    color: rgba(255,255,255,0.8);
}

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

.lb-tab-content.hidden {
    display: none;
}

.lb-player {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.35);
}

.lb-row-self {
    border-left: 2px solid var(--primary) !important;
}

.lb-player-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
}

.lb-player-row:nth-child(1) { background: rgba(250, 204, 21, 0.1); }
.lb-player-row:nth-child(2) { background: rgba(148, 163, 184, 0.1); }
.lb-player-row:nth-child(3) { background: rgba(180, 83, 9, 0.1); }

.lb-player-name {
    flex: 1;
    font-weight: 700;
    font-size: 0.9rem;
}

.lb-player-score {
    font-weight: 800;
    color: #facc15;
    font-size: 0.95rem;
}

.bestiary-panel {
    width: 820px !important;
    max-width: 92vw !important;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
}

.bestiary-layout {
    display: flex;
    gap: 12px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.bestiary-sidebar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 130px;
    padding-right: 10px;
    border-right: 1px solid rgba(255,255,255,0.1);
}

.bestiary-filter {
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255,255,255,0.6);
    transition: all 0.15s;
}

.bestiary-filter:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.9);
}

.bestiary-filter.active {
    background: rgba(59, 130, 246, 0.25);
    color: #60a5fa;
}

.bestiary-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
    overflow-y: auto;
    align-content: start;
    padding: 2px;
    max-height: 50vh;
}

.bestiary-entry {
    aspect-ratio: 1;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid rgba(255,255,255,0.08);
    transition: all 0.15s;
    padding: 6px;
    gap: 4px;
    position: relative;
}

.bestiary-entry:hover {
    border-color: rgba(255,255,255,0.25);
    transform: scale(1.04);
}

.bestiary-entry.selected {
    border-color: #60a5fa;
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.3);
}

.bestiary-entry.discovered {
    background: rgba(255,255,255,0.06);
    border: 2px solid transparent;
}

.bestiary-entry.undiscovered {
    background: rgba(30, 30, 50, 0.5);
}

.bestiary-entry .entry-icon {
    font-size: 1.6rem;
    line-height: 0;
}

.bestiary-entry .entry-name {
    font-size: 0.6rem;
    text-align: center;
    line-height: 1.1;
    color: rgba(255,255,255,0.8);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bestiary-entry .entry-question {
    font-size: 2rem;
    color: rgba(255,255,255,0.2);
    font-weight: 800;
}

.bestiary-entry.rarity-common { border: 2px solid #94a3b8; background: rgba(148, 163, 184, 0.3); }
.bestiary-entry.rarity-common .entry-name { color: #cbd5e1; }
.bestiary-entry.rarity-common .entry-icon svg { color: #94a3b8; }

.bestiary-entry.rarity-uncommon { border: 2px solid #4ade80; background: rgba(74, 222, 128, 0.35); }
.bestiary-entry.rarity-uncommon .entry-name { color: #4ade80; }
.bestiary-entry.rarity-uncommon .entry-icon svg { color: #4ade80; }

.bestiary-entry.rarity-unusual { border: 2px solid #38bdf8; background: rgba(56, 189, 248, 0.35); }
.bestiary-entry.rarity-unusual .entry-name { color: #38bdf8; }
.bestiary-entry.rarity-unusual .entry-icon svg { color: #38bdf8; }

.bestiary-entry.rarity-rare { border: 2px solid #a78bfa; background: rgba(167, 139, 250, 0.4); }
.bestiary-entry.rarity-rare .entry-name { color: #a78bfa; }
.bestiary-entry.rarity-rare .entry-icon svg { color: #a78bfa; }

.bestiary-entry.rarity-legendary { border: 2px solid #facc15; background: rgba(250, 204, 21, 0.35); }
.bestiary-entry.rarity-legendary .entry-name { color: #facc15; }
.bestiary-entry.rarity-legendary .entry-icon svg { color: #facc15; }

.bestiary-entry.rarity-secret { border: 2px solid #888; background: linear-gradient(180deg, rgba(0,0,0,0.5), rgba(200,200,200,0.25), rgba(0,0,0,0.5)); animation: secret-shimmer 2s ease-in-out infinite; }
.bestiary-entry.rarity-secret .entry-name { color: #ccc; }
.bestiary-entry.rarity-secret .entry-icon svg { color: #ccc; }
.bestiary-entry.rarity-secret .entry-question { color: rgba(255,255,255,0.4); }

.bestiary-detail {
    min-width: 180px;
    max-width: 200px;
    padding-left: 10px;
    border-left: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bestiary-detail-placeholder {
    color: rgba(255,255,255,0.3);
    font-size: 0.8rem;
    text-align: center;
    margin-top: 40px;
}

.bestiary-detail .detail-icon {
    text-align: center;
    font-size: 2.5rem;
    line-height: 0;
    padding: 20px 0;
}

.bestiary-detail .detail-name {
    font-size: 1rem;
    font-weight: 800;
    text-align: center;
}

.bestiary-detail .detail-rarity {
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bestiary-detail .detail-rarity.common { color: #94a3b8; }
.bestiary-detail .detail-rarity.uncommon { color: #4ade80; }
.bestiary-detail .detail-rarity.unusual { color: #38bdf8; }
.bestiary-detail .detail-rarity.rare { color: #a78bfa; }
.bestiary-detail .detail-rarity.legendary { color: #facc15; }

.bestiary-detail .detail-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.7);
    margin-top: 8px;
}

.bestiary-detail .detail-stats .stat-row {
    display: flex;
    justify-content: space-between;
}

.bestiary-detail .detail-stats .stat-label {
    color: rgba(255,255,255,0.4);
}

.bestiary-footer {
    text-align: center;
    padding: 8px 0 2px;
    font-size: 0.8rem;
    color: #4ade80;
    font-weight: 600;
}

/* ===== Mobile Touch Controls ===== */

/* Hidden by default on all devices */
#mobile-controls {
    display: none;
}

/* Only show on touch-primary devices (phones/tablets) */
@media (pointer: coarse) {
    #mobile-controls {
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
        z-index: 4;
    }

    /* Joystick zone — bottom-left, large touch area */
    #joystick-zone {
        position: absolute;
        bottom: 20px;
        left: 20px;
        width: 150px;
        height: 150px;
        pointer-events: auto;
        touch-action: none;
    }

    #joystick-base {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 120px;
        height: 120px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.08);
        border: 2px solid rgba(255, 255, 255, 0.2);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #joystick-thumb {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.25);
        border: 2px solid rgba(255, 255, 255, 0.4);
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        transition: none;
    }

    /* Action button — bottom-right */
    #action-btn {
        position: absolute;
        bottom: 30px;
        right: 30px;
        width: 70px;
        height: 70px;
        border-radius: 50%;
        background: rgba(59, 130, 246, 0.3);
        border: 2px solid rgba(59, 130, 246, 0.6);
        display: flex;
        align-items: center;
        justify-content: center;
        pointer-events: auto;
        touch-action: none;
        cursor: pointer;
        transition: background 0.1s;
    }

    #action-btn:active {
        background: rgba(59, 130, 246, 0.6);
    }

    #action-btn-label {
        font-family: 'Outfit', sans-serif;
        font-size: 1.5rem;
        font-weight: 800;
        color: rgba(255, 255, 255, 0.8);
        pointer-events: none;
    }

    /* Move hotbar up so it does not overlap joystick/action btn */
    #hotbar-container {
        bottom: 180px;
    }

    /* Move minigame higher to avoid overlap */
    #fishing-minigame {
        bottom: 260px;
        width: 90%;
        max-width: 600px;
    }

    /* Shrink top-right panels slightly on small screens */
    #coin-display, #inventory-display, #score-display {
        padding: 6px 12px;
        font-size: 1rem;
        right: 10px;
    }

    #score-display { top: 130px; }
    #coin-display { top: 85px; }
    #inventory-display { top: 40px; }

    #music-toggle {
        right: 10px;
        top: 5px;
        padding: 5px 10px;
        font-size: 0.85rem;
    }
}
